HHH-13952 Remove all WildFly based integration tests
This commit is contained in:
parent
2b279c6a83
commit
1aa2e858ba
|
@ -31,7 +31,7 @@ ext {
|
|||
|
||||
geolatteVersion = '1.4.0'
|
||||
|
||||
// Wildfly version targeted by module ZIP; Arquillian/Shrinkwrap versions used for CDI testing and testing the module ZIP
|
||||
// Wildfly version targeted by the custom Jipijapa build
|
||||
wildflyVersion = '17.0.1.Final'
|
||||
arquillianVersion = '1.4.1.Final'
|
||||
shrinkwrapVersion = '1.2.6'
|
||||
|
|
|
@ -240,16 +240,6 @@ artifacts {
|
|||
tests testJar
|
||||
}
|
||||
|
||||
processTestResources {
|
||||
doLast {
|
||||
copy {
|
||||
from file( 'src/test/resources' )
|
||||
into file( "${buildDir}/resources/test" )
|
||||
include 'org/hibernate/test/wf/ddl/manifest.mf'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
systemProperty 'file.encoding', 'utf-8'
|
||||
beforeTest { descriptor ->
|
||||
|
|
|
@ -1,70 +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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.cdi.extended;
|
||||
|
||||
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;
|
||||
|
||||
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.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
|
||||
public static Archive<?> buildDeployment() {
|
||||
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
|
||||
.addClass( Event.class )
|
||||
.addClass( ConversationalEventManager.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-beans-basic" )
|
||||
.clazz( Event.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.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
|
||||
}
|
||||
|
||||
@EJB
|
||||
private ConversationalEventManager eventManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testIt() throws Exception {
|
||||
Event event = eventManager.saveEvent( "Untold" );
|
||||
assertEquals(0, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
eventManager.endConversation();
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,72 +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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.cdi.extended;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
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;
|
||||
|
||||
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.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
|
||||
public static Archive<?> buildDeployment() {
|
||||
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
|
||||
.addClass( Event.class )
|
||||
.addClass( ManualFlushConversationalEventManager.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-beans-basic" )
|
||||
.clazz( Event.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.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
|
||||
}
|
||||
|
||||
@EJB
|
||||
private ManualFlushConversationalEventManager eventManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-11019" )
|
||||
public void testIt() throws Exception {
|
||||
Event event = eventManager.saveEvent( "Untold" );
|
||||
//This is going to be fixed by HHH-11019 since we could rely on FlushMode to implement long conversations properly
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
eventManager.endConversation();
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.cdi.extended;
|
||||
|
||||
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;
|
||||
|
||||
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.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
|
||||
public static Archive<?> buildDeployment() {
|
||||
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
|
||||
.addClass( Event.class )
|
||||
.addClass( NonConversationalEventManager.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-beans-basic" )
|
||||
.clazz( Event.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.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
|
||||
}
|
||||
|
||||
@EJB
|
||||
private NonConversationalEventManager eventManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Test
|
||||
public void testIt() throws Exception {
|
||||
Event event = eventManager.saveEvent( "Untold" );
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
eventManager.endConversation();
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class WildFlyDdlEntity {
|
||||
@Id
|
||||
Integer id;
|
||||
String name;
|
||||
}
|
|
@ -1,66 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.emf;
|
||||
|
||||
import javax.ejb.Remove;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
/**
|
||||
* Arquillian "component" for testing auto-ddl execution when initiated by the "app"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.BEAN)
|
||||
public class BmtEmfStatefulBean {
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@Inject
|
||||
UserTransaction utx;
|
||||
|
||||
public void start() {
|
||||
// creating the SF should run schema creation
|
||||
emf = Persistence.createEntityManagerFactory( "pu-wf-ddl" );
|
||||
}
|
||||
|
||||
@Remove
|
||||
public void stop() {
|
||||
|
||||
try {
|
||||
utx.begin();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to start JTA transaction via UserTransaction", e );
|
||||
}
|
||||
|
||||
try {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
emf.close();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
try {
|
||||
utx.rollback();
|
||||
}
|
||||
catch (Exception e1) {
|
||||
throw new RuntimeException( "Unable to rollback JTA transaction via UserTransaction", e );
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
utx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to commit JTA transaction via UserTransaction", e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.emf;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import javax.annotation.Resource;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||
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;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
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";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "pu-wf-ddl";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive buildDeployment() {
|
||||
WebArchive war = ShrinkWrap.create( WebArchive.class )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClass( WildFlyDdlEntity.class )
|
||||
// .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml")
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), PERSISTENCE_XML_RESOURCE_NAME )
|
||||
.addAsResource( "org/hibernate/test/wf/ddl/log4j.properties", "log4j.properties" );
|
||||
System.out.println( war.toString(true) );
|
||||
return war;
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
final PersistenceDescriptor pd = Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit().name( PERSISTENCE_UNIT_NAME )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.clazz( WildFlyDdlEntity.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up()
|
||||
// this should not be needed, but...
|
||||
.getOrCreateProperties().createProperty().name( AvailableSettings.JTA_PLATFORM ).value( JBossAppServerJtaPlatform.class.getName() ).up().up()
|
||||
.up();
|
||||
|
||||
|
||||
System.out.println( "persistence.xml: " );
|
||||
pd.exportTo( System.out );
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
@ArquillianResource
|
||||
private InitialContext initialContext;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop() throws Exception {
|
||||
URL persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( PERSISTENCE_XML_RESOURCE_NAME );
|
||||
if ( persistenceXmlUrl == null ) {
|
||||
persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( '/' + PERSISTENCE_XML_RESOURCE_NAME );
|
||||
}
|
||||
|
||||
assertNotNull( persistenceXmlUrl );
|
||||
|
||||
ParsedPersistenceXmlDescriptor persistenceUnit = PersistenceXmlParser.locateIndividualPersistenceUnit( persistenceXmlUrl );
|
||||
// creating the EMF causes SchemaCreator to be run...
|
||||
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder( persistenceUnit, Collections.emptyMap() ).build();
|
||||
|
||||
// closing the EMF causes the delayed SchemaDropper to be run...
|
||||
// wrap in a transaction just to see if we can get this to fail in the way the WF report says;
|
||||
// in my experience however this succeeds with or without the transaction
|
||||
final TransactionManager tm = emf.unwrap( SessionFactoryImplementor.class ).getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
|
||||
|
||||
tm.begin();
|
||||
Transaction txn = tm.getTransaction();
|
||||
emf.close();
|
||||
txn.commit();
|
||||
}
|
||||
}
|
|
@ -1,76 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.sf;
|
||||
|
||||
import javax.ejb.Remove;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
|
||||
/**
|
||||
* Arquillian "component" for testing auto-ddl execution when initiated by the "app"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.BEAN)
|
||||
public class BmtSfStatefulBean {
|
||||
private static SessionFactory sessionFactory;
|
||||
|
||||
@Inject
|
||||
UserTransaction utx;
|
||||
|
||||
public void start() {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration = configuration.configure( "hibernate.cfg.xml" );
|
||||
configuration.addAnnotatedClass( WildFlyDdlEntity.class );
|
||||
|
||||
// creating the SF should run schema creation
|
||||
sessionFactory = configuration.buildSessionFactory();
|
||||
}
|
||||
|
||||
@Remove
|
||||
public void stop() {
|
||||
try {
|
||||
utx.begin();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to start JTA transaction via UserTransaction", e );
|
||||
}
|
||||
|
||||
try {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
sessionFactory.close();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
try {
|
||||
utx.rollback();
|
||||
}
|
||||
catch (Exception e1) {
|
||||
throw new RuntimeException( "Unable to rollback JTA transaction via UserTransaction", e );
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
try {
|
||||
utx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to commit JTA transaction via UserTransaction", e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,67 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
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;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@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();
|
||||
|
||||
public static final String hibernate_cfg = "<?xml version='1.0' encoding='utf-8'?>"
|
||||
+ "<!DOCTYPE hibernate-configuration PUBLIC " + "\"//Hibernate/Hibernate Configuration DTD 3.0//EN\" "
|
||||
+ "\"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">"
|
||||
+ "<hibernate-configuration><session-factory>" + "<property name=\"show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.hbm2ddl.auto\">create-drop</property>"
|
||||
+ "<property name=\"hibernate.connection.datasource\">java:jboss/datasources/ExampleDS</property>"
|
||||
+ "<property name=\"hibernate.transaction.jta.platform\">JBossAS</property>"
|
||||
+ "<property name=\"hibernate.transaction.coordinator_class\">jta</property>"
|
||||
+ "<property name=\"hibernate.id.new_generator_mappings\">true</property>"
|
||||
+ "</session-factory></hibernate-configuration>";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive deploy() throws Exception {
|
||||
final WebArchive war = ShrinkWrap.create( WebArchive.class, ARCHIVE_NAME + ".war" )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClasses( WildFlyDdlEntity.class )
|
||||
.addAsResource( new StringAsset( hibernate_cfg ), "hibernate.cfg.xml" )
|
||||
.addClasses( BmtSfStatefulBean.class )
|
||||
.addClasses( DdlInWildFlyUsingBmtAndSfTest.class );
|
||||
return war;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop(BmtSfStatefulBean ejb) throws Exception {
|
||||
assert ejb != null : "Method injected StatefulCMTBean reference was null";
|
||||
|
||||
try {
|
||||
ejb.start();
|
||||
}
|
||||
finally {
|
||||
ejb.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.emf;
|
||||
|
||||
import javax.ejb.Remove;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
|
||||
/**
|
||||
* Arquillian "component" for testing auto-ddl execution when initiated by the "app"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.CONTAINER)
|
||||
public class CmtEmfStatefulBean {
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.NEVER)
|
||||
public void start() {
|
||||
// creating the SF should run schema creation
|
||||
emf = Persistence.createEntityManagerFactory( "pu-wf-ddl" );
|
||||
}
|
||||
|
||||
@Remove
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public void stop() {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
emf.close();
|
||||
}
|
||||
}
|
|
@ -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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.emf;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||
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;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
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";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "pu-wf-ddl";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive buildDeployment() {
|
||||
WebArchive war = ShrinkWrap.create( WebArchive.class )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClass( WildFlyDdlEntity.class )
|
||||
// .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml")
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), PERSISTENCE_XML_RESOURCE_NAME )
|
||||
.addAsResource( "org/hibernate/test/wf/ddl/log4j.properties", "log4j.properties" );
|
||||
System.out.println( war.toString(true) );
|
||||
return war;
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
final PersistenceDescriptor pd = Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit().name( PERSISTENCE_UNIT_NAME )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.clazz( WildFlyDdlEntity.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up()
|
||||
// this should not be needed, but...
|
||||
.getOrCreateProperties().createProperty().name( AvailableSettings.JTA_PLATFORM ).value( JBossAppServerJtaPlatform.class.getName() ).up().up()
|
||||
.up();
|
||||
|
||||
|
||||
System.out.println( "persistence.xml: " );
|
||||
pd.exportTo( System.out );
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
@ArquillianResource
|
||||
private InitialContext initialContext;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop() throws Exception {
|
||||
URL persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( PERSISTENCE_XML_RESOURCE_NAME );
|
||||
if ( persistenceXmlUrl == null ) {
|
||||
persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( '/' + PERSISTENCE_XML_RESOURCE_NAME );
|
||||
}
|
||||
|
||||
assertNotNull( persistenceXmlUrl );
|
||||
|
||||
ParsedPersistenceXmlDescriptor persistenceUnit = PersistenceXmlParser.locateIndividualPersistenceUnit( persistenceXmlUrl );
|
||||
// creating the EMF causes SchemaCreator to be run...
|
||||
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder( persistenceUnit, Collections.emptyMap() ).build();
|
||||
|
||||
// closing the EMF causes the delayed SchemaDropper to be run...
|
||||
// wrap in a transaction just to see if we can get this to fail in the way the WF report says;
|
||||
// in my experience however this succeeds with or without the transaction
|
||||
final TransactionManager tm = emf.unwrap( SessionFactoryImplementor.class ).getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
|
||||
|
||||
tm.begin();
|
||||
Transaction txn = tm.getTransaction();
|
||||
emf.close();
|
||||
txn.commit();
|
||||
}
|
||||
}
|
|
@ -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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.sf;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
|
||||
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.CONTAINER)
|
||||
public class CmtSfStatefulBean {
|
||||
|
||||
private static SessionFactory sessionFactory;
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.NEVER)
|
||||
public void start() {
|
||||
try {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration = configuration.configure( "hibernate.cfg.xml" );
|
||||
configuration.addAnnotatedClass( WildFlyDdlEntity.class );
|
||||
|
||||
sessionFactory = configuration.buildSessionFactory();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
System.err.println( "Initial SessionFactory creation failed." + ex );
|
||||
throw new ExceptionInInitializerError( ex );
|
||||
}
|
||||
}
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public void stop() {
|
||||
sessionFactory.close();
|
||||
}
|
||||
}
|
|
@ -1,67 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
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;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@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();
|
||||
|
||||
public static final String hibernate_cfg = "<?xml version='1.0' encoding='utf-8'?>"
|
||||
+ "<!DOCTYPE hibernate-configuration PUBLIC " + "\"//Hibernate/Hibernate Configuration DTD 3.0//EN\" "
|
||||
+ "\"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">"
|
||||
+ "<hibernate-configuration><session-factory>" + "<property name=\"show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.hbm2ddl.auto\">create-drop</property>"
|
||||
+ "<property name=\"hibernate.connection.datasource\">java:jboss/datasources/ExampleDS</property>"
|
||||
+ "<property name=\"hibernate.transaction.jta.platform\">JBossAS</property>"
|
||||
+ "<property name=\"hibernate.transaction.coordinator_class\">jta</property>"
|
||||
+ "<property name=\"hibernate.id.new_generator_mappings\">true</property>"
|
||||
+ "</session-factory></hibernate-configuration>";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive deploy() throws Exception {
|
||||
final WebArchive war = ShrinkWrap.create( WebArchive.class, ARCHIVE_NAME + ".war" )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClasses( WildFlyDdlEntity.class )
|
||||
.addAsResource( new StringAsset( hibernate_cfg ), "hibernate.cfg.xml" )
|
||||
.addClasses( CmtSfStatefulBean.class )
|
||||
.addClasses( DdlInWildFlyUsingCmtAndSfTest.class );
|
||||
return war;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop(CmtSfStatefulBean ejb) throws Exception {
|
||||
assert ejb != null : "Method injected StatefulCMTBean reference was null";
|
||||
|
||||
try {
|
||||
ejb.start();
|
||||
}
|
||||
finally {
|
||||
ejb.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package containing various tests running inside a WildFly container via Arquillian.
|
||||
*/
|
||||
package org.hibernate.test.wf;
|
|
@ -1,23 +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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
#
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.rootLogger=info, stdout
|
||||
|
||||
# the test that this is used for is testing DDL execution within WF,
|
||||
# so for sure we want the schema-tooling logging cranked up...
|
||||
log4j.logger.org.hibernate.SQL=debug
|
||||
log4j.logger.org.hibernate.tool.schema=trace
|
||||
log4j.logger.org.hibernate.tool.hbm2ddl=trace
|
||||
|
||||
# low-level "resource" logging is likely to be useful as well
|
||||
log4j.logger.org.hibernate.resource=trace
|
||||
|
||||
log4j.logger.org.hibernate.engine.transaction.jta=trace
|
|
@ -1 +0,0 @@
|
|||
Dependencies: org.hibernate:5.3 services
|
Loading…
Reference in New Issue