openejb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1167393 - /openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/
Date Fri, 09 Sep 2011 23:18:07 GMT
Author: dblevins
Date: Fri Sep  9 23:18:07 2011
New Revision: 1167393

URL: http://svn.apache.org/viewvc?rev=1167393&view=rev
Log:
Some more tweaks.
Split some tests into a new ServletResourceEnvEntryTests

Added:
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletResourceEnvEntryInjectionTest.java
      - copied, changed from r1165129, openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java
Modified:
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEjbRemoteTest.java
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEnvEntryInjectionTest.java
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java

Modified: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEjbRemoteTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEjbRemoteTest.java?rev=1167393&r1=1167392&r2=1167393&view=diff
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEjbRemoteTest.java
(original)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEjbRemoteTest.java
Fri Sep  9 23:18:07 2011
@@ -65,19 +65,13 @@ public class ServletEjbRemoteTest {
                 .addClass(RemoteServlet.class)
                 .addClass(CompanyRemote.class)
                 .addClass(DefaultCompany.class)
-                .setWebXML(new StringAsset(descriptor.exportAsString()))
-                .addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+                .setWebXML(new StringAsset(descriptor.exportAsString()));
 
         System.err.println(descriptor.exportAsString());
 
         return archive;
     }
 
-    public static enum Code {
-        OK,
-        ERROR;
-    }
-
     public static class RemoteServlet extends HttpServlet {
 
         @EJB

Modified: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEnvEntryInjectionTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEnvEntryInjectionTest.java?rev=1167393&r1=1167392&r2=1167393&view=diff
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEnvEntryInjectionTest.java
(original)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletEnvEntryInjectionTest.java
Fri Sep  9 23:18:07 2011
@@ -54,23 +54,6 @@ public class ServletEnvEntryInjectionTes
 
     public static final String TEST_NAME = ServletEnvEntryInjectionTest.class.getSimpleName();
 
-    @Test
-    public void localEjbInjectionShouldSucceed() throws Exception {
-        final String expectedOutput = "Local: OpenEJB is employed at TomEE Software Inc.";
-        validateTest(expectedOutput);
-    }
-
-    @Test
-    public void localBeanEjbInjectionShouldSucceed() throws Exception {
-        final String expectedOutput = "OpenEJB shops at Apache Marketplace";
-        validateTest(expectedOutput);
-    }
-
-//    @Test
-    public void pojoInjectionShouldSucceed() throws Exception {
-        final String expectedOutput = "OpenEJB is on the wheel of a 2011 Lexus IS 350";
-        validateTest(expectedOutput);
-    }
 
     @Test
     public void stringEnvEntryInjectionShouldSucceed() throws Exception {

Modified: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java?rev=1167393&r1=1167392&r2=1167393&view=diff
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java
(original)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java
Fri Sep  9 23:18:07 2011
@@ -77,8 +77,7 @@ public class ServletPersistenceInjection
                 .addClass(PersistenceServlet.class)
                 .addClass(Address.class)
                 .addAsManifestResource("persistence.xml", ArchivePaths.create("persistence.xml"))
-                .setWebXML(new StringAsset(descriptor.exportAsString()))
-                .addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+                .setWebXML(new StringAsset(descriptor.exportAsString()));
 
         System.err.println(descriptor.exportAsString());
 

Copied: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletResourceEnvEntryInjectionTest.java
(from r1165129, openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletResourceEnvEntryInjectionTest.java?p2=openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletResourceEnvEntryInjectionTest.java&p1=openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java&r1=1165129&r2=1167393&rev=1167393&view=diff
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletPersistenceInjectionTest.java
(original)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletResourceEnvEntryInjectionTest.java
Fri Sep  9 23:18:07 2011
@@ -19,9 +19,7 @@ package org.apache.openejb.arquillian;
 import org.apache.commons.lang.StringUtils;
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ArchivePaths;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
 import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.jboss.shrinkwrap.descriptor.api.Descriptors;
@@ -30,12 +28,16 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import javax.annotation.Resource;
-import javax.persistence.*;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
 import javax.transaction.UserTransaction;
+import javax.validation.Valid;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -45,9 +47,9 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertTrue;
 
 @RunWith(Arquillian.class)
-public class ServletPersistenceInjectionTest {
+public class ServletResourceEnvEntryInjectionTest {
 
-    public static final String TEST_NAME = ServletPersistenceInjectionTest.class.getSimpleName();
+    public static final String TEST_NAME = ServletResourceEnvEntryInjectionTest.class.getSimpleName();
 
     @Test
     public void transactionInjectionShouldSucceed() throws Exception {
@@ -55,46 +57,37 @@ public class ServletPersistenceInjection
         validateTest(expectedOutput);
     }
 
-    @Test
-    public void persistentContextInjectionShouldSucceed() throws Exception {
-        final String expectedOutput = "Transaction manager injection successful";
-        validateTest(expectedOutput);
-    }
-
-    @Test
-    public void persistenceUnitInjectionShouldSucceed() throws Exception {
-        final String expectedOutput = "Transaction manager factory injection successful";
-        validateTest(expectedOutput);
-    }
-
     @Deployment(testable = false)
     public static WebArchive createDeployment() {
         WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
                 .version("3.0")
-                .servlet(PersistenceServlet.class, "/" + TEST_NAME);
+                .servlet(TestServlet.class, "/" + TEST_NAME);
 
         WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
-                .addClass(PersistenceServlet.class)
-                .addClass(Address.class)
-                .addAsManifestResource("persistence.xml", ArchivePaths.create("persistence.xml"))
-                .setWebXML(new StringAsset(descriptor.exportAsString()))
-                .addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+                .addClass(TestServlet.class)
+                .setWebXML(new StringAsset(descriptor.exportAsString()));
 
         System.err.println(descriptor.exportAsString());
 
         return archive;
     }
 
-    public static class PersistenceServlet extends HttpServlet {
+    public static class TestServlet extends HttpServlet {
 
         @Resource
         private UserTransaction transaction;
 
-        @PersistenceUnit
-        private EntityManagerFactory entityMgrFactory;
+        @Resource
+        private TransactionSynchronizationRegistry transactionSynchronizationRegistry;
+
+        @Resource
+        private Validator validator;
+
+        @Resource
+        private ValidatorFactory validatorFactory;
 
-        @PersistenceContext
-        private EntityManager entityManager;
+        @Resource
+        private TransactionManager transactionManager;
 
         @Override
         protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
@@ -112,69 +105,9 @@ public class ServletPersistenceInjection
                     ex.printStackTrace();
                 }
             }
-            if (entityManager != null) {
-                Address a = new Address();
-                try {
-                    entityManager.contains(a);
-                    resp.getOutputStream().println("Transaction manager injection successful");
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            }
-            if (entityMgrFactory != null) {
-                Address a = new Address();
-                try {
-                    EntityManager em = entityMgrFactory.createEntityManager();
-                    em.contains(a);
-                    resp.getOutputStream().println("Transaction manager factory injection
successful");
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            }
-        }
-
-
-    }
-
-    @Entity
-    public static class Address {
-        public String getStreet() {
-            return street;
-        }
-
-        public void setStreet(String street) {
-            this.street = street;
-        }
-
-        public String getCity() {
-            return city;
         }
 
-        public void setCity(String city) {
-            this.city = city;
-        }
-
-        public String getState() {
-            return state;
-        }
 
-        public void setState(String state) {
-            this.state = state;
-        }
-
-        public String getZip() {
-            return zip;
-        }
-
-        public void setZip(String zip) {
-            this.zip = zip;
-        }
-
-        private String street = "123 Lakeview St.", city = "Paradise", state = "ZZ", zip
= "00000";
-
-        public String toString() {
-            return "Street: " + street + ", City: " + city + ", State: " + state + ", Zip:
" + zip;
-        }
     }
 
     private void validateTest(String expectedOutput) throws IOException {



Mime
View raw message