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 java.io.File;
23  
24  import org.apache.maven.it.util.ResourceExtractor;
25  
26  /**
27   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4262">MNG-4262</a>.
28   *
29   * @author Benjamin Bentmann
30   */
31  public class MavenITmng4262MakeLikeReactorDottedPathTest
32      extends AbstractMavenIntegrationTestCase
33  {
34  
35      public MavenITmng4262MakeLikeReactorDottedPathTest()
36      {
37          super( "[3.0-alpha-3,4.0.0-alpha-1)" );
38      }
39  
40      private void clean( Verifier verifier )
41          throws Exception
42      {
43          verifier.deleteDirectory( "target" );
44          verifier.deleteDirectory( "../sub-a/target" );
45      }
46  
47      /**
48       * Verify that the project list can select the root project by its relative path ".".
49       *
50       * @throws Exception in case of failure
51       */
52      public void testitMakeRoot()
53          throws Exception
54      {
55          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4262" );
56  
57          Verifier verifier = newVerifier( new File( testDir, "parent" ).getAbsolutePath() );
58          verifier.setAutoclean( false );
59          clean( verifier );
60          verifier.addCliOption( "-pl" );
61          verifier.addCliOption( "." );
62          verifier.setLogFileName( "log-root.txt" );
63          verifier.executeGoal( "validate" );
64          verifier.verifyErrorFreeLog();
65          verifier.resetStreams();
66  
67          verifier.assertFilePresent( "target/touch.txt" );
68          verifier.assertFileNotPresent( "../sub-a/target/touch.txt" );
69      }
70  
71      /**
72       * Verify that the project list can select a sub module by a relative path like {@code "../<something>"}.
73       *
74       * @throws Exception in case of failure
75       */
76      public void testitMakeModule()
77          throws Exception
78      {
79          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4262" );
80  
81          Verifier verifier = newVerifier( new File( testDir, "parent" ).getAbsolutePath() );
82          verifier.setAutoclean( false );
83          clean( verifier );
84          verifier.addCliOption( "-pl" );
85          verifier.addCliOption( "../sub-a" );
86          verifier.setLogFileName( "log-module.txt" );
87          verifier.executeGoal( "validate" );
88          verifier.verifyErrorFreeLog();
89          verifier.resetStreams();
90  
91          verifier.assertFileNotPresent( "target/touch.txt" );
92          verifier.assertFilePresent( "../sub-a/target/touch.txt" );
93      }
94  
95  }