You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/01/29 17:52:34 UTC
svn commit: r1237343 - in /openejb/trunk/openejb:
arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/
arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/...
Author: rmannibucau
Date: Sun Jan 29 16:52:33 2012
New Revision: 1237343
URL: http://svn.apache.org/viewvc?rev=1237343&view=rev
Log:
adding 2 tests to check webmodule init (dd was ignored)
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/JAXWSDDTest.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePUServlet.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePersistenceTest.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person1.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person2.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/dd/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/dd/ejb-jar.xml
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/multiple/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/JAXWSDDTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/JAXWSDDTest.java?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/JAXWSDDTest.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/dd/JAXWSDDTest.java Sun Jan 29 16:52:33 2012
@@ -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.jaxws.dd;
+
+import org.apache.openejb.arquillian.tests.jaxws.Hello;
+import org.apache.openejb.arquillian.tests.jaxws.HelloWS;
+import org.apache.ziplock.IO;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class JAXWSDDTest {
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ final WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
+ .version("3.0");
+
+ final WebArchive archive = ShrinkWrap.create(WebArchive.class, JAXWSDDTest.class.getSimpleName() + ".war")
+ .setWebXML(new StringAsset(descriptor.exportAsString()))
+ .addAsLibraries(JarLocation.jarLocation(Test.class))
+ .addClass(Hello.class).addClass(HelloWS.class)
+ .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/jaxws/dd/ejb-jar.xml"), "META-INF/ejb-jar.xml");
+
+ return archive;
+ }
+
+ @Test
+ public void invokeStdDeployment() throws Exception {
+ checkWSDLExists("HelloWS");
+ }
+
+ @Test
+ public void invokeDDDeployment() throws Exception {
+ checkWSDLExists("HelloWSDD");
+ }
+
+ private void checkWSDLExists(final String name) throws Exception {
+ final URL url = new URL("http://localhost:" + System.getProperty("tomee.http.port", "11080") + "/JAXWSDDTest/webservices/" + name + "?wsdl");
+ assertTrue(IO.slurp(url).contains(name));
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePUServlet.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePUServlet.java?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePUServlet.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePUServlet.java Sun Jan 29 16:52:33 2012
@@ -0,0 +1,63 @@
+/**
+ * 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.persistence.multiple;
+
+import org.apache.openejb.arquillian.tests.Runner;
+
+import javax.annotation.Resource;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+import java.io.IOException;
+
+import static org.junit.Assert.assertNotNull;
+
+public class MultiplePUServlet extends HttpServlet {
+ @Resource
+ private UserTransaction transaction;
+
+ @PersistenceContext(name = "pu1")
+ private EntityManager entityManager1;
+
+ @PersistenceContext(name = "pu2")
+ private EntityManager entityManager2;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ Runner.run(req, resp, this);
+ }
+
+ public void testEntityManager1() throws Exception {
+ testEm(entityManager1, new Person1("p1"));
+ }
+
+ public void testEntityManager2() throws Exception {
+ testEm(entityManager2, new Person2("p2"));
+ }
+
+ private void testEm(final EntityManager em, final Object person) throws Exception {
+ assertNotNull(em);
+ transaction.begin();
+ em.persist(person);
+ transaction.commit();
+ }
+}
\ No newline at end of file
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePersistenceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePersistenceTest.java?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePersistenceTest.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/MultiplePersistenceTest.java Sun Jan 29 16:52:33 2012
@@ -0,0 +1,94 @@
+/**
+ * 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.persistence.multiple;
+
+import org.apache.openejb.arquillian.tests.Runner;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class MultiplePersistenceTest {
+
+ public static final String TEST_NAME = MultiplePersistenceTest.class.getSimpleName();
+
+ @Test
+ public void testEntityManager2() throws Exception {
+ validateTest("testEntityManager2=true");
+ }
+
+ @Test
+ public void testEntityManager1() throws Exception {
+ validateTest("testEntityManager1=true");
+ }
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
+ .version("3.0")
+ .servlet(MultiplePUServlet.class, "/" + TEST_NAME);
+
+ WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
+ .addClass(MultiplePUServlet.class)
+ .addClass(Person1.class).addClass(Person2.class)
+ .addClass(Runner.class)
+ .addAsLibraries(JarLocation.jarLocation(Test.class))
+ .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml"), "META-INF/persistence.xml")
+ .setWebXML(new StringAsset(descriptor.exportAsString()));
+
+ return archive;
+ }
+
+
+ private void validateTest(String expectedOutput) throws IOException {
+ final InputStream is = new URL("http://localhost:" + System.getProperty("tomee.http.port", "11080") + "/" + TEST_NAME + "/" + TEST_NAME).openStream();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ int bytesRead;
+ byte[] buffer = new byte[8192];
+ while ((bytesRead = is.read(buffer)) > -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+
+ is.close();
+ os.close();
+
+ String output = new String(os.toByteArray(), "UTF-8");
+ assertNotNull("Response shouldn't be null", output);
+ assertTrue("Output should contain: " + expectedOutput, output.contains(expectedOutput));
+ }
+
+}
+
+
+
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person1.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person1.java?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person1.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person1.java Sun Jan 29 16:52:33 2012
@@ -0,0 +1,37 @@
+package org.apache.openejb.arquillian.tests.persistence.multiple;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Person1 {
+ @Id @GeneratedValue
+ private long id;
+
+ private String name;
+
+ public Person1(String name) {
+ this.name = name;
+ }
+
+ public Person1() {
+ // no-op
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person2.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person2.java?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person2.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/persistence/multiple/Person2.java Sun Jan 29 16:52:33 2012
@@ -0,0 +1,37 @@
+package org.apache.openejb.arquillian.tests.persistence.multiple;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Person2 {
+ @Id @GeneratedValue
+ private long id;
+
+ private String name;
+
+ public Person2(String name) {
+ this.name = name;
+ }
+
+ public Person2() {
+ // no-op
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/dd/ejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/dd/ejb-jar.xml?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/dd/ejb-jar.xml (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jaxws/dd/ejb-jar.xml Sun Jan 29 16:52:33 2012
@@ -0,0 +1,12 @@
+<ejb-jar version="3.1" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
+ <enterprise-beans>
+ <session>
+ <ejb-name>HelloWSDD</ejb-name>
+ <service-endpoint>org.apache.openejb.arquillian.tests.jaxws.Hello</service-endpoint>
+ <ejb-class>org.apache.openejb.arquillian.tests.jaxws.HelloWS</ejb-class>
+ <session-type>Stateless</session-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml?rev=1237343&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml Sun Jan 29 16:52:33 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="pu1">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.apache.openejb.arquillian.tests.persistence.multiple.Person1</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ <persistence-unit name="pu2">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.apache.openejb.arquillian.tests.persistence.multiple.Person2</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1237343&r1=1237342&r2=1237343&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java Sun Jan 29 16:52:33 2012
@@ -646,7 +646,12 @@ public class DeploymentLoader implements
//
// EjbModule webEjbModule = new EjbModule(webModule.getClassLoader(), webModule.getModuleId(), webModule.getJarLocation(), null, null);
EjbModule webEjbModule = null;
- StringBuilder webInfClassesPath = new StringBuilder(warPath);
+ StringBuilder webInfClassesPath;
+ if (!warPath.toLowerCase().endsWith(".war")) {
+ webInfClassesPath = new StringBuilder(warPath);
+ } else {
+ webInfClassesPath = new StringBuilder(warPath.substring(0, warPath.length() - 4));
+ }
if (!warPath.endsWith("/")) {
webInfClassesPath.append("/");
}