[seam-commits] Seam SVN: r15529 - in branches/enterprise/WFK-2_1/examples/restbay: restbay-ear and 18 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Jun 3 13:00:29 EDT 2013


Author: maschmid
Date: 2013-06-03 13:00:28 -0400 (Mon, 03 Jun 2013)
New Revision: 15529

Added:
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/AuctionServiceTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/BasicServiceTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ContextDataTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/Deployments.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceHomeTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SecurityTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SubresourceTest.java
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/arquillian.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/components.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/jboss-deployment-structure.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/example/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/example/restbay/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/example/restbay/test/
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/example/restbay/test/dbunitdata.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/pages.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/persistence.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/web.xml
Removed:
   branches/enterprise/WFK-2_1/examples/restbay/restbay-tests/
Modified:
   branches/enterprise/WFK-2_1/examples/restbay/pom.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ear/pom.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/pom.xml
   branches/enterprise/WFK-2_1/examples/restbay/restbay-web/pom.xml
Log:
migrated restbay


Modified: branches/enterprise/WFK-2_1/examples/restbay/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/pom.xml	2013-06-03 16:49:04 UTC (rev 15528)
+++ branches/enterprise/WFK-2_1/examples/restbay/pom.xml	2013-06-03 17:00:28 UTC (rev 15529)
@@ -3,27 +3,49 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.jboss.seam.examples</groupId>
     <artifactId>restbay</artifactId>
-    <parent>
-        <groupId>org.jboss.seam</groupId>
-        <artifactId>examples</artifactId>
-        <version>2.3.1.Final-redhat-2</version>
-    </parent>
+    <version>2.3.1.Final-redhat-2</version>
+    
     <packaging>pom</packaging>
     <name>Restbay Example (EE6)</name>
     
     <properties>
         <example.name>restbay</example.name>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.target>1.6</maven.compiler.target>
+        <maven.compiler.source>1.6</maven.compiler.source>
+
+        <!-- To use jacoco, set jacoco.agent system property to something like
+                     -javaagent:/path/to/jacocoagent.jar=append=true,destfile=/path/to/output/jacoco.exec -->
+        <jacoco.agent />
+
+        <!-- To use custom Maven settings with ShrinkWrap Resolver, uncomment 
+                          and customize the following property.  -->
+        <!--<maven.user.settings>/path/to/custom/settings.xml</maven.user.settings>-->
+
+        <version.commons.logging>1.1.1</version.commons.logging>
+        <version.shrinkwrap.resolver>2.0.0-beta-4</version.shrinkwrap.resolver>
+
+        <!-- Plugin versions -->
+        <version.dependency.plugin>2.5.1</version.dependency.plugin>
+        <version.surefire.plugin>2.10</version.surefire.plugin>
+        <version.resources.plugin>2.6</version.resources.plugin>
+        <version.compiler.plugin>2.3.1</version.compiler.plugin>
+        <version.ear.plugin>2.6</version.ear.plugin>
+        <version.war.plugin>2.1.1</version.war.plugin>
+        <version.ejb.plugin>2.3</version.ejb.plugin>
+        <version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin>
     </properties>
     
     <modules>
         <module>restbay-ear</module>
         <module>restbay-ejb</module>
         <module>restbay-web</module>
-        <module>restbay-tests</module>
+        
     </modules>
     
     <dependencyManagement>
         <dependencies>
+            <!-- Modules -->
             <dependency>
                 <groupId>org.jboss.seam.examples.restbay</groupId>
                 <artifactId>restbay-ejb</artifactId>
@@ -41,6 +63,82 @@
                 <artifactId>restbay-ear</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <!-- BOMs -->
+            <dependency>
+                <groupId>org.jboss.shrinkwrap.resolver</groupId>
+                <artifactId>shrinkwrap-resolver-bom</artifactId>
+                <version>${version.shrinkwrap.resolver}</version>
+                <scope>import</scope>
+                <type>pom</type>
+            </dependency>
+
+            <dependency>
+                <groupId>org.jboss.seam</groupId>
+                <artifactId>bom</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+            <!-- Common provided dependencies -->
+            <dependency>
+                <groupId>commons-logging</groupId>
+                <artifactId>commons-logging</artifactId>
+                <version>${version.commons.logging}</version>
+                <scope>provided</scope>
+            </dependency>
+
+            <!-- TestNG is not necessary -->
+            <dependency>
+                <groupId>org.jboss.seam</groupId>
+                <artifactId>jboss-seam</artifactId>
+                <version>${project.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.testng</groupId>
+                        <artifactId>testng</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>junit</groupId>
+                        <artifactId>junit</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <!-- Manage plugin versions for build stability -->
+                <plugin>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>${version.surefire.plugin}</version>
+                    <configuration>
+                        <systemPropertyVariables>
+                            <org.apache.maven.user-settings>${maven.user.settings}</org.apache.maven.user-settings>
+                        </systemPropertyVariables>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-dependency-plugin</artifactId>
+                    <version>${version.dependency.plugin}</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-resources-plugin</artifactId>
+                    <version>${version.resources.plugin}</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>${version.compiler.plugin}</version>
+                    <configuration>
+                        <source>${maven.compiler.source}</source>
+                        <target>${maven.compiler.target}</target>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
 </project>

Modified: branches/enterprise/WFK-2_1/examples/restbay/restbay-ear/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ear/pom.xml	2013-06-03 16:49:04 UTC (rev 15528)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ear/pom.xml	2013-06-03 17:00:28 UTC (rev 15529)
@@ -49,10 +49,20 @@
 
     <build>
         <finalName>seam-restbay</finalName>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.jboss.as.plugins</groupId>
+                    <artifactId>jboss-as-maven-plugin</artifactId>
+                    <version>${version.jboss.maven.plugin}</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-ear-plugin</artifactId>
+                <version>${version.ear.plugin}</version>
                 <configuration>
                     <version>6</version>
                     <defaultLibBundleDir>lib</defaultLibBundleDir>

Modified: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/pom.xml	2013-06-03 16:49:04 UTC (rev 15528)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/pom.xml	2013-06-03 17:00:28 UTC (rev 15529)
@@ -83,6 +83,125 @@
             <groupId>org.opensymphony.quartz</groupId>
             <artifactId>quartz</artifactId>
         </dependency>
+
+        <!-- Test dependencies -->
+        <dependency>
+            <groupId>org.jboss.shrinkwrap.resolver</groupId>
+            <artifactId>shrinkwrap-resolver-depchain</artifactId>
+            <type>pom</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.dbunit</groupId>
+            <artifactId>dbunit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss.arquillian.junit</groupId>
+            <artifactId>arquillian-junit-container</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss.arquillian.protocol</groupId>
+            <artifactId>arquillian-protocol-servlet</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
-   
+
+    <profiles>
+        <profile>
+            <id>integration-tests</id>
+            <activation>
+                <property>
+                    <name>arquillian</name>
+                </property>
+            </activation>
+            <properties>
+                <jndiPattern>java:app/seam-restbay/#{ejbName}</jndiPattern>
+                <distributable>false</distributable>
+            </properties>
+            <build>
+                <testResources>
+                    <testResource>
+                        <directory>src/test/resources</directory>
+                        <filtering>true</filtering>
+                    </testResource>
+                </testResources>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>arq-jbossas-7-managed</id>
+            <activation>
+                <property>
+                    <name>arquillian</name>
+                    <value>jbossas-managed-7</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.jboss.as</groupId>
+                    <artifactId>jboss-as-arquillian-container-managed</artifactId>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <profile>
+            <id>arq-jbossas-7-remote</id>
+            <activation>
+                <property>
+                    <name>arquillian</name>
+                    <value>jbossas-remote-7</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.jboss.as</groupId>
+                    <artifactId>jboss-as-arquillian-container-remote</artifactId>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+  
+    <build>
+        <plugins>
+
+            <plugin>
+                <artifactId>maven-ejb-plugin</artifactId>
+                <version>${version.ejb.plugin}</version>
+                <configuration>
+                    <ejbVersion>3.1</ejbVersion>
+                </configuration>
+            </plugin>
+            <!-- Skip tests by default, since they require a container -->
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+ 
 </project>

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/AuctionServiceTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/AuctionServiceTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/AuctionServiceTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,122 @@
+package org.jboss.seam.example.restbay.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+ at RunWith(Arquillian.class)
+public class AuctionServiceTest extends JUnitSeamTest
+{
+   @Deployment(name="AuctionServiceTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+
+   ResourceRequestEnvironment requestEnv;
+
+   @Before
+   public void prepareEnv() throws Exception
+   {
+      requestEnv = new ResourceRequestEnvironment(this)
+      {
+         @Override
+         public Map<String, Object> getDefaultHeaders()
+         {
+            return new HashMap<String, Object>()
+            {{
+                  put("Accept", "text/plain");
+               }};
+         }
+      };
+   }
+
+   @Test
+   public void testCategories() throws Exception
+   {
+
+      // Just verify we can do that, even if it doesn't make much sense
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/restv1/category").run();
+      
+      reset();
+
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/category")
+      {
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assert response.getStatus() == 200;
+            String[] lines = response.getContentAsString().split("\n");
+            assert lines[0].equals("1,Antiques");
+            assert lines[1].equals("2,Art");
+            assert lines[2].equals("3,Books");
+         }
+
+      }.run();
+      
+      reset();
+
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/category/1")
+      {
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assert response.getStatus() == 200;
+            assert response.getContentAsString().equals("Antiques");
+         }
+
+      }.run();
+
+   }
+
+   @Test
+   public void testAuctions() throws Exception
+   {
+
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/auction")
+      {
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assert response.getStatus() == 200;
+            // TODO: Assert content
+         }
+
+      }.run();
+      
+      reset();
+
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/auction/19264723")
+      {
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assert response.getStatus() == 200;
+            assert response.getContentAsString().equals("Whistler's Mother, original painting by James McNeill Whistler");
+         }
+
+      }.run();
+
+   }
+
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/BasicServiceTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/BasicServiceTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/BasicServiceTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,480 @@
+package org.jboss.seam.example.restbay.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+
+import javax.servlet.http.Cookie;
+import javax.ws.rs.core.MediaType;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * <p>
+ * This is the test matrix for resources:
+ * </p>
+ *
+ * <pre>
+ *                                    | EVENT | CONVERSATION | SESSION | APPLICATION | STATELESS
+ * ---------------------------------------------------------------------------------------------
+ * Plain JAX-RS Resource              |  OK   |      -       |    -    |      -      |    -
+ * ---------------------------------------------------------------------------------------------
+ * POJO Seam Component Resource       |  OK   |      ?       |    ?    |     OK      |   OK
+ * ---------------------------------------------------------------------------------------------
+ * POJO interface-annotated Component |  OK   |      ?       |    ?    |     OK      |   OK
+ * ---------------------------------------------------------------------------------------------
+ * EJB Plain SLSB Resource            |   -   |      -       |    -    |      -      |   OK
+ * ---------------------------------------------------------------------------------------------
+ * EJB SLSB Seam Component Resource   |   -   |      -       |    -    |      -      |   OK
+ * ---------------------------------------------------------------------------------------------
+ * EJB SFSB Seam Component Resource   |   ?   |      ?       |    ?    |      ?      |    -
+ * ---------------------------------------------------------------------------------------------
+ * </pre>
+ *
+ * <p>
+ * Note that all EJB resources are always @Path annotated on their interface, not the implementation class.
+ * </p>
+ *
+ * <p>
+ * This is the test matrix for providers:
+ * </p>
+ *
+ * <pre>
+ *                                    | EVENT | CONVERSATION | SESSION | APPLICATION | STATELESS
+ * ---------------------------------------------------------------------------------------------
+ * Plain JAX-RS Provider              |   -   |      -       |    -    |      -      |   OK
+ * ---------------------------------------------------------------------------------------------
+ * RESTEasy StringConverter Provider  |   -   |      -       |    -    |      -      |   OK
+ * ---------------------------------------------------------------------------------------------
+ * RESTEasy StringConverter Component |   ?   |      -       |    -    |      ?      |    ?
+ * ---------------------------------------------------------------------------------------------
+ * POJO Seam Component Provider       |   ?   |      -       |    -    |     OK      |    ?
+ * ---------------------------------------------------------------------------------------------
+ * POJO interface-annotated Component |   ?   |      -       |    -    |     OK      |    ?
+ * ---------------------------------------------------------------------------------------------
+ * EJB Plain SLSB Provider            |   -   |      -       |    -    |      -      |    ?
+ * ---------------------------------------------------------------------------------------------
+ * EJB SLSB Seam Component Provider   |   -   |      -       |    -    |      -      |    ?
+ * ---------------------------------------------------------------------------------------------
+ * EJB SFSB Seam Component Resource   |   ?   |      -       |    -    |      ?      |    -
+ * ---------------------------------------------------------------------------------------------
+ * </pre>
+ *
+ */
+ at RunWith(Arquillian.class)
+public class BasicServiceTest extends JUnitSeamTest
+{
+   @Deployment(name="BasicServiceTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+
+   ResourceRequestEnvironment requestEnv;
+
+   @Before
+   public void prepareEnv() throws Exception
+   {
+      requestEnv = new ResourceRequestEnvironment(this)
+      {
+         @Override
+         public Map<String, Object> getDefaultHeaders()
+         {
+            return new HashMap<String, Object>()
+                  {{
+                     put("Accept", "text/plain");
+                  }};
+         }
+
+         @Override
+         public String getServletPath()
+         {
+            return "/override/seam/resource/is/not/my/path/for/SeamResourceServlet";
+         }
+
+      };
+   }
+
+   public String[] getQueryPaths()
+   {
+      return new String[] {
+            "/restv1/plainTest",
+
+            "/restv1/eventComponentTest",
+            "/restv1/applicationComponentTest",
+            "/restv1/statelessComponentTest",
+
+            "/restv1/interfaceEventComponentTest",
+            "/restv1/interfaceApplicationComponentTest",
+            "/restv1/interfaceStatelessComponentTest",
+
+            "/restv1/statelessEjbTest",
+            "/restv1/statelessEjbComponentTest"
+      };
+   }
+
+   @Test
+   public void testRootResource() throws Exception {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/")
+      {
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals(200, response.getStatus());
+            assertEquals("Root", response.getContentAsString());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void testExeptionMapping() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/trigger/unsupported")
+         {
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 501;
+               assert response.getStatusMessage().equals("The request operation is not supported: foo");
+            }
+
+         }.run();
+      }
+   }
+
+   @Test
+   public void testEchos() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echouri")
+         {
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().endsWith("/echouri");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoquery")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.setQueryString("asdf=123");
+               request.addQueryParameter("bar", "bbb");
+               request.addQueryParameter("baz", "bzzz");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("bbb");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoheader")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.addHeader("bar", "baz");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("baz");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echocookie")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.addCookie(new Cookie("bar", "baz"));
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("baz");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/foo/bar/asdf")
+         {
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("bar: asdf");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echotwoparams/foo/bar")
+         {
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("foobar");
+            }
+
+         }.run();
+      }
+
+   }
+
+   @Test
+   public void testEncoding() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoencoded/foo bar")
+         {
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("foo%20bar");
+            }
+
+         }.run();
+      }
+   }
+
+   @Test
+   public void testFormHandling() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         new ResourceRequest(requestEnv, Method.POST, resourcePath + "/echoformparams")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+               request.addParameter("foo", new String[]
+               {"bar", "baz"});
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("barbaz");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.POST, resourcePath + "/echoformparams2")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+               request.addParameter("foo", new String[]
+               {"bar", "baz"});
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("barbaz");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.POST, resourcePath + "/echoformparams3")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+               request.addHeader("bar", "foo");
+               request.addParameter("foo", new String[]
+               {"bar", "baz"});
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("foobarbaz");
+            }
+
+         }.run();
+
+         reset();
+      }
+   }
+
+   @Test()
+   public void testStringConverter() throws Exception
+   {
+      final String ISO_DATE = "2007-07-10T14:54:56-0500";
+      final String ISO_DATE_MILLIS = "1184097296000";
+      
+      for (String resourcePath : getQueryPaths())
+      {
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/convertDate/" + ISO_DATE)
+         {
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assertEquals(ISO_DATE_MILLIS, response.getContentAsString());
+            }
+
+         }.run();
+      }
+   }
+
+   @Test
+   public void testProvider() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/commaSeparated")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.addHeader("Accept", "text/csv");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("foo,bar\r\nasdf,123\r\n");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/commaSeparatedStrings")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.addHeader("Accept", "text/plain");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("abc,foo,bar,baz");
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(requestEnv, Method.GET, resourcePath + "/commaSeparatedIntegers")
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               request.addHeader("Accept", "text/plain");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assert response.getStatus() == 200;
+               assert response.getContentAsString().equals("abc,1,2,3");
+            }
+         };
+         // }.run();
+         // TODO: Retracted support for Seam component providers, injection shouldn't happen, see https://jira.jboss.org/jira/browse/JBSEAM-4247
+      }
+   }
+
+   @Test
+   // JBPAPP-3713
+   public void synchronizationsLookup() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/eventComponentTest/synchronizationsLookup")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus(), 200);
+            assert response.getContentAsString().equals("true");
+         }
+
+      }.run();
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,110 @@
+package org.jboss.seam.example.restbay.test;
+
+import org.dbunit.operation.DatabaseOperation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.DBJUnitSeamTest;
+
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ *
+ */
+ at RunWith(Arquillian.class)
+public class CategoryServiceDBUnitTest extends DBJUnitSeamTest
+{
+   @Deployment(name="CategoryServiceDBUnitTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      WebArchive web = Deployments.restbayDeployment();
+      web.addAsLibraries(Maven.resolver().loadPomFromFile("pom.xml")
+    		  	.resolve("org.dbunit:dbunit:jar:2.2")
+    		  	.withoutTransitivity()
+                .asFile());
+      
+      web.addAsResource("org/jboss/seam/example/restbay/test/dbunitdata.xml", "org/jboss/seam/example/restbay/test/dbunitdata.xml");
+      
+      return web;
+   }
+
+   protected void prepareDBUnitOperations() {
+      
+      setDatabase("hsql");
+      setDatasourceJndiName("java:/jboss/datasources/ExampleDS");
+      
+      beforeTestOperations.add(
+            new DataSetOperation("org/jboss/seam/example/restbay/test/dbunitdata.xml", DatabaseOperation.CLEAN_INSERT)
+      );
+   }
+
+   // Or, if you don't want shared headers between test methods, just use
+   // it directly in your test method:
+
+   // new ResourceRequest(new ResourceRequestTest(this), Method.GET, ...).run();
+
+   ResourceRequestEnvironment sharedEnvironment;
+   @Before
+   public void prepareSharedEnvironment() throws Exception
+   {
+      sharedEnvironment = new ResourceRequestEnvironment(this)
+      {
+         @Override
+         public Map<String, Object> getDefaultHeaders()
+         {
+            return new HashMap<String, Object>()
+            {{
+                  put("Accept", "text/plain");
+               }};
+         }
+      };
+   }
+
+   @Test
+   public void testCategories() throws Exception
+   {
+      // new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/restv1/category")
+      // or:
+      new ResourceRequest(sharedEnvironment, Method.GET, "/restv1/category")
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            // Or set it as default in environment
+            request.addHeader("Accept", "text/plain");
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assert response.getStatus() == 200;
+            String[] lines = response.getContentAsString().split("\n");
+            assert lines[0].equals("16,foo");
+            assert lines[1].equals("17,bar");
+            assert lines[2].equals("18,baz");
+         }
+
+      }.run();
+
+   }
+
+
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ContextDataTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ContextDataTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ContextDataTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,67 @@
+package org.jboss.seam.example.restbay.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ *
+ * @author Jozef Hartinger
+ */
+ at RunWith(Arquillian.class)
+public class ContextDataTest extends JUnitSeamTest
+{
+   @Deployment(name="ContextDataTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+   
+   public String[] getContextDataTypePaths()
+   {
+      return new String[]{ "/providers", "/registry", "/dispatcher" };
+   }
+   
+   @Test
+   public void testContextData() throws Exception
+   {
+
+      for (String pathSegment : getContextDataTypePaths())
+      {
+         String path = "/restv1/contextData" + pathSegment;
+
+         new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               super.prepareRequest(request);
+               request.addHeader("Accept", "text/plain");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assertEquals("Unexpected response code.", 200, response.getStatus());
+               assertEquals("Unexpected response.", "true", response.getContentAsString());
+            }
+
+         }.run();
+      }
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/Deployments.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/Deployments.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/Deployments.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,44 @@
+package org.jboss.seam.example.restbay.test;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.importer.ZipImporter;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+import java.io.File;
+
+public class Deployments {
+   public static WebArchive restbayDeployment() {
+        File[] libs = Maven.resolver().loadPomFromFile("pom.xml")
+                .importCompileAndRuntimeDependencies()
+                // force resolve jboss-seam, because it is provided-scoped in the pom, but we need it bundled in the WAR
+                .resolve("org.jboss.seam:jboss-seam")
+                .withTransitivity().asFile();
+
+        WebArchive war = ShrinkWrap.create(WebArchive.class, "seam-restbay.war")
+                .addPackages(false, "org.jboss.seam.example.restbay")
+                .addPackages(true,  "org.jboss.seam.example.restbay.resteasy")
+
+                // already in EJB module
+                .addAsWebInfResource("import.sql", "classes/import.sql")
+                .addAsWebInfResource("seam.properties", "classes/seam.properties")
+                .addAsWebInfResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
+
+                // test specific persistence.xml
+                .addAsWebInfResource("persistence.xml", "classes/META-INF/persistence.xml")
+
+                // manually copied from Web module
+                .addAsWebInfResource("pages.xml", "pages.xml")
+
+                // manually copied from Web module, modified
+                .addAsWebInfResource("web.xml", "web.xml") // only contains MockSeamListener definition
+                .addAsWebInfResource("components.xml", "components.xml") // corrected ejb component jndi-name references from java:app/jboss-seam to java:app/seam-restbay
+
+                // manually copied from EAR module
+                .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml")
+                .addAsLibraries(libs);
+
+        return war;
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceHomeTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceHomeTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceHomeTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,194 @@
+package org.jboss.seam.example.restbay.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.JUnitSeamTest;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * 
+ * @author Jozef Hartinger
+ * 
+ */
+ at RunWith(Arquillian.class)
+public class ResourceHomeTest extends JUnitSeamTest
+{
+   @Deployment(name="ResourceHomeTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+
+   public String[] getQueryPaths()
+   {
+      return new String[]{ "/configuredCategory", "/extendedCategory" };
+   }
+
+   @Test
+   public void testResourceHomeRead() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         final String expectedResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><category><categoryId>1</categoryId><name>Antiques</name></category>";
+         final String path = "/restv1" + resourcePath + "/1";
+
+         new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               super.prepareRequest(request);
+               request.addHeader("Accept", "application/xml");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assertEquals("Unexpected response.", expectedResponse, response.getContentAsString());
+            }
+
+         }.run();
+      }
+   }
+
+   @Test
+   public void testResourceHomeCreate() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         final String name = "Airplanes";
+         final String body = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><category><name>" + name
+               + "</name></category>";
+         final String mediaType = "application/xml";
+         final String path = "/restv1" + resourcePath;
+
+         new ResourceRequest(new ResourceRequestEnvironment(this), Method.POST, path)
+         {
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               super.prepareRequest(request);
+               // TODO for some reason content type must be set using both these
+               // methods
+               request.addHeader("Content-Type", mediaType);
+               request.setContentType(mediaType);
+               request.setContent(body.getBytes());
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assertEquals("Unexpected response code.", 201, response.getStatus(), 201);
+            }
+
+         }.run();
+      }
+   }
+
+   @Test
+   public void testResourceHomeUpdate() throws Exception
+   {
+      for (String resourcePath : getQueryPaths())
+      {
+         final String body = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><category><categoryId>5</categoryId><name>"
+               + resourcePath.hashCode() + "</name></category>";
+         final String mediaType = "application/xml";
+         final String path = "/restv1" + resourcePath + "/5";
+
+         new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, path)
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               super.prepareRequest(request);
+               request.setContentType(mediaType);
+               request.addHeader("Content-Type", mediaType);
+               request.setContent(body.getBytes());
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assertEquals("Unexpected response code.", 204, response.getStatus());
+            }
+
+         }.run();
+
+         reset();
+
+         new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               super.prepareRequest(request);
+               request.addHeader("Accept", mediaType);
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               assertEquals("Unexpected response code.", 200, response.getStatus());
+               assertEquals("Unexpected response.", body, response.getContentAsString());
+            }
+
+         }.run();
+      }
+   }
+
+   @Test
+   public void testResourceHomeDelete() throws Exception
+   {
+
+      final String path = "/restv1/configuredCategory/15004";
+
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, path)
+      {
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 204, response.getStatus());
+         }
+
+      }.run();
+      
+      reset();
+      
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "application/xml");
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", response.getStatus(), 404);
+         }
+
+      }.run();
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,81 @@
+package org.jboss.seam.example.restbay.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.regex.Pattern;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.JUnitSeamTest;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * 
+ * @author Jozef Hartinger
+ * 
+ */
+ at RunWith(Arquillian.class)
+public class ResourceQueryTest extends JUnitSeamTest
+{
+   @Deployment(name="ResourceQueryTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+
+   public String[] getQueryPaths()
+   {
+      String[] data = new String[2];
+      data[0] = "/configuredCategory";
+      data[1] = "/extendedCategory";
+      return data;
+   }
+
+   @Test
+   public void testResourceQuery() throws Exception
+   {
+      for (String path : getQueryPaths())
+      {
+         new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/restv1" + path)
+         {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+               super.prepareRequest(request);
+               request.addHeader("Accept", "application/xml");
+               request.setQueryString("start=2&show=2");
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+               String responseString = response.getContentAsString();
+               String expectedResponseRegex = "<\\?xml version=\"1\\.0\" encoding=\"UTF-8\" standalone=\"yes\"\\?>" +
+               		"<collection>" +
+               		   "(<category>" +
+               		      "<categoryId>[^<]+</categoryId><name>[^<]+</name>" +
+               		      "(<parent><categoryId>[^<]+</categoryId><name>[^<]+</name></parent>)?" +
+               		   "</category>){2}" +
+               		"</collection>";
+               assertTrue("The response string doesn't match the expected response. " + responseString, Pattern.matches(expectedResponseRegex, responseString));
+            }
+
+         }.run();
+      }
+   }
+
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SecurityTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SecurityTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SecurityTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,225 @@
+package org.jboss.seam.example.restbay.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class tests RESTEasy integration together with Seam Security.
+ *
+ * @author Jozef Hartinger
+ */
+ at RunWith(Arquillian.class)
+public class SecurityTest extends JUnitSeamTest
+{
+   @Deployment(name="SecurityTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+
+   ResourceRequestEnvironment requestEnv;
+
+   @Before
+   public void prepareEnv() throws Exception
+   {
+      requestEnv = new ResourceRequestEnvironment(this)
+      {
+         @Override
+         public Map<String, Object> getDefaultHeaders()
+         {
+            return new HashMap<String, Object>()
+            {{
+                  put("Accept", "text/plain");
+               }};
+         }
+      };
+   }
+
+   @Test
+   public void basicAuthTest() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/admin")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus(), 200);
+            assertEquals("Unexpected response.", "false", response.getContentAsString());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void invalidCredentialsBasicAuthTest() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpvbWVk"); // demo:omed
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals(
+                  "Invalid authentication header value",
+                  "Basic realm=\"Seam RestBay Application\"",
+                  response.getHeader("WWW-Authenticate")
+            );
+            assertEquals("Unexpected response code.", 401, response.getStatus());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void adminRoleTest() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/admin")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus());
+            assertEquals("true", response.getContentAsString());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void adminRoleTestWithRestriction() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/restrictedAdmin")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus());
+            assertEquals("true", response.getContentAsString());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void invalidAdminAuthorization() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/restrictedAdmin")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            // See AuthorizationException mapping to 403 in pages.xml!
+            assertEquals("Unexpected response code.", 403, response.getStatus());
+            assert response.getStatusMessage().startsWith("Not authorized to access resource");
+         }
+
+      }.run();
+   }
+   
+   @Test
+   // JBPAPP-3713
+   public void ejbLookup() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/ejbLookup")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus(), 200);
+            assert response.getContentAsString().equals("true");
+         }
+         
+      }.run();
+   }
+   
+    @Test
+   // JBPAPP-3713
+   public void synchronizationsLookup() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/synchronizationsLookup")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus());
+            assert response.getContentAsString().equals("true");
+         }
+         
+      }.run();
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SubresourceTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SubresourceTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/java/org/jboss/seam/example/restbay/test/SubresourceTest.java	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,53 @@
+package org.jboss.seam.example.restbay.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
+import org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class SubresourceTest extends JUnitSeamTest
+{
+   @Deployment(name="SubresourceTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.restbayDeployment();
+   }
+   
+   @Test
+   public void testSubresourceGET() throws Exception
+   {
+      final String path = "/restv1/garage/1";
+
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals("Unexpected response code.", 200, response.getStatus());
+            assertEquals("Unexpected response.", "Honda", response.getContentAsString());
+         }
+
+      }.run();
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/arquillian.xml
===================================================================
(Binary files differ)


Property changes on: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/arquillian.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/components.xml
===================================================================
(Binary files differ)


Property changes on: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/components.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/jboss-deployment-structure.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/jboss-deployment-structure.xml	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/jboss-deployment-structure.xml	2013-06-03 17:00:28 UTC (rev 15529)
@@ -0,0 +1,9 @@
+<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
+  <deployment>
+    <dependencies>
+      <module name="org.dom4j" export="true"/>
+      <module name="org.apache.commons.collections" export="true"/>
+      <module name="javax.faces.api" export="true"/>
+    </dependencies>
+  </deployment>
+</jboss-deployment-structure>

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/example/restbay/test/dbunitdata.xml
===================================================================
(Binary files differ)


Property changes on: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/org/jboss/seam/example/restbay/test/dbunitdata.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/pages.xml
===================================================================
(Binary files differ)


Property changes on: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/pages.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/persistence.xml
===================================================================
(Binary files differ)


Property changes on: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/persistence.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Added: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/web.xml
===================================================================
(Binary files differ)


Property changes on: branches/enterprise/WFK-2_1/examples/restbay/restbay-ejb/src/test/resources/web.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Modified: branches/enterprise/WFK-2_1/examples/restbay/restbay-web/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/restbay/restbay-web/pom.xml	2013-06-03 16:49:04 UTC (rev 15528)
+++ branches/enterprise/WFK-2_1/examples/restbay/restbay-web/pom.xml	2013-06-03 17:00:28 UTC (rev 15529)
@@ -62,6 +62,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
+                <version>${version.war.plugin}</version>
                 <configuration>
                     <webResources>
                         <resource>



More information about the seam-commits mailing list