You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2012/10/03 00:53:50 UTC

[1/2] git commit: DELTASPIKE-266 initial test skeleton for JSF based unit tests

Updated Branches:
  refs/heads/master 5864a5509 -> b9967f1bf


DELTASPIKE-266 initial test skeleton for JSF based unit tests

They need a WebProfile at least!


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/b9967f1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/b9967f1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/b9967f1b

Branch: refs/heads/master
Commit: b9967f1bf0a7ceb5d7ca6ea3b55eeec9e5910f0d
Parents: 3ac4e36
Author: Mark Struberg <st...@apache.org>
Authored: Wed Oct 3 00:53:09 2012 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Wed Oct 3 00:53:09 2012 +0200

----------------------------------------------------------------------
 deltaspike/modules/jsf/impl/pom.xml                |   21 ++++
 .../test/scope/view/ViewScopedContextTest.java     |   34 +++++-
 .../jsf/impl/src/test/resources/META-INF/beans.xml |   24 ++++
 .../jsf/impl/src/test/resources/arquillian.xml     |   84 +++++++++++++++
 .../viewScopedContextTest/WEB-INF/web.xml          |   15 +++
 .../resources/viewScopedContextTest/index.html     |    5 +
 .../resources/viewScopedContextTest/page1.xhtml    |    6 +
 7 files changed, 183 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/pom.xml b/deltaspike/modules/jsf/impl/pom.xml
index b535e69..0045543 100644
--- a/deltaspike/modules/jsf/impl/pom.xml
+++ b/deltaspike/modules/jsf/impl/pom.xml
@@ -47,6 +47,27 @@
             <artifactId>deltaspike-jsf-module-api</artifactId>
         </dependency>
 
+        <!-- we use Arquilllian Warp to test our JSF apps -->
+        <dependency>
+            <groupId>org.jboss.arquillian.extension</groupId>
+            <artifactId>arquillian-drone-api</artifactId>
+            <version>1.0.0.Final</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.arquillian.extension</groupId>
+            <artifactId>arquillian-warp-api</artifactId>
+            <version>1.0.0.Alpha1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.arquillian.graphene</groupId>
+            <artifactId>arquillian-graphene</artifactId>
+            <version>2.0.0.Alpha2</version>
+            <type>pom</type>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
 

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/jsf/impl/test/scope/view/ViewScopedContextTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/jsf/impl/test/scope/view/ViewScopedContextTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/jsf/impl/test/scope/view/ViewScopedContextTest.java
index c8298fe..7f2599c 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/jsf/impl/test/scope/view/ViewScopedContextTest.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/jsf/impl/test/scope/view/ViewScopedContextTest.java
@@ -19,10 +19,17 @@
 package org.apache.deltaspike.jsf.impl.test.scope.view;
 
 
-import org.apache.deltaspike.jsf.impl.test.scope.view.util.ArchiveUtils;
+import java.net.URL;
+
 import org.apache.deltaspike.test.category.WebProfileCategory;
+import org.jboss.arquillian.ajocado.framework.GrapheneSelenium;
 import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.drone.api.annotation.Drone;
 import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+//X import org.jboss.arquillian.warp.WarpTest;
+
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.asset.EmptyAsset;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -34,10 +41,17 @@ import org.junit.runner.RunWith;
 /**
  * Test for the DeltaSpike ViewScoped context
  */
+//X @WarpTest
 @RunWith(Arquillian.class)
 @Category(WebProfileCategory.class)
 public class ViewScopedContextTest
 {
+    @Drone
+    private GrapheneSelenium browser;
+
+    @ArquillianResource
+    private URL contextPath;
+
     /**
      * X TODO creating a WebArchive is only a workaround because JavaArchive
      * cannot contain other archives.
@@ -45,22 +59,30 @@ public class ViewScopedContextTest
     @Deployment
     public static WebArchive deploy()
     {
+        // JAR with NO beans.xml!
         JavaArchive testJar = ShrinkWrap
                 .create(JavaArchive.class, "viewScopedContextTest.jar")
-                .addPackage(ViewScopedContextTest.class.getPackage())
-                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+//X                 .addPackage(ViewScopedContextTest.class.getPackage())
+                .addPackage(GrapheneSelenium.class.getPackage())
+                .addPackage(WebProfileCategory.class.getPackage());
 
         return ShrinkWrap
                 .create(WebArchive.class, "viewScopedContextTest.war")
-                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
-                .addAsLibraries(testJar)
+                .addAsLibrary(testJar)
+
+                //X .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
+                .addAsWebInfResource("viewScopedContextTest/WEB-INF/web.xml", "web.xml")
+                .addAsWebResource("viewScopedContextTest/index.html", "index.html")
+                .addAsWebResource("viewScopedContextTest/page1.xhtml", "page1.xhtml")
                 .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
     }
 
 
     @Test
+    @RunAsClient
     public void testViewScopedContext()
     {
-        //X TODO how to best test a JSF app?
+        browser.open(contextPath);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/META-INF/beans.xml b/deltaspike/modules/jsf/impl/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..0eaf52c
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+    <!-- DON'T add content to this file - it's >only< needed as marker file for the test-scan -->
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/arquillian.xml b/deltaspike/modules/jsf/impl/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..973dbb4
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/arquillian.xml
@@ -0,0 +1,84 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+    <!--Uncomment to have test archives exported to the file system for inspection -->
+    <!--
+    <engine>
+        <property name="deploymentExportPath">target/</property>
+    </engine>
+    -->
+
+    <container qualifier="jbossas-managed-7">
+        <configuration>
+            <property name="javaVmArguments">-client -noverify -Xms64m -Xmx1024m -XX:MaxPermSize=512m</property>
+            <property name="outputToConsole">false</property>
+            <property name="allowConnectingToRunningServer">true</property>
+        </configuration>
+    </container>
+
+    <container qualifier="jbossas-build-managed-7">
+        <configuration>
+            <property name="jbossHome">${arquillian.jboss_home}</property>
+            <property name="javaVmArguments">-client -noverify -Xms64m -Xmx1024m -XX:MaxPermSize=512m</property>
+            <property name="outputToConsole">false</property>
+            <property name="allowConnectingToRunningServer">true</property>
+        </configuration>
+    </container>
+
+    <container qualifier="jbossas-remote-7">
+        <!--
+        for remote debugging enable "remote socket debugging" - uncomment:
+            set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
+        in
+            standalone.conf (standalone.conf.bat)
+        and connect to
+            port 8787
+        -->
+    </container>
+
+    <!-- don't remove the qualifier - it's needed for the arquillian.launch property -->
+    <container qualifier="glassfish-remote-3.1">
+    </container>
+
+    <container qualifier="wls-remote-12c">
+        <configuration>
+            <property name="adminUrl">t3://localhost:7001</property>
+            <property name="adminUserName">weblogic1</property>
+            <property name="adminPassword">weblogic1</property>
+            <property name="target">AdminServer</property>
+            <property name="wlsHome">${WLS_HOME}</property>
+        </configuration>
+    </container>
+
+    <container qualifier="tomee">
+        <configuration>
+            <!-- tomee gets copied to this directory during the build -->
+            <property name="dir">target/tomee</property>
+
+            <!-- value '-1' to allow arquillian-tomee-remote to use dynamic settings -->
+            <property name="httpPort">-1</property>
+            <property name="ajpPort">-1</property>
+            <property name="stopPort">-1</property>
+            <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+        </configuration>
+    </container>
+</arquillian>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/WEB-INF/web.xml b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/WEB-INF/web.xml
new file mode 100644
index 0000000..0331abe
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/WEB-INF/web.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         version="2.5">
+    <servlet>
+        <servlet-name>Faces Servlet</servlet-name>
+        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>Faces Servlet</servlet-name>
+        <url-pattern>*.xhtml</url-pattern>
+    </servlet-mapping>
+</web-app>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/index.html
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/index.html b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/index.html
new file mode 100644
index 0000000..78d8dde
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/index.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+index page works!
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/b9967f1b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/page1.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/page1.xhtml b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/page1.xhtml
new file mode 100644
index 0000000..45741e1
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewScopedContextTest/page1.xhtml
@@ -0,0 +1,6 @@
+<html>
+
+<body>
+it works!
+</body>
+</html>