Skip to content
Permalink
Browse files

added ClientTest using JSFUnit.NG

  • Loading branch information...
lfryc committed Apr 30, 2012
1 parent f8890e4 commit df75351ca83540f272424ebd2739605ad7a56f43
@@ -24,6 +24,9 @@
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<version.arquillian.core>1.0.0.Final</version.arquillian.core>
<version.arquillian.drone>1.0.0.Final</version.arquillian.drone>
</properties>

<repositories>
@@ -75,6 +78,24 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Arquillian dependencies -->
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.arquillian.core}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Arquillian Drone dependencies and Selenium dependencies -->
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-bom</artifactId>
<version>${version.arquillian.drone}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

</dependencies>
</dependencyManagement>
@@ -116,6 +137,40 @@
<artifactId>richfaces-components-ui</artifactId>
</dependency>

<!-- JSFUnit.NG -->
<dependency>
<groupId>jsfunitng</groupId>
<artifactId>jsfunitng</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<!-- Arquillian Graphene -->
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>test</scope>
</dependency>

<!-- Arquillian JUnit -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>

<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>



</dependencies>

<build>
@@ -140,6 +195,26 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jbossas-remote-7</id>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
<version>7.1.1.Final</version>
</dependency>
</dependencies>
</profile>
</profiles>

</project>

@@ -0,0 +1,94 @@
/**
JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. 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.
*/
import java.io.File;
import java.net.URL;

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;
import org.jboss.arquillian.warp.ClientAction;
import org.jboss.arquillian.warp.ServerAssertion;
import org.jboss.arquillian.warp.Warp;
import org.jboss.arquillian.warp.jsf.AfterPhase;
import org.jboss.arquillian.warp.jsf.BeforePhase;
import org.jboss.arquillian.warp.jsf.Phase;
import org.jboss.arquillian.warp.test.BeforeServlet;
import org.jboss.as.quickstarts.jsf.RichBean;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.remote.RemoteWebDriver;

@RunWith(Arquillian.class)
public class ClientTest {

@Drone
RemoteWebDriver browser;

@ArquillianResource
URL contextPath;

@Deployment
public static WebArchive createDeployment() {

return ShrinkWrap.create(WebArchive.class, "jsf-test.war").addClasses(RichBean.class)
.addAsWebResource(new File("src/main/webapp/index.xhtml"))
.addAsWebResource(new File("src/main/webapp/templates/template.xhtml"), "templates/template.xhtml")
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"));
}

@Test
@RunAsClient
public void test() {
Warp.execute(new ClientAction() {
public void action() {
browser.navigate().to(contextPath + "index.jsf");
}
}).verify(new JsfAssertion());

}

@SuppressWarnings("serial")
public static class JsfAssertion implements ServerAssertion {

@BeforeServlet
public void test() {
System.out.println("before servlet");
}

@BeforePhase(Phase.RENDER_RESPONSE)
public void beforeRender() {
System.out.println("before render");

}

@AfterPhase(Phase.RENDER_RESPONSE)
public void afterRender() {
System.out.println("after render");

}

}
}
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<container qualifier="jbossas-7-remote" default="true">
</container>



<extension qualifier="graphene">
</extension>

<engine>
<property name="deploymentExportPath">target/</property>
</engine>

</arquillian>

0 comments on commit df75351

Please sign in to comment.
You can’t perform that action at this time.