HHH-12098 - prep 5.3

This commit is contained in:
Steve Ebersole 2017-12-11 13:56:28 -06:00
parent 8c2a683356
commit 7fc5d3e856
13 changed files with 98 additions and 68 deletions

View File

@ -67,7 +67,7 @@ dependencies {
provided( libraries.jacc ) provided( libraries.jacc )
provided( libraries.validation ) provided( libraries.validation )
provided( libraries.ant ) provided( libraries.ant )
provided( "javax.enterprise:cdi-api:${cdiVersion}" ) provided( libraries.cdi )
testCompile( project(':hibernate-testing') ) testCompile( project(':hibernate-testing') )
testCompile( libraries.shrinkwrap_api ) testCompile( libraries.shrinkwrap_api )
@ -79,9 +79,8 @@ dependencies {
testCompile( libraries.mockito ) testCompile( libraries.mockito )
testCompile( libraries.mockito_inline ) testCompile( libraries.mockito_inline )
testCompile( 'joda-time:joda-time:2.3' ) testCompile( 'joda-time:joda-time:2.3' )
// testCompile( "org.jboss.weld:weld-core:2.3.4.Final" )
// testCompile( "org.jboss.arquillian.container:arquillian-weld-ee-embedded-1.1:1.0.0.CR9" ) testCompile( libraries.cdi ) {
testCompile( "javax.enterprise:cdi-api:${cdiVersion}" ) {
// we need to force it to make sure we influence the one coming from arquillian // we need to force it to make sure we influence the one coming from arquillian
force=true force=true
} }
@ -100,6 +99,7 @@ dependencies {
testRuntime( 'jaxen:jaxen:1.1' ) testRuntime( 'jaxen:jaxen:1.1' )
testRuntime( libraries.javassist ) testRuntime( libraries.javassist )
testRuntime( libraries.byteBuddy ) testRuntime( libraries.byteBuddy )
testRuntime( libraries.weld )
testCompile( project( ':hibernate-jpamodelgen' ) ) testCompile( project( ':hibernate-jpamodelgen' ) )

View File

@ -24,7 +24,7 @@ import org.hibernate.tool.schema.SourceType;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface AvailableSettings { public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// JPA defined settings // JPA defined settings

View File

@ -10,92 +10,101 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.enterprise.inject.se.SeContainer;
import javax.inject.Inject; import javax.enterprise.inject.se.SeContainerInitializer;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityListeners; import javax.persistence.EntityListeners;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.PersistenceUnit;
import javax.persistence.PrePersist; import javax.persistence.PrePersist;
import javax.persistence.Table; import javax.persistence.Table;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction; import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.jpa.event.spi.JpaIntegrator;
import org.hibernate.tool.schema.Action;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RunWith(Arquillian.class)
public class BasicCdiTest { public class BasicCdiTest {
@Deployment
public static Archive<?> buildDeployment() {
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
.addClass( MyEntity.class )
.addClass( EventQueue.class )
.addClass( Event.class )
.addClass( Monitor.class )
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" )
.addAsManifestResource( new StringAsset( persistenceXml().exportAsString() ), "persistence.xml" );
}
private static PersistenceDescriptor persistenceXml() {
return Descriptors.create( PersistenceDescriptor.class )
.createPersistenceUnit().name( "pu-cdi-basic" )
.clazz( MyEntity.class.getName() )
.excludeUnlistedClasses( true )
.nonJtaDataSource( "java:jboss/datasources/ExampleDS" )
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
.getOrCreateProperties().createProperty().name( "hibernate.delay_cdi_access" ).value( "true" ).up().up()
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
}
@PersistenceUnit
EntityManagerFactory emf;
@Resource
private UserTransaction utx;
private static int count; private static int count;
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testIt() throws Exception { public void testIt() {
final SeContainerInitializer cdiInitializer = SeContainerInitializer.newInstance()
.disableDiscovery()
.addBeanClasses( Monitor.class, EventQueue.class, Event.class );
count = 0; count = 0;
utx.begin(); try ( final SeContainer cdiContainer = cdiInitializer.initialize() ) {
EntityManager em = emf.createEntityManager(); BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder()
em.persist( new MyEntity( 1 ) ); .applyIntegrator( new JpaIntegrator() )
utx.commit(); .build();
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder( bsr )
.applySetting( AvailableSettings.CDI_BEAN_MANAGER, cdiContainer.getBeanManager() )
.applySetting( AvailableSettings.DELAY_CDI_ACCESS, "true" )
.applySetting( AvailableSettings.HBM2DDL_AUTO, Action.CREATE_DROP )
.build();
final SessionFactoryImplementor sessionFactory;
try {
sessionFactory = (SessionFactoryImplementor) new MetadataSources( ssr )
.addAnnotatedClass( MyEntity.class )
.buildMetadata()
.getSessionFactoryBuilder()
.build();
}
catch ( Exception e ) {
StandardServiceRegistryBuilder.destroy( ssr );
throw e;
}
try {
inTransaction(
sessionFactory,
session -> session.persist( new MyEntity( 1 ) )
);
assertEquals( 1, count ); assertEquals( 1, count );
utx.begin(); inTransaction(
em = emf.createEntityManager(); sessionFactory,
MyEntity it = em.find( MyEntity.class, 1 ); session -> {
MyEntity it = session.find( MyEntity.class, 1 );
assertNotNull( it ); assertNotNull( it );
em.remove( it ); }
utx.commit(); );
}
finally {
inTransaction(
sessionFactory,
session -> {
session.createQuery( "delete MyEntity" ).executeUpdate();
}
);
sessionFactory.close();
}
}
} }
@Entity @Entity( name = "MyEntity" )
@EntityListeners( Monitor.class ) @EntityListeners( Monitor.class )
@Table(name = "my_entity") @Table(name = "my_entity")
public static class MyEntity { public static class MyEntity {
@ -132,7 +141,7 @@ public class BasicCdiTest {
public void addEvent(Event anEvent) { public void addEvent(Event anEvent) {
if ( events == null ) { if ( events == null ) {
events = new ArrayList<Event>(); events = new ArrayList<>();
} }
events.add( anEvent ); events.add( anEvent );
count++; count++;

View File

@ -10,6 +10,7 @@ import javax.ejb.EJB;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -29,6 +30,7 @@ import static org.junit.Assert.assertEquals;
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class ConversationalPersistenceContextExtendedTest { public class ConversationalPersistenceContextExtendedTest {
@Deployment @Deployment

View File

@ -11,6 +11,7 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -30,6 +31,7 @@ import static org.junit.Assert.assertEquals;
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class ManualFlushConversationalPersistenceContextExtendedTest { public class ManualFlushConversationalPersistenceContextExtendedTest {
@Deployment @Deployment

View File

@ -10,6 +10,7 @@ import javax.ejb.EJB;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -29,6 +30,7 @@ import static org.junit.Assert.assertEquals;
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class NonConversationalPersistenceContextExtendedTest { public class NonConversationalPersistenceContextExtendedTest {
@Deployment @Deployment

View File

@ -24,6 +24,7 @@ import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
import org.hibernate.jpa.boot.spi.Bootstrap; import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.test.wf.ddl.WildFlyDdlEntity; import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -43,6 +44,7 @@ import static org.junit.Assert.assertNotNull;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RunWith( Arquillian.class ) @RunWith( Arquillian.class )
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class DdlInWildFlyUsingBmtAndEmfTest { public class DdlInWildFlyUsingBmtAndEmfTest {
public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml"; public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml";

View File

@ -8,6 +8,7 @@ package org.hibernate.test.wf.ddl.bmt.sf;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.test.wf.ddl.WildFlyDdlEntity; import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -22,6 +23,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
*/ */
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
@TestForIssue(jiraKey = "HHH-11024") @TestForIssue(jiraKey = "HHH-11024")
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class DdlInWildFlyUsingBmtAndSfTest { public class DdlInWildFlyUsingBmtAndSfTest {
public static final String ARCHIVE_NAME = BmtSfStatefulBean.class.getSimpleName(); public static final String ARCHIVE_NAME = BmtSfStatefulBean.class.getSimpleName();

View File

@ -22,6 +22,7 @@ import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
import org.hibernate.jpa.boot.spi.Bootstrap; import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.test.wf.ddl.WildFlyDdlEntity; import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -41,6 +42,7 @@ import static org.junit.Assert.assertNotNull;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RunWith( Arquillian.class ) @RunWith( Arquillian.class )
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class DdlInWildFlyUsingBmtAndEmfTest { public class DdlInWildFlyUsingBmtAndEmfTest {
public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml"; public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml";

View File

@ -8,6 +8,7 @@ package org.hibernate.test.wf.ddl.cmt.sf;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.test.wf.ddl.WildFlyDdlEntity; import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -22,6 +23,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
*/ */
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
@TestForIssue(jiraKey = "HHH-11024") @TestForIssue(jiraKey = "HHH-11024")
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
public class DdlInWildFlyUsingCmtAndSfTest { public class DdlInWildFlyUsingCmtAndSfTest {
public static final String ARCHIVE_NAME = CmtSfStatefulBean.class.getSimpleName(); public static final String ARCHIVE_NAME = CmtSfStatefulBean.class.getSimpleName();

View File

@ -20,6 +20,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE }) @Target({ ElementType.METHOD, ElementType.TYPE })
public @interface FailureExpected { public @interface FailureExpected {
String VALIDATE_FAILURE_EXPECTED = "hibernate.test.validatefailureexpected";
/** /**
* The key of a JIRA issue which covers this expected failure. * The key of a JIRA issue which covers this expected failure.
* @return The jira issue key * @return The jira issue key

View File

@ -26,7 +26,7 @@ import org.junit.runners.model.TestClass;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public final class Helper { public final class Helper {
public static final String VALIDATE_FAILURE_EXPECTED = "hibernate.test.validatefailureexpected"; public static final String VALIDATE_FAILURE_EXPECTED = FailureExpected.VALIDATE_FAILURE_EXPECTED;
private Helper() { private Helper() {
} }

View File

@ -15,7 +15,9 @@ ext {
infinispanVersion = '8.2.5.Final' infinispanVersion = '8.2.5.Final'
jnpVersion = '5.0.6.CR1' jnpVersion = '5.0.6.CR1'
elVersion = '2.2.4' elVersion = '2.2.4'
cdiVersion = '1.1'
cdiVersion = '2.0'
weldVersion = '3.0.0.Final'
javassistVersion = '3.22.0-GA' javassistVersion = '3.22.0-GA'
byteBuddyVersion = '1.6.14' // Improved JDK9 compatibility byteBuddyVersion = '1.6.14' // Improved JDK9 compatibility
@ -130,6 +132,9 @@ ext {
proxool: "proxool:proxool:0.8.3", proxool: "proxool:proxool:0.8.3",
hikaricp: "com.zaxxer:HikariCP:2.5.1", hikaricp: "com.zaxxer:HikariCP:2.5.1",
cdi: "javax.enterprise:cdi-api:${cdiVersion}",
weld: "org.jboss.weld.se:weld-se-shaded:${weldVersion}",
// Arquillian/Shrinkwrap // Arquillian/Shrinkwrap
arquillian_junit_container: "org.jboss.arquillian.junit:arquillian-junit-container:${arquillianVersion}", arquillian_junit_container: "org.jboss.arquillian.junit:arquillian-junit-container:${arquillianVersion}",
arquillian_protocol_servlet: "org.jboss.arquillian.protocol:arquillian-protocol-servlet:${arquillianVersion}", arquillian_protocol_servlet: "org.jboss.arquillian.protocol:arquillian-protocol-servlet:${arquillianVersion}",