From 9c585b0cf133219f0039864516dcdc828d3b609c Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 28 Nov 2018 11:51:18 +0000 Subject: [PATCH 01/16] TOMEE-2295 test for element being ignored --- .../src/main/resources/test-orm.xml | 32 +++++++ .../openejb/core/LegacyInterfaceTest.java | 89 +++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 container/openejb-core/src/main/resources/test-orm.xml diff --git a/container/openejb-core/src/main/resources/test-orm.xml b/container/openejb-core/src/main/resources/test-orm.xml new file mode 100644 index 00000000000..0646b30da7b --- /dev/null +++ b/container/openejb-core/src/main/resources/test-orm.xml @@ -0,0 +1,32 @@ + + + + + MyCmpBean + + SELECT OBJECT(DL) FROM License DL + + + + + + + + + \ No newline at end of file diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java index f450f2c9b52..0b4b73f26b1 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java @@ -36,6 +36,9 @@ import org.apache.openejb.jee.SingletonBean; import org.apache.openejb.jee.TransAttribute; import org.apache.openejb.jee.jpa.*; +import org.apache.openejb.jee.jpa.unit.Persistence; +import org.apache.openejb.jee.jpa.unit.PersistenceUnit; +import org.apache.openejb.jee.jpa.unit.TransactionType; import org.junit.AfterClass; import javax.ejb.CreateException; @@ -216,6 +219,92 @@ public void testCustomCmpMappings() throws Exception { assertEquals("wNAME", basicList.get(0).getColumn().getName()); } + public void testCustomCmpMappingsWithMappingFileDefinedInPersistenceXml() throws Exception { + + System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName()); + + final ConfigurationFactory config = new ConfigurationFactory(); + final Assembler assembler = new Assembler(); + + assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); + assembler.createSecurityService(config.configureService(SecurityServiceInfo.class)); + + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new SingletonBean(MySingletonBean.class)); + ejbJar.addEnterpriseBean(new EntityBean(MyBmpBean.class, PersistenceType.BEAN)); + + final EntityBean cmp = ejbJar.addEnterpriseBean(new EntityBean(MyCmpBean.class, PersistenceType.CONTAINER)); + cmp.setPrimKeyClass(Integer.class.getName()); + cmp.setPrimkeyField("id"); + cmp.getCmpField().add(new CmpField("id")); + cmp.getCmpField().add(new CmpField("name")); + final Query query = new Query(); + query.setQueryMethod(new QueryMethod("findByPrimaryKey", Integer.class.getName())); + query.setEjbQl("SELECT OBJECT(DL) FROM License DL"); + cmp.getQuery().add(query); + final List transactions = ejbJar.getAssemblyDescriptor().getContainerTransaction(); + + transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyBmpBean", "*")); + transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyCmpBean", "*")); + transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MySingletonBean", "*")); + + final File f = new File("test").getAbsoluteFile(); + if (!f.exists() && !f.mkdirs()) { + throw new Exception("Failed to create test directory: " + f); + } + + final EntityMappings entityMappings = new EntityMappings(); + + final Entity entity = new Entity(); + entity.setClazz("openejb.org.apache.openejb.core.MyCmpBean"); + entity.setName("MyCmpBean"); + entity.setDescription("MyCmpBean"); + entity.setAttributes(new Attributes()); + + final NamedQuery namedQuery = new NamedQuery(); + namedQuery.setQuery("SELECT OBJECT(DL) FROM License DL"); + entity.getNamedQuery().add(namedQuery); + + final Id id = new Id(); + id.setName("id"); + entity.getAttributes().getId().add(id); + + final Basic basic = new Basic(); + basic.setName("name"); + final Column column = new Column(); + column.setName("wNAME"); + column.setLength(300); + basic.setColumn(column); + entity.getAttributes().getBasic().add(basic); + + entityMappings.getEntity().add(entity); + + final AppModule module = new AppModule(this.getClass().getClassLoader(), f.getAbsolutePath()); + final EjbModule ejbModule = new EjbModule(ejbJar); + + + Persistence persistence = new Persistence(); + PersistenceUnit pu = persistence.addPersistenceUnit("cmp"); + pu.setTransactionType(TransactionType.JTA); + pu.setJtaDataSource("fake"); + pu.setNonJtaDataSource("fake"); + pu.getMappingFile().add("test-orm.xml"); + pu.addClass("openejb.org.apache.openejb.core.MyCmpBean"); + module.addPersistenceModule(new PersistenceModule("pu", persistence)); + + module.getEjbModules().add(ejbModule); + + assertNull(module.getCmpMappings()); + assembler.createApplication(config.configureApplication(module)); + assertNotNull(module.getCmpMappings()); + assertEquals(1, pu.getClazz().size()); + assertEquals("openejb.org.apache.openejb.core.MyCmpBean", pu.getClazz().get(0)); + final List basicList = module.getCmpMappings().getEntityMap().get("openejb.org.apache.openejb.core.MyCmpBean").getAttributes().getBasic(); + assertEquals(1, basicList.size()); + assertEquals(300, basicList.get(0).getColumn().getLength().intValue()); + assertEquals("wNAME", basicList.get(0).getColumn().getName()); + } + @LocalHome(MyLocalHome.class) @RemoteHome(MyRemoteHome.class) public static abstract class MyCmpBean implements javax.ejb.EntityBean { From ddbae44e280cb9e8f0e10ea7754b5eed69733cb4 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 28 Nov 2018 13:53:40 +0000 Subject: [PATCH 02/16] TOMEE-2295 Improvements for JPA/CMP mapping --- .../openejb/config/CmpJpaConversion.java | 110 ++++++++++++------ .../openejb/core/LegacyInterfaceTest.java | 40 ++----- 2 files changed, 84 insertions(+), 66 deletions(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java b/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java index 7f0e3f1e64a..194bbd99960 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java @@ -20,20 +20,7 @@ import org.apache.openejb.OpenEJBException; import org.apache.openejb.core.cmp.CmpUtil; import org.apache.openejb.core.cmp.jpa.JpaCmpEngine; -import org.apache.openejb.jee.CmpField; -import org.apache.openejb.jee.CmpVersion; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.EjbRelation; -import org.apache.openejb.jee.EjbRelationshipRole; -import org.apache.openejb.jee.EnterpriseBean; -import org.apache.openejb.jee.EntityBean; -import org.apache.openejb.jee.Multiplicity; -import org.apache.openejb.jee.PersistenceContextRef; -import org.apache.openejb.jee.PersistenceType; -import org.apache.openejb.jee.Query; -import org.apache.openejb.jee.QueryMethod; -import org.apache.openejb.jee.RelationshipRoleSource; -import org.apache.openejb.jee.Relationships; +import org.apache.openejb.jee.*; import org.apache.openejb.jee.jpa.AttributeOverride; import org.apache.openejb.jee.jpa.Attributes; import org.apache.openejb.jee.jpa.Basic; @@ -58,6 +45,7 @@ import org.apache.openejb.jee.jpa.unit.TransactionType; import org.apache.openejb.jee.oejb3.EjbDeployment; import org.apache.openejb.jee.oejb3.OpenejbJar; +import org.apache.openejb.loader.IO; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; @@ -67,6 +55,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.net.URL; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -99,15 +88,38 @@ public class CmpJpaConversion implements DynamicDeployer { "serialVersionUID" ))); + public static EntityMappings readEntityMappings(final String location) { + + // first try the classpath + EntityMappings entitymappings = null; + + try { + final URL cpUrl = Thread.currentThread().getContextClassLoader().getResource(location); + entitymappings = (EntityMappings) JaxbJavaee.unmarshal(EntityMappings.class, IO.read(cpUrl)); + } catch (Exception e) { + // ignore + } + + if (entitymappings == null) { + // then try reading as a URL + try { + final URL url = new URL(location); + entitymappings = (EntityMappings) JaxbJavaee.unmarshal(EntityMappings.class, IO.read(url)); + } catch (Exception e) { + logger.error("Unable to read entity mappings from " + location, e); + } + } + + return entitymappings; + } + public AppModule deploy(final AppModule appModule) throws OpenEJBException { if (!hasCmpEntities(appModule)) { return appModule; } - // todo scan existing persistence module for all entity mappings and don't generate mappings for them - - // create mappings if no mappings currently exist + // create mappings if no mappings currently exist EntityMappings cmpMappings = appModule.getCmpMappings(); if (cmpMappings == null) { cmpMappings = new EntityMappings(); @@ -115,6 +127,23 @@ public AppModule deploy(final AppModule appModule) throws OpenEJBException { appModule.setCmpMappings(cmpMappings); } + // todo scan existing persistence module for all entity mappings and don't generate mappings for them + + final Set definedMappedClasses = new HashSet<>(); + + // check for an existing "cmp" persistence unit, and look at existing mappings + final PersistenceUnit cmpPersistenceUnit = findCmpPersistenceUnit(appModule); + if (cmpPersistenceUnit != null) { + if (cmpPersistenceUnit.getMappingFile() != null || cmpPersistenceUnit.getMappingFile().size() > 0) { + for (final String mappingFile : cmpPersistenceUnit.getMappingFile()) { + final EntityMappings entityMappings = readEntityMappings(mappingFile); + if (entityMappings != null) { + definedMappedClasses.addAll(entityMappings.getEntityMap().keySet()); + } + } + } + } + // we process this one jar-file at a time...each contributing to the // app mapping data for (final EjbModule ejbModule : appModule.getEjbModules()) { @@ -123,7 +152,7 @@ public AppModule deploy(final AppModule appModule) throws OpenEJBException { // scan for CMP entity beans and merge the data into the collective set for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) { if (isCmpEntity(enterpriseBean)) { - processEntityBean(ejbModule, cmpMappings, (EntityBean) enterpriseBean); + processEntityBean(ejbModule, definedMappedClasses, cmpMappings, (EntityBean) enterpriseBean); } } @@ -152,7 +181,6 @@ public AppModule deploy(final AppModule appModule) throws OpenEJBException { for (final MappedSuperclass mapping : userMappings.getMappedSuperclass()) { logger.warning("openejb-cmp-orm.xml mapping ignored: module=" + ejbModule.getModuleId() + ": "); } - } if (!cmpMappings.getEntity().isEmpty()) { @@ -160,7 +188,9 @@ public AppModule deploy(final AppModule appModule) throws OpenEJBException { persistenceUnit.getMappingFile().add("META-INF/openejb-cmp-generated-orm.xml"); for (final Entity entity : cmpMappings.getEntity()) { - persistenceUnit.getClazz().add(entity.getClazz()); + if (! persistenceUnit.getClazz().contains(entity.getClazz())) { + persistenceUnit.getClazz().add(entity.getClazz()); + } } } @@ -176,17 +206,7 @@ public AppModule deploy(final AppModule appModule) throws OpenEJBException { private PersistenceUnit getCmpPersistenceUnit(final AppModule appModule) { // search for the cmp persistence unit - PersistenceUnit persistenceUnit = null; - for (final PersistenceModule persistenceModule : appModule.getPersistenceModules()) { - final Persistence persistence = persistenceModule.getPersistence(); - for (final PersistenceUnit unit : persistence.getPersistenceUnit()) { - if (CMP_PERSISTENCE_UNIT_NAME.equals(unit.getName())) { - persistenceUnit = unit; - break; - } - - } - } + PersistenceUnit persistenceUnit = findCmpPersistenceUnit(appModule); // if not found create one if (persistenceUnit == null) { persistenceUnit = new PersistenceUnit(); @@ -215,6 +235,21 @@ private PersistenceUnit getCmpPersistenceUnit(final AppModule appModule) { return persistenceUnit; } + private PersistenceUnit findCmpPersistenceUnit(final AppModule appModule) { + PersistenceUnit persistenceUnit = null; + for (final PersistenceModule persistenceModule : appModule.getPersistenceModules()) { + final Persistence persistence = persistenceModule.getPersistence(); + for (final PersistenceUnit unit : persistence.getPersistenceUnit()) { + if (CMP_PERSISTENCE_UNIT_NAME.equals(unit.getName())) { + persistenceUnit = unit; + break; + } + + } + } + return persistenceUnit; + } + private String getPersistenceModuleId(final AppModule appModule) { if (appModule.getModuleId() != null) { return appModule.getModuleId(); @@ -437,12 +472,14 @@ private R addRelationship(final R relationship, final /** * Generate the CMP mapping data for an individual * EntityBean. - * - * @param ejbModule The module containing the bean. + * @param ejbModule The module containing the bean. + * @param ignoreClasses * @param entityMappings The accumulated set of entity mappings. * @param bean The been we're generating the mapping for. */ - private void processEntityBean(final EjbModule ejbModule, final EntityMappings entityMappings, final EntityBean bean) { + private void processEntityBean(final EjbModule ejbModule, final Collection ignoreClasses, + final EntityMappings entityMappings, final EntityBean bean) { + // try to add a new persistence-context-ref for cmp if (!addPersistenceContextRef(bean)) { // Bean already has a persistence-context-ref for cmp @@ -478,6 +515,11 @@ private void processEntityBean(final EjbModule ejbModule, final EntityMappings e } } + // Check that this mapping hasn't already been defined in another mapping file on the persistence unit + if (ignoreClasses.contains(jpaEntityClassName)) { + return; + } + // Look for an existing mapping using the openejb generated subclass name Entity entity = removeEntity(userMappings, jpaEntityClassName); diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java index 0b4b73f26b1..0e1f2d7c4ee 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java @@ -253,43 +253,16 @@ public void testCustomCmpMappingsWithMappingFileDefinedInPersistenceXml() throws throw new Exception("Failed to create test directory: " + f); } - final EntityMappings entityMappings = new EntityMappings(); - - final Entity entity = new Entity(); - entity.setClazz("openejb.org.apache.openejb.core.MyCmpBean"); - entity.setName("MyCmpBean"); - entity.setDescription("MyCmpBean"); - entity.setAttributes(new Attributes()); - - final NamedQuery namedQuery = new NamedQuery(); - namedQuery.setQuery("SELECT OBJECT(DL) FROM License DL"); - entity.getNamedQuery().add(namedQuery); - - final Id id = new Id(); - id.setName("id"); - entity.getAttributes().getId().add(id); - - final Basic basic = new Basic(); - basic.setName("name"); - final Column column = new Column(); - column.setName("wNAME"); - column.setLength(300); - basic.setColumn(column); - entity.getAttributes().getBasic().add(basic); - - entityMappings.getEntity().add(entity); - final AppModule module = new AppModule(this.getClass().getClassLoader(), f.getAbsolutePath()); final EjbModule ejbModule = new EjbModule(ejbJar); - Persistence persistence = new Persistence(); PersistenceUnit pu = persistence.addPersistenceUnit("cmp"); pu.setTransactionType(TransactionType.JTA); pu.setJtaDataSource("fake"); pu.setNonJtaDataSource("fake"); pu.getMappingFile().add("test-orm.xml"); - pu.addClass("openejb.org.apache.openejb.core.MyCmpBean"); + pu.getClazz().add("openejb.org.apache.openejb.core.MyCmpBean"); module.addPersistenceModule(new PersistenceModule("pu", persistence)); module.getEjbModules().add(ejbModule); @@ -297,12 +270,15 @@ public void testCustomCmpMappingsWithMappingFileDefinedInPersistenceXml() throws assertNull(module.getCmpMappings()); assembler.createApplication(config.configureApplication(module)); assertNotNull(module.getCmpMappings()); + + // no mapping should be automatically generated + assertTrue(module.getCmpMappings().getEntityMap().isEmpty()); + + // pu should not be modified, no duplicate classes assertEquals(1, pu.getClazz().size()); assertEquals("openejb.org.apache.openejb.core.MyCmpBean", pu.getClazz().get(0)); - final List basicList = module.getCmpMappings().getEntityMap().get("openejb.org.apache.openejb.core.MyCmpBean").getAttributes().getBasic(); - assertEquals(1, basicList.size()); - assertEquals(300, basicList.get(0).getColumn().getLength().intValue()); - assertEquals("wNAME", basicList.get(0).getColumn().getName()); + assertEquals(1, pu.getMappingFile().size()); + assertEquals("test-orm.xml", pu.getMappingFile().get(0)); } @LocalHome(MyLocalHome.class) From a220243932db5968a78d6a08c7ab238b350b368b Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 28 Nov 2018 20:00:45 +0000 Subject: [PATCH 03/16] TOMEE-2295 PMD --- .../main/java/org/apache/openejb/config/CmpJpaConversion.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java b/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java index 194bbd99960..eca9896bc0d 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java @@ -134,7 +134,7 @@ public AppModule deploy(final AppModule appModule) throws OpenEJBException { // check for an existing "cmp" persistence unit, and look at existing mappings final PersistenceUnit cmpPersistenceUnit = findCmpPersistenceUnit(appModule); if (cmpPersistenceUnit != null) { - if (cmpPersistenceUnit.getMappingFile() != null || cmpPersistenceUnit.getMappingFile().size() > 0) { + if (cmpPersistenceUnit.getMappingFile() != null && cmpPersistenceUnit.getMappingFile().size() > 0) { for (final String mappingFile : cmpPersistenceUnit.getMappingFile()) { final EntityMappings entityMappings = readEntityMappings(mappingFile); if (entityMappings != null) { From c8a734467d3addffe206c4711f56d8abd09f56a3 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Thu, 29 Nov 2018 10:21:24 +0000 Subject: [PATCH 04/16] TOMEE-2295 use single class imports --- .../apache/openejb/config/CmpJpaConversion.java | 16 +++++++++++++++- .../apache/openejb/core/LegacyInterfaceTest.java | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java b/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java index eca9896bc0d..ffe065aa07a 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java @@ -20,7 +20,21 @@ import org.apache.openejb.OpenEJBException; import org.apache.openejb.core.cmp.CmpUtil; import org.apache.openejb.core.cmp.jpa.JpaCmpEngine; -import org.apache.openejb.jee.*; +import org.apache.openejb.jee.CmpField; +import org.apache.openejb.jee.CmpVersion; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.EjbRelation; +import org.apache.openejb.jee.EjbRelationshipRole; +import org.apache.openejb.jee.EnterpriseBean; +import org.apache.openejb.jee.EntityBean; +import org.apache.openejb.jee.JaxbJavaee; +import org.apache.openejb.jee.Multiplicity; +import org.apache.openejb.jee.PersistenceContextRef; +import org.apache.openejb.jee.PersistenceType; +import org.apache.openejb.jee.Query; +import org.apache.openejb.jee.QueryMethod; +import org.apache.openejb.jee.RelationshipRoleSource; +import org.apache.openejb.jee.Relationships; import org.apache.openejb.jee.jpa.AttributeOverride; import org.apache.openejb.jee.jpa.Attributes; import org.apache.openejb.jee.jpa.Basic; diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java index 0e1f2d7c4ee..49f4ee3444d 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java @@ -35,7 +35,13 @@ import org.apache.openejb.jee.QueryMethod; import org.apache.openejb.jee.SingletonBean; import org.apache.openejb.jee.TransAttribute; -import org.apache.openejb.jee.jpa.*; +import org.apache.openejb.jee.jpa.Attributes; +import org.apache.openejb.jee.jpa.Basic; +import org.apache.openejb.jee.jpa.Column; +import org.apache.openejb.jee.jpa.Entity; +import org.apache.openejb.jee.jpa.EntityMappings; +import org.apache.openejb.jee.jpa.Id; +import org.apache.openejb.jee.jpa.NamedQuery; import org.apache.openejb.jee.jpa.unit.Persistence; import org.apache.openejb.jee.jpa.unit.PersistenceUnit; import org.apache.openejb.jee.jpa.unit.TransactionType; From 24692436d004e212dd924b7e4812114762bd11b2 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Thu, 29 Nov 2018 21:43:40 +0000 Subject: [PATCH 05/16] TOMEE-2295 add arquillian test using custom ORM file --- .../tests/cmp/sample/CustomOrmXmlTest.java | 65 ++++++++++ .../arquillian/tests/cmp/sample/Movie.java | 39 ++++++ .../tests/cmp/sample/MovieBean.java | 49 ++++++++ .../tests/cmp/sample/MovieException.java | 35 ++++++ .../tests/cmp/sample/MovieLocalHome.java | 35 ++++++ .../tests/cmp/sample/MovieServlet.java | 79 ++++++++++++ .../arquillian/tests/cmp/sample/MovieVO.java | 79 ++++++++++++ .../tests/cmp/sample/MoviesBusinessBean.java | 115 ++++++++++++++++++ .../tests/cmp/sample/MoviesBusinessLocal.java | 28 +++++ .../cmp/sample/MoviesBusinessLocalHome.java | 26 ++++ .../tests/cmp/sample/custom-orm.xml | 23 ++++ .../arquillian/tests/cmp/sample/ejb-jar.xml | 103 ++++++++++++++++ .../tests/cmp/sample/openejb-jar.xml | 11 ++ .../tests/cmp/sample/persistence.xml | 14 +++ .../arquillian/tests/cmp/sample/web.xml | 42 +++++++ 15 files changed, 743 insertions(+) create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java new file mode 100644 index 00000000000..e06953631f7 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import org.apache.ziplock.IO; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +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.ClassLoaderAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.net.URL; + +/** + * @version $Rev$ $Date$ + */ +@RunWith(Arquillian.class) +public class CustomOrmXmlTest { + + @ArquillianResource + private URL url; + + @Deployment(testable = false) + public static WebArchive createDeployment() { + WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") + .addClasses(MovieServlet.class, Movie.class, MovieBean.class, MovieException.class, MovieLocalHome.class, MoviesBusinessBean.class, MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, MovieVO.class) + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml"), "META-INF/custom-orm.xml") + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml"), "META-INF/persistence.xml") + .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") + .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml") + .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); + + System.out.println(archive.toString(true)); + return archive; + } + + @Test + @RunAsClient + public void checkCmpJpaEntityORMMappings() throws Exception { + final String output = IO.slurp(new URL(url.toExternalForm())); + System.out.println(output); + Assert.assertTrue(output.contains("Movie added successfully")); + Assert.assertTrue(output.contains("Movie removed successfully")); + Assert.assertTrue(output.contains("title='Bad Boys', director='Michael Bay', year=1995")); + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java new file mode 100644 index 00000000000..405280c813e --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +/** + * @version $Revision$ $Date$ + */ +public interface Movie extends javax.ejb.EJBLocalObject { + + java.lang.Integer getId(); + + void setId(java.lang.Integer id); + + String getDirector(); + + void setDirector(String director); + + String getTitle(); + + void setTitle(String title); + + int getYear(); + + void setYear(int year); +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java new file mode 100644 index 00000000000..6f83ef8f947 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.EntityBean; + +public abstract class MovieBean implements EntityBean { + + public MovieBean() { + } + + public Integer ejbCreate(final String director, String title, final int year) { + this.setDirector(director); + this.setTitle(title); + this.setYear(year); + return null; + } + + public abstract java.lang.Integer getId(); + + public abstract void setId(java.lang.Integer id); + + public abstract String getDirector(); + + public abstract void setDirector(String director); + + public abstract String getTitle(); + + public abstract void setTitle(String title); + + public abstract int getYear(); + + public abstract void setYear(int year); + +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java new file mode 100644 index 00000000000..cdf476c4367 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +public class MovieException extends Exception { + + public MovieException() { + } + + public MovieException(String message) { + super(message); + } + + public MovieException(String message, Throwable cause) { + super(message, cause); + } + + public MovieException(Throwable cause) { + super(cause); + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java new file mode 100644 index 00000000000..dfcf910f610 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.CreateException; +import javax.ejb.FinderException; +import java.util.Collection; + +/** + * @version $Revision$ $Date$ + */ +interface MovieLocalHome extends javax.ejb.EJBLocalHome { + + Movie create(String director, String title, int year) throws CreateException; + + Movie findByPrimaryKey(Integer primarykey) throws FinderException; + + Collection findAll() throws FinderException; + + Collection findByDirector(String director) throws FinderException; +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java new file mode 100644 index 00000000000..0670ee5fa6c --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.CreateException; +import javax.ejb.RemoveException; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.rmi.PortableRemoteObject; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Iterator; + +public class MovieServlet extends HttpServlet { + + + @Override + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { + process(req, resp); + } + + @Override + protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { + process(req, resp); + } + + private void process(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { + + final PrintWriter pw = resp.getWriter(); + + try { + final InitialContext context = new InitialContext(); + final MoviesBusinessLocalHome home = (MoviesBusinessLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MoviesBusiness"), MoviesBusinessLocalHome.class); + + final MoviesBusinessLocal bean = home.create(); + + bean.addMovie("Bad Boys", "Michael Bay", 1995); + + pw.println("Movie added successfully"); + + final Collection allMovies = bean.findAll(); + + final Iterator iterator = allMovies.iterator(); + while (iterator.hasNext()) { + final MovieVO movie = (MovieVO) iterator.next(); + pw.println(movie.toString()); + + bean.delete(movie.getId()); + pw.println("Movie removed successfully"); + } + + bean.remove(); + pw.flush(); + + } catch (NamingException | CreateException | RemoveException | MovieException e) { + throw new ServletException(e); + } + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java new file mode 100644 index 00000000000..ee59bf69826 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.io.Serializable; + +public class MovieVO implements Serializable { + + private Integer id; + private String title; + private String director; + private int year; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public static MovieVO from (final Movie movie) { + final MovieVO movieVO = new MovieVO(); + movieVO.setId(movie.getId()); + movieVO.setTitle(movie.getTitle()); + movieVO.setDirector(movie.getDirector()); + movieVO.setYear(movie.getYear()); + + return movieVO; + } + + @Override + public String toString() { + return "MovieVO{" + + "id=" + id + + ", title='" + title + '\'' + + ", director='" + director + '\'' + + ", year=" + year + + '}'; + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java new file mode 100644 index 00000000000..b4318268203 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.FinderException; +import javax.ejb.RemoveException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.rmi.PortableRemoteObject; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class MoviesBusinessBean implements SessionBean { + + private SessionContext ctx; + + @Override + public void ejbActivate() throws EJBException, RemoteException { + } + + @Override + public void ejbPassivate() throws EJBException, RemoteException { + } + + @Override + public void ejbRemove() throws EJBException, RemoteException { + } + + @Override + public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException { + + this.ctx = ctx; + } + + + public void addMovie(final String title, final String director, int year) throws MovieException { + try { + final InitialContext context = new InitialContext(); + final MovieLocalHome home = (MovieLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); + + + home.create(director, title, year); + + } catch (NamingException | CreateException e) { + throw new MovieException(e); + } + } + + public MovieVO findByPrimaryKey(final int id) throws MovieException { + try { + final InitialContext context = new InitialContext(); + final MovieLocalHome home = (MovieLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); + + + return MovieVO.from(home.findByPrimaryKey(id)); + } catch (NamingException | FinderException e) { + throw new MovieException(e); + } + } + + public Collection findAll() throws MovieException { + try { + final InitialContext context = new InitialContext(); + final MovieLocalHome home = (MovieLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); + + final Collection movies = home.findAll(); + + final Collection result = new ArrayList(); + final Iterator iterator = movies.iterator(); + while (iterator.hasNext()) { + Movie movie = (Movie) iterator.next(); + result.add(MovieVO.from(movie)); + } + + return result; + } catch (NamingException | FinderException e) { + throw new MovieException(e); + } + } + + public void delete(Integer id) throws MovieException { + try { + final InitialContext context = new InitialContext(); + final MovieLocalHome home = (MovieLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); + + home.remove(id); + } catch (NamingException | RemoveException e) { + throw new MovieException(e); + } + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java new file mode 100644 index 00000000000..f961fc3bcaf --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.rmi.RemoteException; +import java.util.Collection; + +public interface MoviesBusinessLocal extends javax.ejb.EJBLocalObject { + + void addMovie(final String title, final String director, int year) throws RemoteException, MovieException; + Movie findByPrimaryKey(final int id) throws RemoteException, MovieException; + Collection findAll() throws RemoteException, MovieException; + void delete(Integer id) throws RemoteException, MovieException; +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java new file mode 100644 index 00000000000..a7181b99443 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.CreateException; +import java.rmi.RemoteException; + +public interface MoviesBusinessLocalHome extends javax.ejb.EJBLocalHome { + + MoviesBusinessLocal create() throws RemoteException, CreateException; + +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml new file mode 100644 index 00000000000..2e607350600 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml @@ -0,0 +1,23 @@ + + + + #MovieBean + + + SELECT m FROM MovieBean m WHERE m.director = ?1 + + + SELECT m FROM MovieBean as m + + + + + + + + + + + + + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml new file mode 100644 index 00000000000..3de83ada232 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml @@ -0,0 +1,103 @@ + + + + + + + + A service that handles monetary payments. + + MovieBusinessBean + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocal + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessBean + Stateless + Container + + ejb/MovieBean + Entity + org.apache.openejb.arquillian.tests.cmp.sample.MovieLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.Movie + MovieBean + + + + MovieBean + org.apache.openejb.arquillian.tests.cmp.sample.MovieLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.Movie + org.apache.openejb.arquillian.tests.cmp.sample.MovieBean + Container + java.lang.Integer + false + 2.x + MovieBean + + id + + + director + + + year + + + title + + id + + + findByDirector + + java.lang.String + + + SELECT m FROM MovieBean m WHERE m.director = ?1 + + + + findAll + + + SELECT m FROM MovieBean as m + + + + + + + + + MovieBusinessBean + * + + Required + + + + + MovieBean + * + + Supports + + + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml new file mode 100644 index 00000000000..f86990c8afc --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml @@ -0,0 +1,11 @@ + + + + + MovieBean + + + + + + \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml new file mode 100644 index 00000000000..97f2cc19bda --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml @@ -0,0 +1,14 @@ + + + + Default JDBC Database + Default Unmanaged JDBC Database + META-INF/custom-orm.xml + openejb.org.apache.openejb.arquillian.tests.cmp.sample.MovieBean + + + + + + + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml new file mode 100644 index 00000000000..6d55e756872 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml @@ -0,0 +1,42 @@ + + + + + + MovieServlet + org.apache.openejb.arquillian.tests.cmp.sample.MovieServlet + + + + MovieServlet + /* + + + + ejb/MoviesBusiness + Session + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocal + + \ No newline at end of file From 5d3efd692c4ee3c635d76e5e53b0ff583d692be3 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Mon, 3 Dec 2018 16:46:52 +0000 Subject: [PATCH 06/16] TOMEE-2295 WIP - fails with a NullPointerException which I'm trying to track down --- .../arquillian/tests/cmp/sample/Actor.java | 35 ++++++++++ .../tests/cmp/sample/ActorBean.java | 45 ++++++++++++ .../tests/cmp/sample/ActorLocalHome.java | 33 +++++++++ .../arquillian/tests/cmp/sample/ActorVO.java | 68 ++++++++++++++++++ .../tests/cmp/sample/CustomOrmXmlTest.java | 3 +- .../arquillian/tests/cmp/sample/Movie.java | 6 ++ .../tests/cmp/sample/MovieBean.java | 41 +++++++++++ .../tests/cmp/sample/MovieServlet.java | 4 +- .../arquillian/tests/cmp/sample/MovieVO.java | 10 +++ .../tests/cmp/sample/MoviesBusinessBean.java | 21 +++++- .../tests/cmp/sample/MoviesBusinessLocal.java | 3 +- .../src/test/resources/arquillian.xml | 2 + .../tests/cmp/sample/custom-orm.xml | 43 ++++++++++-- .../arquillian/tests/cmp/sample/ejb-jar.xml | 70 +++++++++++++++++-- .../tests/cmp/sample/openejb-jar.xml | 6 ++ .../tests/cmp/sample/persistence.xml | 42 +++++++---- 16 files changed, 406 insertions(+), 26 deletions(-) create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java new file mode 100644 index 00000000000..562b075b171 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +/** + * @version $Revision$ $Date$ + */ +public interface Actor extends javax.ejb.EJBLocalObject { + + Integer getId(); + + void setId(Integer id); + + String getFirstName(); + + void setFirstName(String director); + + String getLastName(); + + void setLastName(String title); +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java new file mode 100644 index 00000000000..70f0d2336c4 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.EntityBean; + +public abstract class ActorBean implements EntityBean { + + public ActorBean() { + } + + public Integer ejbCreate(final String firstName, final String lastName) { + this.setFirstName(firstName); + this.setLastName(lastName); + return null; + } + + public abstract Integer getId(); + + public abstract void setId(Integer id); + + public abstract String getFirstName(); + + public abstract void setFirstName(String firstName); + + public abstract String getLastName(); + + public abstract void setLastName(String lastName); + + +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java new file mode 100644 index 00000000000..a8f7dd06abf --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.CreateException; +import javax.ejb.FinderException; +import java.util.Collection; + +/** + * @version $Revision$ $Date$ + */ +interface ActorLocalHome extends javax.ejb.EJBLocalHome { + + Actor create(String firstName, String lastName) throws CreateException; + + Actor findByPrimaryKey(Integer primarykey) throws FinderException; + + Collection findAll() throws FinderException; +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java new file mode 100644 index 00000000000..a3c1a1d4230 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.io.Serializable; + +public class ActorVO implements Serializable { + + private Integer id; + private String firstName; + private String lastName; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public static ActorVO from (final Actor actor) { + final ActorVO actorVO = new ActorVO(); + actorVO.setId(actor.getId()); + actorVO.setFirstName(actor.getFirstName()); + actorVO.setLastName(actor.getLastName()); + + return actorVO; + } + + @Override + public String toString() { + return "ActorVO{" + + "id=" + id + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index e06953631f7..138ba536bf5 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -42,7 +42,8 @@ public class CustomOrmXmlTest { @Deployment(testable = false) public static WebArchive createDeployment() { WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") - .addClasses(MovieServlet.class, Movie.class, MovieBean.class, MovieException.class, MovieLocalHome.class, MoviesBusinessBean.class, MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, MovieVO.class) + .addClasses(MovieServlet.class, Movie.class, MovieBean.class, MovieException.class, MovieLocalHome.class, MoviesBusinessBean.class, + MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, MovieVO.class, ActorBean.class, ActorLocalHome.class, Actor.class) .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml"), "META-INF/custom-orm.xml") .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml"), "META-INF/persistence.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java index 405280c813e..1ff9285e2fe 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java @@ -16,6 +16,8 @@ */ package org.apache.openejb.arquillian.tests.cmp.sample; +import java.util.Collection; + /** * @version $Revision$ $Date$ */ @@ -36,4 +38,8 @@ public interface Movie extends javax.ejb.EJBLocalObject { int getYear(); void setYear(int year); + + void addActor(String firstName, String lastName); + + Collection getActorVO(); } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java index 6f83ef8f947..edee3093cc6 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java @@ -16,7 +16,15 @@ */ package org.apache.openejb.arquillian.tests.cmp.sample; +import javax.ejb.CreateException; +import javax.ejb.EJBException; import javax.ejb.EntityBean; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; public abstract class MovieBean implements EntityBean { @@ -46,4 +54,37 @@ public Integer ejbCreate(final String director, String title, final int year) { public abstract void setYear(int year); + public abstract Collection getActors(); + + public abstract void setActors(Collection actors); + + public void addActor(String firstName, String lastName) { + try { + final InitialContext context = new InitialContext(); + + final ActorLocalHome actorBean = (ActorLocalHome) context.lookup("java:comp/env/ejb/ActorBean"); + final Actor actor = actorBean.create(firstName, lastName); + + final Collection actors = this.getActors(); + actors.add(actor); + + } catch (NamingException | CreateException e) { + throw new EJBException(e); + } + } + + public Collection getActorVO() { + List result = new ArrayList(); + + final Collection actors = this.getActors(); + final Iterator iterator = actors.iterator(); + + while (iterator.hasNext()) { + Actor actor = (Actor) iterator.next(); + result.add(ActorVO.from(actor)); + } + + return result; + } + } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java index 0670ee5fa6c..9610abff5b2 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java @@ -54,7 +54,9 @@ private void process(final HttpServletRequest req, final HttpServletResponse res final MoviesBusinessLocal bean = home.create(); - bean.addMovie("Bad Boys", "Michael Bay", 1995); + final int id = bean.addMovie("Bad Boys", "Michael Bay", 1995); + bean.addActor(id, "Will", "Smith"); + bean.addActor(id, "Martin", "Lawrence"); pw.println("Movie added successfully"); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java index ee59bf69826..d7618dc87a7 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java @@ -17,6 +17,9 @@ package org.apache.openejb.arquillian.tests.cmp.sample; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; public class MovieVO implements Serializable { @@ -24,6 +27,7 @@ public class MovieVO implements Serializable { private String title; private String director; private int year; + private List actors = new ArrayList(); public Integer getId() { return id; @@ -57,12 +61,17 @@ public void setYear(int year) { this.year = year; } + public Collection getActors() { + return actors; + } + public static MovieVO from (final Movie movie) { final MovieVO movieVO = new MovieVO(); movieVO.setId(movie.getId()); movieVO.setTitle(movie.getTitle()); movieVO.setDirector(movie.getDirector()); movieVO.setYear(movie.getYear()); + movieVO.getActors().addAll(movie.getActorVO()); return movieVO; } @@ -74,6 +83,7 @@ public String toString() { ", title='" + title + '\'' + ", director='" + director + '\'' + ", year=" + year + + ", actors=" + actors + '}'; } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index b4318268203..6942d4983da 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -53,20 +53,35 @@ public void setSessionContext(final SessionContext ctx) throws EJBException, Rem } - public void addMovie(final String title, final String director, int year) throws MovieException { + public int addMovie(final String title, final String director, int year) throws MovieException { try { final InitialContext context = new InitialContext(); final MovieLocalHome home = (MovieLocalHome) PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); - - home.create(director, title, year); + final Movie movie = home.create(director, title, year); + return movie.getId(); } catch (NamingException | CreateException e) { throw new MovieException(e); } } + public void addActor(final int movieId, final String firstName, final String lastName) throws MovieException { + try { + final InitialContext context = new InitialContext(); + final MovieLocalHome home = (MovieLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); + + final Movie movie = home.findByPrimaryKey(movieId); + movie.addActor(firstName, lastName); + } catch (NamingException | FinderException e) { + throw new MovieException(e); + } catch (Throwable t) { + t.printStackTrace(); + } + } + public MovieVO findByPrimaryKey(final int id) throws MovieException { try { final InitialContext context = new InitialContext(); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java index f961fc3bcaf..40a75f509cd 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java @@ -21,7 +21,8 @@ public interface MoviesBusinessLocal extends javax.ejb.EJBLocalObject { - void addMovie(final String title, final String director, int year) throws RemoteException, MovieException; + int addMovie(final String title, final String director, int year) throws RemoteException, MovieException; + int addActor(final int movieId, final String firstName, final String lastName) throws RemoteException, MovieException; Movie findByPrimaryKey(final int id) throws RemoteException, MovieException; Collection findAll() throws RemoteException, MovieException; void delete(Integer id) throws RemoteException, MovieException; diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml index b80f45dd9e2..fb0f5fdc111 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml @@ -87,6 +87,7 @@ # scan types by configuring a JarScanner with a nested JarScanFilter. tomcat.util.scan.StandardJarScanFilter.jarsToScan=\ log4j-core*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar + openejb.descriptors.output = true @@ -108,6 +109,7 @@ # try to save some permgen mem openejb.cdi.activated-on-ejb = false + openejb.descriptors.output = true diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml index 2e607350600..49b5e27c587 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml @@ -1,7 +1,24 @@ + - #MovieBean + CustomOrmXmlTest#MovieBean

SELECT m FROM MovieBean m WHERE m.director = ?1 @@ -15,9 +32,27 @@ - - - + + + + + + CustomOrmXmlTest#ActorBean +
+ + SELECT a FROM ActorBean as a + + + + + + + + + + + + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml index 3de83ada232..0ca6a12f6ed 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml @@ -24,7 +24,7 @@ - A service that handles monetary payments. + A service that handles movie entities. MovieBusinessBean org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome @@ -39,6 +39,13 @@ org.apache.openejb.arquillian.tests.cmp.sample.Movie MovieBean + + ejb/ActorBean + Entity + org.apache.openejb.arquillian.tests.cmp.sample.ActorLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.Actor + ActorBean + MovieBean @@ -80,9 +87,58 @@ SELECT m FROM MovieBean as m + + ActorBean + org.apache.openejb.arquillian.tests.cmp.sample.ActorLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.Actor + org.apache.openejb.arquillian.tests.cmp.sample.ActorBean + Container + java.lang.Integer + false + 2.x + ActorBean + + id + + + firstName + + + lastName + + id + + + findAll + + + SELECT a FROM ActorBean as a + + - - + + + + Movie-has-many-actors + One + + + MovieBean + + + actors + java.util.Collection + + + + Actor-acts-in-movie + Many + + ActorBean + + + + @@ -91,7 +147,6 @@ Required - MovieBean @@ -99,5 +154,12 @@ Supports + + + ActorBean + * + + Supports + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml index f86990c8afc..e01a3deeca3 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml @@ -7,5 +7,11 @@ + + ActorBean + + + + \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml index 97f2cc19bda..88e5765dc56 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml @@ -1,14 +1,32 @@ + - - Default JDBC Database - Default Unmanaged JDBC Database - META-INF/custom-orm.xml - openejb.org.apache.openejb.arquillian.tests.cmp.sample.MovieBean - - - - - - - + + Default JDBC Database + Default Unmanaged JDBC Database + META-INF/custom-orm.xml + openejb.org.apache.openejb.arquillian.tests.cmp.sample.MovieBean + openejb.org.apache.openejb.arquillian.tests.cmp.sample.ActorBean + + + + + + + \ No newline at end of file From 86aec7f4f5a605389fe87c03d365667538c277c1 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Mon, 3 Dec 2018 16:56:21 +0000 Subject: [PATCH 07/16] TOMEE-2295 this is redundant --- .../openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index 6942d4983da..2b45cdd9882 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -77,8 +77,6 @@ public void addActor(final int movieId, final String firstName, final String las movie.addActor(firstName, lastName); } catch (NamingException | FinderException e) { throw new MovieException(e); - } catch (Throwable t) { - t.printStackTrace(); } } From 79d386fd81683af5742ad3ef55a25936335c4b8d Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Tue, 4 Dec 2018 14:29:14 +0000 Subject: [PATCH 08/16] TOMEE-2295 - ripping a lot of stuff out of this. Still not working. --- .../arquillian-tomee-webprofile-tests/pom.xml | 48 ++++++++++ .../arquillian/tests/cmp/sample/Actor.java | 8 +- .../tests/cmp/sample/ActorBean.java | 12 +-- .../tests/cmp/sample/ActorLocalHome.java | 1 + .../arquillian/tests/cmp/sample/ActorVO.java | 68 -------------- .../tests/cmp/sample/CustomOrmXmlTest.java | 6 +- .../arquillian/tests/cmp/sample/Movie.java | 45 ---------- .../tests/cmp/sample/MovieBean.java | 90 ------------------- .../tests/cmp/sample/MovieLocalHome.java | 35 -------- .../tests/cmp/sample/MovieServlet.java | 21 +---- .../arquillian/tests/cmp/sample/MovieVO.java | 89 ------------------ .../tests/cmp/sample/MoviesBusinessBean.java | 76 +--------------- .../tests/cmp/sample/MoviesBusinessLocal.java | 7 +- .../tests/cmp/sample/custom-orm.xml | 58 ------------ .../arquillian/tests/cmp/sample/ejb-jar.xml | 81 +---------------- .../tests/cmp/sample/persistence.xml | 32 ------- 16 files changed, 70 insertions(+), 607 deletions(-) delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml index e4593e8eec1..b37cdbb9cc0 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml @@ -51,6 +51,54 @@ + + maven-surefire-plugin + 2.21.0 + + + default-test + test + + test + + + true + none + 1 + true + false + + + + test-tomee-embedded + test + + test + + + ${maven.test.skip} + + -javaagent:${settings.localRepository}/org/apache/tomee/openejb-javaagent/8.0.0-SNAPSHOT/openejb-javaagent-8.0.0-SNAPSHOT.jar + + 8.0.0-SNAPSHOT + tomee-embedded + tomee-embedded + + none + 1 + true + false + + + + + true + none + 1 + true + false + + org.apache.openjpa openjpa-maven-plugin diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java index 562b075b171..739b53cd2da 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java @@ -25,11 +25,11 @@ public interface Actor extends javax.ejb.EJBLocalObject { void setId(Integer id); - String getFirstName(); + String getFirstname(); - void setFirstName(String director); + void setFirstname(String firstname); - String getLastName(); + String getLastname(); - void setLastName(String title); + void setLastname(String lastname); } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java index 70f0d2336c4..3ac4087c668 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java @@ -24,8 +24,8 @@ public ActorBean() { } public Integer ejbCreate(final String firstName, final String lastName) { - this.setFirstName(firstName); - this.setLastName(lastName); + this.setFirstname(firstName); + this.setLastname(lastName); return null; } @@ -33,13 +33,13 @@ public Integer ejbCreate(final String firstName, final String lastName) { public abstract void setId(Integer id); - public abstract String getFirstName(); + public abstract String getFirstname(); - public abstract void setFirstName(String firstName); + public abstract void setFirstname(String firstname); - public abstract String getLastName(); + public abstract String getLastname(); - public abstract void setLastName(String lastName); + public abstract void setLastname(String lastname); } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java index a8f7dd06abf..9878d6f3446 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java @@ -30,4 +30,5 @@ interface ActorLocalHome extends javax.ejb.EJBLocalHome { Actor findByPrimaryKey(Integer primarykey) throws FinderException; Collection findAll() throws FinderException; + } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java deleted file mode 100644 index a3c1a1d4230..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorVO.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import java.io.Serializable; - -public class ActorVO implements Serializable { - - private Integer id; - private String firstName; - private String lastName; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public static ActorVO from (final Actor actor) { - final ActorVO actorVO = new ActorVO(); - actorVO.setId(actor.getId()); - actorVO.setFirstName(actor.getFirstName()); - actorVO.setLastName(actor.getLastName()); - - return actorVO; - } - - @Override - public String toString() { - return "ActorVO{" + - "id=" + id + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - '}'; - } -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index 138ba536bf5..7a706f3ece3 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -42,10 +42,8 @@ public class CustomOrmXmlTest { @Deployment(testable = false) public static WebArchive createDeployment() { WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") - .addClasses(MovieServlet.class, Movie.class, MovieBean.class, MovieException.class, MovieLocalHome.class, MoviesBusinessBean.class, - MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, MovieVO.class, ActorBean.class, ActorLocalHome.class, Actor.class) - .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml"), "META-INF/custom-orm.xml") - .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml"), "META-INF/persistence.xml") + .addClasses(MovieServlet.class, MovieException.class, MoviesBusinessBean.class, + MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, ActorBean.class, ActorLocalHome.class, Actor.class) .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java deleted file mode 100644 index 1ff9285e2fe..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import java.util.Collection; - -/** - * @version $Revision$ $Date$ - */ -public interface Movie extends javax.ejb.EJBLocalObject { - - java.lang.Integer getId(); - - void setId(java.lang.Integer id); - - String getDirector(); - - void setDirector(String director); - - String getTitle(); - - void setTitle(String title); - - int getYear(); - - void setYear(int year); - - void addActor(String firstName, String lastName); - - Collection getActorVO(); -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java deleted file mode 100644 index edee3093cc6..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import javax.ejb.CreateException; -import javax.ejb.EJBException; -import javax.ejb.EntityBean; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -public abstract class MovieBean implements EntityBean { - - public MovieBean() { - } - - public Integer ejbCreate(final String director, String title, final int year) { - this.setDirector(director); - this.setTitle(title); - this.setYear(year); - return null; - } - - public abstract java.lang.Integer getId(); - - public abstract void setId(java.lang.Integer id); - - public abstract String getDirector(); - - public abstract void setDirector(String director); - - public abstract String getTitle(); - - public abstract void setTitle(String title); - - public abstract int getYear(); - - public abstract void setYear(int year); - - public abstract Collection getActors(); - - public abstract void setActors(Collection actors); - - public void addActor(String firstName, String lastName) { - try { - final InitialContext context = new InitialContext(); - - final ActorLocalHome actorBean = (ActorLocalHome) context.lookup("java:comp/env/ejb/ActorBean"); - final Actor actor = actorBean.create(firstName, lastName); - - final Collection actors = this.getActors(); - actors.add(actor); - - } catch (NamingException | CreateException e) { - throw new EJBException(e); - } - } - - public Collection getActorVO() { - List result = new ArrayList(); - - final Collection actors = this.getActors(); - final Iterator iterator = actors.iterator(); - - while (iterator.hasNext()) { - Actor actor = (Actor) iterator.next(); - result.add(ActorVO.from(actor)); - } - - return result; - } - -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java deleted file mode 100644 index dfcf910f610..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import javax.ejb.CreateException; -import javax.ejb.FinderException; -import java.util.Collection; - -/** - * @version $Revision$ $Date$ - */ -interface MovieLocalHome extends javax.ejb.EJBLocalHome { - - Movie create(String director, String title, int year) throws CreateException; - - Movie findByPrimaryKey(Integer primarykey) throws FinderException; - - Collection findAll() throws FinderException; - - Collection findByDirector(String director) throws FinderException; -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java index 9610abff5b2..730e78db87f 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java @@ -27,8 +27,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; -import java.util.Collection; -import java.util.Iterator; public class MovieServlet extends HttpServlet { @@ -54,23 +52,8 @@ private void process(final HttpServletRequest req, final HttpServletResponse res final MoviesBusinessLocal bean = home.create(); - final int id = bean.addMovie("Bad Boys", "Michael Bay", 1995); - bean.addActor(id, "Will", "Smith"); - bean.addActor(id, "Martin", "Lawrence"); - - pw.println("Movie added successfully"); - - final Collection allMovies = bean.findAll(); - - final Iterator iterator = allMovies.iterator(); - while (iterator.hasNext()) { - final MovieVO movie = (MovieVO) iterator.next(); - pw.println(movie.toString()); - - bean.delete(movie.getId()); - pw.println("Movie removed successfully"); - } - + bean.addActor("Will", "Smith"); + pw.println("Actor added successfully"); bean.remove(); pw.flush(); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java deleted file mode 100644 index d7618dc87a7..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class MovieVO implements Serializable { - - private Integer id; - private String title; - private String director; - private int year; - private List actors = new ArrayList(); - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDirector() { - return director; - } - - public void setDirector(String director) { - this.director = director; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - - public Collection getActors() { - return actors; - } - - public static MovieVO from (final Movie movie) { - final MovieVO movieVO = new MovieVO(); - movieVO.setId(movie.getId()); - movieVO.setTitle(movie.getTitle()); - movieVO.setDirector(movie.getDirector()); - movieVO.setYear(movie.getYear()); - movieVO.getActors().addAll(movie.getActorVO()); - - return movieVO; - } - - @Override - public String toString() { - return "MovieVO{" + - "id=" + id + - ", title='" + title + '\'' + - ", director='" + director + '\'' + - ", year=" + year + - ", actors=" + actors + - '}'; - } -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index 2b45cdd9882..3baa70a68fd 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -18,18 +18,12 @@ import javax.ejb.CreateException; import javax.ejb.EJBException; -import javax.ejb.FinderException; -import javax.ejb.RemoveException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - public class MoviesBusinessBean implements SessionBean { private SessionContext ctx; @@ -48,81 +42,19 @@ public void ejbRemove() throws EJBException, RemoteException { @Override public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException { - this.ctx = ctx; } - - public int addMovie(final String title, final String director, int year) throws MovieException { + public void addActor(final String firstName, final String lastName) throws MovieException { try { final InitialContext context = new InitialContext(); - final MovieLocalHome home = (MovieLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); - final Movie movie = home.create(director, title, year); - return movie.getId(); + final ActorLocalHome actorLocalHome = (ActorLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/ActorBean"), ActorLocalHome.class); + final Actor actor = actorLocalHome.create(firstName, lastName); } catch (NamingException | CreateException e) { throw new MovieException(e); } } - - public void addActor(final int movieId, final String firstName, final String lastName) throws MovieException { - try { - final InitialContext context = new InitialContext(); - final MovieLocalHome home = (MovieLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); - - final Movie movie = home.findByPrimaryKey(movieId); - movie.addActor(firstName, lastName); - } catch (NamingException | FinderException e) { - throw new MovieException(e); - } - } - - public MovieVO findByPrimaryKey(final int id) throws MovieException { - try { - final InitialContext context = new InitialContext(); - final MovieLocalHome home = (MovieLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); - - - return MovieVO.from(home.findByPrimaryKey(id)); - } catch (NamingException | FinderException e) { - throw new MovieException(e); - } - } - - public Collection findAll() throws MovieException { - try { - final InitialContext context = new InitialContext(); - final MovieLocalHome home = (MovieLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); - - final Collection movies = home.findAll(); - - final Collection result = new ArrayList(); - final Iterator iterator = movies.iterator(); - while (iterator.hasNext()) { - Movie movie = (Movie) iterator.next(); - result.add(MovieVO.from(movie)); - } - - return result; - } catch (NamingException | FinderException e) { - throw new MovieException(e); - } - } - - public void delete(Integer id) throws MovieException { - try { - final InitialContext context = new InitialContext(); - final MovieLocalHome home = (MovieLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class); - - home.remove(id); - } catch (NamingException | RemoveException e) { - throw new MovieException(e); - } - } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java index 40a75f509cd..a9246862b71 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java @@ -17,13 +17,8 @@ package org.apache.openejb.arquillian.tests.cmp.sample; import java.rmi.RemoteException; -import java.util.Collection; public interface MoviesBusinessLocal extends javax.ejb.EJBLocalObject { - int addMovie(final String title, final String director, int year) throws RemoteException, MovieException; - int addActor(final int movieId, final String firstName, final String lastName) throws RemoteException, MovieException; - Movie findByPrimaryKey(final int id) throws RemoteException, MovieException; - Collection findAll() throws RemoteException, MovieException; - void delete(Integer id) throws RemoteException, MovieException; + int addActor(final String firstName, final String lastName) throws RemoteException, MovieException; } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml deleted file mode 100644 index 49b5e27c587..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - CustomOrmXmlTest#MovieBean -

- - SELECT m FROM MovieBean m WHERE m.director = ?1 - - - SELECT m FROM MovieBean as m - - - - - - - - - - - - - CustomOrmXmlTest#ActorBean -
- - SELECT a FROM ActorBean as a - - - - - - - - - - - - - - - diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml index 0ca6a12f6ed..556dfc3f4d4 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml @@ -32,13 +32,6 @@ org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessBeanStatelessContainer - - ejb/MovieBean - Entity - org.apache.openejb.arquillian.tests.cmp.sample.MovieLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.Movie - MovieBean - ejb/ActorBean Entity @@ -47,46 +40,6 @@ ActorBean - - MovieBean - org.apache.openejb.arquillian.tests.cmp.sample.MovieLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.Movie - org.apache.openejb.arquillian.tests.cmp.sample.MovieBean - Container - java.lang.Integer - false - 2.x - MovieBean - - id - - - director - - - year - - - title - - id - - - findByDirector - - java.lang.String - - - SELECT m FROM MovieBean m WHERE m.director = ?1 - - - - findAll - - - SELECT m FROM MovieBean as m - - ActorBean org.apache.openejb.arquillian.tests.cmp.sample.ActorLocalHome @@ -101,10 +54,10 @@ id - firstName + firstname - lastName + lastname id @@ -116,29 +69,6 @@ - - - - Movie-has-many-actors - One - - - MovieBean - - - actors - java.util.Collection - - - - Actor-acts-in-movie - Many - - ActorBean - - - - @@ -147,13 +77,6 @@ Required - - - MovieBean - * - - Supports - ActorBean diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml deleted file mode 100644 index 88e5765dc56..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - Default JDBC Database - Default Unmanaged JDBC Database - META-INF/custom-orm.xml - openejb.org.apache.openejb.arquillian.tests.cmp.sample.MovieBean - openejb.org.apache.openejb.arquillian.tests.cmp.sample.ActorBean - - - - - - - \ No newline at end of file From 4b289065d571c0115499391d6574d263a7c81aca Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Tue, 4 Dec 2018 14:45:20 +0000 Subject: [PATCH 09/16] TOMEE-2295 attempting something else --- .../tests/cmp/sample/CustomOrmXmlTest.java | 2 +- .../tests/cmp/sample/MovieServlet.java | 4 +- .../tests/cmp/sample/MoviesBusinessBean.java | 9 +++-- .../tests/cmp/sample/MoviesBusinessLocal.java | 2 +- .../cmp/sample/{Actor.java => Person.java} | 9 ++--- .../{ActorBean.java => PersonBean.java} | 37 ++++++++++++++----- ...torLocalHome.java => PersonLocalHome.java} | 6 +-- .../arquillian/tests/cmp/sample/ejb-jar.xml | 27 ++++++-------- .../tests/cmp/sample/openejb-jar.xml | 8 +--- 9 files changed, 56 insertions(+), 48 deletions(-) rename arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/{Actor.java => Person.java} (83%) rename arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/{ActorBean.java => PersonBean.java} (60%) rename arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/{ActorLocalHome.java => PersonLocalHome.java} (83%) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index 7a706f3ece3..2a9692597af 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -43,7 +43,7 @@ public class CustomOrmXmlTest { public static WebArchive createDeployment() { WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") .addClasses(MovieServlet.class, MovieException.class, MoviesBusinessBean.class, - MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, ActorBean.class, ActorLocalHome.class, Actor.class) + MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, PersonBean.class, PersonLocalHome.class, Person.class) .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java index 730e78db87f..213439b0f0b 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java @@ -52,8 +52,8 @@ private void process(final HttpServletRequest req, final HttpServletResponse res final MoviesBusinessLocal bean = home.create(); - bean.addActor("Will", "Smith"); - pw.println("Actor added successfully"); + bean.addActor("Will Smith"); + pw.println("Person added successfully"); bean.remove(); pw.flush(); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index 3baa70a68fd..0f6cced9a64 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -45,16 +45,17 @@ public void setSessionContext(final SessionContext ctx) throws EJBException, Rem this.ctx = ctx; } - public void addActor(final String firstName, final String lastName) throws MovieException { + public void addActor(final String name) throws MovieException { try { final InitialContext context = new InitialContext(); - final ActorLocalHome actorLocalHome = (ActorLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/ActorBean"), ActorLocalHome.class); + final PersonLocalHome personLocalHome = (PersonLocalHome) + PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/PersonBean"), PersonLocalHome.class); - final Actor actor = actorLocalHome.create(firstName, lastName); + final Person person = personLocalHome.create(name); } catch (NamingException | CreateException e) { throw new MovieException(e); } } + } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java index a9246862b71..3e458a76ff1 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java @@ -20,5 +20,5 @@ public interface MoviesBusinessLocal extends javax.ejb.EJBLocalObject { - int addActor(final String firstName, final String lastName) throws RemoteException, MovieException; + int addActor(final String name) throws RemoteException, MovieException; } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java similarity index 83% rename from arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java rename to arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java index 739b53cd2da..31aeb871405 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Actor.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java @@ -19,17 +19,14 @@ /** * @version $Revision$ $Date$ */ -public interface Actor extends javax.ejb.EJBLocalObject { +public interface Person extends javax.ejb.EJBLocalObject { Integer getId(); void setId(Integer id); - String getFirstname(); + String getName(); - void setFirstname(String firstname); + void setName(String name); - String getLastname(); - - void setLastname(String lastname); } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java similarity index 60% rename from arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java rename to arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java index 3ac4087c668..39c0ef456fe 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java @@ -16,16 +16,17 @@ */ package org.apache.openejb.arquillian.tests.cmp.sample; +import javax.ejb.CreateException; import javax.ejb.EntityBean; +import javax.ejb.EntityContext; -public abstract class ActorBean implements EntityBean { +public abstract class PersonBean implements EntityBean { - public ActorBean() { + public PersonBean() { } - public Integer ejbCreate(final String firstName, final String lastName) { - this.setFirstname(firstName); - this.setLastname(lastName); + public Integer ejbCreate(final String name) { + this.setName(name); return null; } @@ -33,13 +34,31 @@ public Integer ejbCreate(final String firstName, final String lastName) { public abstract void setId(Integer id); - public abstract String getFirstname(); + public abstract String getName(); - public abstract void setFirstname(String firstname); + public abstract void setName(String name); - public abstract String getLastname(); + public void ejbPostCreate(String name) throws CreateException { + } + + public void setEntityContext(EntityContext ctx) { + } + + public void unsetEntityContext() { + } + + public void ejbRemove() { + } + + public void ejbLoad() { + } - public abstract void setLastname(String lastname); + public void ejbStore() { + } + public void ejbPassivate() { + } + public void ejbActivate() { + } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java similarity index 83% rename from arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java rename to arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java index 9878d6f3446..c35a0ae534d 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorLocalHome.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java @@ -23,11 +23,11 @@ /** * @version $Revision$ $Date$ */ -interface ActorLocalHome extends javax.ejb.EJBLocalHome { +interface PersonLocalHome extends javax.ejb.EJBLocalHome { - Actor create(String firstName, String lastName) throws CreateException; + Person create(String name) throws CreateException; - Actor findByPrimaryKey(Integer primarykey) throws FinderException; + Person findByPrimaryKey(Integer primarykey) throws FinderException; Collection findAll() throws FinderException; diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml index 556dfc3f4d4..c5af41d83c6 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml @@ -33,31 +33,28 @@ Stateless Container - ejb/ActorBean + ejb/PersonBean Entity - org.apache.openejb.arquillian.tests.cmp.sample.ActorLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.Actor - ActorBean + org.apache.openejb.arquillian.tests.cmp.sample.PersonLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.Person + PersonBean - ActorBean - org.apache.openejb.arquillian.tests.cmp.sample.ActorLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.Actor - org.apache.openejb.arquillian.tests.cmp.sample.ActorBean + PersonBean + org.apache.openejb.arquillian.tests.cmp.sample.PersonLocalHome + org.apache.openejb.arquillian.tests.cmp.sample.Person + org.apache.openejb.arquillian.tests.cmp.sample.PersonBean Container java.lang.Integer false 2.x - ActorBean + PersonBean id - firstname - - - lastname + name id @@ -65,7 +62,7 @@ findAll - SELECT a FROM ActorBean as a + SELECT p FROM PersonBean as p @@ -79,7 +76,7 @@ - ActorBean + PersonBean * Supports diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml index e01a3deeca3..1de720e2df1 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml @@ -2,13 +2,7 @@ - MovieBean - - - - - - ActorBean + PersonBean From 7dfdc4ae4cc2755851f3a902b71ccae1bba86173 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Tue, 4 Dec 2018 14:52:56 +0000 Subject: [PATCH 10/16] Ripped everything out --- .../tests/cmp/sample/CustomOrmXmlTest.java | 2 +- .../tests/cmp/sample/MoviesBusinessBean.java | 15 +---- .../arquillian/tests/cmp/sample/Person.java | 32 ---------- .../tests/cmp/sample/PersonBean.java | 64 ------------------- .../tests/cmp/sample/PersonLocalHome.java | 34 ---------- .../arquillian/tests/cmp/sample/ejb-jar.xml | 39 ----------- .../tests/cmp/sample/openejb-jar.xml | 9 +-- 7 files changed, 3 insertions(+), 192 deletions(-) delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index 2a9692597af..c442bcc84c0 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -43,7 +43,7 @@ public class CustomOrmXmlTest { public static WebArchive createDeployment() { WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") .addClasses(MovieServlet.class, MovieException.class, MoviesBusinessBean.class, - MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, PersonBean.class, PersonLocalHome.class, Person.class) + MoviesBusinessLocal.class, MoviesBusinessLocalHome.class) .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index 0f6cced9a64..e4a9b8ea01a 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -16,13 +16,9 @@ */ package org.apache.openejb.arquillian.tests.cmp.sample; -import javax.ejb.CreateException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.rmi.PortableRemoteObject; import java.rmi.RemoteException; public class MoviesBusinessBean implements SessionBean { @@ -46,16 +42,7 @@ public void setSessionContext(final SessionContext ctx) throws EJBException, Rem } public void addActor(final String name) throws MovieException { - try { - final InitialContext context = new InitialContext(); - - final PersonLocalHome personLocalHome = (PersonLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/PersonBean"), PersonLocalHome.class); - - final Person person = personLocalHome.create(name); - } catch (NamingException | CreateException e) { - throw new MovieException(e); - } + // this is literally a no-op now } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java deleted file mode 100644 index 31aeb871405..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Person.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -/** - * @version $Revision$ $Date$ - */ -public interface Person extends javax.ejb.EJBLocalObject { - - Integer getId(); - - void setId(Integer id); - - String getName(); - - void setName(String name); - -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java deleted file mode 100644 index 39c0ef456fe..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonBean.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import javax.ejb.CreateException; -import javax.ejb.EntityBean; -import javax.ejb.EntityContext; - -public abstract class PersonBean implements EntityBean { - - public PersonBean() { - } - - public Integer ejbCreate(final String name) { - this.setName(name); - return null; - } - - public abstract Integer getId(); - - public abstract void setId(Integer id); - - public abstract String getName(); - - public abstract void setName(String name); - - public void ejbPostCreate(String name) throws CreateException { - } - - public void setEntityContext(EntityContext ctx) { - } - - public void unsetEntityContext() { - } - - public void ejbRemove() { - } - - public void ejbLoad() { - } - - public void ejbStore() { - } - - public void ejbPassivate() { - } - - public void ejbActivate() { - } -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java deleted file mode 100644 index c35a0ae534d..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/PersonLocalHome.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import javax.ejb.CreateException; -import javax.ejb.FinderException; -import java.util.Collection; - -/** - * @version $Revision$ $Date$ - */ -interface PersonLocalHome extends javax.ejb.EJBLocalHome { - - Person create(String name) throws CreateException; - - Person findByPrimaryKey(Integer primarykey) throws FinderException; - - Collection findAll() throws FinderException; - -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml index c5af41d83c6..cb5f04758e7 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml @@ -32,39 +32,7 @@ org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessBean Stateless Container - - ejb/PersonBean - Entity - org.apache.openejb.arquillian.tests.cmp.sample.PersonLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.Person - PersonBean - - - PersonBean - org.apache.openejb.arquillian.tests.cmp.sample.PersonLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.Person - org.apache.openejb.arquillian.tests.cmp.sample.PersonBean - Container - java.lang.Integer - false - 2.x - PersonBean - - id - - - name - - id - - - findAll - - - SELECT p FROM PersonBean as p - - @@ -74,12 +42,5 @@ Required - - - PersonBean - * - - Supports - diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml index 1de720e2df1..166128c60e8 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml @@ -1,11 +1,4 @@ - - - PersonBean - - - - - + \ No newline at end of file From cf9d96ea1fba93ecd2decae10893d816372933b2 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 5 Dec 2018 10:57:42 +0000 Subject: [PATCH 11/16] TOMEE-2295 working sample --- .../tests/cmp/sample/ActorBean.java | 70 +++++++++ .../tests/cmp/sample/ActorDetails.java | 39 +++++ .../tests/cmp/sample/CustomOrmXmlTest.java | 13 +- .../tests/cmp/sample/LocalActor.java | 29 ++++ .../tests/cmp/sample/LocalActorHome.java | 31 ++++ .../tests/cmp/sample/LocalMovie.java | 39 +++++ .../tests/cmp/sample/LocalMovieHome.java | 33 +++++ .../tests/cmp/sample/MovieBean.java | 118 +++++++++++++++ .../tests/cmp/sample/MovieDetails.java | 45 ++++++ .../tests/cmp/sample/MovieException.java | 35 ----- .../tests/cmp/sample/MovieServlet.java | 64 -------- .../tests/cmp/sample/MoviesBusiness.java | 25 ++++ .../tests/cmp/sample/MoviesBusinessBean.java | 76 +++++++--- ...LocalHome.java => MoviesBusinessHome.java} | 27 ++-- .../tests/cmp/sample/MoviesBusinessLocal.java | 24 --- .../tests/cmp/sample/MoviesServlet.java | 50 +++++++ .../arquillian/tests/cmp/sample/ejb-jar.xml | 140 ++++++++++++++++-- .../tests/cmp/sample/openejb-jar.xml | 32 +++- .../arquillian/tests/cmp/sample/web.xml | 14 +- 19 files changed, 721 insertions(+), 183 deletions(-) create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActor.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActorHome.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovie.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovieHome.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusiness.java rename arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/{MoviesBusinessLocalHome.java => MoviesBusinessHome.java} (50%) delete mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java new file mode 100644 index 00000000000..de13f96e899 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.util.Collection; +import javax.ejb.CreateException; +import javax.ejb.EntityBean; +import javax.ejb.EntityContext; + + +public abstract class ActorBean implements EntityBean { + private EntityContext context; + + public abstract Integer getActorId(); + + public abstract void setActorId(Integer id); + + public abstract String getName(); + + public abstract void setName(String name); + + public abstract Collection getMovies(); + + public abstract void setMovies(Collection movies); + + public String ejbCreate(String name) throws CreateException { + setName(name); + return null; + } + + public void ejbPostCreate(String name) throws CreateException { + } + + public void setEntityContext(EntityContext ctx) { + context = ctx; + } + + public void unsetEntityContext() { + context = null; + } + + public void ejbRemove() { + } + + public void ejbLoad() { + } + + public void ejbStore() { + } + + public void ejbPassivate() { + } + + public void ejbActivate() { + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java new file mode 100644 index 00000000000..d95debf3986 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +public class ActorDetails implements java.io.Serializable { + private Integer id; + private String name; + + public ActorDetails(Integer id, String name) { + this.id = id; + this.name = name; + } + + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + public String toString() { + return id + " " + name; + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index c442bcc84c0..e23521a0cb5 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -24,7 +24,6 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,8 +41,10 @@ public class CustomOrmXmlTest { @Deployment(testable = false) public static WebArchive createDeployment() { WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") - .addClasses(MovieServlet.class, MovieException.class, MoviesBusinessBean.class, - MoviesBusinessLocal.class, MoviesBusinessLocalHome.class) + .addClasses(ActorBean.class, ActorDetails.class, LocalActor.class, LocalActorHome.class, + LocalMovie.class, LocalMovieHome.class, MovieBean.class, MovieDetails.class, + MoviesBusiness.class, MoviesBusinessBean.class, MoviesBusinessHome.class, + MoviesServlet.class) .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); @@ -57,8 +58,8 @@ public static WebArchive createDeployment() { public void checkCmpJpaEntityORMMappings() throws Exception { final String output = IO.slurp(new URL(url.toExternalForm())); System.out.println(output); - Assert.assertTrue(output.contains("Movie added successfully")); - Assert.assertTrue(output.contains("Movie removed successfully")); - Assert.assertTrue(output.contains("title='Bad Boys', director='Michael Bay', year=1995")); + //Assert.assertTrue(output.contains("Movie added successfully")); + //Assert.assertTrue(output.contains("Movie removed successfully")); + //Assert.assertTrue(output.contains("title='Bad Boys', director='Michael Bay', year=1995")); } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActor.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActor.java new file mode 100644 index 00000000000..26a0dafab88 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActor.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.util.Collection; +import javax.ejb.EJBLocalObject; + + +public interface LocalActor extends EJBLocalObject { + Integer getActorId(); + + String getName(); + + Collection getMovies(); +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActorHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActorHome.java new file mode 100644 index 00000000000..b86b00bb101 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalActorHome.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.util.Collection; +import javax.ejb.CreateException; +import javax.ejb.EJBLocalHome; +import javax.ejb.FinderException; + + +public interface LocalActorHome extends EJBLocalHome { + LocalActor create(String name) throws CreateException; + + LocalActor findByPrimaryKey(String id) throws FinderException; + + Collection findAll() throws FinderException; +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovie.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovie.java new file mode 100644 index 00000000000..682926e0c5a --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovie.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.util.ArrayList; +import java.util.Collection; +import javax.ejb.EJBLocalObject; + + +public interface LocalMovie extends EJBLocalObject { + Integer getMovieId(); + + String getName(); + + String getGenre(); + + Collection getActors(); + + ArrayList getCopyOfActors(); + + void addActor(LocalActor actor); + + void removeActor(LocalActor actor); +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovieHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovieHome.java new file mode 100644 index 00000000000..fc343a72bc8 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/LocalMovieHome.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.CreateException; +import javax.ejb.EJBLocalHome; +import javax.ejb.FinderException; +import java.util.Collection; + + +public interface LocalMovieHome extends EJBLocalHome { + LocalMovie create(String name, String genre) throws CreateException; + + LocalMovie findByPrimaryKey(String id) throws FinderException; + + Collection findAll() throws FinderException; +} + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java new file mode 100644 index 00000000000..88f69da8ece --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.EntityBean; +import javax.ejb.EntityContext; + + +public abstract class MovieBean implements EntityBean { + private EntityContext context; + + public abstract Integer getMovieId(); + + public abstract void setMovieId(Integer id); + + public abstract String getName(); + + public abstract void setName(String name); + + public abstract String getGenre(); + + public abstract void setGenre(String city); + + public abstract Collection getActors(); + + public abstract void setActors(Collection actors); + + public ArrayList getCopyOfActors() { + ArrayList actorList = new ArrayList(); + Collection actors = getActors(); + + Iterator i = actors.iterator(); + + while (i.hasNext()) { + LocalActor actor = (LocalActor) i.next(); + ActorDetails details = + new ActorDetails(actor.getActorId(), actor.getName()); + + actorList.add(details); + } + + return actorList; + } + + public void addActor(LocalActor player) { + try { + Collection actors = getActors(); + + actors.add(player); + } catch (Exception ex) { + throw new EJBException(ex.getMessage()); + } + } + + public void removeActor(LocalActor actor) { + try { + Collection players = getActors(); + + players.remove(actor); + } catch (Exception ex) { + throw new EJBException(ex.getMessage()); + } + } + + public String ejbCreate(String name, String genre) + throws CreateException { + setName(name); + setGenre(genre); + + return null; + } + + public void ejbPostCreate(String name, String genre) + throws CreateException { + } + + public void setEntityContext(EntityContext ctx) { + context = ctx; + } + + public void unsetEntityContext() { + context = null; + } + + public void ejbRemove() { + } + + public void ejbLoad() { + } + + public void ejbStore() { + } + + public void ejbPassivate() { + } + + public void ejbActivate() { + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java new file mode 100644 index 00000000000..f08c257ce9a --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +public class MovieDetails implements java.io.Serializable { + private String id; + private String name; + private String genre; + + public MovieDetails(String id, String name, String genre) { + this.id = id; + this.name = name; + this.genre = genre; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getGenre() { + return genre; + } + + public String toString() { + return id + " " + name + " " + genre; + } +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java deleted file mode 100644 index cdf476c4367..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -public class MovieException extends Exception { - - public MovieException() { - } - - public MovieException(String message) { - super(message); - } - - public MovieException(String message, Throwable cause) { - super(message, cause); - } - - public MovieException(Throwable cause) { - super(cause); - } -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java deleted file mode 100644 index 213439b0f0b..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import javax.ejb.CreateException; -import javax.ejb.RemoveException; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.rmi.PortableRemoteObject; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; - -public class MovieServlet extends HttpServlet { - - - @Override - protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - process(req, resp); - } - - @Override - protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - process(req, resp); - } - - private void process(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - - final PrintWriter pw = resp.getWriter(); - - try { - final InitialContext context = new InitialContext(); - final MoviesBusinessLocalHome home = (MoviesBusinessLocalHome) - PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MoviesBusiness"), MoviesBusinessLocalHome.class); - - final MoviesBusinessLocal bean = home.create(); - - bean.addActor("Will Smith"); - pw.println("Person added successfully"); - bean.remove(); - pw.flush(); - - } catch (NamingException | CreateException | RemoveException | MovieException e) { - throw new ServletException(e); - } - } -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusiness.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusiness.java new file mode 100644 index 00000000000..2ec73b3fe36 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusiness.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import javax.ejb.EJBObject; +import java.rmi.RemoteException; + + +public interface MoviesBusiness extends EJBObject { + void doLogic() throws RemoteException; +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index e4a9b8ea01a..43c8667e5b5 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -1,48 +1,80 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.openejb.arquillian.tests.cmp.sample; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import javax.ejb.CreateException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; -import java.rmi.RemoteException; +import javax.naming.Context; +import javax.naming.InitialContext; + public class MoviesBusinessBean implements SessionBean { + public void doLogic() { + try { + Context initial = new InitialContext(); + + LocalActorHome actorHome = (LocalActorHome) initial.lookup("java:comp/env/ejb/Actor"); + Context initial1 = new InitialContext(); + + LocalMovieHome movieHome = (LocalMovieHome) initial1.lookup("java:comp/env/ejb/Movie"); + + final LocalMovie movie = movieHome.create("Bad Boys", "Action Comedy"); + + final LocalActor actor1 = actorHome.create("Will Smith"); + final LocalActor actor2 = actorHome.create("Martin Lawrence"); - private SessionContext ctx; + movie.addActor(actor1); + movie.addActor(actor2); + } catch (Exception ex) { + throw new EJBException(ex.getMessage()); + } + } - @Override - public void ejbActivate() throws EJBException, RemoteException { + public void ejbCreate() throws CreateException { } - @Override - public void ejbPassivate() throws EJBException, RemoteException { + public void ejbActivate() { } - @Override - public void ejbRemove() throws EJBException, RemoteException { + public void ejbPassivate() { } - @Override - public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException { - this.ctx = ctx; + public void ejbRemove() { } - public void addActor(final String name) throws MovieException { - // this is literally a no-op now + public void setSessionContext(SessionContext sc) { } + private ArrayList copyActorsToDetails(Collection actors) { + ArrayList detailsList = new ArrayList(); + Iterator i = actors.iterator(); + + while (i.hasNext()) { + LocalActor player = (LocalActor) i.next(); + ActorDetails details = + new ActorDetails(player.getActorId(), player.getName()); + + detailsList.add(details); + } + + return detailsList; + } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessHome.java similarity index 50% rename from arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java rename to arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessHome.java index a7181b99443..6898c9632cd 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessHome.java @@ -1,26 +1,27 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + package org.apache.openejb.arquillian.tests.cmp.sample; -import javax.ejb.CreateException; import java.rmi.RemoteException; +import javax.ejb.CreateException; +import javax.ejb.EJBHome; -public interface MoviesBusinessLocalHome extends javax.ejb.EJBLocalHome { - - MoviesBusinessLocal create() throws RemoteException, CreateException; +public interface MoviesBusinessHome extends EJBHome { + MoviesBusiness create() throws RemoteException, CreateException; } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java deleted file mode 100644 index 3e458a76ff1..00000000000 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.arquillian.tests.cmp.sample; - -import java.rmi.RemoteException; - -public interface MoviesBusinessLocal extends javax.ejb.EJBLocalObject { - - int addActor(final String name) throws RemoteException, MovieException; -} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java new file mode 100644 index 00000000000..983294c617c --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.openejb.arquillian.tests.cmp.sample; + +import java.io.IOException; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +public class MoviesServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + Context initial = new InitialContext(); + Object objref = initial.lookup("java:comp/env/ejb/MoviesBusiness"); + + MoviesBusinessHome home = + (MoviesBusinessHome) PortableRemoteObject.narrow(objref, + MoviesBusinessHome.class); + + MoviesBusiness moviesBusiness = home.create(); + moviesBusiness.doLogic(); + + } catch (Exception ex) { + throw new ServletException(ex); + } + } + +} diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml index cb5f04758e7..8b390534db8 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml @@ -16,28 +16,146 @@ See the License for the specific language governing permissions and limitations under the License. --> - - + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> + RosterJAR - - A service that handles movie entities. - - MovieBusinessBean - org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocal + RosterBean + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessHome + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusiness org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessBean Stateless Container + + ejb/Actor + Entity + org.apache.openejb.arquillian.tests.cmp.sample.LocalActorHome + org.apache.openejb.arquillian.tests.cmp.sample.LocalActor + ActorBean + + + ejb/Movie + Entity + org.apache.openejb.arquillian.tests.cmp.sample.LocalMovieHome + org.apache.openejb.arquillian.tests.cmp.sample.LocalMovie + MovieBean + + + + + + MovieBean + org.apache.openejb.arquillian.tests.cmp.sample.LocalMovieHome + org.apache.openejb.arquillian.tests.cmp.sample.LocalMovie + org.apache.openejb.arquillian.tests.cmp.sample.MovieBean + Container + java.lang.Integer + false + 2.x + Movie + + no description + movieId + + + no description + name + + + no description + genre + + movieId + + + + + + findAll + + + select object(m) from Movie m + + + + ActorBean + org.apache.openejb.arquillian.tests.cmp.sample.LocalActorHome + org.apache.openejb.arquillian.tests.cmp.sample.LocalActor + org.apache.openejb.arquillian.tests.cmp.sample.ActorBean + Container + java.lang.Integer + false + 2.x + Actor + + no description + actorId + + + no description + name + + actorId + + + + + + findAll + + + select object(a) from Actor a + + + + + + Many + + ActorBean + + + movies + java.util.Collection + + + + Many + + MovieBean + + + actors + java.util.Collection + + + + - MovieBusinessBean + RosterBean + Remote + * + + Required + + + + MovieBean + Local + * + + Required + + + + ActorBean + Local * Required diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml index 166128c60e8..b6ab94d45cd 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml @@ -1,4 +1,34 @@ + - + + + MovieBean + + + + + + ActorBean + + + + + \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml index 6d55e756872..a536e17f1ef 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml @@ -24,19 +24,19 @@ id="WebApp_ID" version="2.5"> - MovieServlet - org.apache.openejb.arquillian.tests.cmp.sample.MovieServlet + RosterServlet + org.apache.openejb.arquillian.tests.cmp.sample.MoviesServlet - MovieServlet + RosterServlet /* - + ejb/MoviesBusiness Session - org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome - org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocal - + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessHome + org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusiness + \ No newline at end of file From ff6639ec0d5c38c706e655398b0a1b3c1a91edc4 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 5 Dec 2018 12:35:58 +0000 Subject: [PATCH 12/16] Finals and formatting --- .../tests/cmp/sample/ActorBean.java | 6 ++-- .../tests/cmp/sample/ActorDetails.java | 2 +- .../tests/cmp/sample/CustomOrmXmlTest.java | 2 +- .../tests/cmp/sample/MovieBean.java | 28 +++++++++---------- .../tests/cmp/sample/MovieDetails.java | 2 +- .../tests/cmp/sample/MoviesBusinessBean.java | 22 +++++++-------- .../tests/cmp/sample/MoviesServlet.java | 14 ++++------ 7 files changed, 37 insertions(+), 39 deletions(-) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java index de13f96e899..55426736523 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorBean.java @@ -37,15 +37,15 @@ public abstract class ActorBean implements EntityBean { public abstract void setMovies(Collection movies); - public String ejbCreate(String name) throws CreateException { + public String ejbCreate(final String name) throws CreateException { setName(name); return null; } - public void ejbPostCreate(String name) throws CreateException { + public void ejbPostCreate(final String name) throws CreateException { } - public void setEntityContext(EntityContext ctx) { + public void setEntityContext(final EntityContext ctx) { context = ctx; } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java index d95debf3986..23c1ce5b0aa 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/ActorDetails.java @@ -20,7 +20,7 @@ public class ActorDetails implements java.io.Serializable { private Integer id; private String name; - public ActorDetails(Integer id, String name) { + public ActorDetails(final Integer id, final String name) { this.id = id; this.name = name; } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index e23521a0cb5..ce871966a36 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -40,7 +40,7 @@ public class CustomOrmXmlTest { @Deployment(testable = false) public static WebArchive createDeployment() { - WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") + final WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war") .addClasses(ActorBean.class, ActorDetails.class, LocalActor.class, LocalActorHome.class, LocalMovie.class, LocalMovieHome.class, MovieBean.class, MovieDetails.class, MoviesBusiness.class, MoviesBusinessBean.class, MoviesBusinessHome.class, diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java index 88f69da8ece..f200bdb8f62 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java @@ -45,14 +45,14 @@ public abstract class MovieBean implements EntityBean { public abstract void setActors(Collection actors); public ArrayList getCopyOfActors() { - ArrayList actorList = new ArrayList(); - Collection actors = getActors(); + final ArrayList actorList = new ArrayList(); + final Collection actors = getActors(); - Iterator i = actors.iterator(); + final Iterator i = actors.iterator(); while (i.hasNext()) { - LocalActor actor = (LocalActor) i.next(); - ActorDetails details = + final LocalActor actor = (LocalActor) i.next(); + final ActorDetails details = new ActorDetails(actor.getActorId(), actor.getName()); actorList.add(details); @@ -61,27 +61,27 @@ public ArrayList getCopyOfActors() { return actorList; } - public void addActor(LocalActor player) { + public void addActor(final LocalActor player) { try { - Collection actors = getActors(); + final Collection actors = getActors(); actors.add(player); - } catch (Exception ex) { + } catch (final Exception ex) { throw new EJBException(ex.getMessage()); } } - public void removeActor(LocalActor actor) { + public void removeActor(final LocalActor actor) { try { - Collection players = getActors(); + final Collection players = getActors(); players.remove(actor); - } catch (Exception ex) { + } catch (final Exception ex) { throw new EJBException(ex.getMessage()); } } - public String ejbCreate(String name, String genre) + public String ejbCreate(final String name, final String genre) throws CreateException { setName(name); setGenre(genre); @@ -89,11 +89,11 @@ public String ejbCreate(String name, String genre) return null; } - public void ejbPostCreate(String name, String genre) + public void ejbPostCreate(final String name, final String genre) throws CreateException { } - public void setEntityContext(EntityContext ctx) { + public void setEntityContext(final EntityContext ctx) { context = ctx; } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java index f08c257ce9a..84fe1317672 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieDetails.java @@ -21,7 +21,7 @@ public class MovieDetails implements java.io.Serializable { private String name; private String genre; - public MovieDetails(String id, String name, String genre) { + public MovieDetails(final String id, final String name, final String genre) { this.id = id; this.name = name; this.genre = genre; diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java index 43c8667e5b5..9227dbf2c72 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java @@ -29,12 +29,12 @@ public class MoviesBusinessBean implements SessionBean { public void doLogic() { try { - Context initial = new InitialContext(); + final Context initial = new InitialContext(); - LocalActorHome actorHome = (LocalActorHome) initial.lookup("java:comp/env/ejb/Actor"); - Context initial1 = new InitialContext(); + final LocalActorHome actorHome = (LocalActorHome) initial.lookup("java:comp/env/ejb/Actor"); + final Context initial1 = new InitialContext(); - LocalMovieHome movieHome = (LocalMovieHome) initial1.lookup("java:comp/env/ejb/Movie"); + final LocalMovieHome movieHome = (LocalMovieHome) initial1.lookup("java:comp/env/ejb/Movie"); final LocalMovie movie = movieHome.create("Bad Boys", "Action Comedy"); @@ -43,7 +43,7 @@ public void doLogic() { movie.addActor(actor1); movie.addActor(actor2); - } catch (Exception ex) { + } catch (final Exception ex) { throw new EJBException(ex.getMessage()); } } @@ -60,16 +60,16 @@ public void ejbPassivate() { public void ejbRemove() { } - public void setSessionContext(SessionContext sc) { + public void setSessionContext(final SessionContext sc) { } - private ArrayList copyActorsToDetails(Collection actors) { - ArrayList detailsList = new ArrayList(); - Iterator i = actors.iterator(); + private ArrayList copyActorsToDetails(final Collection actors) { + final ArrayList detailsList = new ArrayList(); + final Iterator i = actors.iterator(); while (i.hasNext()) { - LocalActor player = (LocalActor) i.next(); - ActorDetails details = + final LocalActor player = (LocalActor) i.next(); + final ActorDetails details = new ActorDetails(player.getActorId(), player.getName()); detailsList.add(details); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java index 983294c617c..54f0893814e 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java @@ -30,19 +30,17 @@ public class MoviesServlet extends HttpServlet { @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { - Context initial = new InitialContext(); - Object objref = initial.lookup("java:comp/env/ejb/MoviesBusiness"); + final Context initial = new InitialContext(); - MoviesBusinessHome home = - (MoviesBusinessHome) PortableRemoteObject.narrow(objref, - MoviesBusinessHome.class); + final MoviesBusinessHome home = (MoviesBusinessHome) + PortableRemoteObject.narrow(initial.lookup("java:comp/env/ejb/MoviesBusiness"), MoviesBusinessHome.class); - MoviesBusiness moviesBusiness = home.create(); + final MoviesBusiness moviesBusiness = home.create(); moviesBusiness.doLogic(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new ServletException(ex); } } From 1ba03751cc9962bf9e06d6830642bec3291808b3 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 5 Dec 2018 13:55:47 +0000 Subject: [PATCH 13/16] TOMEE-2295 add custom mapping back --- .../arquillian-tomee-webprofile-tests/pom.xml | 50 +---------------- .../tests/cmp/sample/CustomOrmXmlTest.java | 2 + .../tests/cmp/sample/custom-orm.xml | 54 +++++++++++++++++++ .../tests/cmp/sample/persistence.xml | 31 +++++++++++ 4 files changed, 88 insertions(+), 49 deletions(-) create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml create mode 100644 arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml index b37cdbb9cc0..b2c9a86e589 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/pom.xml @@ -51,54 +51,6 @@ - - maven-surefire-plugin - 2.21.0 - - - default-test - test - - test - - - true - none - 1 - true - false - - - - test-tomee-embedded - test - - test - - - ${maven.test.skip} - - -javaagent:${settings.localRepository}/org/apache/tomee/openejb-javaagent/8.0.0-SNAPSHOT/openejb-javaagent-8.0.0-SNAPSHOT.jar - - 8.0.0-SNAPSHOT - tomee-embedded - tomee-embedded - - none - 1 - true - false - - - - - true - none - 1 - true - false - - org.apache.openjpa openjpa-maven-plugin @@ -144,4 +96,4 @@ - + \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index ce871966a36..f261015b412 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -45,6 +45,8 @@ public static WebArchive createDeployment() { LocalMovie.class, LocalMovieHome.class, MovieBean.class, MovieDetails.class, MoviesBusiness.class, MoviesBusinessBean.class, MoviesBusinessHome.class, MoviesServlet.class) + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml"), "META-INF/custom-orm.xml") + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml"), "META-INF/persistence.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml") .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml new file mode 100644 index 00000000000..22dbae5601c --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml @@ -0,0 +1,54 @@ + + + + + CustomOrmXmlTest#MovieBean +

+ + select object(m) from Movie m + + + + + + + + + + + + + + CustomOrmXmlTest#ActorBean +
+ + select object(a) from Actor a + + + + + + + + + + + + + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml new file mode 100644 index 00000000000..d184dd93c07 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml @@ -0,0 +1,31 @@ + + + + + Default JDBC Database + Default Unmanaged JDBC Database + META-INF/custom-orm.xml + openejb.org.apache.openejb.arquillian.tests.cmp.sample.Movie + openejb.org.apache.openejb.arquillian.tests.cmp.sample.Actor + + + + + + From 46a731e7f11206f2bec39f21435fc2525ac67b1a Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 5 Dec 2018 14:55:40 +0000 Subject: [PATCH 14/16] TOMEE-2295 check the correct database schema is in place --- .../tests/cmp/sample/CustomOrmXmlTest.java | 15 +++++-- .../tests/cmp/sample/MoviesServlet.java | 43 +++++++++++++++++++ .../arquillian/tests/cmp/sample/web.xml | 5 +++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index f261015b412..e8141b6c918 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -24,6 +24,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -60,8 +61,16 @@ public static WebArchive createDeployment() { public void checkCmpJpaEntityORMMappings() throws Exception { final String output = IO.slurp(new URL(url.toExternalForm())); System.out.println(output); - //Assert.assertTrue(output.contains("Movie added successfully")); - //Assert.assertTrue(output.contains("Movie removed successfully")); - //Assert.assertTrue(output.contains("title='Bad Boys', director='Michael Bay', year=1995")); + + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR, COLUMN_NAME: ACTORID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR, COLUMN_NAME: ACTOR_NAME, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 250")); + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR_MOVIE, COLUMN_NAME: ACTORS_ACTORID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR_MOVIE, COLUMN_NAME: MOVIES_MOVIEID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: MOVIEID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: GENRE, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 255")); + Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: MOVIE_NAME, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 250")); + + final String[] split = output.split("\r\n"); + Assert.assertEquals(7, split.length); } } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java index 54f0893814e..63d868ca946 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesServlet.java @@ -18,6 +18,11 @@ package org.apache.openejb.arquillian.tests.cmp.sample; import java.io.IOException; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; @@ -25,6 +30,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.sql.DataSource; public class MoviesServlet extends HttpServlet { @@ -32,6 +38,9 @@ public class MoviesServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { + + final PrintWriter pw = resp.getWriter(); + final Context initial = new InitialContext(); final MoviesBusinessHome home = (MoviesBusinessHome) @@ -40,6 +49,40 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res final MoviesBusiness moviesBusiness = home.create(); moviesBusiness.doLogic(); + final DataSource ds = (DataSource) initial.lookup("java:comp/env/db/DataSource"); + try (final Connection connection = ds.getConnection(); + final PreparedStatement ps = connection.prepareStatement( + "select TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH " + + "from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = 'PUBLIC'"); + + final ResultSet rs = ps.executeQuery()) { + + final ResultSetMetaData metaData = rs.getMetaData(); + final int columnCount = metaData.getColumnCount(); + + final String[] columnNames = new String[columnCount]; + + for (int c = 0; c < columnCount; c++) { + columnNames[c] = metaData.getColumnName(c + 1); + } + + while (rs.next()) { + final StringBuilder sb = new StringBuilder(); + + for (int c = 0; c < columnCount; c++) { + if (c > 0) { + sb.append(", "); + } + + sb.append(columnNames[c]).append(": ").append(rs.getString(c + 1)); + } + + pw.println(sb.toString()); + } + } + + pw.flush(); + } catch (final Exception ex) { throw new ServletException(ex); } diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml index a536e17f1ef..cd3c5912fcd 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml @@ -39,4 +39,9 @@ org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessHome org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusiness + + + db/DataSource + javax.sql.DataSource + \ No newline at end of file From 5aab80789590b920b14f6c092512c2977708a345 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 5 Dec 2018 16:53:24 +0000 Subject: [PATCH 15/16] TOMEE-2295 ensure this works across all profiles --- .../openejb/arquillian/tests/cmp/sample/persistence.xml | 5 +++-- .../org/apache/openejb/arquillian/tests/cmp/sample/web.xml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml index d184dd93c07..69b89715eee 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml @@ -18,14 +18,15 @@ --> - Default JDBC Database - Default Unmanaged JDBC Database + My DataSource + My Unmanaged DataSource META-INF/custom-orm.xml openejb.org.apache.openejb.arquillian.tests.cmp.sample.Movie openejb.org.apache.openejb.arquillian.tests.cmp.sample.Actor + diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml index cd3c5912fcd..68cbacb1c7c 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml @@ -43,5 +43,6 @@ db/DataSource javax.sql.DataSource + My DataSource \ No newline at end of file From 29c8208d82c2d6312a1c7dc2228dec8420daae71 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 5 Dec 2018 21:56:49 +0000 Subject: [PATCH 16/16] TOMEE-2295 fixing test --- .../openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java index e8141b6c918..d48d27eb7ef 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java @@ -70,7 +70,7 @@ public void checkCmpJpaEntityORMMappings() throws Exception { Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: GENRE, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 255")); Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: MOVIE_NAME, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 250")); - final String[] split = output.split("\r\n"); + final String[] split = output.split("\r?\n"); Assert.assertEquals(7, split.length); } }