Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Property changes on: frameworks
- ___________________________________________________________________
- Added: svn:ignore
- + .classpath
- .project
- .settings
- target
- Property changes on: frameworks/jsfunit
- ___________________________________________________________________
- Added: svn:ignore
- + .classpath
- .project
- .settings
- target
- Index: frameworks/jsfunit/src/main/java/org/jboss/arquillian/framework/jsfunit/JSFUnitPackager.java
- ===================================================================
- --- frameworks/jsfunit/src/main/java/org/jboss/arquillian/framework/jsfunit/JSFUnitPackager.java (revision 0)
- +++ frameworks/jsfunit/src/main/java/org/jboss/arquillian/framework/jsfunit/JSFUnitPackager.java (revision 0)
- @@ -0,0 +1,52 @@
- +/*
- + * 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 org.jboss.arquillian.framework.jsfunit;
- +
- +import java.util.Collection;
- +
- +import org.jboss.arquillian.spi.DeploymentPackager;
- +import org.jboss.shrinkwrap.api.Archive;
- +import org.jboss.shrinkwrap.api.spec.WebArchive;
- +
- +/**
- + * JSFUnitPackager
- + *
- + * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
- + * @version $Revision: $
- + */
- +public class JSFUnitPackager implements DeploymentPackager
- +{
- +
- + /* (non-Javadoc)
- + * @see org.jboss.arquillian.spi.DeploymentPackager#generateDeployment(org.jboss.shrinkwrap.api.Archive, java.util.Collection)
- + */
- + @Override
- + public Archive<?> generateDeployment(Archive<?> applicationArchive, Collection<Archive<?>> auxiliaryArchives)
- + {
- + if(WebArchive.class.isInstance(applicationArchive))
- + {
- + WebArchive applicationWebArchive = WebArchive.class.cast(applicationArchive);
- + applicationWebArchive.addLibraries(auxiliaryArchives.toArray(new Archive[0]));
- +
- + return applicationWebArchive;
- + }
- + throw new RuntimeException(
- + "Only ApplicatonArchives of type " + WebArchive.class.getName() + " are supported by the JSFUnitPackager, " +
- + "ApplicationArchive is of type " + applicationArchive.getClass().getName());
- + }
- +
- +}
- Index: frameworks/jsfunit/src/main/java/org/jboss/arquillian/framework/jsfunit/JSFUnitArchiveAppender.java
- ===================================================================
- --- frameworks/jsfunit/src/main/java/org/jboss/arquillian/framework/jsfunit/JSFUnitArchiveAppender.java (revision 0)
- +++ frameworks/jsfunit/src/main/java/org/jboss/arquillian/framework/jsfunit/JSFUnitArchiveAppender.java (revision 0)
- @@ -0,0 +1,69 @@
- +/*
- + * 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 org.jboss.arquillian.framework.jsfunit;
- +
- +import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
- +
- +import org.jboss.shrinkwrap.api.Archive;
- +import org.jboss.shrinkwrap.api.Archives;
- +import org.jboss.shrinkwrap.api.spec.JavaArchive;
- +
- +
- +/**
- + * JSFUnitArchiveAppender
- + *
- + * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
- + * @version $Revision: $
- + */
- +public class JSFUnitArchiveAppender implements AuxiliaryArchiveAppender
- +{
- +
- + /* (non-Javadoc)
- + * @see org.jboss.arquillian.spi.AuxiliaryArchiveAppender#createAuxiliaryArchive()
- + */
- + @Override
- + public Archive<?> createAuxiliaryArchive()
- + {
- + return Archives.create("arquillian-jsfunit.jar", JavaArchive.class)
- + .addPackages(
- + true,
- + org.jboss.jsfunit.jsfsession.JSFSession.class.getPackage(),
- + org.jboss.jsfunit.framework.WebClientSpec.class.getPackage(),
- + org.jboss.jsfunit.context.JSFUnitFacesContext.class.getPackage(),
- + org.jboss.jsfunit.seam.SeamUtil.class.getPackage(),
- + com.gargoylesoftware.htmlunit.BrowserVersion.class.getPackage(),
- + org.apache.commons.codec.Decoder.class.getPackage(),
- + org.apache.commons.httpclient.HttpClient.class.getPackage(),
- + org.apache.commons.io.IOUtils.class.getPackage(),
- + org.apache.commons.lang.StringUtils.class.getPackage(),
- + net.sourceforge.htmlunit.corejs.javascript.EvaluatorException.class.getPackage(),
- + org.w3c.css.sac.CSSException.class.getPackage(),
- + com.steadystate.css.dom.CSSOMObject.class.getPackage(),
- + org.cyberneko.html.HTMLComponent.class.getPackage())
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/FF2.properties")
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/FF3.properties")
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/IE6.properties")
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/IE7.properties")
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/IE8.properties")
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml")
- + .addResource("com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xsd")
- + .addManifestResource("faces-config.xml")
- + .addManifestResource("web-fragment.xml");
- +
- + }
- +
- +}
- Index: frameworks/jsfunit/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
- ===================================================================
- --- frameworks/jsfunit/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender (revision 0)
- +++ frameworks/jsfunit/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender (revision 0)
- @@ -0,0 +1 @@
- +org.jboss.arquillian.framework.jsfunit.JSFUnitArchiveAppender
- \ No newline at end of file
- Index: frameworks/jsfunit/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager
- ===================================================================
- --- frameworks/jsfunit/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager (revision 0)
- +++ frameworks/jsfunit/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager (revision 0)
- @@ -0,0 +1 @@
- +org.jboss.arquillian.framework.jsfunit.JSFUnitPackager
- \ No newline at end of file
- Index: frameworks/jsfunit/src/main/resources/faces-config.xml
- ===================================================================
- --- frameworks/jsfunit/src/main/resources/faces-config.xml (revision 0)
- +++ frameworks/jsfunit/src/main/resources/faces-config.xml (revision 0)
- @@ -0,0 +1,16 @@
- +<?xml version="1.0"?>
- +<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>
- Index: frameworks/jsfunit/src/main/resources/web-fragment.xml
- ===================================================================
- --- frameworks/jsfunit/src/main/resources/web-fragment.xml (revision 0)
- +++ frameworks/jsfunit/src/main/resources/web-fragment.xml (revision 0)
- @@ -0,0 +1,31 @@
- +<web-fragment 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-fragment_3_0.xsd"
- + version="3.0">
- +
- + <filter>
- + <filter-name>JSFUnitFilter</filter-name>
- + <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class>
- + </filter>
- +
- + <filter-mapping>
- + <filter-name>JSFUnitFilter</filter-name>
- + <url-pattern>/ArquillianServletRunner</url-pattern>
- + </filter-mapping>
- +
- +<!--
- + <servlet>
- + <servlet-name>JSFUnit Faces Servlet</servlet-name>
- + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
- + </servlet>
- +
- + <servlet-mapping>
- + <servlet-name>JSFUnit Faces Servlet</servlet-name>
- + <url-pattern>*.jsfunit</url-pattern>
- + </servlet-mapping>
- +
- + <welcome-file-list>
- + <welcome-file>jsfunit/index.html</welcome-file>
- + </welcome-file-list>
- + -->
- +</web-fragment>
- \ No newline at end of file
- Index: frameworks/jsfunit/pom.xml
- ===================================================================
- --- frameworks/jsfunit/pom.xml (revision 0)
- +++ frameworks/jsfunit/pom.xml (revision 0)
- @@ -0,0 +1,85 @@
- +<?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">
- +
- + <!-- Parent -->
- + <parent>
- + <groupId>org.jboss.arquillian</groupId>
- + <artifactId>arquillian-build</artifactId>
- + <version>1.0.0-SNAPSHOT</version>
- + <relativePath>../build/pom.xml</relativePath>
- + </parent>
- +
- + <!-- Model Version -->
- + <modelVersion>4.0.0</modelVersion>
- +
- + <!-- Artifact Configuration -->
- + <groupId>org.jboss.arquillian.framework</groupId>
- + <artifactId>arquillian-framework-jsfunit</artifactId>
- + <name>Arquillian Framework JSFUnit</name>
- + <description>JSFUnit integration for the Arquillian project</description>
- +
- +
- + <!-- Properties -->
- + <properties>
- +
- +
- + </properties>
- +
- + <!-- Dependencies -->
- + <dependencies>
- +
- + <!--
- + org.jboss.arquillian
- + -->
- + <dependency>
- + <groupId>org.jboss.arquillian</groupId>
- + <artifactId>arquillian-spi</artifactId>
- + <version>${project.version}</version>
- + </dependency>
- +
- + <dependency>
- + <groupId>org.jboss.shrinkwrap</groupId>
- + <artifactId>shrinkwrap-impl-base</artifactId>
- + </dependency>
- + <dependency>
- + <groupId>org.jboss.shrinkwrap</groupId>
- + <artifactId>shrinkwrap-spi</artifactId>
- + </dependency>
- +
- + <!--
- + org.jboss.jsfunit
- + -->
- +
- + <dependency>
- + <groupId>org.jboss.jsfunit</groupId>
- + <artifactId>jboss-jsfunit-core</artifactId>
- + <version>1.2.0.Final</version>
- + <scope>compile</scope>
- + </dependency>
- +
- + <!--
- + External Projects
- + -->
- +
- + <dependency>
- + <groupId>jboss.web</groupId>
- + <artifactId>servlet-api</artifactId>
- + <version>3.0.0.alpha-25</version>
- + <scope>provided</scope>
- + </dependency>
- +
- +
- + <dependency>
- + <groupId>junit</groupId>
- + <artifactId>junit</artifactId>
- + <scope>test</scope>
- + </dependency>
- +
- + </dependencies>
- +
- +</project>
- +
- Index: frameworks/pom.xml
- ===================================================================
- --- frameworks/pom.xml (revision 0)
- +++ frameworks/pom.xml (revision 0)
- @@ -0,0 +1,33 @@
- +<?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">
- +
- + <!-- Parent -->
- + <parent>
- + <groupId>org.jboss.arquillian</groupId>
- + <artifactId>arquillian-parent</artifactId>
- + <version>1.0.0-SNAPSHOT</version>
- + </parent>
- +
- + <!-- Model Information -->
- + <modelVersion>4.0.0</modelVersion>
- +
- + <!-- Artifact Information -->
- + <groupId>org.jboss.arquillian.framework</groupId>
- + <artifactId>arquillian-framework-parent</artifactId>
- + <packaging>pom</packaging>
- + <name>Arguillian Framework Aggregator</name>
- + <url>http://www.jboss.org</url>
- + <description>Arguillian Framework Aggregator</description>
- +
- + <!-- Aggregate Modules -->
- + <modules>
- +
- + <module>jsfunit</module>
- +
- + </modules>
- +
- +</project>
- Index: protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java
- ===================================================================
- --- protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java (revision 4178)
- +++ protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java (working copy)
- @@ -19,6 +19,7 @@
- import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
- import org.jboss.shrinkwrap.api.Archive;
- import org.jboss.shrinkwrap.api.Archives;
- +import org.jboss.shrinkwrap.api.spec.JavaArchive;
- import org.jboss.shrinkwrap.api.spec.WebArchive;
- /**
- @@ -39,12 +40,21 @@
- @Override
- public Archive<?> createAuxiliaryArchive()
- {
- + JavaArchive archive = Archives.create("arquillian-protocol.jar", JavaArchive.class)
- + .addClasses(
- + SecurityActions.class,
- + ServletTestRunner.class
- + )
- + .addManifestResource("org/jboss/arquillian/protocol/servlet/web-fragment.xml", "web-fragment.xml");
- +
- + /*
- WebArchive archive = Archives.create("arquillian-protocol.war", WebArchive.class)
- .setWebXML("org/jboss/arquillian/protocol/servlet/web.xml")
- .addClasses(
- SecurityActions.class,
- ServletTestRunner.class
- );
- + */
- return archive;
- }
- Index: protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java
- ===================================================================
- --- protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java (revision 4178)
- +++ protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java (working copy)
- @@ -49,7 +49,7 @@
- }
- Class<?> testClass = testMethodExecutor.getInstance().getClass();
- - String url = baseURL.toExternalForm() + "arquillian-protocol/" +
- + String url = baseURL.toExternalForm() + "test/ArquillianServletRunner" +
- "?outputMode=serializedObject&className=" + testClass.getName() +
- "&methodName=" + testMethodExecutor.getMethod().getName();
- Index: protocols/servlet/src/main/resources/org/jboss/arquillian/protocol/servlet/web.xml
- ===================================================================
- --- protocols/servlet/src/main/resources/org/jboss/arquillian/protocol/servlet/web.xml (revision 4178)
- +++ protocols/servlet/src/main/resources/org/jboss/arquillian/protocol/servlet/web.xml (working copy)
- @@ -1,5 +1,10 @@
- -<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
- -<web-app version="2.4">
- +<?xml version="1.0" encoding="UTF-8"?>
- +<web-app version="2.5"
- + 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">
- +
- <display-name>Arquillian</display-name>
- <servlet>
- <servlet-name>ServletTestRunner</servlet-name>
- @@ -7,6 +12,6 @@
- </servlet>
- <servlet-mapping>
- <servlet-name>ServletTestRunner</servlet-name>
- - <url-pattern>/*</url-pattern>
- + <url-pattern>/ArquillianServletRunner</url-pattern>
- </servlet-mapping>
- </web-app>
- \ No newline at end of file
- Index: protocols/servlet/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml
- ===================================================================
- --- protocols/servlet/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml (revision 0)
- +++ protocols/servlet/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml (revision 0)
- @@ -0,0 +1,16 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +<web-fragment version="3.0"
- + 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-fragment_3_0.xsd">
- +
- + <servlet>
- + <servlet-name>ServletTestRunner</servlet-name>
- + <servlet-class>org.jboss.arquillian.protocol.servlet.ServletTestRunner</servlet-class>
- + </servlet>
- + <servlet-mapping>
- + <servlet-name>ServletTestRunner</servlet-name>
- + <url-pattern>/ArquillianServletRunner</url-pattern>
- + </servlet-mapping>
- +</web-fragment>
- \ No newline at end of file
- Index: examples/junit/src/test/java/com/acme/jsf/JSFUnitTestCase.java
- ===================================================================
- --- examples/junit/src/test/java/com/acme/jsf/JSFUnitTestCase.java (revision 0)
- +++ examples/junit/src/test/java/com/acme/jsf/JSFUnitTestCase.java (revision 0)
- @@ -0,0 +1,84 @@
- +/*
- + * 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.Archives;
- +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 Archives.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}"));
- + }
- +}
- Index: examples/junit/src/main/java/com/acme/jsf/ScopeAwareBean.java
- ===================================================================
- --- examples/junit/src/main/java/com/acme/jsf/ScopeAwareBean.java (revision 0)
- +++ examples/junit/src/main/java/com/acme/jsf/ScopeAwareBean.java (revision 0)
- @@ -0,0 +1,33 @@
- +package com.acme.jsf;
- +
- +import java.util.Map;
- +
- +import javax.faces.context.ExternalContext;
- +import javax.faces.context.FacesContext;
- +
- +/**
- + *
- + * @author ssilvert
- + */
- +public class ScopeAwareBean {
- +
- + 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";
- + }
- +}
- Index: examples/junit/src/main/java/com/acme/jsf/RequestScopeBean.java
- ===================================================================
- --- examples/junit/src/main/java/com/acme/jsf/RequestScopeBean.java (revision 0)
- +++ examples/junit/src/main/java/com/acme/jsf/RequestScopeBean.java (revision 0)
- @@ -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
- +{
- +
- +}
- Index: examples/junit/src/main/resources/jsf/index.xhtml
- ===================================================================
- --- examples/junit/src/main/resources/jsf/index.xhtml (revision 0)
- +++ examples/junit/src/main/resources/jsf/index.xhtml (revision 0)
- @@ -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>
- Index: examples/junit/src/main/resources/jsf/faces-config.xml
- ===================================================================
- --- examples/junit/src/main/resources/jsf/faces-config.xml (revision 0)
- +++ examples/junit/src/main/resources/jsf/faces-config.xml (revision 0)
- @@ -0,0 +1,32 @@
- +<?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">
- +
- +
- +</faces-config>
- Index: examples/junit/src/main/resources/jsf/jsf-web.xml
- ===================================================================
- --- examples/junit/src/main/resources/jsf/jsf-web.xml (revision 0)
- +++ examples/junit/src/main/resources/jsf/jsf-web.xml (revision 0)
- @@ -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>
- Index: examples/junit/pom.xml
- ===================================================================
- --- examples/junit/pom.xml (revision 4178)
- +++ examples/junit/pom.xml (working copy)
- @@ -223,7 +223,23 @@
- <version>${project.version}</version>
- </dependency>
- + <!-- JSF Setup TEST -->
- +
- <dependency>
- + <groupId>org.jboss.arquillian.framework</groupId>
- + <artifactId>arquillian-framework-jsfunit</artifactId>
- + <version>${project.version}</version>
- + </dependency>
- +
- + <dependency>
- + <groupId>javax.faces</groupId>
- + <artifactId>jsf-api</artifactId>
- + <version>2.0.2-FCS</version>
- + <scope>provided</scope>
- + </dependency>
- +
- +
- + <dependency>
- <groupId>org.jboss.arquillian.example</groupId>
- <artifactId>arquillian-example-domain</artifactId>
- <version>${project.version}</version>
- @@ -259,8 +275,14 @@
- <version>1.4.1</version>
- <scope>test</scope>
- </dependency>
- -
- +
- <dependency>
- + <groupId>org.jboss.shrinkwrap</groupId>
- + <artifactId>shrinkwrap-extension-classmanipulation</artifactId>
- + <scope>test</scope>
- + </dependency>
- +
- + <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- Index: pom.xml
- ===================================================================
- --- pom.xml (revision 4178)
- +++ pom.xml (working copy)
- @@ -59,7 +59,9 @@
- <module>containers</module>
- <module>examples</module>
- -
- +
- + <module>frameworks</module>
- +
- <module>doc/reference</module>
- </modules>
- Index: examples/junit/pom.xml
- ===================================================================
- --- examples/junit/pom.xml (revision 4178)
- +++ examples/junit/pom.xml (working copy)
- @@ -223,7 +223,23 @@
- <version>${project.version}</version>
- </dependency>
- + <!-- JSF Setup TEST -->
- +
- <dependency>
- + <groupId>org.jboss.arquillian.framework</groupId>
- + <artifactId>arquillian-framework-jsfunit</artifactId>
- + <version>${project.version}</version>
- + </dependency>
- +
- + <dependency>
- + <groupId>javax.faces</groupId>
- + <artifactId>jsf-api</artifactId>
- + <version>2.0.2-FCS</version>
- + <scope>provided</scope>
- + </dependency>
- +
- +
- + <dependency>
- <groupId>org.jboss.arquillian.example</groupId>
- <artifactId>arquillian-example-domain</artifactId>
- <version>${project.version}</version>
- @@ -259,8 +275,14 @@
- <version>1.4.1</version>
- <scope>test</scope>
- </dependency>
- -
- +
- <dependency>
- + <groupId>org.jboss.shrinkwrap</groupId>
- + <artifactId>shrinkwrap-extension-classmanipulation</artifactId>
- + <scope>test</scope>
- + </dependency>
- +
- + <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement