diff --git a/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/StaticClassLists.java b/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/StaticClassLists.java index 7197f42917..f7ce9ef39d 100644 --- a/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/StaticClassLists.java +++ b/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/StaticClassLists.java @@ -84,10 +84,12 @@ final class StaticClassLists { org.hibernate.event.spi.PreLoadEventListener[].class, org.hibernate.event.spi.PreDeleteEventListener[].class, org.hibernate.event.spi.PreUpdateEventListener[].class, + org.hibernate.event.spi.PreUpsertEventListener[].class, org.hibernate.event.spi.PreInsertEventListener[].class, org.hibernate.event.spi.PostLoadEventListener[].class, org.hibernate.event.spi.PostDeleteEventListener[].class, org.hibernate.event.spi.PostUpdateEventListener[].class, + org.hibernate.event.spi.PostUpsertEventListener[].class, org.hibernate.event.spi.PostInsertEventListener[].class, org.hibernate.event.spi.PreCollectionRecreateEventListener[].class, org.hibernate.event.spi.PreCollectionRemoveEventListener[].class, diff --git a/hibernate-graalvm/src/test/java/org/hibernate/graalvm/internal/BasicConstructorsAvailableTest.java b/hibernate-graalvm/src/test/java/org/hibernate/graalvm/internal/BasicConstructorsAvailableTest.java deleted file mode 100644 index dd60ab9762..0000000000 --- a/hibernate-graalvm/src/test/java/org/hibernate/graalvm/internal/BasicConstructorsAvailableTest.java +++ /dev/null @@ -1,50 +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.graalvm.internal; - -import java.lang.reflect.Constructor; - -import org.hibernate.internal.util.ReflectHelper; - -import org.junit.Assert; -import org.junit.Test; - -public class BasicConstructorsAvailableTest { - - @Test - public void checkNonDefaultConstructorsCanBeLoaded() { - Class[] classes = StaticClassLists.typesNeedingAllConstructorsAccessible(); - for ( Class c : classes ) { - Constructor[] declaredConstructors = c.getDeclaredConstructors(); - Assert.assertTrue( declaredConstructors.length > 0 ); - if ( declaredConstructors.length == 1 ) { - //If there's only one, let's check that this class wasn't placed in the wrong cathegory: - Assert.assertTrue( declaredConstructors[0].getParameterCount() > 0 ); - } - } - } - - @Test - public void checkDefaultConstructorsAreAvailable() { - Class[] classes = StaticClassLists.typesNeedingDefaultConstructorAccessible(); - for ( Class c : classes ) { - Constructor constructor = ReflectHelper.getDefaultConstructor( c ); - Assert.assertNotNull( "Failed for class: " + c.getName(), constructor ); - } - } - - @Test - public void checkArraysAreArrays() { - Class[] classes = StaticClassLists.typesNeedingArrayCopy(); - for ( Class c : classes ) { - Assert.assertTrue( "Wrong category for type: " + c.getName(), c.isArray() ); - Constructor[] constructors = c.getConstructors(); - Assert.assertEquals( 0, constructors.length ); - } - } - -} diff --git a/hibernate-graalvm/src/test/java/org/hibernate/graalvm/internal/StaticClassListsTest.java b/hibernate-graalvm/src/test/java/org/hibernate/graalvm/internal/StaticClassListsTest.java new file mode 100644 index 0000000000..2a73c0e026 --- /dev/null +++ b/hibernate-graalvm/src/test/java/org/hibernate/graalvm/internal/StaticClassListsTest.java @@ -0,0 +1,75 @@ +/* + * 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.graalvm.internal; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.hibernate.event.spi.EventType; +import org.hibernate.internal.util.ReflectHelper; + +import org.junit.Assert; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +public class StaticClassListsTest { + + @Nested + class TypesNeedingArrayCopy { + @Test + void containsEventListenerInterfaces() { + assertThat( StaticClassLists.typesNeedingArrayCopy() ) + .containsAll( eventListenerInterfaces().collect( Collectors.toSet() ) ); + } + + static Stream> eventListenerInterfaces() { + return EventType.values().stream().map( EventType::baseListenerInterface ) + .map( c -> Array.newInstance( c, 0 ).getClass() ); + } + } + + @Nested + class BasicConstructorsAvailable { + + @Test + void checkNonDefaultConstructorsCanBeLoaded() { + Class[] classes = StaticClassLists.typesNeedingAllConstructorsAccessible(); + for ( Class c : classes ) { + Constructor[] declaredConstructors = c.getDeclaredConstructors(); + Assert.assertTrue( declaredConstructors.length > 0 ); + if ( declaredConstructors.length == 1 ) { + //If there's only one, let's check that this class wasn't placed in the wrong cathegory: + Assert.assertTrue( declaredConstructors[0].getParameterCount() > 0 ); + } + } + } + + @Test + void checkDefaultConstructorsAreAvailable() { + Class[] classes = StaticClassLists.typesNeedingDefaultConstructorAccessible(); + for ( Class c : classes ) { + Constructor constructor = ReflectHelper.getDefaultConstructor( c ); + Assert.assertNotNull( "Failed for class: " + c.getName(), constructor ); + } + } + + @Test + public void checkArraysAreArrays() { + Class[] classes = StaticClassLists.typesNeedingArrayCopy(); + for ( Class c : classes ) { + Assert.assertTrue( "Wrong category for type: " + c.getName(), c.isArray() ); + Constructor[] constructors = c.getConstructors(); + Assert.assertEquals( 0, constructors.length ); + } + } + + } +}