[seam-commits] Seam SVN: r15535 - in branches/enterprise/WFK-2_1/examples/tasks: tasks-ear and 12 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Jun 3 16:25:05 EDT 2013


Author: maschmid
Date: 2013-06-03 16:25:04 -0400 (Mon, 03 Jun 2013)
New Revision: 15535

Added:
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/CategoryResourceTest.java
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/Deployments.java
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/TaskResourceTest.java
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/arquillian.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/components.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/jboss-deployment-structure.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/pages.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/persistence.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/web.xml
Removed:
   branches/enterprise/WFK-2_1/examples/tasks/tasks-tests/
Modified:
   branches/enterprise/WFK-2_1/examples/tasks/pom.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ear/pom.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/pom.xml
   branches/enterprise/WFK-2_1/examples/tasks/tasks-web/pom.xml
Log:
tasks example migrated


Modified: branches/enterprise/WFK-2_1/examples/tasks/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/pom.xml	2013-06-03 19:31:51 UTC (rev 15534)
+++ branches/enterprise/WFK-2_1/examples/tasks/pom.xml	2013-06-03 20:25:04 UTC (rev 15535)
@@ -3,27 +3,49 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.jboss.seam.examples</groupId>
     <artifactId>tasks</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>Tasks Example (EE6)</name>
     
     <properties>
         <example.name>tasks</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>tasks-ear</module>
         <module>tasks-ejb</module>
         <module>tasks-web</module>
-        <module>tasks-tests</module>
+        
     </modules>
     
     <dependencyManagement>
         <dependencies>
+            <!-- Modules -->
             <dependency>
                 <groupId>org.jboss.seam.examples.tasks</groupId>
                 <artifactId>tasks-ejb</artifactId>
@@ -41,6 +63,82 @@
                 <artifactId>tasks-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/tasks/tasks-ear/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ear/pom.xml	2013-06-03 19:31:51 UTC (rev 15534)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ear/pom.xml	2013-06-03 20:25:04 UTC (rev 15535)
@@ -49,10 +49,20 @@
 
     <build>
         <finalName>seam-tasks</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/tasks/tasks-ejb/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/pom.xml	2013-06-03 19:31:51 UTC (rev 15534)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/pom.xml	2013-06-03 20:25:04 UTC (rev 15535)
@@ -84,6 +84,113 @@
                 </exclusion>
             </exclusions>
         </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.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-tasks/#{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>
+            <!-- Skip tests by default -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+ 
 </project>

Added: branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/CategoryResourceTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/CategoryResourceTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/CategoryResourceTest.java	2013-06-03 20:25:04 UTC (rev 15535)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test class for /category part of API
+ * @author Jozef Hartinger
+ *
+ */
+ at RunWith(Arquillian.class)
+public class CategoryResourceTest extends JUnitSeamTest
+{
+   @Deployment(name="CategoryResourceTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.tasksDeployment();
+   }
+
+   @Test
+   public void getCategoryListTest() throws Exception
+   {
+      String[][] data = new String[][] { new String[] { "application/xml", "<category><name>School</name></category>" }, new String[] { "application/json", "{\"category\":{\"name\":\"School\"}}" } };
+      
+      for (final String[] caseData : data) {
+        new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category")
+        {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+                super.prepareRequest(request);
+                request.addHeader("Accept", caseData[0]);
+                request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+                super.onResponse(response);
+                assertEquals("Unexpected response code.", 200, response.getStatus());
+                assertTrue("Unexpected response.", response.getContentAsString().contains(caseData[1]));
+            }
+
+        }.run();
+      }
+   }
+
+   @Test
+   public void deleteCategoryTest() throws Exception
+   {
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, "/v1/auth/category/Work")
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "application/xml");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 204, response.getStatus());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void createCategoryTest() throws Exception
+   {
+      
+      final String uri = "/v1/auth/category/Test%20Category";
+      final String mimeType = "application/json";
+      final String expectedResponse = "{\"category\":{\"name\":\"Test Category\"}}";
+      
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, uri)
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 201, response.getStatus());
+         }
+
+      }.run();
+
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, uri)
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", mimeType);
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 200, response.getStatus());
+            assertEquals("Unexpected response.", expectedResponse, response.getContentAsString());
+         }
+
+      }.run();
+   }
+
+   @Test
+   public void noAuthorizationHeaderTest() throws Exception
+   {
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category")
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "application/xml");
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 401, response.getStatus());
+         }
+
+      }.run();
+   }
+
+}

Added: branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/Deployments.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/Deployments.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/Deployments.java	2013-06-03 20:25:04 UTC (rev 15535)
@@ -0,0 +1,42 @@
+package org.jboss.seam.example.tasks.test;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.importer.ZipImporter;
+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 tasksDeployment() {
+      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-tasks.war")
+                .addPackages(true, "org.jboss.seam.example.tasks")
+
+                // already in EJB module
+                .addAsResource("import.sql", "import.sql")
+                .addAsResource("seam.properties", "seam.properties")
+                .addAsWebInfResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
+
+                // test-specific persistence.xml
+                .addAsResource("persistence.xml", "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-tasks
+
+                // 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/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java	2013-06-03 20:25:04 UTC (rev 15535)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+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.WebArchive;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+/**
+ * Test class for /user/{username}/tasks/resolved part of API.
+ * @author Jozef Hartinger
+ *
+ */
+ at RunWith(Arquillian.class)
+public class ResolvedTaskResourceQueryTest extends JUnitSeamTest
+{
+
+   @Deployment(name="ResolvedTaskResourceQueryTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.tasksDeployment();
+   }
+    
+   // We could do this BeforeClass only once but we can't do ResourceRequests there
+   @Before
+   public void resolveTask() throws Exception {
+      
+      final String mimeType = "application/xml";
+      final String representation = "<task><id>14</id></task>";
+      
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, "/v1/auth/category/School/resolved/14")
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+            request.addHeader("Content-Type", mimeType);
+            request.setContentType(mimeType);
+            request.setContent(representation.getBytes());
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 204, response.getStatus());
+         }
+
+      }.run();
+   }
+   
+   @Test
+   public void editTaskTest() throws Exception
+   {
+      String[][] data = new String[][] {
+            new String[] {"application/xml", "<name>Get a haircut</name>"},
+            new String[] {"application/json", "\"name\":\"Get a haircut\""},
+            new String[] {"application/atom+xml", "<atom:title>Get a haircut</atom:title>"}
+      }; 
+      
+      for(final String[] caseData : data) {
+        new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/user/demo/tasks/resolved")
+        {
+
+            @Override
+            protected void prepareRequest(EnhancedMockHttpServletRequest request)
+            {
+                super.prepareRequest(request);
+                request.addHeader("Accept", caseData[0]);
+            }
+
+            @Override
+            protected void onResponse(EnhancedMockHttpServletResponse response)
+            {
+                super.onResponse(response);
+                assertEquals("Unexpected response code.", 200, response.getStatus());
+                assertTrue("Unexpected response.", response.getContentAsString().contains(caseData[1]));
+            }
+
+        }.run();
+      }
+   }
+}

Added: branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/TaskResourceTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/TaskResourceTest.java	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/java/org/jboss/seam/example/tasks/test/TaskResourceTest.java	2013-06-03 20:25:04 UTC (rev 15535)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+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.WebArchive;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.runner.RunWith;
+
+/**
+ * Test class for TaskResourceHome and TaskResourceQuery components.
+ * @author Jozef Hartinger
+ *
+ */
+ at RunWith(Arquillian.class)
+public class TaskResourceTest extends JUnitSeamTest
+{
+   @Deployment(name="TaskResourceTest")
+   @OverProtocol("Servlet 3.0")
+   public static Archive<?> createDeployment()
+   {
+      return Deployments.tasksDeployment();
+   }
+    
+   @Test
+   public void createTaskTest() throws Exception
+   {
+      final String mimeType = "application/json";
+      final String representation = "{\"task\":{\"name\":\"Test task\"}}";
+      
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.POST, "/v1/auth/category/School/unresolved")
+      {
+         
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+            request.addHeader("Content-Type", mimeType);
+            request.setContentType(mimeType);
+            request.setContent(representation.getBytes());
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 201, response.getStatus());
+         }
+         
+      }.run();
+   }
+
+   @Test
+   public void editTaskTest() throws Exception
+   {
+      final String mimeType = "application/xml";
+      final String representation = "<task><id>4</id><name>Learn new English vocabulary</name></task>";
+
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, "/v1/auth/category/School/unresolved/4")
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+            request.addHeader("Content-Type", mimeType);
+            request.setContentType(mimeType);
+            request.setContent(representation.getBytes());
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 204, response.getStatus());
+         }
+
+      }.run();
+
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category/School/unresolved/4")
+      {
+
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "application/xml");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 200, response.getStatus());
+            assertTrue("Unexpected response.", response.getContentAsString().contains("Learn new English vocabulary"));
+         }
+
+      }.run();
+   }
+   
+   @Test
+   public void deleteTaskTest() throws Exception
+   {
+      new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, "/v1/auth/category/School/unresolved/2")
+      {
+         
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            super.onResponse(response);
+            assertEquals("Unexpected response code.", 204, response.getStatus());
+         }
+         
+      }.run();
+   }
+}

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


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

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


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

Added: branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/jboss-deployment-structure.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/jboss-deployment-structure.xml	                        (rev 0)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-ejb/src/test/resources/jboss-deployment-structure.xml	2013-06-03 20:25:04 UTC (rev 15535)
@@ -0,0 +1,12 @@
+<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>
+        <exclusions>
+            <module name="org.jboss.resteasy.resteasy-jackson-provider" slot="main"/>
+        </exclusions>
+    </deployment>
+</jboss-deployment-structure>

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


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

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


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

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


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

Modified: branches/enterprise/WFK-2_1/examples/tasks/tasks-web/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/tasks/tasks-web/pom.xml	2013-06-03 19:31:51 UTC (rev 15534)
+++ branches/enterprise/WFK-2_1/examples/tasks/tasks-web/pom.xml	2013-06-03 20:25:04 UTC (rev 15535)
@@ -72,6 +72,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