From 85e4a845522f1424b52e91f67553687d28bb8468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kraus?= Date: Wed, 5 Oct 2022 22:01:20 +0200 Subject: [PATCH] Issue 4740 - JPA integration tests should run on every build (#5080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Kraus Signed-off-by: Tomáš Kraus --- tests/integration/jpa/appl/pom.xml | 142 +++++------------- .../tests/integration/jpa/appl/JdbcApiIT.java | 8 +- .../tests/integration/jpa/appl/UpdateIT.java | 3 +- .../src/main/resources/hibernate.properties | 3 +- .../jpa/appl/test/LifeCycleExtension.java | 6 +- .../tests/integration/jpa/model/Pokemon.java | 13 +- .../integration/jpa/model/Settlement.java | 5 +- .../tests/integration/jpa/model/Stadium.java | 10 +- .../tests/integration/jpa/model/Trainer.java | 10 +- tests/integration/jpa/simple/pom.xml | 6 +- .../integration/jpa/simple/init/InitIT.java | 48 ------ .../integration/jpa/simple/test/DeleteIT.java | 6 +- .../integration/jpa/simple/test/InsertIT.java | 36 +---- .../integration/jpa/simple/test/QueryIT.java | 18 +-- .../integration/jpa/simple/test/UpdateIT.java | 13 +- tests/integration/pom.xml | 10 +- 16 files changed, 81 insertions(+), 256 deletions(-) delete mode 100644 tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/init/InitIT.java diff --git a/tests/integration/jpa/appl/pom.xml b/tests/integration/jpa/appl/pom.xml index a5cf352f37f..41df1a2fbd8 100644 --- a/tests/integration/jpa/appl/pom.xml +++ b/tests/integration/jpa/appl/pom.xml @@ -105,6 +105,11 @@ jandex runtime + + org.jboss + jboss-transaction-spi-jakarta + runtime + org.junit.jupiter junit-jupiter-api @@ -120,13 +125,6 @@ - - ${basedir}/src/main/resources - - META-INF/microprofile-config.properties - META-INF/persistence.xml - - ${basedir}/src/main/resources/META-INF META-INF @@ -136,6 +134,13 @@ true + + ${basedir}/src/main/resources + + META-INF/microprofile-config.properties + META-INF/persistence.xml + + @@ -227,6 +232,9 @@ 10 true + ${db.user} + ${db.password} + ${db.url} @@ -319,10 +327,11 @@ io.fabric8 docker-maven-plugin + start - pre-integration-test + package start @@ -339,21 +348,22 @@ + + h2 - h2 + !db 9092 localhost - pokemon + test sa - root - jdbc:h2:tcp://${db.host}:${db.port}/test + jdbc:h2:mem:test;INIT=SET TRACE_LEVEL_FILE=4 org.hibernate.dialect.H2Dialect org.h2.jdbcx.JdbcDataSource @@ -362,77 +372,19 @@ io.helidon.integrations.db h2 + + com.h2database + h2 + runtime + - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - ${db.user} - ${db.password} - ${db.url} - - - - - org.codehaus.mojo - exec-maven-plugin - - - start-db - pre-integration-test - - exec - - - java - - -classpath - ${project.build.directory}/libs/h2-${version.lib.h2}.jar - ${mainClassH2} - -tcp - -tcpPassword - ${h2.db.password} - -tcpPort - ${h2.db.port} - -baseDir - ${project.build.directory}/h2 - -ifNotExists - - true - - - - stop-db - post-integration-test - - exec - - - java - - -classpath - ${project.build.directory}/libs/h2-${version.lib.h2}.jar - ${mainClassH2} - -tcpShutdown - tcp://localhost:${h2.db.port} - -tcpPassword - ${h2.db.password} - - - - - - - mysql - mysql + db + mysql @@ -444,7 +396,7 @@ password root jdbc:mysql://${db.host}:${db.port}/${db.database}?${db.args} - org.hibernate.dialect.MySQL5Dialect + org.hibernate.dialect.MySQL8Dialect com.mysql.cj.jdbc.MysqlDataSource com.mysql.cj.jdbc.Driver @@ -462,17 +414,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - - ${db.user} - ${db.password} - ${db.url} - - - io.fabric8 docker-maven-plugin @@ -493,13 +434,14 @@ ${db.host}:${db.port}:3306 - + + MySQL init process done. Ready for start up. @@ -515,7 +457,8 @@ pgsql - pgsql + db + pgsql @@ -525,8 +468,8 @@ user password jdbc:postgresql://${db.host}:${db.port}/${db.database} - org.hibernate.dialect.PostgreSQL10Dialect - org.postgresql.jdbc3.Jdbc3PoolingDataSource + org.hibernate.dialect.PostgreSQLDialect + org.postgresql.ds.PGSimpleDataSource org.postgresql.Driver @@ -543,17 +486,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - - ${db.user} - ${db.password} - ${db.url} - - - io.fabric8 docker-maven-plugin diff --git a/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/JdbcApiIT.java b/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/JdbcApiIT.java index 947c102d473..598f5966065 100644 --- a/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/JdbcApiIT.java +++ b/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/JdbcApiIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,13 +56,13 @@ public TestResult setup(TestResult result) { final String dbPassword = config.getProperty("javax.sql.DataSource.test.dataSource.password"); final String dbUrl = config.getProperty("javax.sql.DataSource.test.dataSource.url"); if (dbUser == null) { - throw new IllegalStateException("Database user name was not set!"); + throw new IllegalStateException("Database user name was not set, check javax.sql.DataSource.test.dataSource.user property! "); } if (dbPassword == null) { - throw new IllegalStateException("Database user password was not set!"); + throw new IllegalStateException("Database user password was not set, check javax.sql.DataSource.test.dataSource.password property!"); } if (dbUrl == null) { - throw new IllegalStateException("Database URL was not set!"); + throw new IllegalStateException("Database URL was not set, check javax.sql.DataSource.test.dataSource.url property!"); } try { conn = DriverManager.getConnection(dbUrl, dbUser, dbPassword); diff --git a/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/UpdateIT.java b/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/UpdateIT.java index c9aff1eb3a1..96cec511ad8 100644 --- a/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/UpdateIT.java +++ b/tests/integration/jpa/appl/src/main/java/io/helidon/tests/integration/jpa/appl/UpdateIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -193,7 +193,6 @@ public TestResult testUpdateSaffron(TestResult result) { City city = em.find(City.class, cities[0].getId()); stadium = city.getStadium(); Trainer trainer = stadium.getTrainer(); - em.refresh(trainer); pokemons = trainer.getPokemons(); result.assertEquals(trainer.getName(), "Janine"); for (Pokemon pokemon : pokemons) { diff --git a/tests/integration/jpa/appl/src/main/resources/hibernate.properties b/tests/integration/jpa/appl/src/main/resources/hibernate.properties index 5d0d4b0e120..a86b25d6136 100644 --- a/tests/integration/jpa/appl/src/main/resources/hibernate.properties +++ b/tests/integration/jpa/appl/src/main/resources/hibernate.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020 Oracle and/or its affiliates. +# Copyright (c) 2020, 2022 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,4 +17,3 @@ # Byte code for JPA must be generated at compile time. # This is a limitation of native image hibernate.bytecode.provider=none - diff --git a/tests/integration/jpa/appl/src/test/java/io/helidon/tests/integration/jpa/appl/test/LifeCycleExtension.java b/tests/integration/jpa/appl/src/test/java/io/helidon/tests/integration/jpa/appl/test/LifeCycleExtension.java index 340ae5136dc..25c916a4853 100644 --- a/tests/integration/jpa/appl/src/test/java/io/helidon/tests/integration/jpa/appl/test/LifeCycleExtension.java +++ b/tests/integration/jpa/appl/src/test/java/io/helidon/tests/integration/jpa/appl/test/LifeCycleExtension.java @@ -102,13 +102,13 @@ public static void waitForDatabase() { final String dbUrl = System.getProperty("db.url"); boolean connected = false; if (dbUser == null) { - throw new IllegalStateException("Database user name was not set!"); + throw new IllegalStateException("Database user name was not set, check db.user property!"); } if (dbPassword == null) { - throw new IllegalStateException("Database user password was not set!"); + throw new IllegalStateException("Database user password was not set, check db.password property!"); } if (dbUrl == null) { - throw new IllegalStateException("Database URL was not set!"); + throw new IllegalStateException("Database URL was not set, check db.url property"); } long endTm = 1000 * TIMEOUT + System.currentTimeMillis(); while (true) { diff --git a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Pokemon.java b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Pokemon.java index 693fac352e9..6d4799464aa 100644 --- a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Pokemon.java +++ b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Pokemon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,7 @@ import java.util.Objects; import java.util.logging.Logger; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.UniqueConstraint; +import jakarta.persistence.*; /** * Pokemon entity. @@ -39,7 +32,7 @@ public class Pokemon implements Serializable { private static final Logger LOGGER = Logger.getLogger(Pokemon.class.getName()); @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.TABLE) private int id; @ManyToOne diff --git a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Settlement.java b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Settlement.java index ca89bc3d157..eb4c0749482 100644 --- a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Settlement.java +++ b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Settlement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import java.util.Objects; import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; @@ -28,7 +29,7 @@ public class Settlement { @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String name; diff --git a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Stadium.java b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Stadium.java index ac1fa64ea3d..f3932403e2d 100644 --- a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Stadium.java +++ b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Stadium.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,7 @@ import java.util.Objects; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.*; /** * Pokemon stadium. @@ -30,7 +26,7 @@ public class Stadium { @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String name; diff --git a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Trainer.java b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Trainer.java index 5bc94901829..2e79bbf7e8a 100644 --- a/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Trainer.java +++ b/tests/integration/jpa/model/src/main/java/io/helidon/tests/integration/jpa/model/Trainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,7 @@ import java.util.List; import java.util.Objects; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; +import jakarta.persistence.*; /** * Trainer entity. @@ -32,7 +28,7 @@ public class Trainer implements Serializable { @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String name; diff --git a/tests/integration/jpa/simple/pom.xml b/tests/integration/jpa/simple/pom.xml index 2c30a1618c4..d1448b32e63 100644 --- a/tests/integration/jpa/simple/pom.xml +++ b/tests/integration/jpa/simple/pom.xml @@ -102,7 +102,6 @@ h2 test - org.junit.jupiter junit-jupiter-api @@ -113,7 +112,6 @@ hamcrest-all test - org.jboss jandex @@ -162,16 +160,14 @@ 10 - - test + test-run integration-test integration-test - io.helidon.tests.integration.jpa.simple.init.*IT io.helidon.tests.integration.jpa.simple.test.*IT diff --git a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/init/InitIT.java b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/init/InitIT.java deleted file mode 100644 index 169c0836ed5..00000000000 --- a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/init/InitIT.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.helidon.tests.integration.jpa.simple.init; - -import io.helidon.tests.integration.jpa.simple.DbUtils; -import io.helidon.tests.integration.jpa.simple.PU; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -/** - * Initialize tests. - */ -public class InitIT { - - private static PU pu; - - @BeforeAll - public static void setup() { - pu = PU.getInstance(); - } - - @AfterAll - public static void destroy() { - pu = null; - } - - - @Test - public void testInsertData() { - pu.tx(pu -> DbUtils.dbInit(pu)); - } - -} diff --git a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/DeleteIT.java b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/DeleteIT.java index e7e3ef9acb5..b4c956cf88f 100644 --- a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/DeleteIT.java +++ b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/DeleteIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ import java.util.List; +import io.helidon.tests.integration.jpa.simple.DbUtils; import jakarta.persistence.EntityManager; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaDelete; @@ -67,12 +68,13 @@ private static void dbDeleteMisty() { @BeforeAll public static void setup() { pu = PU.getInstance(); + pu.tx(pu -> DbUtils.dbInit(pu)); dbInsertMisty(); } @AfterAll public static void destroy() { - dbDeleteMisty(); + pu.tx(pu -> DbUtils.dbCleanup(pu)); pu = null; } diff --git a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/InsertIT.java b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/InsertIT.java index 6f73b557f20..fb38a7974a9 100644 --- a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/InsertIT.java +++ b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/InsertIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.List; import java.util.Set; +import io.helidon.tests.integration.jpa.simple.DbUtils; import jakarta.persistence.EntityManager; import io.helidon.tests.integration.jpa.model.Pokemon; @@ -51,41 +52,12 @@ public class InsertIT { @BeforeAll public static void setup() { pu = PU.getInstance(); + pu.tx(pu -> DbUtils.dbInit(pu)); } @AfterAll public static void destroy() { - pu.tx(pu -> { - final EntityManager em = pu.getEm(); - // testInsertType cleanup - em.createQuery("DELETE FROM Type t WHERE t.id = :id") - .setParameter("id", 20) - .executeUpdate(); - // Towns cleanup - DELETE_TOWNS.forEach((id) -> { - em.createQuery("DELETE FROM City c WHERE c.id = :id") - .setParameter("id", id) - .executeUpdate(); - }); - // Stadiums cleanup - DELETE_STADIUMS.forEach((id) -> { - em.createQuery("DELETE FROM Stadium s WHERE s.id = :id") - .setParameter("id", id) - .executeUpdate(); - }); - // Pokemons cleanup - DELETE_POKEMONS.forEach((id) -> { - em.createQuery("DELETE FROM Pokemon p WHERE p.id = :id") - .setParameter("id", id) - .executeUpdate(); - }); - // Trainers cleanup - DELETE_TRAINERS.forEach((id) -> { - em.createQuery("DELETE FROM Trainer t WHERE t.id = :id") - .setParameter("id", id) - .executeUpdate(); - }); - }); + pu.tx(pu -> DbUtils.dbCleanup(pu)); pu = null; } diff --git a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/QueryIT.java b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/QueryIT.java index 2267e66f25a..347f8abd70d 100644 --- a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/QueryIT.java +++ b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/QueryIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,10 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Join; import jakarta.persistence.criteria.Root; import io.helidon.tests.integration.jpa.model.City; import io.helidon.tests.integration.jpa.model.Pokemon; -import io.helidon.tests.integration.jpa.model.Stadium; import io.helidon.tests.integration.jpa.model.Trainer; import io.helidon.tests.integration.jpa.simple.DbUtils; import io.helidon.tests.integration.jpa.simple.PU; @@ -42,16 +40,18 @@ * Verify query operations of ORM. */ public class QueryIT { - + private static PU pu; @BeforeAll public static void setup() { pu = PU.getInstance(); + pu.tx(pu -> DbUtils.dbInit(pu)); } @AfterAll public static void destroy() { + pu.tx(pu -> DbUtils.dbCleanup(pu)); pu = null; } @@ -77,7 +77,7 @@ public void testQueryJPQL() { pu.tx(pu -> { final EntityManager em = pu.getCleanEm(); Trainer ash = em.createQuery( - "SELECT t FROM Trainer t JOIN FETCH t.pokemons p WHERE t.id = :id", Trainer.class) + "SELECT t FROM Trainer t JOIN FETCH t.pokemons p WHERE t.id = :id", Trainer.class) .setParameter("id", DbUtils.ASH_ID) .getSingleResult(); List pokemons = ash.getPokemons(); @@ -113,10 +113,10 @@ public void testQueryCeladonJPQL() { pu.tx(pu -> { final EntityManager em = pu.getCleanEm(); City city = em.createQuery( - "SELECT c FROM City c " - + "JOIN FETCH c.stadium s " - + "JOIN FETCH s.trainer t " - + "WHERE c.name = :name", City.class) + "SELECT c FROM City c " + + "JOIN FETCH c.stadium s " + + "JOIN FETCH s.trainer t " + + "WHERE c.name = :name", City.class) .setParameter("name", "Celadon City") .getSingleResult(); assertEquals(city.getName(), "Celadon City"); diff --git a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/UpdateIT.java b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/UpdateIT.java index b811069fa1f..ec593021522 100644 --- a/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/UpdateIT.java +++ b/tests/integration/jpa/simple/src/test/java/io/helidon/tests/integration/jpa/simple/test/UpdateIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import jakarta.persistence.criteria.Root; import io.helidon.tests.integration.jpa.dao.Create; -import io.helidon.tests.integration.jpa.dao.Delete; import io.helidon.tests.integration.jpa.model.City; import io.helidon.tests.integration.jpa.model.Pokemon; import io.helidon.tests.integration.jpa.model.Stadium; @@ -54,6 +53,7 @@ public static void setup() { pu = PU.getInstance(); pu.tx(pu -> { final EntityManager em = pu.getEm(); + DbUtils.dbInit(pu); Create.dbInsertBrock(em); Create.dbInsertSaffron(em); }); @@ -61,12 +61,8 @@ public static void setup() { @AfterAll public static void destroy() { - pu.tx(pu -> { - final EntityManager em = pu.getEm(); - Delete.dbDeleteBrock(em); - Delete.dbDeleteSaffron(em); - pu = null; - }); + pu.tx(pu -> DbUtils.dbCleanup(pu)); + pu = null; } /** @@ -195,7 +191,6 @@ public void testUpdateSaffron() { City city = em.find(City.class, cities[0].getId()); Stadium stadium = city.getStadium(); Trainer trainer = stadium.getTrainer(); - em.refresh(trainer); List pokemons = trainer.getPokemons(); assertEquals(trainer.getName(), "Janine"); for (Pokemon pokemon : pokemons) { diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml index b9ff35c1fb9..be2aa7d16be 100644 --- a/tests/integration/pom.xml +++ b/tests/integration/pom.xml @@ -55,6 +55,7 @@ mp-gh-4123 mp-gh-4654 kafka + jpa jms config jep290 @@ -78,15 +79,6 @@ - - native-image - - true - - - jpa - - dbclient-it