You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/10/07 22:26:24 UTC
maven-surefire git commit: [SUREFIRE] improved Surefire855*IT and
JAVA_HOME inherited from main process to IT JVM
Repository: maven-surefire
Updated Branches:
refs/heads/master b40fe6da3 -> 0c2656f71
[SUREFIRE] improved Surefire855*IT and JAVA_HOME inherited from main process to IT JVM
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/0c2656f7
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/0c2656f7
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/0c2656f7
Branch: refs/heads/master
Commit: 0c2656f71ca014d362b185c4bcf034c80b85b48d
Parents: b40fe6d
Author: Tibor17 <ti...@lycos.com>
Authored: Wed Oct 7 22:25:07 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Wed Oct 7 22:25:07 2015 +0200
----------------------------------------------------------------------
.../surefire/its/fixture/SurefireLauncher.java | 28 ++++++++++
.../surefire-855-failsafe-use-bundle/pom.xml | 6 +++
.../java/jiras/surefre855/bundle/FooIT.java | 56 +++++++++++++++++---
.../test/java/jiras/surefire855/jar/FooIT.java | 45 ++++++++++++++--
.../surefire-855-failsafe-use-war/pom.xml | 6 +++
.../test/java/jiras/surefire855/war/FooIT.java | 55 ++++++++++++++++---
6 files changed, 180 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0c2656f7/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index d78deb1..cf0d90d 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.its.fixture;
*/
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.artifact.versioning.ArtifactVersion;
@@ -68,8 +69,35 @@ public class SurefireLauncher
{
mavenLauncher.addGoal( s );
}
+ setInProcessJavaHome();
}
+ public SurefireLauncher setInProcessJavaHome()
+ {
+ String javaHome = System.getenv( "JAVA_HOME" );
+ if ( javaHome != null && javaHome.length() > 0 )
+ {
+ try
+ {
+ File javaHomeAsDir = new File( javaHome ).getCanonicalFile();
+ if ( javaHomeAsDir.isDirectory() )
+ {
+ setLauncherJavaHome( javaHomeAsDir.getPath() );
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+ return this;
+ }
+
+ public SurefireLauncher setLauncherJavaHome( String javaHome )
+ {
+ mavenLauncher.addEnvVar( "JAVA_HOME", javaHome );
+ return this;
+ }
public SurefireLauncher getSubProjectLauncher( String subProject )
throws VerificationException
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0c2656f7/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
index db53997..bca3e1e 100644
--- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
+++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
@@ -55,6 +55,12 @@
<version>2.0M9</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0c2656f7/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java
index 6787b91..aeb666d 100644
--- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java
+++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java
@@ -27,13 +27,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Properties;
+import java.util.jar.JarFile;
import java.util.jar.Manifest;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.contentOf;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public final class FooIT
@@ -44,11 +43,16 @@ public final class FooIT
private static final String TEST_RESOURCE = "/jiras/surefire855/bundle/properties/surefire855.properties";
+ private static File surefireDir()
+ throws IOException
+ {
+ return new File( "target/surefire" ).getCanonicalFile();
+ }
+
private static File[] surefireProviderProperties()
throws IOException
{
- final File surefireDir = new File( "target/surefire" ).getCanonicalFile();
- return surefireDir.listFiles( new FileFilter()
+ return surefireDir().listFiles( new FileFilter()
{
public boolean accept( File pathname )
{
@@ -64,6 +68,25 @@ public final class FooIT
} );
}
+ private static File[] surefireBooterJar()
+ throws IOException
+ {
+ return surefireDir().listFiles( new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ try
+ {
+ return isSurefireBooter( pathname );
+ }
+ catch ( IOException e )
+ {
+ return false;
+ }
+ }
+ } );
+ }
+
/**
* See BooterSerializer#serialize().
*/
@@ -76,11 +99,30 @@ public final class FooIT
&& fileName.endsWith( "tmp" );
}
+ private static boolean isSurefireBooter( File pathname )
+ throws IOException
+ {
+ pathname = pathname.getCanonicalFile();
+ String fileName = pathname.getName();
+ return pathname.isFile() && fileName.startsWith( "surefirebooter" ) && fileName.endsWith( ".jar" );
+ }
+
private static String manifestClassPath( Class clazz )
throws IOException
{
- Manifest manifest = new Manifest( clazz.getResourceAsStream( "/META-INF/MANIFEST.MF" ) );
- return manifest.getMainAttributes().getValue( "Class-Path" );
+ File[] booters = surefireBooterJar();
+ assertThat( booters, is( arrayWithSize( 1 ) ) );
+ File booter = booters[0];
+ JarFile jarFile = new JarFile( booter );
+ try
+ {
+ Manifest manifest = jarFile.getManifest();
+ return manifest.getMainAttributes().getValue( "Class-Path" );
+ }
+ finally
+ {
+ jarFile.close();
+ }
}
private static Properties loadProperties( Class clazz, String resourcePath )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0c2656f7/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java
index cb1526d..606985a 100644
--- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java
+++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java
@@ -27,11 +27,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Properties;
+import java.util.jar.JarFile;
import java.util.jar.Manifest;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.contentOf;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assume.assumeThat;
@@ -68,6 +69,25 @@ public final class FooIT
} );
}
+ private static File[] surefireBooterJar()
+ throws IOException
+ {
+ return surefireDir().listFiles( new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ try
+ {
+ return isSurefireBooter( pathname );
+ }
+ catch ( IOException e )
+ {
+ return false;
+ }
+ }
+ } );
+ }
+
/**
* See BooterSerializer#serialize().
*/
@@ -80,11 +100,30 @@ public final class FooIT
&& fileName.endsWith( "tmp" );
}
+ private static boolean isSurefireBooter( File pathname )
+ throws IOException
+ {
+ pathname = pathname.getCanonicalFile();
+ String fileName = pathname.getName();
+ return pathname.isFile() && fileName.startsWith( "surefirebooter" ) && fileName.endsWith( ".jar" );
+ }
+
private static String manifestClassPath( Class clazz )
throws IOException
{
- Manifest manifest = new Manifest( clazz.getResourceAsStream( "/META-INF/MANIFEST.MF" ) );
- return manifest.getMainAttributes().getValue( "Class-Path" );
+ File[] booters = surefireBooterJar();
+ assertThat( booters, is( arrayWithSize( 1 ) ) );
+ File booter = booters[0];
+ JarFile jarFile = new JarFile( booter );
+ try
+ {
+ Manifest manifest = jarFile.getManifest();
+ return manifest.getMainAttributes().getValue( "Class-Path" );
+ }
+ finally
+ {
+ jarFile.close();
+ }
}
private static Properties loadProperties( Class clazz, String resourcePath )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0c2656f7/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml
index 4b0fb51..5dea1b0 100644
--- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml
+++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml
@@ -55,6 +55,12 @@
<version>2.0M9</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0c2656f7/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java
index 7905079..f15bd15 100644
--- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java
+++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java
@@ -27,12 +27,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Properties;
+import java.util.jar.JarFile;
import java.util.jar.Manifest;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.contentOf;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public final class FooIT
@@ -41,11 +41,16 @@ public final class FooIT
private static final String TEST_RESOURCE = "/jiras/surefire855/war/properties/surefire855.properties";
+ private static File surefireDir()
+ throws IOException
+ {
+ return new File( "target/surefire" ).getCanonicalFile();
+ }
+
private static File[] surefireProviderProperties()
throws IOException
{
- final File surefireDir = new File( "target/surefire" ).getCanonicalFile();
- return surefireDir.listFiles( new FileFilter()
+ return surefireDir().listFiles( new FileFilter()
{
public boolean accept( File pathname )
{
@@ -61,6 +66,25 @@ public final class FooIT
} );
}
+ private static File[] surefireBooterJar()
+ throws IOException
+ {
+ return surefireDir().listFiles( new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ try
+ {
+ return isSurefireBooter( pathname );
+ }
+ catch ( IOException e )
+ {
+ return false;
+ }
+ }
+ } );
+ }
+
/**
* See BooterSerializer#serialize().
*/
@@ -73,11 +97,30 @@ public final class FooIT
&& fileName.endsWith( "tmp" );
}
+ private static boolean isSurefireBooter( File pathname )
+ throws IOException
+ {
+ pathname = pathname.getCanonicalFile();
+ String fileName = pathname.getName();
+ return pathname.isFile() && fileName.startsWith( "surefirebooter" ) && fileName.endsWith( ".jar" );
+ }
+
private static String manifestClassPath( Class clazz )
throws IOException
{
- Manifest manifest = new Manifest( clazz.getResourceAsStream( "/META-INF/MANIFEST.MF" ) );
- return manifest.getMainAttributes().getValue( "Class-Path" );
+ File[] booters = surefireBooterJar();
+ assertThat( booters, is( arrayWithSize( 1 ) ) );
+ File booter = booters[0];
+ JarFile jarFile = new JarFile( booter );
+ try
+ {
+ Manifest manifest = jarFile.getManifest();
+ return manifest.getMainAttributes().getValue( "Class-Path" );
+ }
+ finally
+ {
+ jarFile.close();
+ }
}
private static Properties loadProperties( Class clazz, String resourcePath )