[jboss-cvs] JBossAS SVN: r108597 - in projects/jboss-jsf-int/trunk: arquillian and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 15 09:12:19 EDT 2010


Author: stan.silvert at jboss.com
Date: 2010-10-15 09:12:19 -0400 (Fri, 15 Oct 2010)
New Revision: 108597

Added:
   projects/jboss-jsf-int/trunk/arquillian/
   projects/jboss-jsf-int/trunk/arquillian/pom.xml
   projects/jboss-jsf-int/trunk/arquillian/readme.txt
   projects/jboss-jsf-int/trunk/arquillian/src/
   projects/jboss-jsf-int/trunk/arquillian/src/main/
   projects/jboss-jsf-int/trunk/arquillian/src/main/resources/
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-faces-config.xml
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-web.xml
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/jsf12-empty-faces-config.xml
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/mojarra-12-web.xml
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/myfaces-20-web.xml
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.jsp
   projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.xhtml
   projects/jboss-jsf-int/trunk/arquillian/src/test/
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/BasicHelloTest.java
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/Mojarra12BasicHelloTest.java
   projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/MyFaces20BasicHelloTest.java
   projects/jboss-jsf-int/trunk/arquillian/src/test/resources/
   projects/jboss-jsf-int/trunk/arquillian/src/test/resources/arquillian.xml
   projects/jboss-jsf-int/trunk/arquillian/src/test/resources/jndi.properties
Modified:
   projects/jboss-jsf-int/trunk/pom.xml
Log:
JBAS-8529 Create Arquillian tests for JSF Deployer


Added: projects/jboss-jsf-int/trunk/arquillian/pom.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/pom.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/pom.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,189 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.jboss.jsf.integration</groupId>
+    <artifactId>jboss-jsf-int</artifactId>
+    <version>1.0.3-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>jsf-deployer-arquillian-tests</artifactId>
+  <packaging>war</packaging>
+  <name>jsf-deployer-arquillian-tests</name>
+  <version>1.0.3-SNAPSHOT</version>
+
+  <properties>
+    <arquillian.version>1.0.0.Alpha4</arquillian.version>
+    <version.jboss_60>6.0.0-SNAPSHOT</version.jboss_60>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.enterprise</groupId>
+      <artifactId>cdi-api</artifactId>
+      <version>1.0-SP1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.6.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>1.6.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.jsfunit</groupId>
+      <artifactId>jboss-jsfunit-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.arquillian</groupId>
+      <artifactId>arquillian-junit</artifactId>
+      <version>${arquillian.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.arquillian.framework</groupId>
+      <artifactId>arquillian-framework-jsfunit</artifactId>
+      <version>${arquillian.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-client</artifactId>
+      <version>${version.jboss_60}</version>
+      <type>pom</type>
+    </dependency>
+
+    <dependency>
+      <groupId>com.sun.faces</groupId>
+      <artifactId>jsf-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <!--
+    <dependency>
+      <groupId>jboss.web</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>3.0.0.alpha-19</version>
+      <scope>provided</scope>
+    </dependency>
+-->
+
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>jbossas-remote-6</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.jboss.arquillian.container</groupId>
+          <artifactId>arquillian-jbossas-remote-6</artifactId>
+          <version>${arquillian.version}</version>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <profile>
+      <id>jbossas-managed-6</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.jboss.arquillian.container</groupId>
+          <artifactId>arquillian-jbossas-managed-6</artifactId>
+          <version>${arquillian.version}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.jboss.jbossas</groupId>
+          <artifactId>jboss-server-manager</artifactId>
+          <version>1.0.3.GA</version>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <profile>
+      <id>jbossas-embedded-6</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.jboss.arquillian.container</groupId>
+          <artifactId>arquillian-jbossas-embedded-6</artifactId>
+          <version>${arquillian.version}</version>
+        </dependency>
+
+        <!-- Exclude Seam core.  See JBAS-8503 -->
+        <dependency>
+          <groupId>org.jboss.jbossas</groupId>
+          <artifactId>jboss-as-depchain</artifactId>
+          <version>${version.jboss_60}</version>
+          <type>pom</type>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jboss.seam.integration</groupId>
+              <artifactId>jboss-seam-int-jbossas</artifactId>
+            </exclusion>
+          </exclusions>
+        </dependency>
+
+      </dependencies>
+      <dependencyManagement>
+        <dependencies>
+          <dependency>
+            <groupId>org.jboss.jbossas</groupId>
+            <artifactId>jboss-as-depchain</artifactId>
+            <version>${version.jboss_60}</version>
+            <type>pom</type>
+            <scope>import</scope>
+          </dependency>
+        </dependencies>
+      </dependencyManagement>
+
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <additionalClasspathElements>
+                <additionalClasspathElement>${JBOSS_HOME}/client/jbossws-native-core.jar</additionalClasspathElement>
+                <!--
+                            Because jbossweb.sar contains shared web.xml, which must be
+                            visible from same CL as TomcatDeployer.class.getClassLoader
+                        -->
+                <additionalClasspathElement>${JBOSS_HOME}/server/default/deploy/jbossweb.sar</additionalClasspathElement>
+              </additionalClasspathElements>
+
+              <redirectTestOutputToFile>true</redirectTestOutputToFile>
+              <trimStackTrace>false</trimStackTrace>
+              <printSummary>true</printSummary>
+              <forkMode>once</forkMode>
+
+              <!--
+                        MaxPermSize Required to bump the space for relective data like
+                        classes, methods, etc. EMB-41. Endorsed required for things like
+                        WS support (EMB-61)
+                    -->
+              <argLine>-Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed -Djboss.home=${JBOSS_HOME} -Djboss.boot.server.log.dir=${JBOSS_HOME}</argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+</project>

Added: projects/jboss-jsf-int/trunk/arquillian/readme.txt
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/readme.txt	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/readme.txt	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,16 @@
+Arquillian embedded mode is not working for this suite right now.
+
+To run these tests:
+1. Start AS6
+
+2. Edit settings.xml to have 
+    <profile>
+      <id>jboss6x</id>
+      <properties>        
+        <JBOSS_HOME>/path_to_astrunk/build/target/jboss-6.0.0-SNAPSHOT</JBOSS_HOME>
+      </properties>
+    </profile>
+
+3. From the command line:
+
+mvn -Pjboss6x,jbossas-remote-6 test
\ No newline at end of file

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-faces-config.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-faces-config.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-faces-config.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,6 @@
+<faces-config 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-facesconfig_2_0.xsd"
+              version="2.0">
+
+</faces-config>
\ No newline at end of file

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-web.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-web.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/empty-web.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<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_3_0.xsd"
+    version="3.0">
+
+
+
+</web-app>

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/jsf12-empty-faces-config.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/jsf12-empty-faces-config.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/jsf12-empty-faces-config.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+
+<!DOCTYPE faces-config PUBLIC
+  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+<faces-config>
+
+  
+
+</faces-config>

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/mojarra-12-web.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/mojarra-12-web.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/mojarra-12-web.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+   <context-param>
+      <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
+      <param-value>Mojarra-1.2</param-value>
+   </context-param>
+
+ <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>*.faces</url-pattern>
+ </servlet-mapping>
+
+
+</web-app>

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/myfaces-20-web.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/myfaces-20-web.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/WEB-INF/myfaces-20-web.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<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_3_0.xsd"
+    version="3.0">
+
+   <context-param>
+      <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
+      <param-value>MyFaces-2.0</param-value>
+   </context-param>
+
+ <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>*.faces</url-pattern>
+ </servlet-mapping>
+
+
+</web-app>

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.jsp
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.jsp	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.jsp	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,15 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<html>
+     <f:view>
+        <h:form id="form1">
+          <h:outputText value="Enter Your Name:"/>
+          <h:inputText id="name"/>
+          <h:commandButton id="submit" value="Submit" />
+        </h:form>
+        <h:outputText rendered="#{not empty request.getParameter('form1:name')}" 
+                      value=" Hello #{request.getParameter('form1:name')}"/>
+     </f:view>
+     
+</html>

Added: projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.xhtml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.xhtml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/main/webapp/index.xhtml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+     <f:view>
+        <h:form id="form1">
+          <h:outputText value="Enter Your Name:"/>
+          <h:inputText id="name"/>
+          <h:commandButton id="submit" value="Submit" />
+        </h:form>
+        <h:outputText rendered="#{not empty request.getParameter('form1:name')}" 
+                      value=" Hello #{request.getParameter('form1:name')}"/>
+     </f:view>
+     
+</html>

Added: projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/BasicHelloTest.java
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/BasicHelloTest.java	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/BasicHelloTest.java	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 20010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jsf.deployer;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Assert;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.jsfunit.framework.Environment;
+import org.jboss.jsfunit.jsfsession.JSFClientSession;
+import org.jboss.jsfunit.jsfsession.JSFServerSession;
+import org.jboss.jsfunit.jsfsession.JSFSession;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ *  
+ * @author Stan Silvert
+ */
+ at RunWith(Arquillian.class)
+public class BasicHelloTest
+{
+
+   private JSFClientSession client;
+   private JSFServerSession server;
+
+   @Deployment
+   public static WebArchive createDeployment() {
+      WebArchive war =
+         ShrinkWrap.create(WebArchive.class, "test.war")
+            .setWebXML(new File("src/main/webapp/WEB-INF/empty-web.xml"))
+            .addResource(new File("src/main/webapp", "index.xhtml"))
+            .addWebResource(new File("src/main/webapp/WEB-INF/empty-faces-config.xml"), "faces-config.xml");
+
+      // Uncomment to print the archive for debugging
+      // war.as(ExplodedExporter.class).exportExploded(new File("exploded"));
+      // System.out.println(war.toString(true));
+
+      return war;
+   }
+
+   /**
+    * Start a JSFUnit session by getting the /index.faces page.  Note that
+    * because setUp() is called before each test, a new HttpSession will be
+    * created each time a test is run.
+    */
+   public void setUp() throws IOException
+   {
+      // Initial JSF request
+      JSFSession jsfSession = new JSFSession("/index.faces");
+      this.client = jsfSession.getJSFClientSession();
+      this.server = jsfSession.getJSFServerSession();
+   } 
+
+   @Test
+   public void testJSFVersion() throws IOException
+   {
+      Assert.assertEquals(2, Environment.getJSFMajorVersion());
+   }
+
+   @Test
+   public void testHello() throws IOException
+   {
+      setUp();
+      client.setValue("name", "Stan");
+      client.click("submit");
+      Assert.assertTrue("html page does not contain 'Hello Stan'",
+                        client.getPageAsText().contains("Hello Stan"));
+      Assert.assertEquals("Stan", server.getManagedBeanValue("#{request.getParameter('form1:name')}"));
+   }
+}

Added: projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/Mojarra12BasicHelloTest.java
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/Mojarra12BasicHelloTest.java	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/Mojarra12BasicHelloTest.java	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 20010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jsf.deployer;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Assert;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.jsfunit.framework.Environment;
+import org.jboss.jsfunit.jsfsession.JSFClientSession;
+import org.jboss.jsfunit.jsfsession.JSFServerSession;
+import org.jboss.jsfunit.jsfsession.JSFSession;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ *  
+ * @author Stan Silvert
+ */
+ at RunWith(Arquillian.class)
+public class Mojarra12BasicHelloTest
+{
+
+   private JSFClientSession client;
+   private JSFServerSession server;
+
+   @Deployment
+   public static WebArchive createDeployment() {
+      WebArchive war =
+         ShrinkWrap.create(WebArchive.class, "test.war")
+            .setWebXML(new File("src/main/webapp/WEB-INF/mojarra-12-web.xml"))
+            .addResource(new File("src/main/webapp", "index.jsp"))
+            .addWebResource(new File("src/main/webapp/WEB-INF/jsf12-empty-faces-config.xml"), "faces-config.xml");
+
+      // Uncomment to print the archive for debugging
+      // war.as(ExplodedExporter.class).exportExploded(new File("exploded"));
+      // System.out.println(war.toString(true));
+
+      return war;
+   }
+
+   /**
+    * Start a JSFUnit session by getting the /index.faces page.  Note that
+    * because setUp() is called before each test, a new HttpSession will be
+    * created each time a test is run.
+    */
+   public void setUp() throws IOException
+   {
+      // Initial JSF request
+      JSFSession jsfSession = new JSFSession("/index.faces");
+      this.client = jsfSession.getJSFClientSession();
+      this.server = jsfSession.getJSFServerSession();
+   } 
+
+   @Test
+   public void testJSFVersion() throws IOException
+   {
+      Assert.assertEquals(1, Environment.getJSFMajorVersion());
+   }
+
+   @Test
+   public void testHello() throws IOException
+   {
+      setUp();
+      client.setValue("name", "Stan");
+      client.click("submit");
+      Assert.assertTrue("html page does not contain 'Hello Stan'",
+                        client.getPageAsText().contains("Hello Stan"));
+      Assert.assertEquals("Stan", server.getManagedBeanValue("#{request.getParameter('form1:name')}"));
+   }
+}

Added: projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/MyFaces20BasicHelloTest.java
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/MyFaces20BasicHelloTest.java	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/test/java/org/jboss/jsf/deployer/MyFaces20BasicHelloTest.java	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 20010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jsf.deployer;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Assert;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.jsfunit.framework.Environment;
+import org.jboss.jsfunit.jsfsession.JSFClientSession;
+import org.jboss.jsfunit.jsfsession.JSFServerSession;
+import org.jboss.jsfunit.jsfsession.JSFSession;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ *  
+ * @author Stan Silvert
+ */
+ at RunWith(Arquillian.class)
+public class MyFaces20BasicHelloTest
+{
+
+   private JSFClientSession client;
+   private JSFServerSession server;
+
+   @Deployment
+   public static WebArchive createDeployment() {
+      WebArchive war =
+         ShrinkWrap.create(WebArchive.class, "test.war")
+            .setWebXML(new File("src/main/webapp/WEB-INF/myfaces-20-web.xml"))
+            .addResource(new File("src/main/webapp", "index.xhtml"))
+            .addWebResource(new File("src/main/webapp/WEB-INF/empty-faces-config.xml"), "faces-config.xml");
+
+      // Uncomment to print the archive for debugging
+      // war.as(ExplodedExporter.class).exportExploded(new File("exploded"));
+      // System.out.println(war.toString(true));
+
+      return war;
+   }
+
+   /**
+    * Start a JSFUnit session by getting the /index.faces page.  Note that
+    * because setUp() is called before each test, a new HttpSession will be
+    * created each time a test is run.
+    */
+   public void setUp() throws IOException
+   {
+      // Initial JSF request
+      JSFSession jsfSession = new JSFSession("/index.faces");
+      this.client = jsfSession.getJSFClientSession();
+      this.server = jsfSession.getJSFServerSession();
+   } 
+
+   @Test
+   public void testJSFVersion() throws IOException
+   {
+      Assert.assertEquals(2, Environment.getJSFMajorVersion());
+   }
+
+   @Test
+   public void testHello() throws IOException
+   {
+      setUp();
+      client.setValue("name", "Stan");
+      client.click("submit");
+      Assert.assertTrue("html page does not contain 'Hello Stan'",
+                        client.getPageAsText().contains("Hello Stan"));
+      Assert.assertEquals("Stan", server.getManagedBeanValue("#{request.getParameter('form1:name')}"));
+   }
+}

Added: projects/jboss-jsf-int/trunk/arquillian/src/test/resources/arquillian.xml
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/test/resources/arquillian.xml	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/test/resources/arquillian.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+<arquillian xmlns="http://jboss.com/arquillian"
+		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+	<engine>
+		<deploymentExportPath>target/</deploymentExportPath>
+	</engine>
+	
+</arquillian>
\ No newline at end of file

Added: projects/jboss-jsf-int/trunk/arquillian/src/test/resources/jndi.properties
===================================================================
--- projects/jboss-jsf-int/trunk/arquillian/src/test/resources/jndi.properties	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/arquillian/src/test/resources/jndi.properties	2010-10-15 13:12:19 UTC (rev 108597)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces 
+java.naming.provider.url=jnp://localhost:1099
\ No newline at end of file

Modified: projects/jboss-jsf-int/trunk/pom.xml
===================================================================
--- projects/jboss-jsf-int/trunk/pom.xml	2010-10-15 10:06:01 UTC (rev 108596)
+++ projects/jboss-jsf-int/trunk/pom.xml	2010-10-15 13:12:19 UTC (rev 108597)
@@ -77,7 +77,7 @@
          <dependency>
             <groupId>org.jboss.jsfunit</groupId>
             <artifactId>jboss-jsfunit-core</artifactId>
-            <version>1.2.0.Final</version>
+            <version>1.3.0.Final</version>
          </dependency>
 
          <dependency>



More information about the jboss-cvs-commits mailing list