HHH-11024 - Exception still thrown when dropping schema with a managed connection - extend test task dependencies to the matrix-tesing plugin test tasks
This commit is contained in:
parent
dddf01740e
commit
7038b3e983
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl;
|
||||
package org.hibernate.test.wf.ddl.bmt.emf;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
|
@ -23,6 +23,7 @@ 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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -42,27 +43,28 @@ import static org.junit.Assert.assertNotNull;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@RunWith( Arquillian.class )
|
||||
public class WildFlyDdlTest {
|
||||
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 jar = ShrinkWrap.create( WebArchive.class )
|
||||
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( jar.toString(true) );
|
||||
return jar;
|
||||
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 )
|
||||
.createPersistenceUnit().name( PERSISTENCE_UNIT_NAME )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.clazz( WildFlyDdlEntity.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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,35 +1,30 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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;
|
||||
package org.hibernate.test.wf.ddl.bmt.sf;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
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.junit.BeforeClass;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
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")
|
||||
public class WildFlyHibernateDdlTest {
|
||||
public class DdlInWildFlyUsingBmtAndSfTest {
|
||||
|
||||
public static final String ARCHIVE_NAME = "WildFlyHibernateDdlTest";
|
||||
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\" "
|
||||
|
@ -38,50 +33,33 @@ public class WildFlyHibernateDdlTest {
|
|||
+ "<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\">JBossAppServerJtaPlatform.class</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>";
|
||||
|
||||
@ArquillianResource
|
||||
private static InitialContext iniCtx;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws NamingException {
|
||||
iniCtx = new InitialContext();
|
||||
}
|
||||
|
||||
@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( SFSBHibernateSessionFactory.class )
|
||||
.addClasses( WildFlyHibernateDdlTest.class );
|
||||
.addClasses( BmtSfStatefulBean.class )
|
||||
.addClasses( DdlInWildFlyUsingBmtAndSfTest.class );
|
||||
return war;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop() throws Exception {
|
||||
final SFSBHibernateSessionFactory sfsb = lookup(
|
||||
"SFSBHibernateSessionFactory",
|
||||
SFSBHibernateSessionFactory.class
|
||||
);
|
||||
public void testCreateThenDrop(BmtSfStatefulBean ejb) throws Exception {
|
||||
assert ejb != null : "Method injected StatefulCMTBean reference was null";
|
||||
|
||||
try {
|
||||
sfsb.setupConfig();
|
||||
ejb.start();
|
||||
}
|
||||
finally {
|
||||
sfsb.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> T lookup(String beanName, Class<T> interfaceType) throws NamingException {
|
||||
try {
|
||||
return interfaceType.cast( iniCtx.lookup( "java:global/" + ARCHIVE_NAME + "/" + beanName + "!"
|
||||
+ interfaceType.getName() ) );
|
||||
}
|
||||
catch (NamingException e) {
|
||||
throw e;
|
||||
ejb.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,12 +4,14 @@
|
|||
* 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;
|
||||
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;
|
||||
|
||||
|
@ -19,17 +21,20 @@ import javax.persistence.Persistence;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
public class WildFlyDdlComponent {
|
||||
@TransactionManagement(TransactionManagementType.CONTAINER)
|
||||
public class CmtEmfStatefulBean {
|
||||
EntityManagerFactory emf;
|
||||
|
||||
// @TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
@TransactionAttribute(TransactionAttributeType.NEVER)
|
||||
public void start() {
|
||||
// creating the SF should run schema creation
|
||||
emf = Persistence.createEntityManagerFactory( "pu-wf-ddl" );
|
||||
}
|
||||
|
||||
@Remove
|
||||
// @TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public void stop() {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
emf.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.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 )
|
||||
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.2" ).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,10 +1,10 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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;
|
||||
package org.hibernate.test.wf.ddl.cmt.sf;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
|
@ -19,15 +19,17 @@ 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 SFSBHibernateSessionFactory {
|
||||
public class CmtSfStatefulBean {
|
||||
|
||||
private static SessionFactory sessionFactory;
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.NEVER)
|
||||
public void setupConfig() {
|
||||
public void start() {
|
||||
try {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration = configuration.configure( "hibernate.cfg.xml" );
|
||||
|
@ -41,7 +43,8 @@ public class SFSBHibernateSessionFactory {
|
|||
}
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public void stop() {
|
||||
sessionFactory.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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.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")
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue