From e0e44433a99630982b5f4e92c538dc52a188ff75 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 25 Jan 2021 15:07:53 +0100 Subject: [PATCH] Fix some issues with tests migration --- .../cacheable/api/JpaCacheApiUsageTest.java | 58 +++++ .../jpa => jpa/test}/cacheable/api/Order.java | 2 +- .../cacheable/api/JpaCacheApiUsageTest.java | 110 -------- .../jpa/callbacks/CallbacksDisabledTest.java | 22 +- .../orm/test/jpa/callbacks/CallbacksTest.java | 244 ++++++++---------- .../orm/test/jpa/cascade/CascadeTest.java | 6 +- .../orm/test/jpa/cdi/NoCdiAvailableTest.java | 4 +- .../extended/ConversationalEventManager.java | 38 --- .../orm/test/jpa/cdi/extended/Event.java | 41 --- ...ManualFlushConversationalEventManager.java | 44 ---- .../NonConversationalEventManager.java | 35 --- .../testing/orm/junit/BaseUnitTest.java | 1 - 12 files changed, 174 insertions(+), 431 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/JpaCacheApiUsageTest.java rename hibernate-core/src/test/java/org/hibernate/{orm/test/jpa => jpa/test}/cacheable/api/Order.java (95%) delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/JpaCacheApiUsageTest.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ConversationalEventManager.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/Event.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ManualFlushConversationalEventManager.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/NonConversationalEventManager.java diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/JpaCacheApiUsageTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/JpaCacheApiUsageTest.java new file mode 100644 index 0000000000..fd3f23bc28 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/JpaCacheApiUsageTest.java @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.jpa.test.cacheable.api; + +import javax.persistence.EntityManagerFactory; + +import org.hibernate.cfg.AvailableSettings; + +import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; +import org.hibernate.testing.orm.junit.Jpa; +import org.hibernate.testing.orm.junit.Setting; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * @author Steve Ebersole + */ +// TODO Convert to annotation based testing? Setting the CachingRegionFactory as below leads to a CNFE +@Jpa( + annotatedClasses = Order.class, + integrationSettings = { + @Setting(name = AvailableSettings.CACHE_REGION_FACTORY, value = "org.hibernate.testing.cache.CachingRegionFactory"), + @Setting(name = AvailableSettings.JPA_SHARED_CACHE_MODE, value = "ALL"), + @Setting(name = AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, value = "read-write"), + @Setting(name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "true"), + } +) +public class JpaCacheApiUsageTest { + + @Test + public void testEviction(EntityManagerFactoryScope scope) { + // first create an Order + scope.inTransaction( + entityManager -> + entityManager.persist( new Order( 1, 500 ) ) + ); + + + final EntityManagerFactory entityManagerFactory = scope.getEntityManagerFactory(); + assertTrue( entityManagerFactory.getCache().contains( Order.class, 1 ) ); + + scope.inTransaction( + entityManager -> { + assertTrue( entityManagerFactory.getCache().contains( Order.class, 1 ) ); + entityManager.createQuery( "delete Order" ).executeUpdate(); + } + ); + + assertFalse( entityManagerFactory.getCache().contains( Order.class, 1 ) ); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/Order.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/Order.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/Order.java rename to hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/Order.java index f859e270ac..7a3aa3a54a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/Order.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/cacheable/api/Order.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.orm.test.jpa.cacheable.api; +package org.hibernate.jpa.test.cacheable.api; import javax.persistence.Cacheable; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/JpaCacheApiUsageTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/JpaCacheApiUsageTest.java deleted file mode 100644 index 2645d27412..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cacheable/api/JpaCacheApiUsageTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.jpa.cacheable.api; - -import javax.persistence.EntityManager; -import javax.persistence.SharedCacheMode; - -import java.util.Map; - -import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; -import org.hibernate.testing.cache.CachingRegionFactory; -import org.hibernate.testing.orm.junit.NotImplementedYet; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * @author Steve Ebersole - */ -// TODO Convert to annotation based testing? Setting the CachingRegionFactory as below leads to a CNFE -//@DomainModel( -// annotatedClasses = Order.class -//) -//@ServiceRegistry( -// settings = { -// @Setting(name = AvailableSettings.CACHE_REGION_FACTORY, value = "CachingRegionFactory.class"), -// @Setting(name = AvailableSettings.JPA_SHARED_CACHE_MODE, value = "ALL") -// } -//) -//@SessionFactory -public class JpaCacheApiUsageTest /*extends BaseEntityManagerFunctionalTestCase*/ { -// @Override -// protected Class[] getAnnotatedClasses() { -// return new Class[] { Order.class }; -// } -// -// @Override -// @SuppressWarnings("unchecked") -// protected void addConfigOptions(Map options) { -//// options.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); -// options.put( AvailableSettings.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() ); -//// options.put( AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "read-write" ); -// options.put( org.hibernate.jpa.AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.ALL ); -// } - - @Test - @NotImplementedYet(reason = "BulkOperationCleanupAction is never created", expectedVersion = "6.0") - public void testEviction() { - throw new NotYetImplementedFor6Exception(); - // first create an Order -// EntityManager em = getOrCreateEntityManager(); -// em.getTransaction().begin(); -// em.persist( new Order( 1, 500 ) ); -// em.getTransaction().commit(); -// em.close(); -// -// assertTrue( entityManagerFactory().getCache().contains( Order.class, 1 ) ); -// -// em = getOrCreateEntityManager(); -// em.getTransaction().begin(); -// assertTrue( entityManagerFactory().getCache().contains( Order.class, 1 ) ); -// em.createQuery( "delete Order" ).executeUpdate(); -// em.getTransaction().commit(); -// em.close(); -// -// assertFalse( entityManagerFactory().getCache().contains( Order.class, 1 ) ); - } - -// @Test -// public void testEviction(SessionFactoryScope scope) { -// scope.inTransaction( -// session -> { -// session.getTransaction().begin(); -// session.persist( new Order( 1, 500 ) ); -// session.getTransaction().commit(); -// session.close(); -// } -// ); -// -// scope.inSession( -// session -> { -// assertTrue( session.getEntityManagerFactory().getCache().contains( Order.class, 1 ) ); -// } -// ); -// -// scope.inTransaction( -// session -> { -// session.getTransaction().begin(); -// assertTrue( session.getEntityManagerFactory().getCache().contains( Order.class, 1 ) ); -// session.createQuery( "delete Order" ).executeUpdate(); -// session.getTransaction().commit(); -// session.close(); -// } -// ); -// -// scope.inSession( -// session -> { -// assertFalse( session.getEntityManagerFactory().getCache().contains( Order.class, 1 ) ); -// } -// ); -// } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksDisabledTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksDisabledTest.java index 0b7cb419ae..9322346f36 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksDisabledTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksDisabledTest.java @@ -15,7 +15,6 @@ import org.hibernate.jpa.test.Kitten; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Setting; - import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -39,28 +38,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class CallbacksDisabledTest { @Test - public void testCallbacksAreDisabled(EntityManagerFactoryScope scope) throws Exception { - int id = scope.fromTransaction( + public void testCallbacksAreDisabled(EntityManagerFactoryScope scope) { + scope.inTransaction( entityManager -> { Cat c = new Cat(); c.setName( "Kitty" ); c.setDateOfBirth( new Date( 90, 11, 15 ) ); entityManager.persist( c ); - return c.getId(); - } - ); - - scope.inTransaction( - entityManager -> { - Cat _c = entityManager.find( Cat.class, id ); + entityManager.getTransaction().commit(); + entityManager.clear(); + entityManager.getTransaction().begin(); + Cat _c = entityManager.find( Cat.class, c.getId() ); assertTrue( _c.getAge() == 0 ); // With listeners enabled this would be false. Proven by org.hibernate.orm.test.jpa.callbacks.CallbacksTest.testCallbackMethod } ); - - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Cat" ).executeUpdate(); - } - ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksTest.java index eb6e20d1c1..06ddc1704a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/CallbacksTest.java @@ -16,7 +16,7 @@ import org.hibernate.jpa.test.Kitten; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.FailureExpected; import org.hibernate.testing.orm.junit.Jpa; - +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -38,34 +38,40 @@ import static org.junit.jupiter.api.Assertions.fail; Rythm.class }) public class CallbacksTest { + + @AfterEach + public void tearDown(EntityManagerFactoryScope scope) { + scope.inTransaction( + entityManager -> { + entityManager.createQuery( "delete from Cat" ).executeUpdate(); + entityManager.createQuery( "delete from Television" ).executeUpdate(); + entityManager.createQuery( "delete from Plant" ).executeUpdate(); + entityManager.createQuery( "delete from Kitten" ).executeUpdate(); + } + ); + } + @Test public void testCallbackMethod(EntityManagerFactoryScope scope) { - int id = scope.fromTransaction( + scope.inTransaction( entityManager -> { Cat c = new Cat(); c.setName( "Kitty" ); c.setDateOfBirth( new Date( 90, 11, 15 ) ); entityManager.persist( c ); - return c.getId(); - } - ); - scope.inTransaction( - entityManager -> { - Cat _c = entityManager.find( Cat.class, id ); - assertFalse( _c.getAge() == 0 ); - _c.setName( "Tomcat" ); //update this entity - } - ); - scope.inTransaction( - entityManager -> { - Cat _c = entityManager.find( Cat.class, id ); - assertEquals( "Tomcat", _c.getName() ); - } - ); + entityManager.getTransaction().commit(); - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Cat" ).executeUpdate(); + entityManager.clear(); + + entityManager.getTransaction().begin(); + c = entityManager.find( Cat.class, c.getId() ); + assertFalse( c.getAge() == 0 ); + c.setName( "Tomcat" ); //update this entity + entityManager.getTransaction().commit(); + entityManager.clear(); + entityManager.getTransaction().begin(); + c = entityManager.find( Cat.class, c.getId() ); + assertEquals( "Tomcat", c.getName() ); } ); } @@ -76,44 +82,38 @@ public class CallbacksTest { PV(int version) { this.version = version; } + private int version; + private void set(int version) { this.version = version; } + private int get() { return version; } } - - Cat c = new Cat(); - c.setName( "Kitty" ); - c.setLength( 12 ); - c.setDateOfBirth( new Date( 90, 11, 15 ) ); - PV previousVersion = new PV( c.getManualVersion() ); - - scope.inTransaction( - entityManager -> entityManager.persist( c ) - ); scope.inTransaction( entityManager -> { - Cat _c = entityManager.find( Cat.class, c.getId() ); - assertNotNull( _c.getLastUpdate() ); - assertTrue( previousVersion.get() < _c.getManualVersion() ); - assertEquals( 12, _c.getLength() ); - previousVersion.set( _c.getManualVersion() ); - _c.setName( "new name" ); - } - ); - scope.inTransaction( - entityManager -> { - Cat _c = entityManager.find( Cat.class, c.getId() ); - assertTrue( previousVersion.get() < _c.getManualVersion() ); - } - ); + Cat c = new Cat(); + c.setName( "Kitty" ); + c.setLength( 12 ); + c.setDateOfBirth( new Date( 90, 11, 15 ) ); + PV previousVersion = new PV( c.getManualVersion() ); + entityManager.persist( c ); + entityManager.getTransaction().commit(); - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Cat" ).executeUpdate(); + entityManager.getTransaction().begin(); + c = entityManager.find( Cat.class, c.getId() ); + assertNotNull( c.getLastUpdate() ); + assertTrue( previousVersion.get() < c.getManualVersion() ); + assertEquals( 12, c.getLength() ); + previousVersion.set( c.getManualVersion() ); + c.setName( "new name" ); + entityManager.getTransaction().commit(); + entityManager.getTransaction().begin(); + c = entityManager.find( Cat.class, c.getId() ); + assertTrue( previousVersion.get() < c.getManualVersion() ); } ); } @@ -135,12 +135,6 @@ public class CallbacksTest { List ids = Cat.getIdList(); Object id = Cat.getIdList().get( ids.size() - 1 ); assertNotNull( id ); - - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Cat" ).executeUpdate(); - } - ); } //Not a test since the spec did not make the proper change on listeners @@ -173,20 +167,14 @@ public class CallbacksTest { public void testPrePersistOnCascade(EntityManagerFactoryScope scope) { scope.inTransaction( entityManager -> { - Television tv = new Television(); - RemoteControl rc = new RemoteControl(); - entityManager.persist( tv ); - entityManager.flush(); - tv.setControl( rc ); - tv.init(); - entityManager.flush(); - assertNotNull( rc.getCreationDate() ); - } - ); - - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Television" ).executeUpdate(); + Television tv = new Television(); + RemoteControl rc = new RemoteControl(); + entityManager.persist( tv ); + entityManager.flush(); + tv.setControl( rc ); + tv.init(); + entityManager.flush(); + assertNotNull( rc.getCreationDate() ); } ); } @@ -205,12 +193,6 @@ public class CallbacksTest { assertTrue( tv.isLast ); } ); - - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Television" ).executeUpdate(); - } - ); } @Test @@ -229,7 +211,8 @@ public class CallbacksTest { } catch (Exception e) { fail( "should have raised an ArythmeticException:" + e.getClass() ); - } finally { + } + finally { entityManager.getTransaction().rollback(); entityManager.close(); } @@ -247,81 +230,62 @@ public class CallbacksTest { entityManager.flush(); } ); - - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Plant" ).executeUpdate(); - } - ); } @Test @FailureExpected(reason = "collection change does not trigger an event", jiraKey = "EJB-288") public void testPostUpdateCollection(EntityManagerFactoryScope scope) { - // create a cat - Cat cat = new Cat(); - cat.setLength( 23 ); - cat.setAge( 2 ); - cat.setName( "Beetle" ); - cat.setDateOfBirth( new Date() ); - - scope.inTransaction( + scope.inEntityManager( entityManager -> { - entityManager.persist( cat ); - } - ); + try { + // create a cat + Cat cat = new Cat(); + cat.setLength( 23 ); + cat.setAge( 2 ); + cat.setName( "Beetle" ); + cat.setDateOfBirth( new Date() ); + entityManager.getTransaction().begin(); + entityManager.persist( cat ); + entityManager.getTransaction().commit(); + // assert it is persisted + List ids = Cat.getIdList(); + Object id = Cat.getIdList().get( ids.size() - 1 ); + assertNotNull( id ); - // assert it is persisted - List ids = Cat.getIdList(); - Object id = Cat.getIdList().get( ids.size() - 1 ); - assertNotNull( id ); + // add a kitten to the cat - triggers PostCollectionRecreateEvent + int postVersion = Cat.postVersion; + entityManager.getTransaction().begin(); + Kitten kitty = new Kitten(); + kitty.setName( "kitty" ); + List kittens = new ArrayList(); + kittens.add( kitty ); + cat.setKittens( kittens ); + entityManager.getTransaction().commit(); + assertEquals( postVersion + 1, Cat.postVersion, "Post version should have been incremented." ); - // add a kitten to the cat - triggers PostCollectionRecreateEvent - scope.inTransaction( - entityManager -> { - int postVersion = Cat.postVersion; - Kitten kitty = new Kitten(); - kitty.setName( "kitty" ); - List kittens = new ArrayList(); - kittens.add( kitty ); - cat.setKittens( kittens ); - assertEquals( postVersion + 1, Cat.postVersion, "Post version should have been incremented." ); - } - ); + Kitten tom = new Kitten(); + tom.setName( "Tom" ); - Kitten tom = new Kitten(); - tom.setName( "Tom" ); - scope.inTransaction( - entityManager -> { - // add another kitten - triggers PostCollectionUpdateEvent. - int postVersion = Cat.postVersion; - cat.getKittens().add( tom ); - assertEquals( postVersion + 1, Cat.postVersion, "Post version should have been incremented." ); - } - ); + // add another kitten - triggers PostCollectionUpdateEvent. + postVersion = Cat.postVersion; + entityManager.getTransaction().begin(); + cat.getKittens().add( tom ); + entityManager.getTransaction().commit(); + assertEquals( postVersion + 1, Cat.postVersion, "Post version should have been incremented." ); - scope.inTransaction( - entityManager -> { - // delete a kitty - triggers PostCollectionUpdateEvent - int postVersion = Cat.postVersion; - cat.getKittens().remove( tom ); - assertEquals( postVersion + 1, Cat.postVersion, "Post version should have been incremented." ); - } - ); - - scope.inTransaction( - entityManager -> { - // delete and recreate kittens - triggers PostCollectionRemoveEvent and PostCollectionRecreateEvent) - int postVersion = Cat.postVersion; - cat.setKittens( new ArrayList() ); - assertEquals( postVersion + 2, Cat.postVersion, "Post version should have been incremented." ); - } - ); - - scope.inTransaction( - entityManager -> { - entityManager.createQuery( "delete from Cat" ).executeUpdate(); - entityManager.createQuery( "delete from Kitten" ).executeUpdate(); + // delete a kitty - triggers PostCollectionUpdateEvent + postVersion = Cat.postVersion; + entityManager.getTransaction().begin(); + cat.getKittens().remove( tom ); + entityManager.getTransaction().commit(); + assertEquals( postVersion + 1, Cat.postVersion, "Post version should have been incremented." ); + } + catch (Exception e) { + if ( entityManager.getTransaction().isActive() ) { + entityManager.getTransaction().rollback(); + } + throw e; + } } ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cascade/CascadeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cascade/CascadeTest.java index f6f245da0b..4aaa497504 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cascade/CascadeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cascade/CascadeTest.java @@ -35,11 +35,9 @@ public class CascadeTest { student.setPrimaryTeacher( teacher ); entityManager.persist( teacher ); - } - ); + entityManager.getTransaction().commit(); - scope.inTransaction( - entityManager -> { + entityManager.getTransaction().begin(); Teacher foundTeacher = (Teacher) entityManager.createQuery( "select t from Teacher as t" ) .getSingleResult(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/NoCdiAvailableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/NoCdiAvailableTest.java index f1d21b9b62..6d53eb6884 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/NoCdiAvailableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/NoCdiAvailableTest.java @@ -11,8 +11,9 @@ import java.lang.reflect.Method; import javax.persistence.EntityManagerFactory; import org.hibernate.testing.junit4.ClassLoadingIsolater; +import org.hibernate.testing.orm.junit.BaseUnitTest; import org.junit.Rule; -import org.junit.jupiter.api.Test; +import org.junit.Test; import static org.junit.jupiter.api.Assertions.fail; @@ -21,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.fail; * * @author Steve Ebersole */ +@BaseUnitTest public class NoCdiAvailableTest { public static final String[] EXCLUDED_PACKAGES = new String[] { "javax.enterprise.inject.", diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ConversationalEventManager.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ConversationalEventManager.java deleted file mode 100644 index c0008bcfae..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ConversationalEventManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.jpa.cdi.extended; - -import javax.ejb.LocalBean; -import javax.ejb.Stateful; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; - -/** - * @author Vlad Mihalcea - */ -@Stateful -@LocalBean -public class ConversationalEventManager { - - @PersistenceContext(type = PersistenceContextType.EXTENDED) - private EntityManager em; - - @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) - public Event saveEvent(String eventName) { - final Event event = new Event(); - event.setName( eventName ); - em.persist( event ); - return event; - } - - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void endConversation() { - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/Event.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/Event.java deleted file mode 100644 index 8c990a038d..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/Event.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.jpa.cdi.extended; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -/** - * @author Vlad Mihalcea - */ -@Entity(name = "Event") -public class Event { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private String name; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ManualFlushConversationalEventManager.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ManualFlushConversationalEventManager.java deleted file mode 100644 index 1aec0d81c2..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/ManualFlushConversationalEventManager.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.jpa.cdi.extended; - -import javax.annotation.PostConstruct; -import javax.ejb.LocalBean; -import javax.ejb.Stateful; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; - -import org.hibernate.FlushMode; -import org.hibernate.Session; - -/** - * @author Vlad Mihalcea - */ -@Stateful -@LocalBean -public class ManualFlushConversationalEventManager { - - @PersistenceContext(type = PersistenceContextType.EXTENDED) - private EntityManager em; - - @PostConstruct - public void init() { - em.unwrap( Session.class ).setHibernateFlushMode( FlushMode.MANUAL ); - } - - public Event saveEvent(String eventName) { - final Event event = new Event(); - event.setName( eventName ); - em.persist( event ); - return event; - } - - public void endConversation() { - em.flush(); - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/NonConversationalEventManager.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/NonConversationalEventManager.java deleted file mode 100644 index 80c2ff9e94..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/cdi/extended/NonConversationalEventManager.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.jpa.cdi.extended; - -import javax.ejb.LocalBean; -import javax.ejb.Stateful; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; - -/** - * @author Vlad Mihalcea - */ -@Stateful -@LocalBean -public class NonConversationalEventManager { - - @PersistenceContext(type = PersistenceContextType.EXTENDED) - private EntityManager em; - - public Event saveEvent(String eventName) { - final Event event = new Event(); - event.setName( eventName ); - em.persist( event ); - return event; - } - - public void endConversation() { - em.flush(); - } -} diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseUnitTest.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseUnitTest.java index 70339edd93..d918effebe 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseUnitTest.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseUnitTest.java @@ -13,7 +13,6 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ParameterContext; @Inherited @Target( ElementType.TYPE )