View Javadoc
1   package org.apache.maven.it;
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 org.apache.maven.it.util.ResourceExtractor;
23  
24  import java.io.File;
25  import java.util.Arrays;
26  import java.util.List;
27  
28  /**
29   * An integration test to check that concurrently running projects are finished
30   * in --fail-fast mode, while downstream projects are skipped.
31   *
32   * <a href="https://issues.apache.org/jira/browse/MNG-6720">MNG-6720</a>.
33   *
34   */
35  public class MavenITmng6720FailFastTest
36      extends AbstractMavenIntegrationTestCase
37  {
38  
39      public MavenITmng6720FailFastTest()
40      {
41          super( "[3.6.2,)" );
42      }
43  
44      public void testItShouldWaitForConcurrentModulesToFinish()
45          throws Exception
46      {
47          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6720-fail-fast" );
48  
49          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
50          verifier.setMavenDebug( false );
51          verifier.setAutoclean( false );
52          verifier.addCliOption( "-T" );
53          verifier.addCliOption( "2" );
54          verifier.addCliOption( "-Dmaven.test.redirectTestOutputToFile=true" );
55  
56          try
57          {
58              verifier.executeGoals( Arrays.asList( "clean", "test" ) );
59          } catch (VerificationException e)
60          {
61              //expected
62          }
63          verifier.resetStreams();
64  
65          List<String> module1Lines = verifier.loadFile(
66              new File( testDir, "module-1/target/surefire-reports/Module1Test-output.txt" ), false );
67          assertTrue( module1Lines.contains( "Module1" ) );
68          List<String> module2Lines = verifier.loadFile(
69              new File( testDir, "module-2/target/surefire-reports/Module2Test-output.txt" ), false );
70          assertTrue(module2Lines.contains( "Module2" ) );
71          List<String> module3Lines = verifier.loadFile(
72              new File( testDir, "module-3/target/surefire-reports/Module3Test-output.txt" ), false );
73          assertTrue( module3Lines.isEmpty() );
74  
75  
76      }
77  }