You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2011/09/05 01:08:17 UTC

svn commit: r1165131 - in /openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test: java/org/apache/openejb/arquillian/ resources/

Author: dblevins
Date: Sun Sep  4 23:08:17 2011
New Revision: 1165131

URL: http://svn.apache.org/viewvc?rev=1165131&view=rev
Log:
Patch from Rangarajan Sreenivasan, OPENEJB-1651: Arquillian: Servlet Filter Tests
Thanks, Ranga!

Added:
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPersistenceInjectionTest.java
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPojoInjectionTest.java
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterRemoteEjbTest.java
Modified:
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/resources/persistence.xml

Added: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPersistenceInjectionTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPersistenceInjectionTest.java?rev=1165131&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPersistenceInjectionTest.java (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPersistenceInjectionTest.java Sun Sep  4 23:08:17 2011
@@ -0,0 +1,207 @@
+/**
+ * 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;
+
+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;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.persistence.*;
+import javax.servlet.*;
+import javax.transaction.UserTransaction;
+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 ServletFilterPersistenceInjectionTest {
+
+    public static final String TEST_NAME = ServletFilterPersistenceInjectionTest.class.getSimpleName();
+
+    @Test
+    public void transactionInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Transaction injection successful";
+        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")
+                .filter(PersistenceServletFilter.class, "/" + TEST_NAME);
+
+        WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
+                .addClass(PersistenceServletFilter.class)
+                .addClass(Address.class)
+                .addAsManifestResource("persistence.xml", ArchivePaths.create("persistence.xml"))
+                .setWebXML(new StringAsset(descriptor.exportAsString()))
+                .addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+
+        System.err.println(descriptor.exportAsString());
+
+        return archive;
+    }
+
+    public static class PersistenceServletFilter implements Filter {
+
+        @Resource
+        private UserTransaction transaction;
+
+        @PersistenceUnit
+        private EntityManagerFactory entityMgrFactory;
+
+        @PersistenceContext
+        private EntityManager entityManager;
+
+        private FilterConfig config;
+
+        public void init(FilterConfig config) {
+            this.config = config;
+        }
+
+        public void destroy() {
+        }
+
+        @Override
+        public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
+            String name = req.getParameter("name");
+            if (StringUtils.isEmpty(name)) {
+                name = "OpenEJB";
+            }
+
+            if (transaction != null) {
+                try {
+                    transaction.begin();
+                    transaction.commit();
+                    resp.getOutputStream().println("Transaction injection successful");
+                } catch (Exception ex) {
+                    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 {
+        final InputStream is = new URL("http://localhost:9080/" + TEST_NAME + "/" + TEST_NAME).openStream();
+        final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+        int bytesRead = -1;
+        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/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPojoInjectionTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPojoInjectionTest.java?rev=1165131&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPojoInjectionTest.java (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterPojoInjectionTest.java Sun Sep  4 23:08:17 2011
@@ -0,0 +1,345 @@
+/**
+ * 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;
+
+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;
+import org.jboss.shrinkwrap.descriptor.api.Node;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.jboss.shrinkwrap.descriptor.spi.NodeProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+import javax.servlet.*;
+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 ServletFilterPojoInjectionTest {
+
+    public static final String TEST_NAME = ServletFilterPojoInjectionTest.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 {
+        final String expectedOutput = "tomee@apache.org";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void integerTypeEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Connection Pool: 20";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void longTypeEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Start Count: 200000";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void shortTypeEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Init Size: 5";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void byteTypeEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Total Quantity: 5";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void booleanTypeEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Enable Email: true";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void charTypeEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Option Default: X";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void classEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "java.lang.String";
+        validateTest(expectedOutput);
+    }
+
+    @Test
+    public void enumEnvEntryInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "DefaultCode: OK";
+        validateTest(expectedOutput);
+    }
+
+    @Deployment(testable = false)
+    public static WebArchive createDeployment() {
+        WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
+                .version("3.0")
+                .filter(PojoServletFilter.class, "/" + TEST_NAME);
+
+        addEnvEntry(descriptor, "returnEmail", "java.lang.String", "tomee@apache.org");
+        addEnvEntry(descriptor, "connectionPool", "java.lang.Integer", "20");
+        addEnvEntry(descriptor, "startCount", "java.lang.Long", "200000");
+        addEnvEntry(descriptor, "initSize", "java.lang.Short", "5");
+        addEnvEntry(descriptor, "enableEmail", "java.lang.Boolean", "true");
+        addEnvEntry(descriptor, "totalQuantity", "java.lang.Byte", "5");
+        addEnvEntry(descriptor, "optionDefault", "java.lang.Character", "X");
+        addEnvEntry(descriptor, "auditWriter", "java.lang.Class", "java.lang.String");
+        addEnvEntry(descriptor, "defaultCode", "java.lang.Enum", "org.apache.openejb.arquillian.ServletFilterPojoInjectionTest$Code.OK");
+
+        WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
+                .addClass(PojoServletFilter.class)
+                .addClass(Car.class)
+                .addClass(CompanyLocal.class)
+                .addClass(Company.class)
+                .addClass(DefaultCompany.class)
+                .addClass(SuperMarket.class)
+                .setWebXML(new StringAsset(descriptor.exportAsString()))
+                .addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+
+        System.err.println(descriptor.exportAsString());
+
+        return archive;
+    }
+
+    public static enum Code {
+        OK,
+        ERROR;
+    }
+
+    public static class PojoServletFilter implements Filter {
+
+        @Inject
+        private Car car;
+
+        @EJB
+        private CompanyLocal localCompany;
+
+        @EJB
+        private SuperMarket market;
+
+        @Resource(name = "returnEmail")
+        private String returnEmail;
+
+        @Resource(name = "connectionPool")
+        private Integer connectionPool;
+
+        @Resource(name = "startCount")
+        private Long startCount;
+
+        @Resource(name = "initSize")
+        private Short initSize;
+
+        @Resource(name = "totalQuantity")
+        private Byte totalQuantity;
+
+        @Resource(name = "enableEmail")
+        private Boolean enableEmail;
+
+        @Resource(name = "optionDefault")
+        private Character optionDefault;
+
+        /* TODO: Enable this resource after functionality is fixed
+        @Resource
+        */
+        private Code defaultCode;
+
+        /* TODO: Enable this resource after functionality is fixed
+                @Resource
+                @SuppressWarnings("unchecked")
+        */
+        private Class auditWriter;
+
+
+        private FilterConfig config;
+
+        public void init(FilterConfig config) {
+            this.config = config;
+        }
+
+        public void destroy() {
+        }
+
+        @Override
+        public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
+            String name = req.getParameter("name");
+            if (StringUtils.isEmpty(name)) {
+                name = "OpenEJB";
+            }
+
+            if (car != null) {
+                resp.getOutputStream().println(car.drive(name));
+            }
+            if (localCompany != null) {
+                resp.getOutputStream().println("Local: " + localCompany.employ(name));
+            }
+            if (market != null) {
+                resp.getOutputStream().println(market.shop(name));
+            }
+            if (connectionPool != null) {
+                resp.getOutputStream().println("Connection Pool: " + connectionPool);
+            }
+            if (startCount != null) {
+                resp.getOutputStream().println("Start Count: " + startCount);
+            }
+            if (initSize != null) {
+                resp.getOutputStream().println("Init Size: " + initSize);
+            }
+            if (totalQuantity != null) {
+                resp.getOutputStream().println("Total Quantity: " + totalQuantity);
+            }
+            if (enableEmail != null) {
+                resp.getOutputStream().println("Enable Email: " + enableEmail);
+            }
+            if (optionDefault != null) {
+                resp.getOutputStream().println("Option Default: " + optionDefault);
+            }
+            if (StringUtils.isNotEmpty(returnEmail) && returnEmail.equals("tomee@apache.org")) {
+                resp.getOutputStream().println(returnEmail);
+            }
+            if (auditWriter != null) {
+                resp.getOutputStream().println(auditWriter.getClass().getName());
+            }
+            if (defaultCode != null) {
+                resp.getOutputStream().println("DefaultCode: " + defaultCode);
+            }
+        }
+
+
+    }
+
+    public static class Car {
+        private final String make = "Lexus", model = "IS 350";
+        private final int year = 2011;
+
+        public String drive(String name) {
+            return name + " is on the wheel of a " + year + " " + make + " " + model;
+        }
+    }
+
+
+    public static interface Company {
+        public String employ(String employeeName);
+    }
+
+    @Local
+    public static interface CompanyLocal extends Company {
+    }
+
+    @Stateless
+    public static class DefaultCompany implements CompanyLocal {
+
+        private final String name = "TomEE Software Inc.";
+
+        public String employ(String employeeName) {
+            return employeeName + " is employed at " + name;
+        }
+
+    }
+
+    @Stateless
+    @LocalBean
+    public static class SuperMarket {
+
+        private final String name = "Apache Marketplace";
+
+        public String shop(String employeeName) {
+            return employeeName + " shops at " + name;
+        }
+
+    }
+
+    private static void addEnvEntry(WebAppDescriptor descriptor, String name, String type, String value) {
+        Node rootNode = ((NodeProvider) descriptor).getRootNode();
+        Node appNode = rootNode.get("/web-app").iterator().next();
+        appNode.create("/env-entry")
+                .create("env-entry-name").text(name)
+                .parent()
+                .create("env-entry-type").text(type)
+                .parent()
+                .create("env-entry-value").text(value)
+/*
+                .parent()
+                .create("injection-target")
+                .create("injection-target-class").text("org.apache.openejb.arquillian.ServletPojoInjectionTest$PojoServletFilter")
+                .parent()
+                .create("injection-target-name").text(name)
+*/
+        ;
+
+    }
+
+    private void validateTest(String expectedOutput) throws IOException {
+        final InputStream is = new URL("http://localhost:9080/" + TEST_NAME + "/" + TEST_NAME).openStream();
+        final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+        int bytesRead = -1;
+        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/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterRemoteEjbTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterRemoteEjbTest.java?rev=1165131&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterRemoteEjbTest.java (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/ServletFilterRemoteEjbTest.java Sun Sep  4 23:08:17 2011
@@ -0,0 +1,143 @@
+/**
+ * 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;
+
+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;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.servlet.*;
+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 ServletFilterRemoteEjbTest {
+
+    public static final String TEST_NAME = ServletFilterRemoteEjbTest.class.getSimpleName();
+
+    @Test
+    public void ejbInjectionShouldSucceed() throws Exception {
+        final String expectedOutput = "Remote: OpenEJB is employed at TomEE Software Inc.";
+        validateTest(expectedOutput);
+    }
+
+    @Deployment(testable = false)
+    public static WebArchive createDeployment() {
+        WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
+                .version("3.0")
+                .filter(RemoteServletFilter.class, "/" + TEST_NAME);
+
+        WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
+                .addClass(RemoteServletFilter.class)
+                .addClass(CompanyRemote.class)
+                .addClass(DefaultCompany.class)
+                .setWebXML(new StringAsset(descriptor.exportAsString()))
+                .addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+
+        System.err.println(descriptor.exportAsString());
+
+        return archive;
+    }
+
+    public static enum Code {
+        OK,
+        ERROR;
+    }
+
+    public static class RemoteServletFilter implements Filter {
+
+        @EJB
+        private CompanyRemote remoteCompany;
+
+        private FilterConfig config;
+
+        public void init(FilterConfig config) {
+            this.config = config;
+        }
+
+        public void destroy() {
+        }
+
+        @Override
+        public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
+            String name = req.getParameter("name");
+            if (StringUtils.isEmpty(name)) {
+                name = "OpenEJB";
+            }
+
+            if (remoteCompany != null) {
+                resp.getOutputStream().println("Remote: " + remoteCompany.employ(name));
+            }
+        }
+
+    }
+
+    @Remote
+    public static interface CompanyRemote {
+        public String employ(String employeeName);
+    }
+
+    @Stateless
+    public static class DefaultCompany implements CompanyRemote {
+
+        private final String name = "TomEE Software Inc.";
+
+        public String employ(String employeeName) {
+            return employeeName + " is employed at " + name;
+        }
+
+    }
+
+    private void validateTest(String expectedOutput) throws IOException {
+        final InputStream is = new URL("http://localhost:9080/" + TEST_NAME + "/" + TEST_NAME).openStream();
+        final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+        int bytesRead = -1;
+        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));
+    }
+
+}
+
+
+

Modified: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/resources/persistence.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/resources/persistence.xml?rev=1165131&r1=1165130&r2=1165131&view=diff
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/resources/persistence.xml (original)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-embedded/src/test/resources/persistence.xml Sun Sep  4 23:08:17 2011
@@ -4,6 +4,7 @@
              version="2.0">
     <persistence-unit name="test">
         <class>org.apache.openejb.arquillian.ServletPersistenceInjectionTest$Address</class>
+        <class>org.apache.openejb.arquillian.ServletFilterPersistenceInjectionTest$Address</class>
 <!--
         <properties>
             <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>