Skip to content

Commit

Permalink
Added RepeatedDrone tests and OpenShift container
Browse files Browse the repository at this point in the history
  • Loading branch information
kpiwko committed Feb 14, 2012
1 parent 53772e5 commit 45e8b1e
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 32 deletions.
71 changes: 71 additions & 0 deletions drone-demo/pom.xml
Expand Up @@ -350,6 +350,60 @@
</dependencies>
</profile>

<profile>
<id>repeated-drone-execution</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/RepeatedDroneTest*</include>
</includes>
</configuration>
<executions>
<execution>
<id>default-test</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>firefox8</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
<configuration>
<systemPropertyVariables>
<arquillian.xml>arquillian-ff9.xml</arquillian.xml>
<reportNameSuffix>ff9</reportNameSuffix>
</systemPropertyVariables>
</configuration>
</execution>
<execution>
<id>chrome17</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
<configuration>
<systemPropertyVariables>
<arquillian.xml>arquillian-ch17.xml</arquillian.xml>
<reportNameSuffix>ch17</reportNameSuffix>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
Expand All @@ -366,8 +420,25 @@
<warName>ROOT</warName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<arquillian.launch>openshift</arquillian.launch>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-openshift-express</artifactId>
<version>1.0.0.Alpha1</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

</profiles>
Expand Down
46 changes: 46 additions & 0 deletions drone-demo/src/test/java/com/acme/example/test/AjocadoTest.java
@@ -0,0 +1,46 @@
package com.acme.example.test;

import static org.jboss.arquillian.ajocado.Ajocado.guardXhr;
import static org.jboss.arquillian.ajocado.Ajocado.id;

import java.net.URL;

import org.jboss.arquillian.ajocado.framework.AjaxSelenium;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.MavenImporter;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class AjocadoTest {

@ArquillianResource
URL contextPath;

@Deployment(testable = false)
public static Archive<?> getApplicationDeployment() {
return ShrinkWrap.create(MavenImporter.class).loadEffectivePom("pom.xml").importBuildOutput().as(WebArchive.class);
}

@Test
public void xhrAjocadoTest(@Drone AjaxSelenium ajocado) {
ajocado.open(contextPath);

ajocado.type(id("name"), "Samuel Vimes");
ajocado.type(id("email"), "samuel@vimes.dw");
ajocado.type(id("phoneNumber"), "1234567890");

// see the guard? we are waiting for an XHR request here
guardXhr(ajocado).click(id("register"));

Assert.assertTrue("Vimes was registered", ajocado.isTextPresent("Samuel Vimes"));
}

}
15 changes: 0 additions & 15 deletions drone-demo/src/test/java/com/acme/example/test/Chrome1.java

This file was deleted.

15 changes: 0 additions & 15 deletions drone-demo/src/test/java/com/acme/example/test/Chrome2.java

This file was deleted.

@@ -0,0 +1,43 @@
package com.acme.example.test;

import java.net.URL;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.MavenImporter;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

@RunWith(Arquillian.class)
public class RepeatedDroneTest {

@ArquillianResource
URL contextPath;

@Deployment(testable = false)
public static Archive<?> getApplicationDeployment() {
return ShrinkWrap.create(MavenImporter.class).loadEffectivePom("pom.xml").importBuildOutput().as(WebArchive.class);
}

@Test
public void simpleWebdriverTest(@Drone WebDriver webdriver) {
webdriver.get(contextPath.toString());

webdriver.findElement(By.id("name")).sendKeys("Samuel");
webdriver.findElement(By.id("email")).sendKeys("samuel@vimes.dw");
webdriver.findElement(By.id("phoneNumber")).sendKeys("1234567890");
webdriver.findElement(By.id("register")).submit();

// FIXME with Ajocado, you can wait for a request
Assert.assertTrue(true);
}

}
28 changes: 28 additions & 0 deletions drone-demo/src/test/resources/arquillian-ch17.xml
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<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> -->

<!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->
<defaultProtocol type="Servlet 3.0" />

<!-- Example configuration for a remote JBoss AS 7 instance -->
<container qualifier="jboss" default="true">
<!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property -->
<configuration>
<property name="jbossHome">/home/kpiwko/jboss-as-7.1.0.CR1b</property>
</configuration>
</container>

<extension qualifier="webdriver">
<property name="implementationClass">org.openqa.selenium.chrome.ChromeDriver</property>
<property name="chromeBinary">/opt/google/chrome/chrome</property>
<property name="chromeSwitches">--user-data-dir=/tmp --disable-web-security</property>
</extension>

</arquillian>
27 changes: 27 additions & 0 deletions drone-demo/src/test/resources/arquillian-ff9.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<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> -->

<!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->
<defaultProtocol type="Servlet 3.0" />

<!-- Example configuration for a remote JBoss AS 7 instance -->
<container qualifier="jboss" default="true">
<!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property -->
<configuration>
<property name="jbossHome">/home/kpiwko/jboss-as-7.1.0.CR1b</property>
</configuration>
</container>

<extension qualifier="webdriver">
<property name="implementationClass">org.openqa.selenium.firefox.FirefoxDriver</property>
<property name="firefoxBinary">/opt/firefox-9.0.1/firefox-bin</property>
</extension>

</arquillian>
15 changes: 13 additions & 2 deletions drone-demo/src/test/resources/arquillian.xml
Expand Up @@ -15,7 +15,18 @@
<container qualifier="jboss" default="true">
<!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property -->
<configuration>
<property name="jbossHome">/path/to/jboss/as</property>
<property name="jbossHome">/home/kpiwko/jboss-as-7.1.0.CR1b</property>
</configuration>
</container>

<container qualifier="openshift">
<configuration>
<property name="namespace">arqtest</property>
<property name="application">drone</property>
<property name="sshUserName">2a15cbe193da441f9f3a9aa4039695b1</property>
<!-- Passphrase can be specified by defining the environment variable SSH_PASSPHRASE -->
<!-- <property name="passphrase"></property> -->
<property name="login">kpiwko@redhat.com</property>
</configuration>
</container>

Expand All @@ -32,4 +43,4 @@
<property name="chromeSwitches">--user-data-dir=/tmp --disable-web-security</property>
</extension>

</arquillian>
</arquillian>

0 comments on commit 45e8b1e

Please sign in to comment.