Coverage Report - org.apache.maven.plugin.failsafe.IntegrationTestMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
IntegrationTestMojo
0%
0/229
0%
0/28
1.112
 
 1  
 package org.apache.maven.plugin.failsafe;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *     http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.BufferedOutputStream;
 23  
 import java.io.File;
 24  
 import java.io.FileOutputStream;
 25  
 import java.io.IOException;
 26  
 import java.io.OutputStreamWriter;
 27  
 import java.io.Writer;
 28  
 import java.util.HashMap;
 29  
 import java.util.List;
 30  
 import java.util.Map;
 31  
 import java.util.Properties;
 32  
 
 33  
 import org.apache.maven.artifact.factory.ArtifactFactory;
 34  
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 35  
 import org.apache.maven.artifact.repository.ArtifactRepository;
 36  
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 37  
 import org.apache.maven.execution.MavenSession;
 38  
 import org.apache.maven.plugin.MojoExecutionException;
 39  
 import org.apache.maven.plugin.MojoFailureException;
 40  
 import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
 41  
 import org.apache.maven.plugin.surefire.SurefireExecutionParameters;
 42  
 import org.apache.maven.project.MavenProject;
 43  
 import org.apache.maven.surefire.booter.SurefireBooter;
 44  
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 45  
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 46  
 import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
 47  
 import org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
 48  
 import org.apache.maven.toolchain.ToolchainManager;
 49  
 import org.codehaus.plexus.util.ReaderFactory;
 50  
 import org.codehaus.plexus.util.StringUtils;
 51  
 
 52  
 /**
 53  
  * Run integration tests using Surefire.
 54  
  *
 55  
  * @author Jason van Zyl
 56  
  * @author Stephen Connolly
 57  
  * @requiresProject true
 58  
  * @requiresDependencyResolution test
 59  
  * @goal integration-test
 60  
  * @phase integration-test
 61  
  * @threadSafe
 62  
  */
 63  0
 public class IntegrationTestMojo
 64  
     extends AbstractSurefireMojo
 65  
     implements SurefireExecutionParameters
 66  
 {
 67  
 
 68  
     /**
 69  
      * Set this to 'true' to skip running tests, but still compile them. Its use is NOT RECOMMENDED, but quite
 70  
      * convenient on occasion.
 71  
      *
 72  
      * @parameter default-value="false" expression="${skipTests}"
 73  
      * @since 2.4
 74  
      */
 75  
     private boolean skipTests;
 76  
 
 77  
     /**
 78  
      * Set this to 'true' to skip running integration tests, but still compile them. Its use is NOT RECOMMENDED, but quite
 79  
      * convenient on occasion.
 80  
      *
 81  
      * @parameter expression="${skipITs}"
 82  
      * @since 2.4.3-alpha-2
 83  
      */
 84  
     private boolean skipITs;
 85  
 
 86  
     /**
 87  
      * This old parameter is just like skipTests, but bound to the old property maven.test.skip.exec.
 88  
      *
 89  
      * @parameter expression="${maven.test.skip.exec}"
 90  
      * @since 2.3
 91  
      * @deprecated Use -DskipTests instead.
 92  
      */
 93  
     private boolean skipExec;
 94  
 
 95  
     /**
 96  
      * Set this to 'true' to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you
 97  
      * enable it using the "maven.test.skip" property, because maven.test.skip disables both running the
 98  
      * tests and compiling the tests.  Consider using the skipTests parameter instead.
 99  
      *
 100  
      * @parameter default-value="false" expression="${maven.test.skip}"
 101  
      */
 102  
     private boolean skip;
 103  
 
 104  
     /**
 105  
      * The base directory of the project being tested. This can be obtained in your unit test by
 106  
      * System.getProperty("basedir").
 107  
      *
 108  
      * @parameter default-value="${basedir}"
 109  
      */
 110  
     private File basedir;
 111  
 
 112  
     /**
 113  
      * The directory containing generated test classes of the project being tested.
 114  
      * This will be included at the beginning the test classpath.
 115  
      *
 116  
      * @parameter default-value="${project.build.testOutputDirectory}"
 117  
      */
 118  
     private File testClassesDirectory;
 119  
 
 120  
     /**
 121  
      * The directory containing generated classes of the project being tested.
 122  
      * This will be included after the test classes in the test classpath.
 123  
      *
 124  
      * @parameter default-value="${project.build.outputDirectory}"
 125  
      */
 126  
     private File classesDirectory;
 127  
 
 128  
     /**
 129  
      * The Maven Project Object
 130  
      *
 131  
      * @parameter default-value="${project}"
 132  
      * @readonly
 133  
      */
 134  
     private MavenProject project;
 135  
 
 136  
     /**
 137  
      * List of dependencies to exclude from the test classpath.
 138  
      * Each dependency string must follow the format <i>groupId:artifactId</i>.
 139  
      * For example: <i>org.acme:project-a</i>
 140  
      * 
 141  
      *  @parameter
 142  
      *  @since 2.6
 143  
      */
 144  
     private List classpathDependencyExcludes;
 145  
     
 146  
     /**
 147  
      * A dependency scope to exclude from the test classpath
 148  
      * The scope should be one of the scopes defined by org.apache.maven.artifact.Artifact.
 149  
      * This includes the following
 150  
      * 
 151  
      * <ul>
 152  
      * <li><i>compile</i> - system, provided, compile
 153  
      * <li><i>runtime</i> - compile, runtime
 154  
      * <li><i>compile+runtime</i> - system, provided, compile, runtime
 155  
      * <li><i>runtime+system</i> - system, compile, runtime
 156  
      * <li><i>test</i> - system, provided, compile, runtime, test
 157  
      * </ul>
 158  
      * 
 159  
      * @parameter default-value=""
 160  
      * @since 2.6
 161  
      */
 162  
     private String classpathDependencyScopeExclude;
 163  
 
 164  
     /**
 165  
      * Additional elements to be appended to the classpath.
 166  
      *
 167  
      * @parameter
 168  
      * @since 2.4
 169  
      */
 170  
     private List additionalClasspathElements;
 171  
 
 172  
     /**
 173  
      * Base directory where all reports are written to.
 174  
      *
 175  
      * @parameter default-value="${project.build.directory}/failsafe-reports"
 176  
      */
 177  
     private File reportsDirectory;
 178  
 
 179  
     /**
 180  
      * The test source directory containing test class sources.
 181  
      *
 182  
      * @parameter default-value="${project.build.testSourceDirectory}"
 183  
      * @required
 184  
      * @since 2.2
 185  
      */
 186  
     private File testSourceDirectory;
 187  
 
 188  
     /**
 189  
      * Specify this parameter to run individual tests by file name, overriding the <code>includes/excludes</code>
 190  
      * parameters.  Each pattern you specify here will be used to create an
 191  
      * include pattern formatted like <code>**&#47;${test}.java</code>, so you can just type "-Dtest=MyTest"
 192  
      * to run a single test called "foo/MyTest.java".  This parameter will override the TestNG suiteXmlFiles
 193  
      * parameter.
 194  
      *
 195  
      * @parameter expression="${it.test}"
 196  
      */
 197  
     private String test;
 198  
 
 199  
     /**
 200  
      * List of patterns (separated by commas) used to specify the tests that should be included in testing. When not
 201  
      * specified and when the <code>test</code> parameter is not specified, the default includes will be
 202  
      * <code>**&#47;IT*.java   **&#47;*IT.java   **&#47;*ITCase.java</code>.  This parameter is ignored if
 203  
      * TestNG suiteXmlFiles are specified.
 204  
      *
 205  
      * @parameter
 206  
      */
 207  
     private List includes;
 208  
 
 209  
     /**
 210  
      * List of patterns (separated by commas) used to specify the tests that should be excluded in testing. When not
 211  
      * specified and when the <code>test</code> parameter is not specified, the default excludes will be
 212  
      * <code>**&#47;*$*</code> (which excludes all inner classes).  This parameter is ignored if
 213  
      * TestNG suiteXmlFiles are specified.
 214  
      *
 215  
      * @parameter
 216  
      */
 217  
     private List excludes;
 218  
 
 219  
     /**
 220  
      * ArtifactRepository of the localRepository. To obtain the directory of localRepository in unit tests use
 221  
      * System.setProperty( "localRepository").
 222  
      *
 223  
      * @parameter expression="${localRepository}"
 224  
      * @required
 225  
      * @readonly
 226  
      */
 227  
     private ArtifactRepository localRepository;
 228  
 
 229  
     /**
 230  
      * List of System properties to pass to the JUnit tests.
 231  
      *
 232  
      * @parameter
 233  
      * @deprecated Use systemPropertyVariables instead.
 234  
      */
 235  
     private Properties systemProperties;
 236  
 
 237  
     /**
 238  
      * List of System properties to pass to the JUnit tests.
 239  
      *
 240  
      * @parameter
 241  
      * @since 2.5
 242  
      */
 243  
     private Map systemPropertyVariables;
 244  
 
 245  
     /**
 246  
      * List of properties for configuring all TestNG related configurations. This is the new
 247  
      * preferred method of configuring TestNG.
 248  
      *
 249  
      * @parameter
 250  
      * @since 2.4
 251  
      */
 252  
     private Properties properties;
 253  
 
 254  
     /**
 255  
      * Map of of plugin artifacts.
 256  
      *
 257  
      * @parameter expression="${plugin.artifactMap}"
 258  
      * @required
 259  
      * @readonly
 260  
      */
 261  
     private Map pluginArtifactMap;
 262  
 
 263  
     /**
 264  
      * Map of of project artifacts.
 265  
      *
 266  
      * @parameter expression="${project.artifactMap}"
 267  
      * @required
 268  
      * @readonly
 269  
      */
 270  
     private Map projectArtifactMap;
 271  
 
 272  
     /**
 273  
      * The summary file to write integration test results to.
 274  
      *
 275  
      * @parameter expression="${project.build.directory}/failsafe-reports/failsafe-summary.xml"
 276  
      * @required
 277  
      */
 278  
     private File summaryFile;
 279  
 
 280  
     /**
 281  
      * Option to print summary of test suites or just print the test cases that has errors.
 282  
      *
 283  
      * @parameter expression="${failsafe.printSummary}" default-value="true"
 284  
      */
 285  
     private boolean printSummary;
 286  
 
 287  
     /**
 288  
      * Selects the formatting for the test report to be generated. Can be set as brief or plain.
 289  
      *
 290  
      * @parameter expression="${failsafe.reportFormat}" default-value="brief"
 291  
      */
 292  
     private String reportFormat;
 293  
 
 294  
     /**
 295  
      * Option to generate a file test report or just output the test report to the console.
 296  
      *
 297  
      * @parameter expression="${failsafe.useFile}" default-value="true"
 298  
      */
 299  
     private boolean useFile;
 300  
 
 301  
     /**
 302  
      * When forking, set this to true to redirect the unit test standard output to a file (found in
 303  
      * reportsDirectory/testName-output.txt).
 304  
      *
 305  
      * @parameter expression="${maven.test.redirectTestOutputToFile}" default-value="false"
 306  
      * @since 2.3
 307  
      */
 308  
     private boolean redirectTestOutputToFile;
 309  
 
 310  
     /**
 311  
      * Set this to "true" to cause a failure if there are no tests to run. Defaults to false.
 312  
      *
 313  
      * @parameter expression="${failIfNoTests}"
 314  
      * @since 2.4
 315  
      */
 316  
     private Boolean failIfNoTests;
 317  
 
 318  
     /**
 319  
      * Option to specify the forking mode. Can be "never", "once" or "always". "none" and "pertest" are also accepted
 320  
      * for backwards compatibility.
 321  
      *
 322  
      * @parameter expression="${forkMode}" default-value="once"
 323  
      * @since 2.1
 324  
      */
 325  
     private String forkMode;
 326  
 
 327  
     /**
 328  
      * Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the
 329  
      * jvm will be the same as the one used to run Maven.
 330  
      *
 331  
      * @parameter expression="${jvm}"
 332  
      * @since 2.1
 333  
      */
 334  
     private String jvm;
 335  
 
 336  
     /**
 337  
      * Arbitrary JVM options to set on the command line.
 338  
      *
 339  
      * @parameter expression="${argLine}"
 340  
      * @since 2.1
 341  
      */
 342  
     private String argLine;
 343  
 
 344  
     /**
 345  
      * Attach a debugger to the forked JVM.  If set to "true", the process will suspend and
 346  
      * wait for a debugger to attach on port 5005.  If set to some other string, that
 347  
      * string will be appended to the argLine, allowing you to configure arbitrary
 348  
      * debuggability options (without overwriting the other options specified in the argLine).
 349  
      *
 350  
      * @parameter expression="${maven.failsafe.debug}"
 351  
      * @since 2.4
 352  
      */
 353  
     private String debugForkedProcess;
 354  
 
 355  
     /**
 356  
      * Kill the forked test process after a certain number of seconds.  If set to 0,
 357  
      * wait forever for the process, never timing out.
 358  
      *
 359  
      * @parameter expression="${failsafe.timeout}"
 360  
      * @since 2.4
 361  
      */
 362  
     private int forkedProcessTimeoutInSeconds;
 363  
 
 364  
     /**
 365  
      * Additional environments to set on the command line.
 366  
      *
 367  
      * @parameter
 368  
      * @since 2.1.3
 369  
      */
 370  0
     private Map environmentVariables = new HashMap();
 371  
 
 372  
     /**
 373  
      * Command line working directory.
 374  
      *
 375  
      * @parameter expression="${basedir}"
 376  
      * @since 2.1.3
 377  
      */
 378  
     private File workingDirectory;
 379  
 
 380  
     /**
 381  
      * When false it makes tests run using the standard classloader delegation instead of the default Maven isolated
 382  
      * classloader. Only used when forking (forkMode is not "none").<br/> Setting it to false helps with some problems
 383  
      * caused by conflicts between xml parsers in the classpath and the Java 5 provider parser.
 384  
      *
 385  
      * @parameter expression="${childDelegation}" default-value="false"
 386  
      * @since 2.1
 387  
      */
 388  
     private boolean childDelegation;
 389  
 
 390  
     /**
 391  
      * (TestNG only) Groups for this test. Only classes/methods/etc decorated with one of the groups specified here will be included
 392  
      * in test run, if specified.  This parameter is overridden if suiteXmlFiles are specified.
 393  
      *
 394  
      * @parameter expression="${groups}"
 395  
      * @since 2.2
 396  
      */
 397  
     private String groups;
 398  
 
 399  
     /**
 400  
      * (TestNG only) Excluded groups. Any methods/classes/etc with one of the groups specified in this list will specifically not be
 401  
      * run.  This parameter is overridden if suiteXmlFiles are specified.
 402  
      *
 403  
      * @parameter expression="${excludedGroups}"
 404  
      * @since 2.2
 405  
      */
 406  
     private String excludedGroups;
 407  
 
 408  
     /**
 409  
      * (TestNG only) List of TestNG suite xml file locations, seperated by commas. Note that suiteXmlFiles is incompatible
 410  
      * with several other parameters on this plugin, like includes/excludes.  This parameter is ignored if
 411  
      * the "test" parameter is specified (allowing you to run a single test instead of an entire suite).
 412  
      *
 413  
      * @parameter
 414  
      * @since 2.2
 415  
      */
 416  
     private File[] suiteXmlFiles;
 417  
 
 418  
     /**
 419  
      * Allows you to specify the name of the JUnit artifact. If not set, <code>junit:junit</code> will be used.
 420  
      *
 421  
      * @parameter expression="${junitArtifactName}" default-value="junit:junit"
 422  
      * @since 2.3.1
 423  
      */
 424  
     private String junitArtifactName;
 425  
 
 426  
     /**
 427  
      * Allows you to specify the name of the TestNG artifact. If not set, <code>org.testng:testng</code> will be used.
 428  
      *
 429  
      * @parameter expression="${testNGArtifactName}" default-value="org.testng:testng"
 430  
      * @since 2.3.1
 431  
      */
 432  
     private String testNGArtifactName;
 433  
 
 434  
     /**
 435  
      * (TestNG/JUnit 4.7 provider only) The attribute thread-count allows you to specify how many threads should be allocated for this execution. Only
 436  
      * makes sense to use in conjunction with parallel.
 437  
      *
 438  
      * @parameter expression="${threadCount}"
 439  
      * @since 2.2
 440  
      */
 441  
     private int threadCount;
 442  
 
 443  
     /**
 444  
      * (JUnit 4.7 provider) Indicates that threadCount is per cpu core. Defaults to true
 445  
      *
 446  
      * @parameter expression="${perCoreThreadCount}"
 447  
      * @since 2.5
 448  
      */
 449  
     private String perCoreThreadCount;
 450  
 
 451  
     /**
 452  
      * (JUnit 4.7 provider) Indicates that the thread pool will be unlimited. The parallel parameter and the actual number of classes/methods
 453  
      * will decide. Setting this to true effectively disables perCoreThreadCount and threadCount.
 454  
      *
 455  
      * @parameter expression="${useUnlimitedThreads}"
 456  
      * @since 2.5
 457  
      */
 458  
     private String useUnlimitedThreads;
 459  
 
 460  
     /**
 461  
      * (TestNG only) When you use the parallel attribute, TestNG will try to run all your test methods in separate threads, except for
 462  
      * methods that depend on each other, which will be run in the same thread in order to respect their order of
 463  
      * execution.
 464  
      * <p/>
 465  
      * (JUnit 4.7 provider) Supports values classes/methods/both to run in separate threads, as controlled by threadCount.
 466  
      *
 467  
      * @parameter expression="${parallel}"
 468  
      * @todo test how this works with forking, and console/file output parallelism
 469  
      * @since 2.2
 470  
      */
 471  
     private String parallel;
 472  
 
 473  
     /**
 474  
      * Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace.
 475  
      *
 476  
      * @parameter expression="${trimStackTrace}" default-value="true"
 477  
      * @since 2.2
 478  
      */
 479  
     private boolean trimStackTrace;
 480  
 
 481  
     /**
 482  
      * Resolves the artifacts needed.
 483  
      *
 484  
      * @component
 485  
      */
 486  
     private ArtifactResolver artifactResolver;
 487  
 
 488  
     /**
 489  
      * Creates the artifact
 490  
      *
 491  
      * @component
 492  
      */
 493  
     private ArtifactFactory artifactFactory;
 494  
 
 495  
     /**
 496  
      * The plugin remote repositories declared in the POM.
 497  
      *
 498  
      * @parameter expression="${project.pluginArtifactRepositories}"
 499  
      * @since 2.2
 500  
      */
 501  
     private List remoteRepositories;
 502  
 
 503  
     /**
 504  
      * For retrieval of artifact's metadata.
 505  
      *
 506  
      * @component
 507  
      */
 508  
     private ArtifactMetadataSource metadataSource;
 509  
 
 510  
     private static final String BRIEF_REPORT_FORMAT = "brief";
 511  
 
 512  
     private static final String PLAIN_REPORT_FORMAT = "plain";
 513  
 
 514  
     private Properties originalSystemProperties;
 515  
 
 516  
     /**
 517  
      * systemPropertyVariables + systemProperties
 518  
      */
 519  0
     private Properties internalSystemProperties = new Properties();
 520  
 
 521  
     /**
 522  
      * Flag to disable the generation of report files in xml format.
 523  
      *
 524  
      * @parameter expression="${disableXmlReport}" default-value="false"
 525  
      * @since 2.2
 526  
      */
 527  
     private boolean disableXmlReport;
 528  
 
 529  
     /**
 530  
      * Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.
 531  
      * Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's
 532  
      * classloader.  Default value is "true".
 533  
      *
 534  
      * @parameter expression="${failsafe.useSystemClassLoader}"
 535  
      * @since 2.3
 536  
      */
 537  
     private Boolean useSystemClassLoader;
 538  
 
 539  
     /**
 540  
      * By default, Surefire forks your tests using a manifest-only JAR; set this parameter
 541  
      * to "false" to force it to launch your tests with a plain old Java classpath.
 542  
      * (See http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
 543  
      * for a more detailed explanation of manifest-only JARs and their benefits.)
 544  
      * <p/>
 545  
      * Beware, setting this to "false" may cause your tests to
 546  
      * fail on Windows if your classpath is too long.
 547  
      *
 548  
      * @parameter expression="${failsafe.useManifestOnlyJar}" default-value="true"
 549  
      * @since 2.4.3
 550  
      */
 551  
     private boolean useManifestOnlyJar;
 552  
 
 553  
     /**
 554  
      * By default, Surefire enables JVM assertions for the execution of your test cases. To disable the assertions, set
 555  
      * this flag to <code>false</code>.
 556  
      *
 557  
      * @parameter expression="${enableAssertions}" default-value="true"
 558  
      * @since 2.3.1
 559  
      */
 560  
     private boolean enableAssertions;
 561  
 
 562  
     /**
 563  
      * The current build session instance.
 564  
      *
 565  
      * @parameter expression="${session}"
 566  
      * @required
 567  
      * @readonly
 568  
      */
 569  
     private MavenSession session;
 570  
 
 571  
     /**
 572  
      * (TestNG only) Define the factory class used to create all test instances
 573  
      *
 574  
      * @parameter expression="${objectFactory}"
 575  
      * @since 2.5
 576  
      */
 577  
     private String objectFactory;
 578  
 
 579  
     /**
 580  
      * The character encoding scheme to be applied.
 581  
      *
 582  
      * @parameter expression="${encoding}" default-value="${project.reporting.outputEncoding}"
 583  
      */
 584  
     private String encoding;
 585  
 
 586  
     /** @parameter default-value="${session.parallel}" */
 587  
     private Boolean parallelMavenExecution;
 588  
 
 589  
     /**
 590  
      * @component
 591  
      */
 592  
     private ToolchainManager toolchainManager;
 593  
 
 594  
 
 595  
     public void execute()
 596  
         throws MojoExecutionException, MojoFailureException
 597  
     {
 598  0
         if ( verifyParameters() )
 599  
         {
 600  0
             SurefireBooter surefireBooter = constructSurefireBooter();
 601  
 
 602  0
             getLog().info(
 603  
                 StringUtils.capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() );
 604  
 
 605  0
             FailsafeSummary result = new FailsafeSummary();
 606  
             try
 607  
             {
 608  0
                 result.setResult( surefireBooter.run() );
 609  
             }
 610  0
             catch ( SurefireBooterForkException e )
 611  
             {
 612  
                 // Don't stop processing when timeout or other exception occures
 613  
                 // Otherwise, the following life cycles (e.g. post-integration-test)
 614  
                 // won't be executed
 615  0
                 result.setResult( SurefireBooter.TESTS_FAILED_EXIT_CODE );
 616  0
                 result.setException( e.getMessage() );
 617  
             }
 618  0
             catch ( SurefireExecutionException e )
 619  
             {
 620  
                 // Don't stop processing when timeout or other exception occures
 621  
                 // Otherwise, the following life cycles (e.g. post-integration-test)
 622  
                 // won't be executed
 623  0
                 result.setResult( SurefireBooter.TESTS_FAILED_EXIT_CODE );
 624  0
                 result.setException( e.getMessage() );
 625  0
             }
 626  
 
 627  0
             if ( getOriginalSystemProperties() != null && !surefireBooter.isForking() )
 628  
             {
 629  
                 // restore system properties, only makes sense when not forking..
 630  0
                 System.setProperties( getOriginalSystemProperties() );
 631  
             }
 632  
 
 633  0
             if ( !getSummaryFile().getParentFile().isDirectory() )
 634  
             {
 635  0
                 getSummaryFile().getParentFile().mkdirs();
 636  
             }
 637  
 
 638  
             try
 639  
             {
 640  
                 String encoding;
 641  0
                 if ( StringUtils.isEmpty( this.encoding ) )
 642  
                 {
 643  0
                     getLog().warn(
 644  
                         "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
 645  
                             + ", i.e. build is platform dependent!" );
 646  0
                     encoding = ReaderFactory.FILE_ENCODING;
 647  
                 }
 648  
                 else
 649  
                 {
 650  0
                     encoding = this.encoding;
 651  
                 }
 652  
 
 653  0
                 FileOutputStream fileOutputStream = new FileOutputStream( getSummaryFile() );
 654  0
                 BufferedOutputStream bufferedOutputStream = new BufferedOutputStream( fileOutputStream );
 655  0
                 Writer writer = new OutputStreamWriter( bufferedOutputStream, encoding );
 656  0
                 FailsafeSummaryXpp3Writer xpp3Writer = new FailsafeSummaryXpp3Writer();
 657  0
                 xpp3Writer.write( writer, result );
 658  0
                 writer.close();
 659  0
                 bufferedOutputStream.close();
 660  0
                 fileOutputStream.close();
 661  
             }
 662  0
             catch ( IOException e )
 663  
             {
 664  0
                 throw new MojoExecutionException( e.getMessage(), e );
 665  0
             }
 666  
         }
 667  0
     }
 668  
 
 669  
     protected boolean verifyParameters()
 670  
         throws MojoFailureException
 671  
     {
 672  0
         if ( isSkip() || isSkipTests() || isSkipITs() || isSkipExec() )
 673  
         {
 674  0
             getLog().info( "Tests are skipped." );
 675  0
             return false;
 676  
         }
 677  
 
 678  
 
 679  0
         if ( !getTestClassesDirectory().exists() )
 680  
         {
 681  0
             if ( getFailIfNoTests() != null && getFailIfNoTests().booleanValue() )
 682  
             {
 683  0
                 throw new MojoFailureException( "No tests to run!" );
 684  
             }
 685  0
             getLog().info( "No tests to run." );
 686  0
             return false;
 687  
         }
 688  
 
 689  0
         ensureWorkingDirectoryExists();
 690  
 
 691  0
         ensureParallelRunningCompatibility();
 692  
 
 693  0
         warnIfUselessUseSystemClassLoaderParameter();
 694  
 
 695  0
         return true;
 696  
     }
 697  
 
 698  
     protected String getPluginName()
 699  
     {
 700  0
         return "failsafe";
 701  
     }
 702  
 
 703  
     protected String[] getDefaultIncludes()
 704  
     {
 705  0
         return new String[]{"**/IT*.java", "**/*IT.java", "**/*ITCase.java"} ;
 706  
     }
 707  
 
 708  
     public boolean isSkipTests()
 709  
     {
 710  0
         return skipTests;
 711  
     }
 712  
 
 713  
     public void setSkipTests( boolean skipTests )
 714  
     {
 715  0
         this.skipTests = skipTests;
 716  0
     }
 717  
 
 718  
     public boolean isSkipITs()
 719  
     {
 720  0
         return skipITs;
 721  
     }
 722  
 
 723  
     public void setSkipITs( boolean skipITs )
 724  
     {
 725  0
         this.skipITs = skipITs;
 726  0
     }
 727  
 
 728  
     public boolean isSkipExec()
 729  
     {
 730  0
         return skipExec;
 731  
     }
 732  
 
 733  
     public void setSkipExec( boolean skipExec )
 734  
     {
 735  0
         this.skipExec = skipExec;
 736  0
     }
 737  
 
 738  
     public boolean isSkip()
 739  
     {
 740  0
         return skip;
 741  
     }
 742  
 
 743  
     public void setSkip( boolean skip )
 744  
     {
 745  0
         this.skip = skip;
 746  0
     }
 747  
 
 748  
     public File getBasedir()
 749  
     {
 750  0
         return basedir;
 751  
     }
 752  
 
 753  
     public void setBasedir( File basedir )
 754  
     {
 755  0
         this.basedir = basedir;
 756  0
     }
 757  
 
 758  
     public File getTestClassesDirectory()
 759  
     {
 760  0
         return testClassesDirectory;
 761  
     }
 762  
 
 763  
     public void setTestClassesDirectory( File testClassesDirectory )
 764  
     {
 765  0
         this.testClassesDirectory = testClassesDirectory;
 766  0
     }
 767  
 
 768  
     public File getClassesDirectory()
 769  
     {
 770  0
         return classesDirectory;
 771  
     }
 772  
 
 773  
     public void setClassesDirectory( File classesDirectory )
 774  
     {
 775  0
         this.classesDirectory = classesDirectory;
 776  0
     }
 777  
 
 778  
     public MavenProject getProject()
 779  
     {
 780  0
         return project;
 781  
     }
 782  
 
 783  
     public void setProject( MavenProject project )
 784  
     {
 785  0
         this.project = project;
 786  0
     }
 787  
 
 788  
     public List getClasspathDependencyExcludes()
 789  
     {
 790  0
         return classpathDependencyExcludes;
 791  
     }
 792  
 
 793  
     public void setClasspathDependencyExcludes( List classpathDependencyExcludes )
 794  
     {
 795  0
         this.classpathDependencyExcludes = classpathDependencyExcludes;
 796  0
     }
 797  
 
 798  
     public String getClasspathDependencyScopeExclude()
 799  
     {
 800  0
         return classpathDependencyScopeExclude;
 801  
     }
 802  
 
 803  
     public void setClasspathDependencyScopeExclude( String classpathDependencyScopeExclude )
 804  
     {
 805  0
         this.classpathDependencyScopeExclude = classpathDependencyScopeExclude;
 806  0
     }
 807  
 
 808  
     public List getAdditionalClasspathElements()
 809  
     {
 810  0
         return additionalClasspathElements;
 811  
     }
 812  
 
 813  
     public void setAdditionalClasspathElements( List additionalClasspathElements )
 814  
     {
 815  0
         this.additionalClasspathElements = additionalClasspathElements;
 816  0
     }
 817  
 
 818  
     public File getReportsDirectory()
 819  
     {
 820  0
         return reportsDirectory;
 821  
     }
 822  
 
 823  
     public void setReportsDirectory( File reportsDirectory )
 824  
     {
 825  0
         this.reportsDirectory = reportsDirectory;
 826  0
     }
 827  
 
 828  
     public File getTestSourceDirectory()
 829  
     {
 830  0
         return testSourceDirectory;
 831  
     }
 832  
 
 833  
     public void setTestSourceDirectory( File testSourceDirectory )
 834  
     {
 835  0
         this.testSourceDirectory = testSourceDirectory;
 836  0
     }
 837  
 
 838  
     public String getTest()
 839  
     {
 840  0
         return test;
 841  
     }
 842  
 
 843  
     public void setTest( String test )
 844  
     {
 845  0
         this.test = test;
 846  0
     }
 847  
 
 848  
     public List getIncludes()
 849  
     {
 850  0
         return includes;
 851  
     }
 852  
 
 853  
     public void setIncludes( List includes )
 854  
     {
 855  0
         this.includes = includes;
 856  0
     }
 857  
 
 858  
     public List getExcludes()
 859  
     {
 860  0
         return excludes;
 861  
     }
 862  
 
 863  
     public void setExcludes( List excludes )
 864  
     {
 865  0
         this.excludes = excludes;
 866  0
     }
 867  
 
 868  
     public ArtifactRepository getLocalRepository()
 869  
     {
 870  0
         return localRepository;
 871  
     }
 872  
 
 873  
     public void setLocalRepository( ArtifactRepository localRepository )
 874  
     {
 875  0
         this.localRepository = localRepository;
 876  0
     }
 877  
 
 878  
     public Properties getSystemProperties()
 879  
     {
 880  0
         return systemProperties;
 881  
     }
 882  
 
 883  
     public void setSystemProperties( Properties systemProperties )
 884  
     {
 885  0
         this.systemProperties = systemProperties;
 886  0
     }
 887  
 
 888  
     public Map getSystemPropertyVariables()
 889  
     {
 890  0
         return systemPropertyVariables;
 891  
     }
 892  
 
 893  
     public void setSystemPropertyVariables( Map systemPropertyVariables )
 894  
     {
 895  0
         this.systemPropertyVariables = systemPropertyVariables;
 896  0
     }
 897  
 
 898  
     public Properties getProperties()
 899  
     {
 900  0
         return properties;
 901  
     }
 902  
 
 903  
     public void setProperties( Properties properties )
 904  
     {
 905  0
         this.properties = properties;
 906  0
     }
 907  
 
 908  
     public Map getPluginArtifactMap()
 909  
     {
 910  0
         return pluginArtifactMap;
 911  
     }
 912  
 
 913  
     public void setPluginArtifactMap( Map pluginArtifactMap )
 914  
     {
 915  0
         this.pluginArtifactMap = pluginArtifactMap;
 916  0
     }
 917  
 
 918  
     public Map getProjectArtifactMap()
 919  
     {
 920  0
         return projectArtifactMap;
 921  
     }
 922  
 
 923  
     public void setProjectArtifactMap( Map projectArtifactMap )
 924  
     {
 925  0
         this.projectArtifactMap = projectArtifactMap;
 926  0
     }
 927  
 
 928  
     public File getSummaryFile()
 929  
     {
 930  0
         return summaryFile;
 931  
     }
 932  
 
 933  
     public void setSummaryFile( File summaryFile )
 934  
     {
 935  0
         this.summaryFile = summaryFile;
 936  0
     }
 937  
 
 938  
     public boolean isPrintSummary()
 939  
     {
 940  0
         return printSummary;
 941  
     }
 942  
 
 943  
     public void setPrintSummary( boolean printSummary )
 944  
     {
 945  0
         this.printSummary = printSummary;
 946  0
     }
 947  
 
 948  
     public String getReportFormat()
 949  
     {
 950  0
         return reportFormat;
 951  
     }
 952  
 
 953  
     public void setReportFormat( String reportFormat )
 954  
     {
 955  0
         this.reportFormat = reportFormat;
 956  0
     }
 957  
 
 958  
     public boolean isUseFile()
 959  
     {
 960  0
         return useFile;
 961  
     }
 962  
 
 963  
     public void setUseFile( boolean useFile )
 964  
     {
 965  0
         this.useFile = useFile;
 966  0
     }
 967  
 
 968  
     public boolean isRedirectTestOutputToFile()
 969  
     {
 970  0
         return redirectTestOutputToFile;
 971  
     }
 972  
 
 973  
     public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
 974  
     {
 975  0
         this.redirectTestOutputToFile = redirectTestOutputToFile;
 976  0
     }
 977  
 
 978  
     public Boolean getFailIfNoTests()
 979  
     {
 980  0
         return failIfNoTests;
 981  
     }
 982  
 
 983  
     public void setFailIfNoTests( Boolean failIfNoTests )
 984  
     {
 985  0
         this.failIfNoTests = failIfNoTests;
 986  0
     }
 987  
 
 988  
     public String getForkMode()
 989  
     {
 990  0
         return forkMode;
 991  
     }
 992  
 
 993  
     public void setForkMode( String forkMode )
 994  
     {
 995  0
         this.forkMode = forkMode;
 996  0
     }
 997  
 
 998  
     public String getJvm()
 999  
     {
 1000  0
         return jvm;
 1001  
     }
 1002  
 
 1003  
     public void setJvm( String jvm )
 1004  
     {
 1005  0
         this.jvm = jvm;
 1006  0
     }
 1007  
 
 1008  
     public String getArgLine()
 1009  
     {
 1010  0
         return argLine;
 1011  
     }
 1012  
 
 1013  
     public void setArgLine( String argLine )
 1014  
     {
 1015  0
         this.argLine = argLine;
 1016  0
     }
 1017  
 
 1018  
     public String getDebugForkedProcess()
 1019  
     {
 1020  0
         return debugForkedProcess;
 1021  
     }
 1022  
 
 1023  
     public void setDebugForkedProcess( String debugForkedProcess )
 1024  
     {
 1025  0
         this.debugForkedProcess = debugForkedProcess;
 1026  0
     }
 1027  
 
 1028  
     public int getForkedProcessTimeoutInSeconds()
 1029  
     {
 1030  0
         return forkedProcessTimeoutInSeconds;
 1031  
     }
 1032  
 
 1033  
     public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
 1034  
     {
 1035  0
         this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
 1036  0
     }
 1037  
 
 1038  
     public Map getEnvironmentVariables()
 1039  
     {
 1040  0
         return environmentVariables;
 1041  
     }
 1042  
 
 1043  
     public void setEnvironmentVariables( Map environmentVariables )
 1044  
     {
 1045  0
         this.environmentVariables = environmentVariables;
 1046  0
     }
 1047  
 
 1048  
     public File getWorkingDirectory()
 1049  
     {
 1050  0
         return workingDirectory;
 1051  
     }
 1052  
 
 1053  
     public void setWorkingDirectory( File workingDirectory )
 1054  
     {
 1055  0
         this.workingDirectory = workingDirectory;
 1056  0
     }
 1057  
 
 1058  
     public boolean isChildDelegation()
 1059  
     {
 1060  0
         return childDelegation;
 1061  
     }
 1062  
 
 1063  
     public void setChildDelegation( boolean childDelegation )
 1064  
     {
 1065  0
         this.childDelegation = childDelegation;
 1066  0
     }
 1067  
 
 1068  
     public String getGroups()
 1069  
     {
 1070  0
         return groups;
 1071  
     }
 1072  
 
 1073  
     public void setGroups( String groups )
 1074  
     {
 1075  0
         this.groups = groups;
 1076  0
     }
 1077  
 
 1078  
     public String getExcludedGroups()
 1079  
     {
 1080  0
         return excludedGroups;
 1081  
     }
 1082  
 
 1083  
     public void setExcludedGroups( String excludedGroups )
 1084  
     {
 1085  0
         this.excludedGroups = excludedGroups;
 1086  0
     }
 1087  
 
 1088  
     public File[] getSuiteXmlFiles()
 1089  
     {
 1090  0
         return suiteXmlFiles;
 1091  
     }
 1092  
 
 1093  
     public void setSuiteXmlFiles( File[] suiteXmlFiles )
 1094  
     {
 1095  0
         this.suiteXmlFiles = suiteXmlFiles;
 1096  0
     }
 1097  
 
 1098  
     public String getJunitArtifactName()
 1099  
     {
 1100  0
         return junitArtifactName;
 1101  
     }
 1102  
 
 1103  
     public void setJunitArtifactName( String junitArtifactName )
 1104  
     {
 1105  0
         this.junitArtifactName = junitArtifactName;
 1106  0
     }
 1107  
 
 1108  
     public String getTestNGArtifactName()
 1109  
     {
 1110  0
         return testNGArtifactName;
 1111  
     }
 1112  
 
 1113  
     public void setTestNGArtifactName( String testNGArtifactName )
 1114  
     {
 1115  0
         this.testNGArtifactName = testNGArtifactName;
 1116  0
     }
 1117  
 
 1118  
     public int getThreadCount()
 1119  
     {
 1120  0
         return threadCount;
 1121  
     }
 1122  
 
 1123  
     public void setThreadCount( int threadCount )
 1124  
     {
 1125  0
         this.threadCount = threadCount;
 1126  0
     }
 1127  
 
 1128  
     public String getPerCoreThreadCount()
 1129  
     {
 1130  0
         return perCoreThreadCount;
 1131  
     }
 1132  
 
 1133  
     public void setPerCoreThreadCount( String perCoreThreadCount )
 1134  
     {
 1135  0
         this.perCoreThreadCount = perCoreThreadCount;
 1136  0
     }
 1137  
 
 1138  
     public String getUseUnlimitedThreads()
 1139  
     {
 1140  0
         return useUnlimitedThreads;
 1141  
     }
 1142  
 
 1143  
     public void setUseUnlimitedThreads( String useUnlimitedThreads )
 1144  
     {
 1145  0
         this.useUnlimitedThreads = useUnlimitedThreads;
 1146  0
     }
 1147  
 
 1148  
     public String getParallel()
 1149  
     {
 1150  0
         return parallel;
 1151  
     }
 1152  
 
 1153  
     public void setParallel( String parallel )
 1154  
     {
 1155  0
         this.parallel = parallel;
 1156  0
     }
 1157  
 
 1158  
     public boolean isTrimStackTrace()
 1159  
     {
 1160  0
         return trimStackTrace;
 1161  
     }
 1162  
 
 1163  
     public void setTrimStackTrace( boolean trimStackTrace )
 1164  
     {
 1165  0
         this.trimStackTrace = trimStackTrace;
 1166  0
     }
 1167  
 
 1168  
     public ArtifactResolver getArtifactResolver()
 1169  
     {
 1170  0
         return artifactResolver;
 1171  
     }
 1172  
 
 1173  
     public void setArtifactResolver( ArtifactResolver artifactResolver )
 1174  
     {
 1175  0
         this.artifactResolver = artifactResolver;
 1176  0
     }
 1177  
 
 1178  
     public ArtifactFactory getArtifactFactory()
 1179  
     {
 1180  0
         return artifactFactory;
 1181  
     }
 1182  
 
 1183  
     public void setArtifactFactory( ArtifactFactory artifactFactory )
 1184  
     {
 1185  0
         this.artifactFactory = artifactFactory;
 1186  0
     }
 1187  
 
 1188  
     public List getRemoteRepositories()
 1189  
     {
 1190  0
         return remoteRepositories;
 1191  
     }
 1192  
 
 1193  
     public void setRemoteRepositories( List remoteRepositories )
 1194  
     {
 1195  0
         this.remoteRepositories = remoteRepositories;
 1196  0
     }
 1197  
 
 1198  
     public ArtifactMetadataSource getMetadataSource()
 1199  
     {
 1200  0
         return metadataSource;
 1201  
     }
 1202  
 
 1203  
     public void setMetadataSource( ArtifactMetadataSource metadataSource )
 1204  
     {
 1205  0
         this.metadataSource = metadataSource;
 1206  0
     }
 1207  
 
 1208  
     public Properties getOriginalSystemProperties()
 1209  
     {
 1210  0
         return originalSystemProperties;
 1211  
     }
 1212  
 
 1213  
     public void setOriginalSystemProperties( Properties originalSystemProperties )
 1214  
     {
 1215  0
         this.originalSystemProperties = originalSystemProperties;
 1216  0
     }
 1217  
 
 1218  
     public Properties getInternalSystemProperties()
 1219  
     {
 1220  0
         return internalSystemProperties;
 1221  
     }
 1222  
 
 1223  
     public void setInternalSystemProperties( Properties internalSystemProperties )
 1224  
     {
 1225  0
         this.internalSystemProperties = internalSystemProperties;
 1226  0
     }
 1227  
 
 1228  
     public boolean isDisableXmlReport()
 1229  
     {
 1230  0
         return disableXmlReport;
 1231  
     }
 1232  
 
 1233  
     public void setDisableXmlReport( boolean disableXmlReport )
 1234  
     {
 1235  0
         this.disableXmlReport = disableXmlReport;
 1236  0
     }
 1237  
 
 1238  
     public Boolean getUseSystemClassLoader()
 1239  
     {
 1240  0
         return useSystemClassLoader;
 1241  
     }
 1242  
 
 1243  
     public void setUseSystemClassLoader( Boolean useSystemClassLoader )
 1244  
     {
 1245  0
         this.useSystemClassLoader = useSystemClassLoader;
 1246  0
     }
 1247  
 
 1248  
     public boolean isUseManifestOnlyJar()
 1249  
     {
 1250  0
         return useManifestOnlyJar;
 1251  
     }
 1252  
 
 1253  
     public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
 1254  
     {
 1255  0
         this.useManifestOnlyJar = useManifestOnlyJar;
 1256  0
     }
 1257  
 
 1258  
     public boolean isEnableAssertions()
 1259  
     {
 1260  0
         return enableAssertions;
 1261  
     }
 1262  
 
 1263  
     public void setEnableAssertions( boolean enableAssertions )
 1264  
     {
 1265  0
         this.enableAssertions = enableAssertions;
 1266  0
     }
 1267  
 
 1268  
     public MavenSession getSession()
 1269  
     {
 1270  0
         return session;
 1271  
     }
 1272  
 
 1273  
     public void setSession( MavenSession session )
 1274  
     {
 1275  0
         this.session = session;
 1276  0
     }
 1277  
 
 1278  
     public String getObjectFactory()
 1279  
     {
 1280  0
         return objectFactory;
 1281  
     }
 1282  
 
 1283  
     public void setObjectFactory( String objectFactory )
 1284  
     {
 1285  0
         this.objectFactory = objectFactory;
 1286  0
     }
 1287  
 
 1288  
     public ToolchainManager getToolchainManager()
 1289  
     {
 1290  0
         return toolchainManager;
 1291  
     }
 1292  
 
 1293  
     public void setToolchainManager( ToolchainManager toolchainManager )
 1294  
     {
 1295  0
         this.toolchainManager = toolchainManager;
 1296  0
     }
 1297  
 
 1298  
     // the following will be refactored out once the common code is all in one place
 1299  
 
 1300  
     public boolean isTestFailureIgnore()
 1301  
     {
 1302  0
         return true; // ignore
 1303  
     }
 1304  
 
 1305  
     public void setTestFailureIgnore( boolean testFailureIgnore )
 1306  
     {
 1307  
         // ignore
 1308  0
     }
 1309  
 
 1310  
     public boolean isMavenParallel()
 1311  
     {
 1312  0
         return parallelMavenExecution  != null && parallelMavenExecution.booleanValue();
 1313  
     }
 1314  
 
 1315  
 
 1316  
 }