Skip to content

Commit

Permalink
Added example test project for ARQ-1577
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Miklosovic committed Nov 21, 2013
1 parent b349ffd commit 074e45d
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/droidium-multiple-containers-03/README.adoc
@@ -0,0 +1,20 @@
== Arquillian Droidium multiple containers test

Tests scenario when you have JBoss container on class path and Android container on classpath
and both are specified in arquillian.xml and there is Drone on classpath as well with
webdriver extensions in arquillian.xml but no extension is asking for "android" browser
so it is not necessary to start Android container at all.

This example is related to issue https://issues.jboss.org/browse/ARQ-1577[ARQ-1577]

To execute the test:

`mvn clean test`

JBoss AS container is automatically downloaded for you into `target` so you do not have to
manage your JBoss instance on your own. Please be sure there is not any JBoss AS container already
running before execution of tests.

This project can be run in a headless mode as well, typically in a CI service like Cloudbees.
You are obliged to activate headless profile with `-Pheadless`. It adds the following switches to `emulator` command
upon its start: `-no-skin -no-audio -no-window -nocache -no-snapshot-save -no-snapstorage`.
255 changes: 255 additions & 0 deletions tests/droidium-multiple-containers-03/pom.xml
@@ -0,0 +1,255 @@
<?xml version="1.0"?>
<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc.
and/or its affiliates, 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. -->
<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 version -->
<modelVersion>4.0.0</modelVersion>

<!-- Arfitact configuration -->
<groupId>org.arquillian.droidium.tests</groupId>
<artifactId>arquillian-droidium-multiple-containers-test-03</artifactId>
<version>1.0.0.Alpha3-SNAPSHOT</version>

<description>Shows configuration of multiple container adapters on classpath</description>

<!-- Properties -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<version.shrinkwrap_shrinkwrap>1.2.0</version.shrinkwrap_shrinkwrap>
<version.arquillian.core>1.1.2.Final</version.arquillian.core>
<version.arquillian.drone>1.2.0.Final</version.arquillian.drone>

<version.junit>4.8.1</version.junit>
<version.org.jboss.as>7.1.1.Final</version.org.jboss.as>

<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>

<android.avd.name>testingEmulator</android.avd.name>
<android.emulator.options></android.emulator.options>
</properties>

<!-- Dependency Management -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-bom</artifactId>
<version>${version.shrinkwrap_shrinkwrap}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.arquillian.core}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-webdriver-depchain</artifactId>
<version>${version.arquillian.drone}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>${version.org.jboss.as}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.arquillian.container</groupId>
<artifactId>arquillian-droidium-container</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>${version.junit}</version>
</dependency>
</dependencies>
</dependencyManagement>

<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-webdriver-depchain</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.arquillian.container</groupId>
<artifactId>arquillian-droidium-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<!-- Build -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>process-test-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.1,)
</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<!-- Unpacks JBoss AS to target -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>${version.org.jboss.as}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<!-- Profiles -->
<profiles>
<profile>
<!-- Activate this profile when you want to run in headless mode -->
<id>headless</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>

<!-- Properties -->
<properties>
<android.emulator.options>
-no-skin -no-audio -no-window -nocache -no-snapshot-save -no-snapstorage
</android.emulator.options>
</properties>
</profile>
</profiles>

</project>
@@ -0,0 +1,25 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.arquillian.droidium.showcase.classes;

/**
* @author <a href="mailto:smikloso@redhat.com">Stefan Miklosovic</a>
*
*/
public class Foo {

}
@@ -0,0 +1,56 @@
/**
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.arquillian.droidium.showcase.multiple.test03;

import org.arquillian.droidium.showcase.classes.Foo;
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.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

/**
* Proof of concept test for showing multiple containers on classpath.
*
* @author <a href="mailto:smikloso@redhat.com">Stefan Miklosovic</a>
*
*/
@RunWith(Arquillian.class)
@RunAsClient
public class MultipleContainersTestCase {

// this asks for firefox browser
@Drone
WebDriver browser;

@Deployment(name = "jbossas") // only one container will be started so we can omit @TargetsContainer
public static Archive<?> createJBossASDeployment() {
return ShrinkWrap.create(JavaArchive.class, "jbossas.jar").addClass(Foo.class);
}

@Test
public void test01() {
Assert.assertNotNull(browser);
}

}

0 comments on commit 074e45d

Please sign in to comment.