Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Committed JUDCon 2010 Showcase + Presentation. Warning: JSF demo was …

…based on trunk/snapshot release. API has changed and it does not run with Alpha2. Update to Alpha3 when released.
  • Loading branch information...
commit 5b291a1911f9f94857ce204e071b7628cb13dd7b 1 parent acf15cf
@aslakknutsen aslakknutsen authored
View
144 jsf/pom.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ vi:ts=2:sw=2:expandtab:
+-->
+<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">
+
+ <!-- Model Information -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.sandbox.showcase</groupId>
+ <artifactId>arquillian-sandbox-showcase-profiles</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../profiles/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Information -->
+ <artifactId>arquillian-sandbox-showcase-jsf</artifactId>
+ <packaging>jar</packaging>
+ <name>Arquillian Showcase - JSF</name>
+ <url>http://www.jboss.org</url>
+ <description>Arquillian Showcase - JSF</description>
+
+ <properties>
+ <version.jboss_60>6.0.0.20100429-M3</version.jboss_60>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>jboss-embedded-60</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-embedded-60</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-depchain</artifactId>
+ <version>${version.jboss_60}</version>
+ <type>pom</type>
+ </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>${project.build.directory}/jboss-6.0.0.20100429-M3/client/jbossws-native-client.jar</additionalClasspathElement>
+ <additionalClasspathElement>${project.build.directory}/jboss-6.0.0.20100429-M3/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=${project.build.directory}/jboss-6.0.0.20100429-M3/lib/endorsed -Djboss.home=${project.build.directory}/jboss-6.0.0.20100429-M3 -Djboss.boot.server.log.dir=${project.build.directory}/jboss-6.0.0.20100429-M3</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>process-test-classes</phase> <!-- So run before testing -->
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-distribution</artifactId>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>integration</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-60</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.framework</groupId>
+ <artifactId>arquillian-framework-jsfunit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
View
39 jsf/src/main/java/com/acme/jsf/RequestScopeBean.java
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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 com.acme.jsf;
+
+import javax.enterprise.context.RequestScoped;
+import javax.faces.bean.ManagedBean;
+
+
+/**
+ *
+ * @author Stan Silvert
+ * @since 1.0
+ */
+@ManagedBean(name="requestBean")
+@RequestScoped
+public class RequestScopeBean extends ScopeAwareBean
+{
+
+}
View
39 jsf/src/main/java/com/acme/jsf/ScopeAwareBean.java
@@ -0,0 +1,39 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.acme.jsf;
+
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ *
+ * @author ssilvert
+ */
+public class ScopeAwareBean {
+
+ @SuppressWarnings("unchecked")
+ public String getScope()
+ {
+ FacesContext facesCtx = FacesContext.getCurrentInstance();
+ ExternalContext extCtx = facesCtx.getExternalContext();
+
+ Map scopeMap = extCtx.getRequestMap();
+ if (scopeMap.containsValue(this)) return "request";
+
+ scopeMap = facesCtx.getViewRoot().getViewMap();
+ if (scopeMap.containsValue(this)) return "view";
+
+ scopeMap = extCtx.getSessionMap();
+ if (scopeMap.containsValue(this)) return "session";
+
+ scopeMap = extCtx.getApplicationMap();
+ if (scopeMap.containsValue(this)) return "application";
+
+ return "unknown";
+ }
+}
View
83 jsf/src/test/java/com/acme/jsf/JSFUnitTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.acme.jsf;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.jsfunit.framework.Environment;
+import org.jboss.jsfunit.jsfsession.JSFServerSession;
+import org.jboss.jsfunit.jsfsession.JSFSession;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * JSFUnitTestCase
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@RunWith(Arquillian.class)
+public class JSFUnitTestCase
+{
+ @Deployment
+ public static WebArchive createDeployment()
+ {
+ return ShrinkWrap.create("test.war", WebArchive.class)
+ .addClasses(
+ RequestScopeBean.class,
+ ScopeAwareBean.class)
+ .setWebXML("jsf/jsf-web.xml")
+ .addResource("jsf/index.xhtml", "index.xhtml")
+ .addWebResource("jsf/faces-config.xml", "faces-config.xml")
+ .addWebResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void shouldExecutePage() throws Exception
+ {
+ JSFSession jsfSession = new JSFSession("/index.jsf");
+
+ Assert.assertTrue(Environment.is12Compatible());
+ Assert.assertTrue(Environment.is20Compatible());
+ Assert.assertEquals(2, Environment.getJSFMajorVersion());
+ Assert.assertEquals(0, Environment.getJSFMinorVersion());
+
+ JSFServerSession server = jsfSession.getJSFServerSession();
+
+ Assert.assertEquals("request", server.getManagedBeanValue("#{requestBean.scope}"));
+ }
+
+ @Test
+ public void shouldExecutePage2() throws Exception
+ {
+ JSFSession jsfSession = new JSFSession("/index.jsf");
+
+ Assert.assertTrue(Environment.is12Compatible());
+ Assert.assertTrue(Environment.is20Compatible());
+ Assert.assertEquals(2, Environment.getJSFMajorVersion());
+ Assert.assertEquals(0, Environment.getJSFMinorVersion());
+
+ JSFServerSession server = jsfSession.getJSFServerSession();
+
+ Assert.assertEquals("request", server.getManagedBeanValue("#{requestBean.scope}"));
+ }
+}
View
10 jsf/src/test/resources/arquillian.xml
@@ -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>
View
3  jsf/src/test/resources/jndi.properties
@@ -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
View
41 jsf/src/test/resources/jsf/faces-config.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+
+ <!--
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.
+ -->
+
+<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">
+
+
+ <factory>
+ <faces-context-factory>org.jboss.jsfunit.context.JSFUnitFacesContextFactory</faces-context-factory>
+ </factory>
+
+ <application>
+ <variable-resolver>org.jboss.jsfunit.seam.ConversationScopeVariableResolver</variable-resolver>
+ </application>
+
+
+</faces-config>
View
18 jsf/src/test/resources/jsf/index.xhtml
@@ -0,0 +1,18 @@
+<!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">
+<body>
+
+ <center>
+ <f:view>
+ <h2><h:outputText value="JSF2 Sample Application"/></h2>
+ <h3><h:outputText value="Test Managed Bean Annotations"/></h3>
+ <h:outputText value="requestBean.scope = #{requestBean.scope}"/><br/>
+ <h3><h:outputText value="Test Project Stage"/></h3>
+ <h:outputText value="project stage = #{facesContext.application.projectStage}"/>
+ </f:view>
+
+ </center>
+</body>
+</html>
View
29 jsf/src/test/resources/jsf/jsf-web.xml
@@ -0,0 +1,29 @@
+<?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>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</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>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.xhtml</welcome-file>
+ </welcome-file-list>
+</web-app>
View
1  pom.xml
@@ -23,6 +23,7 @@
<module>ejb</module>
<module>jms</module>
<module>jaxrs</module>
+ <module>jsf</module>
<module>profiles</module>
</modules>
View
BIN  presentations/Arquillian_JUDCon-2010.pdf
Binary file not shown
View
2  profiles/pom.xml
@@ -79,7 +79,7 @@
<dependency>
<groupId>org.jboss.arquillian.framework</groupId>
<artifactId>arquillian-framework-jsfunit</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>${version.arquillian}</version>
<scope>test</scope>
</dependency>
Please sign in to comment.
Something went wrong with that request. Please try again.