You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/12/12 22:00:30 UTC

git commit: o Split the embedded launcher into a generic maven part and a specific surefire part

Updated Branches:
  refs/heads/master d65f9fc5c -> 7e1aee6d5


o Split the embedded launcher into a generic maven part and a specific surefire part


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/7e1aee6d
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/7e1aee6d
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/7e1aee6d

Branch: refs/heads/master
Commit: 7e1aee6d5eb8f0faa0b81a049e504d27c27528c8
Parents: d65f9fc
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Tue Dec 11 22:13:57 2012 +0100
Committer: Kristian Rosenvold <kr...@gmail.com>
Committed: Wed Dec 12 22:00:08 2012 +0100

----------------------------------------------------------------------
 .../surefire/its/IncludesExcludesFromFileIT.java   |   18 +-
 .../maven/surefire/its/IncludesExcludesIT.java     |    8 +-
 .../surefire/its/JUnit47RedirectOutputIT.java      |    2 +-
 .../org/apache/maven/surefire/its/JUnitDepIT.java  |    8 +-
 .../maven/surefire/its/PlexusConflictIT.java       |    2 +-
 .../maven/surefire/its/SiblingAggregatorIT.java    |    7 +-
 .../org/apache/maven/surefire/its/UmlautDirIT.java |   19 +-
 .../maven/surefire/its/UnicodeTestNamesIT.java     |    6 +-
 .../its/fixture/FailsafeOutputValidator.java       |    4 +-
 .../maven/surefire/its/fixture/MavenLauncher.java  |  440 +++++++++++++++
 .../its/fixture/SurefireIntegrationTestCase.java   |   29 +-
 .../fixture/SurefireJUnit4IntegrationTestCase.java |   31 +-
 .../surefire/its/fixture/SurefireLauncher.java     |  361 +++---------
 .../surefire/its/fixture/SurefireLauncherTest.java |    3 +-
 .../its/jiras/Surefire141PluggableProvidersIT.java |    3 -
 .../its/jiras/Surefire162CharsetProviderIT.java    |   11 +-
 .../its/jiras/Surefire772NoFailsafeReportsIT.java  |    3 +-
 .../Surefire920TestFailureIgnoreWithTimeoutIT.java |    3 +-
 18 files changed, 589 insertions(+), 369 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java
index 42fd833..b872223 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java
@@ -38,28 +38,28 @@ public class IncludesExcludesFromFileIT
 
     public void testSimple()
     {
-        testWithProfile( "-Psimple" );
+        testWithProfile( "simple" );
     }
 
     public void testSimpleMixed()
     {
-        testWithProfile( "-Psimple-mixed" );
+        testWithProfile( "simple-mixed" );
     }
 
     public void testRegex()
     {
-        testWithProfile( "-Pregex" );
+        testWithProfile( "regex" );
     }
 
     public void testPath()
     {
-        testWithProfile( "-Ppath" );
+        testWithProfile( "path" );
     }
 
     private void testWithProfile( String profile )
     {
         final OutputValidator outputValidator = unpack().
-            addGoal( profile ).executeTest().verifyErrorFree( 2 );
+            activateProfile( profile ).executeTest().verifyErrorFree( 2 );
 
         outputValidator.getTargetFile( "testTouchFile.txt" ).assertFileExists();
         outputValidator.getTargetFile( "defaultTestTouchFile.txt" ).assertFileExists();
@@ -67,18 +67,18 @@ public class IncludesExcludesFromFileIT
 
     public void testMissingExcludes()
     {
-        expectBuildFailure( "-Pmissing-excludes-file", "Failed to load list from file", "no-such-excludes-file" );
+        expectBuildFailure( "missing-excludes-file", "Failed to load list from file", "no-such-excludes-file" );
     }
 
     public void testMissingIncludes()
     {
-        expectBuildFailure( "-Pmissing-includes-file", "Failed to load list from file", "no-such-includes-file" );
+        expectBuildFailure( "missing-includes-file", "Failed to load list from file", "no-such-includes-file" );
     }
 
     private void expectBuildFailure( final String profile, final String... messages )
     {
-        final OutputValidator outputValidator = unpack().
-            addGoal( profile ).executeTestWithFailure();
+        final OutputValidator outputValidator = unpack().activateProfile( profile )
+            .executeTestWithFailure();
 
         for ( String message : messages )
         {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java
index d8da28f..c884ade 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java
@@ -41,23 +41,23 @@ public class IncludesExcludesIT
      */
     public void testIncludesExcludes()
     {
-        testWithProfile( "-Psimple" );
+        testWithProfile( "simple" );
     }
 
     public void testRegexIncludesExcludes()
     {
-        testWithProfile( "-Pregex" );
+        testWithProfile( "regex" );
     }
 
     public void testPathBasedIncludesExcludes()
     {
-        testWithProfile( "-Ppath" );
+        testWithProfile( "path" );
     }
 
     private void testWithProfile( String profile )
     {
         final OutputValidator outputValidator = unpack().
-            addGoal( profile ).executeTest().verifyErrorFree( 2 );
+            activateProfile( profile ).executeTest().verifyErrorFree( 2 );
         outputValidator.getTargetFile( "testTouchFile.txt" ).assertFileExists();
         outputValidator.getTargetFile( "defaultTestTouchFile.txt" ).assertFileExists();
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
index 651d659..f4e41fa 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
@@ -39,7 +39,7 @@ public class JUnit47RedirectOutputIT
         throws Exception
     {
         final OutputValidator clean =
-            unpack().redirectToFile( true ).addGoal( "clean" ).parallelClasses().executeTest();
+            unpack().redirectToFile( true ).parallelClasses().addGoal( "clean" ).executeTest();
         checkReports( clean );
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java
index 62f4e37..a94741a 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java
@@ -38,28 +38,28 @@ public class JUnitDepIT
     public void testJUnit44Dep()
         throws Exception
     {
-        unpack().debugLogging().addGoal( "-Djunit-dep.version=4.4" ).executeTest().verifyErrorFree( 1 ).verifyTextInLog(
+        unpack().debugLogging().addD( "junit-dep.version", "4.4" ).executeTest().verifyErrorFree( 1 ).verifyTextInLog(
             "surefire-junit4" ); // Ahem. Will match on the 4.7 provider too
     }
 
     public void testJUnit44DepWithSneaky381()
         throws Exception
     {
-        unpack().debugLogging().addGoal( "-Djunit-dep.version=4.4" ).activateProfile(
+        unpack().debugLogging().addD( "junit-dep.version", "4.4" ).activateProfile(
             "provided381" ).executeTest().verifyErrorFree( 1 );
     }
 
     public void testJUnit47Dep()
         throws Exception
     {
-        unpack().debugLogging().addGoal( "-Djunit-dep.version=4.7" ).executeTest().verifyErrorFree( 1 ).verifyTextInLog(
+        unpack().debugLogging().addD( "junit-dep.version","4.7" ).executeTest().verifyErrorFree( 1 ).verifyTextInLog(
             "surefire-junit47" );
     }
 
     public void testJUnit48Dep()
         throws Exception
     {
-        unpack().debugLogging().addGoal( "-Djunit-dep.version=4.8" ).executeTest().verifyErrorFree( 1 ).verifyTextInLog(
+        unpack().debugLogging().addD( "junit-dep.version","4.8" ).executeTest().verifyErrorFree( 1 ).verifyTextInLog(
             "surefire-junit47" );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java
index 8c099f6..f0ee92e 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java
@@ -37,7 +37,7 @@ public class PlexusConflictIT
 
     public void testPlexusConflictIsolatedClassLoader()
     {
-        unpack().addD( "surefire.useSystemClassLoader", "false" ).executeTest().verifyErrorFree( 1 );
+        unpack().useSystemClassLoader(false).executeTest().verifyErrorFree( 1 );
     }
 
     private SurefireLauncher unpack()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java
index f7bbd9d..2aba51a 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.apache.maven.surefire.its.fixture.SurefireIntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
 
@@ -36,7 +37,9 @@ public class SiblingAggregatorIT
         throws Exception
     {
         final SurefireLauncher unpack = unpack( "sibling-aggregator" );
-        unpack.getSubProjectLauncher( "aggregator" ).executeTest().verifyErrorFreeLog();
-        unpack.getSubProjectValidator( "child2" ).assertTestSuiteResults( 1, 0, 0, 0 );
+        SurefireLauncher aggregator = unpack.getSubProjectLauncher( "aggregator" );
+        aggregator.executeTest().verifyErrorFreeLog();
+        OutputValidator child2 = unpack.getSubProjectValidator( "child2" );
+        child2.assertTestSuiteResults( 1, 0, 0, 0 );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java
index f7ccdf7..ad60fcb 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java
@@ -19,14 +19,14 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import org.apache.maven.it.VerificationException;
-import org.apache.maven.it.Verifier;
-import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.surefire.its.fixture.MavenLauncher;
 import org.apache.maven.surefire.its.fixture.SurefireIntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
 
+import java.io.File;
+import java.io.IOException;
+
 /**
  * Test a directory with an umlaut
  *
@@ -50,11 +50,12 @@ public class UmlautDirIT
     SurefireLauncher specialUnpack()
         throws VerificationException, IOException
     {
-        final File unpackLocation = unpack( "junit-pathWithUmlaut" ).getUnpackLocation();
-        File dest = new File( unpackLocation.getParentFile().getPath(), "/junit-pathWith\u00DCmlaut" );
-        FileUtils.deleteDirectory( dest );
-        unpackLocation.renameTo( dest );
-        return new SurefireLauncher( new Verifier( dest.getAbsolutePath() ) );
+        SurefireLauncher unpack = unpack( "junit-pathWithUmlaut" );
+        MavenLauncher maven = unpack.maven();
+
+        File dest = new File( maven.getUnpackedAt().getParentFile().getPath(), "/junit-pathWith\u00DCmlaut" );
+        maven.moveUnpackTo( dest );
+        return unpack;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
index 8868699..a99c142 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
@@ -41,15 +41,15 @@ public class UnicodeTestNamesIT
     public void checkFileNamesWithUnicode()
     {
         SurefireLauncher unpacked = unpack( "unicode-testnames" );
-        File xxyz = new File( unpacked.getUnpackLocation(), "src/test/java/junit/twoTestCases/XXYZTest.java" );
+        File xxyz = new File( unpacked.getUnpackedAt(), "src/test/java/junit/twoTestCases/XXYZTest.java" );
 
-        File dest = new File( unpacked.getUnpackLocation(),
+        File dest = new File( unpacked.getUnpackedAt(),
                               "src/test/java/junit/twoTestCases/\u800C\u7D22\u5176\u60C5Test.java" );
 
         Assume.assumeTrue( xxyz.renameTo( dest ) );
         Assume.assumeTrue( dest.exists() );
         Assume.assumeTrue(
-            !new File( unpacked.getUnpackLocation(), "src/test/java/junit/twoTestCases/????Test.java" ).exists() );
+            !new File( unpacked.getUnpackedAt(), "src/test/java/junit/twoTestCases/????Test.java" ).exists() );
 
         OutputValidator outputValidator = unpacked.executeTest().assertTestSuiteResults( 2, 0, 0, 0 );
         TestFile surefireReportsFile = outputValidator.getSurefireReportsFile( "junit.twoTestCases.而索其情Test.txt" );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
index 26bfbf2..6da61c7 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
@@ -25,9 +25,9 @@ import org.apache.maven.it.Verifier;
 public class FailsafeOutputValidator
     extends OutputValidator
 {
-    public FailsafeOutputValidator( Verifier verifier )
+    public FailsafeOutputValidator( OutputValidator source)
     {
-        super( verifier );
+        super( source.verifier );
     }
 
     public OutputValidator verifyErrorFree( int total )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
new file mode 100755
index 0000000..4395199
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
@@ -0,0 +1,440 @@
+package org.apache.maven.surefire.its.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.text.StrSubstitutor;
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+import org.apache.maven.shared.utils.io.FileUtils;
+
+/**
+ * Encapsulate all needed features to start a maven run
+ * <p/>
+ *
+ * @author Kristian Rosenvold
+ */
+public class MavenLauncher
+{
+    private final List<String> cliOptions = new ArrayList<String>();
+
+    private final List<String> goals = new ArrayList<String>();
+
+    private final Map<String, String> envvars = new HashMap<String, String>();
+
+    private File unpackedAt;
+
+    private Verifier verifier;
+
+    private OutputValidator validator;
+
+    private final Class testCaseBeingRun;
+
+    private final String resourceName;
+
+    private final String suffix;
+
+
+    public MavenLauncher( Class testClass, String resourceName, String suffix )
+    {
+        this.testCaseBeingRun = testClass;
+        this.resourceName = resourceName;
+        this.suffix = suffix != null ? suffix : "";
+        resetGoals();
+        resetCliOptions();
+    }
+
+
+    public File getUnpackedAt()
+    {
+        return ensureUnpacked();
+    }
+
+    private File ensureUnpacked()
+    {
+        if ( unpackedAt == null )
+        {
+            unpackedAt = simpleExtractResources( testCaseBeingRun, resourceName );
+        }
+        return unpackedAt;
+    }
+
+    public void moveUnpackTo( File dest )
+        throws IOException
+    {
+        FileUtils.deleteDirectory( dest );
+        getUnpackedAt().renameTo( dest );
+        unpackedAt = dest;
+    }
+
+    public void resetGoals()
+    {
+        goals.clear();
+    }
+
+    void addCliOption( String cliOption )
+    {
+        cliOptions.add( cliOption );
+    }
+
+
+    String getTestMethodName()
+    {
+        // dirty. Im sure we can use junit4 rules to attach testname to thread instead
+        StackTraceElement[] stackTrace = getStackTraceElements();
+        StackTraceElement topInTestClass;
+        topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun );
+        if ( topInTestClass == null )
+        {
+            // Look in superclass...
+            topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun.getSuperclass() );
+        }
+        if ( topInTestClass != null )
+        {
+            return topInTestClass.getMethodName();
+        }
+        throw new IllegalStateException( "Cannot find " + testCaseBeingRun.getName() + "in stacktrace" );
+    }
+
+    private StackTraceElement findTopElemenent( StackTraceElement[] stackTrace, Class testClassToLookFor )
+    {
+        StackTraceElement bestmatch = null;
+        for ( StackTraceElement stackTraceElement : stackTrace )
+        {
+            if ( stackTraceElement.getClassName().equals( testClassToLookFor.getName() ) )
+            {
+                bestmatch = stackTraceElement;
+            }
+        }
+        return bestmatch;
+    }
+
+    StackTraceElement[] getStackTraceElements()
+    {
+        try
+        {
+            throw new RuntimeException();
+        }
+        catch ( RuntimeException e )
+        {
+            return e.getStackTrace();
+        }
+    }
+
+    public void reset()
+    {
+        resetGoals();
+        resetCliOptions();
+    }
+
+    private void resetCliOptions()
+    {
+        cliOptions.clear();
+    }
+
+    public MavenLauncher getSubProjectLauncher( String subProject )
+        throws VerificationException
+    {
+        MavenLauncher mavenLauncher =
+            new MavenLauncher( testCaseBeingRun, resourceName + File.separator + subProject, suffix );
+        mavenLauncher.unpackedAt = new File(  ensureUnpacked(), subProject );
+        return mavenLauncher;
+    }
+
+    public OutputValidator getSubProjectValidator( String subProject )
+        throws VerificationException
+    {
+        final File subFile = getValidator().getSubFile( subProject );
+        return new OutputValidator( new Verifier( subFile.getAbsolutePath() ) );
+    }
+
+
+    public MavenLauncher addEnvVar( String key, String value )
+    {
+        envvars.put( key, value );
+        return this;
+    }
+
+    public MavenLauncher assertNotPresent( String subFile )
+    {
+        getVerifier().assertFileNotPresent( getValidator().getSubFile( subFile ).getAbsolutePath() );
+        return this;
+    }
+
+    public MavenLauncher showErrorStackTraces()
+    {
+        addCliOption( "-e" );
+        return this;
+    }
+
+    public MavenLauncher debugLogging()
+    {
+        addCliOption( "-X" );
+        return this;
+    }
+
+    public MavenLauncher failNever()
+    {
+        addCliOption( "-fn" );
+        return this;
+    }
+
+    public MavenLauncher offline()
+    {
+        addCliOption( "-o" );
+        return this;
+    }
+
+    public MavenLauncher skipClean()
+    {
+        goals.add( "-Dclean.skip=true" );
+        return this;
+    }
+
+    public MavenLauncher addGoal( String goal )
+    {
+        goals.add( goal );
+        return this;
+    }
+
+    public OutputValidator executeTest()
+    {
+        return execute( "test" );
+    }
+
+    public OutputValidator executeInstall()
+        throws VerificationException
+    {
+        return execute( "install" );
+    }
+
+    public OutputValidator executeTestWithFailure()
+    {
+        try
+        {
+            execute( "test" );
+        }
+        catch ( SurefireVerifierException ignore )
+        {
+            return getValidator();
+        }
+        throw new RuntimeException( "Expecting build failure, got none!" );
+    }
+
+    public OutputValidator executeVerifyWithFailure()
+    {
+        try
+        {
+            executeVerify();
+        }
+        catch ( SurefireVerifierException ignore )
+        {
+            return getValidator();
+        }
+        throw new RuntimeException( "Expecting build failure, got none!" );
+    }
+
+
+    public MavenLauncher addCleanGoal(){
+        addGoal( "clean" );
+        return this;
+    }
+
+    public FailsafeOutputValidator executeVerify()
+    {
+        OutputValidator verify = execute( "verify" );
+        return new FailsafeOutputValidator( verify );
+    }
+
+    public OutputValidator execute( String goal )
+    {
+        addGoal( goal );
+        return executeCurrentGoals();
+    }
+
+    public OutputValidator executeCurrentGoals()
+    {
+
+        String userLocalRepo = System.getProperty( "user.localRepository" );
+        String testBuildDirectory = System.getProperty( "testBuildDirectory" );
+        boolean useInterpolatedSettings = Boolean.getBoolean( "useInterpolatedSettings" );
+
+        try
+        {
+            if ( useInterpolatedSettings )
+            {
+                File interpolatedSettings = new File( testBuildDirectory, "interpolated-settings" );
+
+                if ( !interpolatedSettings.exists() )
+                {
+                    // hack "a la" invoker plugin to download dependencies from local repo
+                    // and not download from central
+
+                    Map<String, String> values = new HashMap<String, String>( 1 );
+                    values.put( "localRepositoryUrl", toUrl( userLocalRepo ) );
+                    StrSubstitutor strSubstitutor = new StrSubstitutor( values );
+
+                    String fileContent = FileUtils.fileRead( new File( testBuildDirectory, "settings.xml" ) );
+
+                    String filtered = strSubstitutor.replace( fileContent );
+
+                    FileUtils.fileWrite( interpolatedSettings.getAbsolutePath(), filtered );
+
+                }
+
+                addCliOption( "-s " + interpolatedSettings.getCanonicalPath() );
+            }
+            getVerifier().setCliOptions( cliOptions );
+
+            getVerifier().executeGoals( goals, envvars );
+            return getValidator();
+        }
+        catch ( IOException e )
+        {
+            throw new SurefireVerifierException( e.getMessage(), e );
+        }
+        catch ( VerificationException e )
+        {
+            throw new SurefireVerifierException( e.getMessage(), e );
+        }
+        finally
+        {
+            getVerifier().resetStreams();
+        }
+    }
+
+    private static String toUrl( String filename )
+    {
+        /*
+         * NOTE: Maven fails to properly handle percent-encoded "file:" URLs (WAGON-111) so don't use File.toURI() here
+         * as-is but use the decoded path component in the URL.
+         */
+        String url = "file://" + new File( filename ).toURI().getPath();
+        if ( url.endsWith( "/" ) )
+        {
+            url = url.substring( 0, url.length() - 1 );
+        }
+        return url;
+    }
+
+    public MavenLauncher activateProfile( String profile )
+    {
+        return addGoal( "-P" + profile );
+    }
+
+    public MavenLauncher addD( String variable, String value )
+    {
+        return addGoal( "-D" + variable + "=" + value );
+    }
+
+    public MavenLauncher addD( String variable, boolean value )
+    {
+        return addGoal( "-D" + variable + "=" + value );
+    }
+
+    public MavenLauncher addD( String variable, int value )
+    {
+        return addGoal( "-D" + variable + "=" + value );
+    }
+
+    public MavenLauncher setEOption()
+    {
+        addCliOption( "-e" );
+        return this;
+    }
+
+    public MavenLauncher deleteSiteDir()
+    {
+        try
+        {
+            FileUtils.deleteDirectory( getValidator().getSubFile( "site" ) );
+        }
+        catch ( IOException e )
+        {
+            throw new SurefireVerifierException( e );
+        }
+        return this;
+    }
+
+    public OutputValidator getValidator()
+    {
+        if ( validator == null )
+        {
+            this.validator = new OutputValidator( getVerifier() );
+        }
+        return validator;
+    }
+
+    private Verifier getVerifier()
+    {
+        if ( verifier == null )
+        {
+            try
+            {
+                this.verifier = new Verifier( ensureUnpacked().getAbsolutePath() );
+            }
+            catch ( VerificationException e )
+            {
+                throw new RuntimeException( e );
+            }
+        }
+        return verifier;
+    }
+
+    private File simpleExtractResources( Class<?> cl, String resourcePath )
+    {
+        if ( !resourcePath.startsWith( "/" ) )
+        {
+            resourcePath = "/" + resourcePath;
+        }
+        File tempDir = getUnpackDir();
+        File testDir = new File( tempDir, resourcePath );
+        try
+        {
+            FileUtils.deleteDirectory( testDir );
+            File file = ResourceExtractor.extractResourceToDestination( cl, resourcePath, tempDir, true );
+            return file.getCanonicalFile();
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( e );
+        }
+
+    }
+
+    File getUnpackDir()
+    {
+        String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) );
+        return new File( tempDirPath,
+                         testCaseBeingRun.getSimpleName() + File.separator + getTestMethodName() + suffix );
+    }
+
+    public File getArtifactPath( String gid, String aid, String version, String ext )
+    {
+        return new File( verifier.getArtifactPath( gid, aid, version, ext ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireIntegrationTestCase.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireIntegrationTestCase.java
index e6a0dee..e2f9f1a 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireIntegrationTestCase.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireIntegrationTestCase.java
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.its.fixture;
  */
 
 import java.io.IOException;
+
 import org.apache.maven.it.VerificationException;
 
 import junit.framework.TestCase;
@@ -44,33 +45,13 @@ public abstract class SurefireIntegrationTestCase
 
     public SurefireLauncher unpack( String sourceName )
     {
-        try
-        {
-            return new SurefireLauncher( this.getClass(), sourceName, "" );
-        }
-        catch ( VerificationException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
-        catch ( IOException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
+        MavenLauncher mavenLauncher = new MavenLauncher( this.getClass(), sourceName, "" );
+        return new SurefireLauncher( mavenLauncher );
     }
 
     public SurefireLauncher unpack( String sourceName, String suffix )
     {
-        try
-        {
-            return new SurefireLauncher( this.getClass(), sourceName, suffix );
-        }
-        catch ( VerificationException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
-        catch ( IOException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
+        MavenLauncher mavenLauncher = new MavenLauncher( this.getClass(), sourceName, suffix );
+        return new SurefireLauncher( mavenLauncher );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
index 06bea62..b7c25a8 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
@@ -19,9 +19,6 @@ package org.apache.maven.surefire.its.fixture;
  * under the License.
  */
 
-import java.io.IOException;
-import org.apache.maven.it.VerificationException;
-
 /**
  * Contains commonly used features for most tests, encapsulating
  * common use cases.
@@ -41,34 +38,14 @@ public abstract class SurefireJUnit4IntegrationTestCase
 
     public SurefireLauncher unpack( String sourceName )
     {
-        try
-        {
-            return new SurefireLauncher( this.getClass(), sourceName, "" );
-        }
-        catch ( VerificationException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
-        catch ( IOException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
+            MavenLauncher mavenLauncher = new MavenLauncher( this.getClass(), sourceName, "" );
+            return new SurefireLauncher( mavenLauncher );
     }
 
     public static SurefireLauncher unpack( Class testClass, String sourceName, String suffix )
     {
-        try
-        {
-            return new SurefireLauncher( testClass, sourceName, suffix );
-        }
-        catch ( VerificationException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
-        catch ( IOException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
+            MavenLauncher mavenLauncher = new MavenLauncher( testClass, sourceName, suffix );
+            return new SurefireLauncher( mavenLauncher );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/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 a572673..efce4f2 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,20 +20,13 @@ package org.apache.maven.surefire.its.fixture;
  */
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang.text.StrSubstitutor;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.it.VerificationException;
-import org.apache.maven.it.Verifier;
-import org.apache.maven.it.util.ResourceExtractor;
-import org.apache.maven.shared.utils.io.FileUtils;
 
 /**
  * Encapsulate all needed features to start a surefire run
@@ -42,172 +35,78 @@ import org.apache.maven.shared.utils.io.FileUtils;
  * files, which AbstractSurefireIntegrationTestClass does not.
  * Thread safe only for running in "classes" mode.
  *
- * @author Kristian Rosenvold
+ * @author Kristian Rosenvold                                 -
  */
 public class SurefireLauncher
 {
-    private final List<String> cliOptions = new ArrayList<String>();
+
+    private final MavenLauncher mavenLauncher;
 
     private final String testNgVersion = System.getProperty( "testng.version" );
 
     private final String surefireVersion = System.getProperty( "surefire.version" );
 
-    private final List<String> goals = getInitialGoals( testNgVersion );
-
-    private final Map<String, String> envvars = new HashMap<String, String>();
-
-    private Verifier verifier;
-
-    private OutputValidator validator;
-
     private boolean failIfNoTests;
 
-    private final Class testClass;
-
-    private final String resourceName;
-
-    private final String suffix;
-
-
-    public SurefireLauncher( Class testClass, String resourceName, String suffix )
-        throws VerificationException, IOException
+    public SurefireLauncher( MavenLauncher mavenLauncher )
     {
-        this.testClass = testClass;
-        this.resourceName = resourceName;
-        this.suffix = suffix != null ? suffix : "";
-        goals.clear();
-        goals.addAll( getInitialGoals( testNgVersion ) );
-        resetCliOptions();
+        this.mavenLauncher = mavenLauncher;
+        reset();
     }
 
-    public SurefireLauncher( Verifier verifier )
+    public MavenLauncher maven()
     {
-        this.testClass = null;
-        this.resourceName = null;
-        this.suffix = "";
-        this.verifier = verifier;
-        goals.clear();
-        goals.addAll( getInitialGoals( testNgVersion ) );
-        resetCliOptions();
+        return mavenLauncher;
     }
 
     private void addCliOption( String cliOption )
     {
-        cliOptions.add( cliOption );
-    }
-
-    private Verifier createVerifier( Class testClass, String resourceName )
-        throws IOException, VerificationException
-    {
-        return new Verifier( simpleExtractResources( testClass, resourceName ).getAbsolutePath() );
-    }
-
-    private File simpleExtractResources( Class<?> cl, String resourcePath )
-        throws IOException
-    {
-        if ( !resourcePath.startsWith( "/" ) )
-        {
-            resourcePath = "/" + resourcePath;
-        }
-        File tempDir = getUnpackDir();
-        File testDir = new File( tempDir, resourcePath );
-        FileUtils.deleteDirectory( testDir );
-
-        File file = ResourceExtractor.extractResourceToDestination( cl, resourcePath, tempDir, true );
-        return file.getCanonicalFile();
-    }
-
-    private File getUnpackDir()
-    {
-        String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) );
-        return new File( tempDirPath, testClass.getSimpleName() + File.separator + getTestMethodName() + suffix );
+        mavenLauncher.addCliOption( cliOption );
     }
 
     String getTestMethodName()
     {
-        // dirty. Im sure we can use junit4 rules to attach testname to thread instead
-        StackTraceElement[] stackTrace = getStackTraceElements();
-        StackTraceElement topInTestClass;
-        topInTestClass = findTopElemenent( stackTrace, testClass );
-        if ( topInTestClass == null )
-        {
-            // Look in superclass...
-            topInTestClass = findTopElemenent( stackTrace, testClass.getSuperclass() );
-        }
-        if ( topInTestClass != null )
-        {
-            return topInTestClass.getMethodName();
-        }
-        throw new IllegalStateException( "Cannot find " + testClass.getName() + "in stacktrace" );
-    }
-
-    private StackTraceElement findTopElemenent( StackTraceElement[] stackTrace, Class testClassToLookFor )
-    {
-        StackTraceElement bestmatch = null;
-        for ( StackTraceElement stackTraceElement : stackTrace )
-        {
-            if ( stackTraceElement.getClassName().equals( testClassToLookFor.getName() ) )
-            {
-                bestmatch = stackTraceElement;
-            }
-        }
-        return bestmatch;
+        return mavenLauncher.getTestMethodName();
     }
 
-    StackTraceElement[] getStackTraceElements()
+    public void reset()
     {
-        try
-        {
-            throw new RuntimeException();
-        }
-        catch ( RuntimeException e )
+        mavenLauncher.reset();
+        for ( String s : getInitialGoals( testNgVersion ) )
         {
-            return e.getStackTrace();
+            mavenLauncher.addGoal( s );
         }
     }
 
-    public void reset()
-    {
-        goals.clear();
-        goals.addAll( getInitialGoals( testNgVersion ) );
-        resetCliOptions();
-    }
-
-    private void resetCliOptions()
-    {
-        cliOptions.clear();
-    }
 
     public SurefireLauncher getSubProjectLauncher( String subProject )
         throws VerificationException
     {
-        final File subFile = getValidator().getSubFile( subProject );
-        return new SurefireLauncher( new Verifier( subFile.getAbsolutePath() ) );
+        return new SurefireLauncher( mavenLauncher.getSubProjectLauncher( subProject ) );
     }
 
     public OutputValidator getSubProjectValidator( String subProject )
         throws VerificationException
     {
-        final File subFile = getValidator().getSubFile( subProject );
-        return new OutputValidator( new Verifier( subFile.getAbsolutePath() ) );
+        return mavenLauncher.getSubProjectValidator( subProject );
     }
 
     public SurefireLauncher addEnvVar( String key, String value )
     {
-        envvars.put( key, value );
+        mavenLauncher.addEnvVar( key, value );
         return this;
     }
 
-    private List<String> getInitialGoals( String testNgVersion1 )
+    private List<String> getInitialGoals( String testNgVersion )
     {
         List<String> goals1 = new ArrayList<String>();
         goals1.add( "-Dsurefire.version=" + surefireVersion );
 
-        if ( testNgVersion != null )
+        if ( this.testNgVersion != null )
         {
-            goals1.add( "-DtestNgVersion=" + testNgVersion1 );
+            goals1.add( "-DtestNgVersion=" + testNgVersion );
 
-            ArtifactVersion v = new DefaultArtifactVersion( testNgVersion1 );
+            ArtifactVersion v = new DefaultArtifactVersion( testNgVersion );
             try
             {
                 if ( VersionRange.createFromVersionSpec( "(,5.12.1)" ).containsVersion( v ) )
@@ -226,77 +125,74 @@ public class SurefireLauncher
 
     public SurefireLauncher resetInitialGoals( String testNgVersion )
     {
-        this.goals.clear();
-        this.goals.addAll( getInitialGoals( testNgVersion ) );
+        mavenLauncher.resetGoals();
+        for ( String s : getInitialGoals( testNgVersion ) )
+        {
+            mavenLauncher.addGoal( s );
+        }
         return this;
     }
 
 
     public SurefireLauncher assertNotPresent( String subFile )
     {
-        getVerifier().assertFileNotPresent( getValidator().getSubFile( subFile ).getAbsolutePath() );
+        mavenLauncher.assertNotPresent( subFile );
         return this;
     }
 
     public SurefireLauncher showErrorStackTraces()
     {
-        addCliOption( "-e" );
+        mavenLauncher.showErrorStackTraces();
         return this;
     }
 
     public SurefireLauncher debugLogging()
     {
-        addCliOption( "-X" );
+        mavenLauncher.debugLogging();
         return this;
     }
 
     public SurefireLauncher debugSurefireFork()
     {
-        addD( "maven.surefire.debug", "true" );
+        mavenLauncher.addD( "maven.surefire.debug", "true" );
         return this;
     }
 
     public SurefireLauncher failNever()
     {
-        addCliOption( "-fn" );
+        mavenLauncher.failNever();
         return this;
     }
 
     public SurefireLauncher offline()
     {
-        addCliOption( "-o" );
-        return this;
-    }
-
-    public SurefireLauncher skipClean()
-    {
-        goals.add( "-Dclean.skip=true" );
+        mavenLauncher.offline();
         return this;
     }
 
     public SurefireLauncher groups( String groups )
     {
-        goals.add( "-Dgroups=" + groups );
+        mavenLauncher.addD( "groups", groups );
         return this;
     }
 
 
     public SurefireLauncher addGoal( String goal )
     {
-        goals.add( goal );
+        mavenLauncher.addGoal( goal );
         return this;
     }
 
     public OutputValidator executeTest()
     {
-        addCliOption( "-o" );
-        return execute( "test" );
+        mavenLauncher.addCliOption( "-o" );
+        return mavenLauncher.execute( "test" );
     }
 
     public OutputValidator executeInstall()
         throws VerificationException
     {
-        return execute( "install" );
+        return mavenLauncher.execute( "install" );
     }
 
     public OutputValidator executeTestWithFailure()
@@ -307,7 +203,7 @@ public class SurefireLauncher
         }
         catch ( SurefireVerifierException ignore )
         {
-            return getValidator();
+            return mavenLauncher.getValidator();
         }
         throw new RuntimeException( "Expecting build failure, got none!" );
     }
@@ -320,7 +216,7 @@ public class SurefireLauncher
         }
         catch ( SurefireVerifierException ignore )
         {
-            return getValidator();
+            return mavenLauncher.getValidator();
         }
         throw new RuntimeException( "Expecting build failure, got none!" );
     }
@@ -329,95 +225,30 @@ public class SurefireLauncher
     public FailsafeOutputValidator executeVerify()
     {
         OutputValidator verify = execute( "verify" );
-        return new FailsafeOutputValidator( verify.getVerifier() );
+        return new FailsafeOutputValidator( verify );
     }
 
     public OutputValidator execute( String goal )
     {
-        addGoal( goal );
-        return executeCurrentGoals();
+        return mavenLauncher.execute( goal );
     }
 
     public OutputValidator executeCurrentGoals()
     {
-
-        String userLocalRepo = System.getProperty( "user.localRepository" );
-        String testBuildDirectory = System.getProperty( "testBuildDirectory" );
-        boolean useInterpolatedSettings = Boolean.getBoolean( "useInterpolatedSettings" );
-
-        try
-        {
-            if ( useInterpolatedSettings )
-            {
-                File interpolatedSettings = new File( testBuildDirectory, "interpolated-settings" );
-
-                if ( !interpolatedSettings.exists() )
-                {
-                    // hack "a la" invoker plugin to download dependencies from local repo
-                    // and not download from central
-
-                    Map<String, String> values = new HashMap<String, String>( 1 );
-                    values.put( "localRepositoryUrl", toUrl( userLocalRepo ) );
-                    StrSubstitutor strSubstitutor = new StrSubstitutor( values );
-
-                    String fileContent = FileUtils.fileRead( new File( testBuildDirectory, "settings.xml" ) );
-
-                    String filtered = strSubstitutor.replace( fileContent );
-
-                    FileUtils.fileWrite( interpolatedSettings.getAbsolutePath(), filtered );
-
-                }
-
-                addCliOption( "-s " + interpolatedSettings.getCanonicalPath() );
-            }
-            getVerifier().setCliOptions( cliOptions );
-
-            getVerifier().executeGoals( goals, envvars );
-            return getValidator();
-        }
-        catch ( IOException e )
-        {
-            throw new SurefireVerifierException( e.getMessage(), e );
-        }
-        catch ( VerificationException e )
-        {
-            throw new SurefireVerifierException( e.getMessage(), e );
-        }
-        finally
-        {
-            getVerifier().resetStreams();
-        }
-    }
-
-    private static String toUrl( String filename )
-    {
-        /*
-         * NOTE: Maven fails to properly handle percent-encoded "file:" URLs (WAGON-111) so don't use File.toURI() here
-         * as-is but use the decoded path component in the URL.
-         */
-        String url = "file://" + new File( filename ).toURI().getPath();
-        if ( url.endsWith( "/" ) )
-        {
-            url = url.substring( 0, url.length() - 1 );
-        }
-        return url;
+        return mavenLauncher.executeCurrentGoals();
     }
 
 
     public SurefireLauncher printSummary( boolean printsummary )
     {
-        return addGoal( "-DprintSummary=" + printsummary );
-    }
-
-    public SurefireLauncher redirectToFileReally( boolean redirect )
-    {
-        return addGoal( "-Dmaven.test.redirectTestOutputToFile=" + redirect );
+        mavenLauncher.addD( "printSummary", printsummary );
+        return this;
     }
 
     public SurefireLauncher redirectToFile( boolean redirect )
     {
-        return redirectToFileReally( redirect );
-        //addGoal( "-Dredirect.to.file=" + redirect );
+        mavenLauncher.addD( "maven.test.redirectTestOutputToFile", redirect );
+        return this;
     }
 
     public SurefireLauncher forkOnce()
@@ -452,39 +283,53 @@ public class SurefireLauncher
 
     public SurefireLauncher threadCount( int threadCount )
     {
-        return addGoal( "-DthreadCount=" + threadCount );
+        mavenLauncher.addD( "threadCount", threadCount );
+        return this;
     }
 
     public SurefireLauncher forkMode( String forkMode )
     {
-        return addGoal( "-DforkMode=" + forkMode );
+        mavenLauncher.addD( "forkMode", forkMode );
+        return this;
     }
 
     public SurefireLauncher runOrder( String runOrder )
     {
-        return addGoal( "-DrunOrder=" + runOrder );
+        mavenLauncher.addD( "runOrder", runOrder );
+        return this;
     }
 
     public SurefireLauncher failIfNoTests( boolean fail )
     {
         this.failIfNoTests = fail;
-        return addGoal( "-DfailIfNoTests=" + fail );
+        mavenLauncher.addD( "failIfNoTests", fail );
+        return this;
+    }
+
+
+    public SurefireLauncher mavenTestFailureIgnore( boolean fail )
+    {
+        mavenLauncher.addD( "maven.test.failure.ignore", fail );
+        return this;
     }
 
     public SurefireLauncher failIfNoSpecifiedTests( boolean fail )
     {
         this.failIfNoTests = fail;
-        return addGoal( "-Dsurefire.failIfNoSpecifiedTests=" + fail );
+        mavenLauncher.addD( "surefire.failIfNoSpecifiedTests", fail );
+        return this;
     }
 
     public SurefireLauncher useSystemClassLoader( boolean useSystemClassLoader )
     {
-        return addGoal( "-DuseSystemClassLoader=" + useSystemClassLoader );
+        mavenLauncher.addD( "useSystemClassLoader", useSystemClassLoader );
+        return this;
     }
 
     public SurefireLauncher activateProfile( String profile )
     {
-        return addGoal( "-P" + profile );
+        mavenLauncher.activateProfile( profile );
+        return this;
     }
 
 
@@ -495,7 +340,9 @@ public class SurefireLauncher
 
     public SurefireLauncher parallel( String parallel )
     {
-        return addD( "parallel", parallel );
+
+        mavenLauncher.addD( "parallel", parallel );
+        return this;
     }
 
 
@@ -512,23 +359,26 @@ public class SurefireLauncher
 
     public SurefireLauncher addD( String variable, String value )
     {
-        return addGoal( "-D" + variable + "=" + value );
+        mavenLauncher.addD( variable, value );
+        return this;
     }
 
     public SurefireLauncher setJUnitVersion( String version )
     {
-        addD( "junit.version", version );
+        mavenLauncher.addD( "junit.version", version );
         return this;
     }
 
     public SurefireLauncher setGroups( String groups )
     {
-        return addD( "groups", groups );
+        mavenLauncher.addD( "groups", groups );
+        return this;
     }
 
     public SurefireLauncher setExcludedGroups( String excludedGroups )
     {
-        return addD( "excludedGroups", excludedGroups );
+        mavenLauncher.addD( "excludedGroups", excludedGroups );
+        return this;
     }
 
     public SurefireLauncher setEOption()
@@ -543,77 +393,44 @@ public class SurefireLauncher
         return failIfNoTests;
     }
 
-    public File getUnpackLocation()
+    public File getUnpackedAt()
     {
-        getVerifier(); // Make sure we have unpacked
-        return getUnpackDir();
+        return mavenLauncher.getUnpackedAt();
     }
 
     public SurefireLauncher addFailsafeReportOnlyGoal()
     {
-        goals.add(
-            "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":failsafe-report-only" );
+        mavenLauncher.addGoal( getReportPluginGoal( ":failsafe-report-only" ) );
         return this;
     }
 
     public SurefireLauncher addSurefireReportGoal()
     {
-        goals.add( "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":report" );
+        mavenLauncher.addGoal( getReportPluginGoal( "report" ) );
         return this;
     }
 
     public SurefireLauncher addSurefireReportOnlyGoal()
     {
-        goals.add( "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":report-only" );
+        mavenLauncher.addGoal( getReportPluginGoal( "report-only" ) );
         return this;
     }
 
+    private String getReportPluginGoal( String goal )
+    {
+        return "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":" + goal;
+    }
+
 
     public SurefireLauncher deleteSiteDir()
     {
-        try
-        {
-            FileUtils.deleteDirectory( getValidator().getSubFile( "site" ) );
-        }
-        catch ( IOException e )
-        {
-            throw new SurefireVerifierException( e );
-        }
+        mavenLauncher.deleteSiteDir();
         return this;
     }
 
     public SurefireLauncher setTestToRun( String basicTest )
     {
-        addD( "test", basicTest );
+        mavenLauncher.addD( "test", basicTest );
         return this;
     }
-
-    public OutputValidator getValidator()
-    {
-        if ( validator == null )
-        {
-            this.validator = new OutputValidator( getVerifier() );
-        }
-        return validator;
-    }
-
-    private Verifier getVerifier()
-    {
-        if ( verifier == null )
-        {
-            try
-            {
-                this.verifier = createVerifier( testClass, resourceName );
-            }
-            catch ( IOException e )
-            {
-                throw new RuntimeException( e );
-            }
-            catch ( VerificationException e )
-            {
-                throw new RuntimeException( e );
-            }
-        }
-        return verifier;
-    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
index 6d3429b..e02b7bd 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
@@ -16,7 +16,8 @@ public class SurefireLauncherTest
     public void launcherGetsProperMethodName()
         throws IOException, VerificationException
     {
-        String method = new SurefireLauncher( SurefireLauncherTest.class, "foo", "" ).getTestMethodName();
+        MavenLauncher mavenLauncher = new MavenLauncher(  SurefireLauncherTest.class, "foo", "");
+        String method = new SurefireLauncher( mavenLauncher ).getTestMethodName();
         assertEquals( "launcherGetsProperMethodName", method );
 
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
index 1cdfe56..2450b13 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
@@ -20,10 +20,7 @@ package org.apache.maven.surefire.its.jiras;
  */
 
 import org.apache.maven.it.VerificationException;
-import org.apache.maven.surefire.its.fixture.OutputValidator;
-import org.apache.maven.surefire.its.fixture.SurefireIntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java
index b593976..435cf87 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java
@@ -20,6 +20,8 @@ package org.apache.maven.surefire.its.jiras;
  */
 
 import java.io.File;
+
+import org.apache.maven.surefire.its.fixture.MavenLauncher;
 import org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.apache.maven.surefire.its.fixture.SurefireIntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
@@ -38,12 +40,13 @@ public class Surefire162CharsetProviderIT
         throws Exception
     {
         SurefireLauncher unpack = unpack( "/surefire-162-charsetProvider" );
-        OutputValidator verifier = unpack.getValidator();
-        File jarFile = new File( verifier.getArtifactPath( "jcharset", "jcharset", "1.2.1", "jar" ) );
+        MavenLauncher maven = unpack.maven();
+        OutputValidator verifier = maven.getValidator();
+        File jarFile = maven.getArtifactPath( "jcharset", "jcharset", "1.2.1", "jar" );
+        File pomFile = maven.getArtifactPath( "jcharset", "jcharset", "1.2.1", "pom" );
         jarFile.getParentFile().mkdirs();
         FileUtils.copyFile( verifier.getSubFile( "repo/jcharset/jcharset/1.2.1/jcharset-1.2.1.jar" ), jarFile );
-        FileUtils.copyFile( verifier.getSubFile( "repo/jcharset/jcharset/1.2.1/jcharset-1.2.1.pom" ),
-                            new File( verifier.getArtifactPath( "jcharset", "jcharset", "1.2.1", "pom" ) ) );
+        FileUtils.copyFile( verifier.getSubFile( "repo/jcharset/jcharset/1.2.1/jcharset-1.2.1.pom" ), pomFile );
         unpack.executeTest().verifyErrorFree( 1 );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java
index 3930133..2908d97 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java
@@ -97,7 +97,8 @@ public class Surefire772NoFailsafeReportsIT
     {
         final SurefireLauncher unpack = unpack( "surefire-772-no-failsafe-reports" );
         unpack.deleteSiteDir();
-        return unpack.skipClean().failNever().assertNotPresent( "site" );
+        unpack.maven().skipClean().failNever().assertNotPresent( "site" );
+        return unpack;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7e1aee6d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
index 2b9d661..7f1592d 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
@@ -37,8 +37,7 @@ public class Surefire920TestFailureIgnoreWithTimeoutIT
     public void timeoutInForkWithNoBuildFail()
     {
         OutputValidator validator =
-            unpack( "fork-timeout" ).addD( "junit.parallel", "none" ).addD( "maven.test.failure.ignore",
-                                                                            "true" ).executeTest();
+            unpack( "fork-timeout" ).addD( "junit.parallel", "none" ).mavenTestFailureIgnore( true ).executeTest();
         validator.verifyTextInLog( "[ERROR] There was a timeout or other error in the fork" );
     }