-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added integration tests for lifecycle methods
- Updated maven-surefire-plugin to 3.0.0-M5 to fix JDK 11 and 8 failures with latest JDK versions
- Loading branch information
Showing
7 changed files
with
503 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.jboss.arquillian.junit5</groupId> | ||
<artifactId>arquillian-junit5-integration-test</artifactId> | ||
|
||
<parent> | ||
<groupId>org.jboss.arquillian</groupId> | ||
<version>1.7.0.Final-SNAPSHOT</version> | ||
<artifactId>arquillian-build</artifactId> | ||
<relativePath>../../build</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<payara.start.skip>${skipITs}</payara.start.skip> | ||
<payara.version>5.2021.2</payara.version> | ||
</properties> | ||
|
||
<name>Arquillian JUnit 5 Container Integration Test</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
<version>1.0.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.activation</groupId> | ||
<artifactId>jakarta.activation-api</artifactId> | ||
<version>1.2.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.xml.bind</groupId> | ||
<artifactId>jakarta.xml.bind-api</artifactId> | ||
<version>2.3.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.arquillian.junit5</groupId> | ||
<artifactId>arquillian-junit5-container</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Payara Java EE Container support (container) --> | ||
<dependency> | ||
<groupId>fish.payara.arquillian</groupId> | ||
<artifactId>arquillian-payara-server-remote</artifactId> | ||
<version>2.4.1</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.jboss.arquillian.protocol</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-container-spi</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-cdi</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-ejb</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-initialcontext</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-resource</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.protocol</groupId> | ||
<artifactId>arquillian-protocol-servlet</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- Disable Surefire Plugin - Integration Only --> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-test</id> | ||
<phase>none</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
</plugin> | ||
|
||
<!-- Download / Unpack Payara --> | ||
<plugin> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.1.2</version> | ||
<executions> | ||
<execution> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<overWrite>false</overWrite> | ||
<outputDirectory>${basedir}/target</outputDirectory> | ||
<markersDirectory>${basedir}/target/dependency-maven-plugin-markers</markersDirectory> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>fish.payara.distributions</groupId> | ||
<artifactId>payara</artifactId> | ||
<version>${payara.version}</version> | ||
<type>zip</type> | ||
</artifactItem> | ||
</artifactItems> | ||
<skip>${skipITs}</skip> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- Start / Stop Payara Domain --> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>start-domain</id> | ||
<phase>pre-integration-test</phase> | ||
<configuration> | ||
<arguments> | ||
<argument>start-domain</argument> | ||
</arguments> | ||
</configuration> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>stop-domain</id> | ||
<phase>post-integration-test</phase> | ||
<configuration> | ||
<arguments> | ||
<argument>stop-domain</argument> | ||
</arguments> | ||
</configuration> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>3.0.0-M5</version> | ||
<executions> | ||
<execution> | ||
<id>integration-test</id> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<runOrder>alphabetical</runOrder> | ||
<includes> | ||
<include>**/*TestCase.java</include> | ||
</includes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<configuration> | ||
<executable>${basedir}/target/payara5/bin/asadmin</executable> | ||
<skip>${payara.start.skip}</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
95 changes: 95 additions & 0 deletions
95
...egration-test/src/test/java/org/jboss/arquillian/junit5/lifecycle/CreateFileTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2021 JBoss by Red Hat. | ||
* | ||
* 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.junit5.lifecycle; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import javax.naming.InitialContext; | ||
import javax.naming.NamingException; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
/** | ||
* | ||
* @author lprimak | ||
*/ | ||
public class CreateFileTestCase { | ||
private static Path TMP_FILE_PATH; | ||
static final String TMP_FILE_ASSET_NAME = "temporaryFileAsset"; | ||
|
||
enum RunsWhere { | ||
CLIENT, | ||
SERVER, | ||
} | ||
|
||
@BeforeAll | ||
static void initTmpFileName(@TempDir Path tmpDirBase) { | ||
TMP_FILE_PATH = tmpDirBase.getParent().resolve( | ||
tmpDirBase.getFileName() + "-arquillianLifecycleTest") | ||
.resolve("lifecycleOutput"); | ||
} | ||
|
||
@Test | ||
void createTmpFile() throws IOException { | ||
TMP_FILE_PATH.getParent().toFile().mkdir(); | ||
File tmpFile = TMP_FILE_PATH.toFile(); | ||
tmpFile.delete(); | ||
assertTrue(tmpFile.createNewFile(), "cannot create results file"); | ||
} | ||
|
||
static Path getTmpFilePath() { | ||
if (isRunningOnServer()) { | ||
try (InputStream istrm = Thread.currentThread().getContextClassLoader() | ||
.getResourceAsStream(TMP_FILE_ASSET_NAME)) { | ||
return Paths.get(new BufferedReader(new InputStreamReader(istrm)).readLine()); | ||
} catch (IOException ioe) { | ||
throw new RuntimeException(ioe); | ||
} | ||
} else { | ||
return TMP_FILE_PATH; | ||
} | ||
} | ||
|
||
static void appendToFile(String str) { | ||
try (FileWriter fw = new FileWriter(getTmpFilePath().toFile(), true)) { | ||
fw.append(str + ","); | ||
} catch (IOException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
|
||
static void checkRunsWhere(RunsWhere expected) { | ||
assertEquals(expected, isRunningOnServer() ? RunsWhere.SERVER : RunsWhere.CLIENT); | ||
} | ||
|
||
static boolean isRunningOnServer() { | ||
try { | ||
new InitialContext().lookup("java:comp/env"); | ||
return true; | ||
} catch (NamingException ex) { | ||
return false; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
junit5/integration-test/src/test/java/org/jboss/arquillian/junit5/lifecycle/Greeter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2021 JBoss by Red Hat. | ||
* | ||
* 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.junit5.lifecycle; | ||
|
||
import java.io.PrintStream; | ||
|
||
/** | ||
* | ||
* @author lprimak | ||
*/ | ||
public class Greeter { | ||
public void greet(PrintStream to, String name) { | ||
to.println(createGreeting(name)); | ||
} | ||
|
||
public String createGreeting(String name) { | ||
return "Hello, " + name + "!"; | ||
} | ||
} |
Oops, something went wrong.