Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds junit5 vintage example using arquillian rules #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions junit5-vintage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.jboss.arquillian.showcase</groupId>
<artifactId>arquillian-showcase-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>arquillian-showcase-junit5-vintage</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.java>1.8</version.java>
<version.junit>4.12</version.junit>
<version.junit.vintage>${version.junit}.2</version.junit.vintage>
<version.junit.platform>1.0.2</version.junit.platform>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${version.java}</source>
<target>${version.java}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
<include>**/*TestCase.java</include>
</includes>
<properties>
<!-- <includeTags>fast</includeTags> -->
<excludeTags>slow</excludeTags>
<!--
<configurationParameters>
junit.jupiter.conditions.deactivate = *
</configurationParameters>
-->
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${version.junit.platform}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>

<!-- Only required to run tests in an IDE that bundles an older version -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${version.junit.vintage}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${version.arquillian_core}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-web-6.0</artifactId>
<type>pom</type>
</dependency>


</dependencies>

<profiles>
<profile>
<id>wildfly-managed</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${version.arquillian_container_wildfly}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${version.org.wildfly}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>wildfly-embedded</id>

<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<version>${version.arquillian_container_wildfly}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${version.org.wildfly}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>


</project>
8 changes: 8 additions & 0 deletions junit5-vintage/src/main/java/com/acme/cdi/Greeter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.acme.cdi;

public class Greeter {

String greet(String userName) {
return "Hello, " + userName;
}
}
59 changes: 59 additions & 0 deletions junit5-vintage/src/test/java/com/acme/cdi/GreeterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.acme.cdi;

import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.ArquillianTest;
import org.jboss.arquillian.junit.ArquillianTestClass;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.ComparisonFailure;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class GreeterTest {

@ClassRule
public static ArquillianTestClass arquillianTestClass = new ArquillianTestClass();

@Rule
public ArquillianTest arquillianTest = new ArquillianTest();

@Rule
public ExpectedException thrown = ExpectedException.none();

@Inject
Greeter greeter;

@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
.addClass(Greeter.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@Test
public void should_greet_earthlings() throws Exception {
String name = "Earthlings";
Assert.assertEquals("Hello, " + name, greeter.greet(name));
}

@Test
public void should_fail() throws Exception {
String name = "Earthlings";
thrown.expect(ComparisonFailure.class);
Assert.assertEquals(" " + name, greeter.greet(name));
}


@Test@Ignore
public void should_skip() throws Exception {
String name = "Earthlings";
Assert.assertEquals("" + name, greeter.greet(name));
}

}
14 changes: 14 additions & 0 deletions junit5-vintage/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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">

<container qualifier="wildfly" default="true">
<configuration>
<property name="jbossHome">target/wildfly-${version.org.wildfly:10.1.0.Final}</property>
<property name="modulePath">target/wildfly-${version.org.wildfly:10.1.0.Final}/modules</property>
</configuration>
</container>


</arquillian>
5 changes: 4 additions & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.arquillian_core>1.0.1.Final</version.arquillian_core>

<version.arquillian_core>1.3.0-SNAPSHOT</version.arquillian_core>
<version.org.wildfly>10.1.0.Final</version.org.wildfly>
<version.arquillian_container_wildfly>2.1.0.Final</version.arquillian_container_wildfly>
<version.arquillian_container_glassfish>1.0.0.CR3</version.arquillian_container_glassfish>
<version.arquillian_container_openwebbeans>1.0.0.CR2</version.arquillian_container_openwebbeans>
<version.arquillian_container_jbossas>1.0.0.CR2</version.arquillian_container_jbossas>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module>multinode</module>
<module>extensions</module>
<module>spring</module>
<module>junit5-vintage</module>
</modules>
</profile>
<profile>
Expand Down