diff --git a/.gitignore b/.gitignore index abb0c4ea..9f1c9b02 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ transaction.log infinispan.log .gradle + +#Misc. +ObjectStore diff --git a/README.md b/README.md index 8363e87e..4004f74c 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,13 @@ This repository contains demos used live during presentations or in blog posts; Accompanies the blog post http://in.relation.to/2018/02/26/putting-bean-validation-constraints-to-multimaps/ * Java 9 - - multi-release-jar-demo: Shows how to build multi-release JARs with Java 9. + - _multi-release-jar-demo_: Shows how to build multi-release JARs with Java 9. Accompanies the blog post http://in.relation.to/2017/02/13/building-multi-release-jars-with-maven/ - - custom-jlink-plugin: Shows how to customize Java 9 modular runtime images with jlink plug-ins. The example shows a plug-in for adding a Jandex annotation index for one or more modules to the runtime image. + - _custom-jlink-plugin_: Shows how to customize Java 9 modular runtime images with jlink plug-ins. The example shows a plug-in for adding a Jandex annotation index for one or more modules to the runtime image. * Other - - wildfly-patch-creation: How to create WildFly patch files. + - _wildfly-patch-creation_: How to create WildFly patch files. Accompanies the blog post http://in.relation.to/2017/05/29/creating-patches-for-wildfly/ + - _cdi-jpa-testing_: How to run JUnit tests using CDI, JPA and JTA ## License diff --git a/other/cdi-jpa-testing/pom.xml b/other/cdi-jpa-testing/pom.xml new file mode 100644 index 00000000..ad0f3beb --- /dev/null +++ b/other/cdi-jpa-testing/pom.xml @@ -0,0 +1,180 @@ + + + + + 4.0.0 + + org.hibernate.demos + jpa-cdi-testing + 1.0-SNAPSHOT + + Demo for testing CDI + JPA + JTA under Java SE + https://hibernate.org/orm + + + UTF-8 + 8 + 8 + + 1.4.197 + 5.4.0.Final + 5.9.2.Final + 5.0.3.GA + 1.1.1.Final + 1.2.17 + 3.0.5.Final + + + + + javax.inject + javax.inject + 1 + provided + + + javax.enterprise + cdi-api + 2.0.SP1 + provided + + + org.jboss.spec.javax.transaction + jboss-transaction-api_1.2_spec + ${version.jboss-transaction-api} + provided + + + junit + junit + 4.12 + test + + + org.hibernate + hibernate-core + ${version.org.hibernate} + + + com.h2database + h2 + ${version.com.h2database} + test + + + org.jboss.weld.se + weld-se-core + ${version.weld} + test + + + org.jboss.weld.module + weld-jta + ${version.weld} + test + + + org.jboss.narayana.jta + narayana-jta + ${version.narayana} + + + org.jboss.logmanager + jboss-logmanager + + + test + + + log4j + log4j + ${version.log4j} + + + org.jboss.naming + jnpserver + ${version.jnpserver} + + + org.jboss.logging + jboss-logging-spi + + + test + + + org.jboss.weld + weld-junit4 + 1.3.1.Final + test + + + org.assertj + assertj-core + 3.11.1 + test + + + + + + + + maven-clean-plugin + 3.1.0 + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + + + + jboss-public-repository-group + JBoss Public Maven Repository Group + https://repository.jboss.org/nexus/content/groups/public/ + + true + + + true + + + + diff --git a/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/GreetingService.java b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/GreetingService.java new file mode 100644 index 00000000..f9d34b30 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/GreetingService.java @@ -0,0 +1,15 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import javax.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class GreetingService { + + public String greet(String name) { + return "Hello, " + name; + } +} diff --git a/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/ObserverTestBean.java b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/ObserverTestBean.java new file mode 100644 index 00000000..601658a8 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/ObserverTestBean.java @@ -0,0 +1,50 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Event; +import javax.enterprise.event.Observes; +import javax.enterprise.event.TransactionPhase; +import javax.inject.Inject; +import javax.transaction.Transactional; + +@ApplicationScoped +public class ObserverTestBean { + + @Inject + private Event event1; + + @Inject + private Event event2; + + @Inject + private Event event3; + + private final StringBuilder sb = new StringBuilder(); + + @Transactional + public void work() { + event1.fire(1L); + event2.fire(2); + event3.fire((short) 3); + } + + public void observesLong(@Observes(during=TransactionPhase.AFTER_COMPLETION) Long event) { + sb.append(event); + } + + public void observeInteger(@Observes(during=TransactionPhase.BEFORE_COMPLETION) Integer event) { + sb.append(event); + } + + public void observesShort(@Observes(during=TransactionPhase.IN_PROGRESS) Short event) { + sb.append(event); + } + + public String getResult() { + return sb.toString(); + } +} diff --git a/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestEntity.java b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestEntity.java new file mode 100644 index 00000000..90e0c8c6 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestEntity.java @@ -0,0 +1,21 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import java.util.UUID; + +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.Id; + +@Entity +@EntityListeners(TestListener.class) +public class TestEntity { + + @Id + public UUID id; + + public String name; +} diff --git a/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestListener.java b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestListener.java new file mode 100644 index 00000000..32c79177 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestListener.java @@ -0,0 +1,20 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.persistence.PostPersist; + +@ApplicationScoped +public class TestListener { + + @Inject + private TestService testService; + + @PostPersist public void onPostPersist(TestEntity entity) { + testService.addTestEntityName(entity.name); + } +} diff --git a/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestService.java b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestService.java new file mode 100644 index 00000000..0e8b2b33 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TestService.java @@ -0,0 +1,32 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import java.util.ArrayList; +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.persistence.EntityManager; + +@ApplicationScoped +public class TestService { + + private final List names = new ArrayList<>(); + private final EntityManager entityManager; + + @Inject + public TestService(EntityManager entityManager) { + this.entityManager = entityManager; + } + + public List getTestEntityNames() { + return names; + } + + public void addTestEntityName(String name) { + names.add(name); + } +} diff --git a/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TransactionalTestService.java b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TransactionalTestService.java new file mode 100644 index 00000000..f060fc88 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/java/org/hibernate/demos/jpacditesting/TransactionalTestService.java @@ -0,0 +1,18 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import javax.enterprise.context.ApplicationScoped; +import javax.transaction.Transactional; +import javax.transaction.Transactional.TxType; + +@ApplicationScoped +public class TransactionalTestService { + + @Transactional(value=TxType.MANDATORY) + public String doSomething() { + return "Success"; + } +} diff --git a/other/cdi-jpa-testing/src/main/resources/META-INF/beans.xml b/other/cdi-jpa-testing/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000..e69de29b diff --git a/other/cdi-jpa-testing/src/main/resources/META-INF/persistence.xml b/other/cdi-jpa-testing/src/main/resources/META-INF/persistence.xml new file mode 100644 index 00000000..856afee9 --- /dev/null +++ b/other/cdi-jpa-testing/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,40 @@ + + + + + + Hibernate test case template Persistence Unit + org.hibernate.jpa.HibernatePersistenceProvider + java:jboss/datasources/MyDS + + false + + + + + + + + + + + + + + + + + + + + + + + diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTest.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTest.java new file mode 100644 index 00000000..c692833f --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTest.java @@ -0,0 +1,126 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.fail; + +import java.util.List; +import java.util.UUID; + +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.transaction.TransactionalException; +import javax.transaction.UserTransaction; + +import org.junit.Test; + +public class CdiJpaTest extends CdiJpaTestBase { + + @Inject + private EntityManager entityManager; + + @Inject + private UserTransaction ut; + + @Inject + private ObserverTestBean observerTestBean; + + @Inject + private TestService testService; + + @Inject + private TransactionalTestService transactionalTestService; + + @Test + public void canInjectEntityManager() { + assertThat(entityManager).isNotNull(); + + entityManager.getTransaction().begin(); + + TestEntity te = new TestEntity(); + te.id = UUID.randomUUID(); + te.name = "Test 1"; + entityManager.persist(te); + + te = new TestEntity(); + te.id = UUID.randomUUID(); + te.name = "Test 2"; + entityManager.persist(te); + + entityManager.getTransaction().commit(); + entityManager.clear(); + + entityManager.getTransaction().begin(); + List loaded = entityManager.createQuery("FROM TestEntity te", TestEntity.class).getResultList(); + assertThat(loaded).hasSize(2); + entityManager.getTransaction().commit(); + } + + @Test + public void canInjectUserTransaction() throws Exception { + assertThat(ut).isNotNull(); + + ut.begin(); + + TestEntity te = new TestEntity(); + te.id = UUID.randomUUID(); + te.name = "Test 1"; + entityManager.persist(te); + + te = new TestEntity(); + te.id = UUID.randomUUID(); + te.name = "Test 2"; + entityManager.persist(te); + + ut.commit(); + entityManager.clear(); + + ut.begin(); + List loaded = entityManager.createQuery("FROM TestEntity te", TestEntity.class).getResultList(); + assertThat(loaded).hasSize(2); + ut.commit(); + } + + @Test + public void shouldProcessTransactionalObservers() { + observerTestBean.work(); + assertThat(observerTestBean.getResult()).isEqualTo("321"); + } + + @Test + public void canUseDiInEntityListener() { + entityManager.getTransaction().begin(); + + TestEntity te = new TestEntity(); + te.id = UUID.randomUUID(); + te.name = "Test 1"; + entityManager.persist(te); + + te = new TestEntity(); + te.id = UUID.randomUUID(); + te.name = "Test 2"; + entityManager.persist(te); + + entityManager.getTransaction().commit(); + + assertThat(testService.getTestEntityNames()).contains("Test 1", "Test 2"); + } + + @Test + public void canUseDeclarativeTxControl() throws Exception { + try { + transactionalTestService.doSomething(); + fail("Exception raised due to missing yet required transaction wasn't raised"); + } + catch(TransactionalException e) { + assertThat(e.getMessage().contains("ARJUNA016110")); + } + + ut.begin(); + assertThat(transactionalTestService.doSomething()).isEqualTo("Success"); + ut.rollback(); + } +} diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTestBase.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTestBase.java new file mode 100644 index 00000000..e3ec189c --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTestBase.java @@ -0,0 +1,59 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import javax.enterprise.context.RequestScoped; + +import org.hibernate.demos.jpacditesting.support.EntityManagerFactoryProducer; +import org.hibernate.demos.jpacditesting.support.EntityManagerProducer; +import org.hibernate.demos.jpacditesting.support.TransactionalConnectionProvider; +import org.jboss.weld.junit4.WeldInitiator; +import org.jnp.server.NamingBeanImpl; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; + +import com.arjuna.ats.jta.cdi.TransactionExtension; +import com.arjuna.ats.jta.utils.JNDIManager; + +public abstract class CdiJpaTestBase { + + private static NamingBeanImpl NAMING_BEAN; + +// @Rule +// public WeldInitiator weld = WeldInitiator.from(new Weld()) +// .activate(RequestScoped.class) +// .inject(this) +// .build(); + + // new Weld() above enables scanning of the classpath; alternatively, only the required beans can be listed explicitly: + + @Rule + public WeldInitiator weld = WeldInitiator.from( + ObserverTestBean.class, + TransactionalTestService.class, + TestService.class, + EntityManagerProducer.class, + EntityManagerFactoryProducer.class, + TransactionExtension.class + ) + .activate(RequestScoped.class) + .inject(this) + .build(); + + @BeforeClass + public static void startJndiAndBindJtaAndDataSource() throws Exception { + NAMING_BEAN = new NamingBeanImpl(); + NAMING_BEAN.start(); + + JNDIManager.bindJTAImplementation(); + TransactionalConnectionProvider.bindDataSource(); + } + + @AfterClass + public static void stopJndi() { + NAMING_BEAN.stop(); + } +} diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/SimpleCdiTest.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/SimpleCdiTest.java new file mode 100644 index 00000000..7a02b786 --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/SimpleCdiTest.java @@ -0,0 +1,31 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting; + +import static org.assertj.core.api.Assertions.assertThat; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.jboss.weld.junit4.WeldInitiator; +import org.junit.Rule; +import org.junit.Test; + +public class SimpleCdiTest { + + @Rule + public WeldInitiator weld = WeldInitiator.from(GreetingService.class) + .activate(RequestScoped.class) + .inject(this) + .build(); + + @Inject + private GreetingService greeter; + + @Test + public void helloWorld() { + assertThat(greeter.greet("Java")).isEqualTo("Hello, Java"); + } +} diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/EntityManagerFactoryProducer.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/EntityManagerFactoryProducer.java new file mode 100644 index 00000000..05c1edbb --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/EntityManagerFactoryProducer.java @@ -0,0 +1,41 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting.support; + +import java.util.HashMap; +import java.util.Map; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +import org.hibernate.cfg.Environment; + +@ApplicationScoped +public class EntityManagerFactoryProducer { + + @Inject + private BeanManager beanManager; + + @Produces + @ApplicationScoped + public EntityManagerFactory produceEntityManagerFactory() { + Map props = new HashMap<>(); + props.put("javax.persistence.bean.manager", beanManager); + props.put(Environment.CONNECTION_PROVIDER, TransactionalConnectionProvider.class); + return Persistence.createEntityManagerFactory( + "myPu", + props + ); + } + + public void close(@Disposes EntityManagerFactory entityManagerFactory) { + entityManagerFactory.close(); + } +} diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/EntityManagerProducer.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/EntityManagerProducer.java new file mode 100644 index 00000000..943363a7 --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/EntityManagerProducer.java @@ -0,0 +1,30 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting.support; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +@ApplicationScoped +public class EntityManagerProducer { + + @Inject + private EntityManagerFactory entityManagerFactory; + + @Produces + @RequestScoped + public EntityManager produceEntityManager() { + return entityManagerFactory.createEntityManager(); + } + + public void close(@Disposes EntityManager entityManager) { + entityManager.close(); + } +} diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/TestingTransactionServices.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/TestingTransactionServices.java new file mode 100644 index 00000000..a8dafe34 --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/TestingTransactionServices.java @@ -0,0 +1,43 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting.support; + +import javax.transaction.Status; +import javax.transaction.Synchronization; +import javax.transaction.SystemException; +import javax.transaction.UserTransaction; + +import org.jboss.weld.transaction.spi.TransactionServices; + +import com.arjuna.ats.jta.common.jtaPropertyManager; + +public class TestingTransactionServices implements TransactionServices { + + @Override + public void cleanup() { + } + + @Override + public void registerSynchronization(Synchronization synchronizedObserver) { + jtaPropertyManager.getJTAEnvironmentBean() + .getTransactionSynchronizationRegistry() + .registerInterposedSynchronization(synchronizedObserver); + } + + @Override + public boolean isTransactionActive() { + try { + return com.arjuna.ats.jta.UserTransaction.userTransaction().getStatus() == Status.STATUS_ACTIVE; + } + catch (SystemException e) { + throw new RuntimeException(e); + } + } + + @Override + public UserTransaction getUserTransaction() { + return com.arjuna.ats.jta.UserTransaction.userTransaction(); + } +} diff --git a/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/TransactionalConnectionProvider.java b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/TransactionalConnectionProvider.java new file mode 100644 index 00000000..66fb6095 --- /dev/null +++ b/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/support/TransactionalConnectionProvider.java @@ -0,0 +1,83 @@ +/* + * License: Apache License, Version 2.0 + * See the LICENSE file in the root directory or . + */ +package org.hibernate.demos.jpacditesting.support; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Properties; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.h2.jdbcx.JdbcDataSource; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.service.UnknownUnwrapTypeException; + +import com.arjuna.ats.jdbc.TransactionalDriver; + +/** + * @author Gytis Trikleris + */ +public class TransactionalConnectionProvider implements ConnectionProvider { + + public static final String DATASOURCE_JNDI = "java:testDS"; + public static final String USERNAME = "sa"; + public static final String PASSWORD = ""; + + private final TransactionalDriver transactionalDriver; + + public TransactionalConnectionProvider() { + transactionalDriver = new TransactionalDriver(); + } + + public static void bindDataSource() { + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1"); + dataSource.setUser(USERNAME); + dataSource.setPassword(PASSWORD); + + try { + InitialContext initialContext = new InitialContext(); + initialContext.bind(DATASOURCE_JNDI, dataSource); + } + catch (NamingException e) { + throw new RuntimeException(e); + } + } + + @Override + public Connection getConnection() throws SQLException { + Properties properties = new Properties(); + properties.setProperty(TransactionalDriver.userName, USERNAME); + properties.setProperty(TransactionalDriver.password, PASSWORD); + return transactionalDriver.connect("jdbc:arjuna:" + DATASOURCE_JNDI, properties); + } + + @Override + public void closeConnection(Connection connection) throws SQLException { + if (!connection.isClosed()) { + connection.close(); + } + } + + @Override + public boolean supportsAggressiveRelease() { + return false; + } + + @Override + public boolean isUnwrappableAs(Class aClass) { + return getClass().isAssignableFrom(aClass); + } + + @Override + public T unwrap(Class aClass) { + if (isUnwrappableAs(aClass)) { + return (T) this; + } + + throw new UnknownUnwrapTypeException(aClass); + } +} diff --git a/other/cdi-jpa-testing/src/test/resources/META-INF/beans.xml b/other/cdi-jpa-testing/src/test/resources/META-INF/beans.xml new file mode 100644 index 00000000..e69de29b diff --git a/other/cdi-jpa-testing/src/test/resources/META-INF/services/org.jboss.weld.bootstrap.api.Service b/other/cdi-jpa-testing/src/test/resources/META-INF/services/org.jboss.weld.bootstrap.api.Service new file mode 100644 index 00000000..82245975 --- /dev/null +++ b/other/cdi-jpa-testing/src/test/resources/META-INF/services/org.jboss.weld.bootstrap.api.Service @@ -0,0 +1 @@ +org.hibernate.demos.jpacditesting.support.TestingTransactionServices diff --git a/other/cdi-jpa-testing/src/test/resources/jndi.properties b/other/cdi-jpa-testing/src/test/resources/jndi.properties new file mode 100644 index 00000000..4bfaed89 --- /dev/null +++ b/other/cdi-jpa-testing/src/test/resources/jndi.properties @@ -0,0 +1,5 @@ +# License: Apache License, Version 2.0 +# See the LICENSE file in the root directory or . + +java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory +java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces diff --git a/other/cdi-jpa-testing/src/test/resources/log4j.properties b/other/cdi-jpa-testing/src/test/resources/log4j.properties new file mode 100644 index 00000000..154b803f --- /dev/null +++ b/other/cdi-jpa-testing/src/test/resources/log4j.properties @@ -0,0 +1,11 @@ +# License: Apache License, Version 2.0 +# See the LICENSE file in the root directory or . + +# Root logger option +log4j.rootLogger=INFO, stdout + +# Direct log messages to stdout +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{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n