HHH-12098 - prep 5.3
This commit is contained in:
parent
8c2a683356
commit
7fc5d3e856
|
@ -67,7 +67,7 @@ dependencies {
|
|||
provided( libraries.jacc )
|
||||
provided( libraries.validation )
|
||||
provided( libraries.ant )
|
||||
provided( "javax.enterprise:cdi-api:${cdiVersion}" )
|
||||
provided( libraries.cdi )
|
||||
|
||||
testCompile( project(':hibernate-testing') )
|
||||
testCompile( libraries.shrinkwrap_api )
|
||||
|
@ -79,9 +79,8 @@ dependencies {
|
|||
testCompile( libraries.mockito )
|
||||
testCompile( libraries.mockito_inline )
|
||||
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( "javax.enterprise:cdi-api:${cdiVersion}" ) {
|
||||
|
||||
testCompile( libraries.cdi ) {
|
||||
// we need to force it to make sure we influence the one coming from arquillian
|
||||
force=true
|
||||
}
|
||||
|
@ -100,6 +99,7 @@ dependencies {
|
|||
testRuntime( 'jaxen:jaxen:1.1' )
|
||||
testRuntime( libraries.javassist )
|
||||
testRuntime( libraries.byteBuddy )
|
||||
testRuntime( libraries.weld )
|
||||
|
||||
testCompile( project( ':hibernate-jpamodelgen' ) )
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.hibernate.tool.schema.SourceType;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AvailableSettings {
|
||||
public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// JPA defined settings
|
||||
|
|
|
@ -10,92 +10,101 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.enterprise.inject.se.SeContainer;
|
||||
import javax.enterprise.inject.se.SeContainerInitializer;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.PersistenceUnit;
|
||||
import javax.persistence.PrePersist;
|
||||
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.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.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
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;
|
||||
|
||||
@Test
|
||||
@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;
|
||||
|
||||
utx.begin();
|
||||
EntityManager em = emf.createEntityManager();
|
||||
em.persist( new MyEntity( 1 ) );
|
||||
utx.commit();
|
||||
try ( final SeContainer cdiContainer = cdiInitializer.initialize() ) {
|
||||
BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder()
|
||||
.applyIntegrator( new JpaIntegrator() )
|
||||
.build();
|
||||
|
||||
assertEquals( 1, count );
|
||||
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();
|
||||
|
||||
utx.begin();
|
||||
em = emf.createEntityManager();
|
||||
MyEntity it = em.find( MyEntity.class, 1 );
|
||||
assertNotNull( it );
|
||||
em.remove( it );
|
||||
utx.commit();
|
||||
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 );
|
||||
|
||||
inTransaction(
|
||||
sessionFactory,
|
||||
session -> {
|
||||
MyEntity it = session.find( MyEntity.class, 1 );
|
||||
assertNotNull( it );
|
||||
}
|
||||
);
|
||||
}
|
||||
finally {
|
||||
inTransaction(
|
||||
sessionFactory,
|
||||
session -> {
|
||||
session.createQuery( "delete MyEntity" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
|
||||
sessionFactory.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Entity( name = "MyEntity" )
|
||||
@EntityListeners( Monitor.class )
|
||||
@Table(name = "my_entity")
|
||||
public static class MyEntity {
|
||||
|
@ -132,7 +141,7 @@ public class BasicCdiTest {
|
|||
|
||||
public void addEvent(Event anEvent) {
|
||||
if ( events == null ) {
|
||||
events = new ArrayList<Event>();
|
||||
events = new ArrayList<>();
|
||||
}
|
||||
events.add( anEvent );
|
||||
count++;
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.ejb.EJB;
|
|||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -29,6 +30,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class ConversationalPersistenceContextExtendedTest {
|
||||
|
||||
@Deployment
|
||||
|
|
|
@ -11,6 +11,7 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -30,6 +31,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class ManualFlushConversationalPersistenceContextExtendedTest {
|
||||
|
||||
@Deployment
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.ejb.EJB;
|
|||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -29,6 +30,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class NonConversationalPersistenceContextExtendedTest {
|
||||
|
||||
@Deployment
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
|
|||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -43,6 +44,7 @@ import static org.junit.Assert.assertNotNull;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@RunWith( Arquillian.class )
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingBmtAndEmfTest {
|
||||
|
||||
public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml";
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.test.wf.ddl.bmt.sf;
|
|||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -22,6 +23,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
|
|||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@TestForIssue(jiraKey = "HHH-11024")
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingBmtAndSfTest {
|
||||
|
||||
public static final String ARCHIVE_NAME = BmtSfStatefulBean.class.getSimpleName();
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
|
|||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -41,6 +42,7 @@ import static org.junit.Assert.assertNotNull;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@RunWith( Arquillian.class )
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingBmtAndEmfTest {
|
||||
|
||||
public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml";
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.test.wf.ddl.cmt.sf;
|
|||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -22,6 +23,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
|
|||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@TestForIssue(jiraKey = "HHH-11024")
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingCmtAndSfTest {
|
||||
|
||||
public static final String ARCHIVE_NAME = CmtSfStatefulBean.class.getSimpleName();
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
public @interface FailureExpected {
|
||||
String VALIDATE_FAILURE_EXPECTED = "hibernate.test.validatefailureexpected";
|
||||
|
||||
/**
|
||||
* The key of a JIRA issue which covers this expected failure.
|
||||
* @return The jira issue key
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.junit.runners.model.TestClass;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
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() {
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ ext {
|
|||
infinispanVersion = '8.2.5.Final'
|
||||
jnpVersion = '5.0.6.CR1'
|
||||
elVersion = '2.2.4'
|
||||
cdiVersion = '1.1'
|
||||
|
||||
cdiVersion = '2.0'
|
||||
weldVersion = '3.0.0.Final'
|
||||
|
||||
javassistVersion = '3.22.0-GA'
|
||||
byteBuddyVersion = '1.6.14' // Improved JDK9 compatibility
|
||||
|
@ -130,6 +132,9 @@ ext {
|
|||
proxool: "proxool:proxool:0.8.3",
|
||||
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_junit_container: "org.jboss.arquillian.junit:arquillian-junit-container:${arquillianVersion}",
|
||||
arquillian_protocol_servlet: "org.jboss.arquillian.protocol:arquillian-protocol-servlet:${arquillianVersion}",
|
||||
|
|
Loading…
Reference in New Issue