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  
26  /**
27   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3885">MNG-3885</a>.
28   *
29   * @author Benjamin Bentmann
30   *
31   */
32  public class MavenITmng3885UniqueVersionFromParentProfileTest
33      extends AbstractMavenIntegrationTestCase
34  {
35  
36      public MavenITmng3885UniqueVersionFromParentProfileTest()
37      {
38          // support for non-unique deployments removed in 3.x (see MNG-4059)
39          super( "(2.0.10,3.0-alpha-1)" );
40      }
41  
42      /**
43       * Test that uniqueVersion=false defined by a parent profile is effective for child modules when building
44       * from the parent.
45       *
46       * @throws Exception in case of failure
47       */
48      public void testitNonUniqueVersionReactor()
49          throws Exception
50      {
51          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3885" );
52  
53          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
54          verifier.setLogFileName( "log-f.txt" );
55          verifier.setAutoclean( false );
56          verifier.deleteDirectory( "repo-f" );
57          verifier.filterFile( "pom-template.xml", "pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
58          verifier.addCliOption( "-Pnon-unique-version" );
59          verifier.executeGoal( "validate" );
60          verifier.verifyErrorFreeLog();
61          verifier.resetStreams();
62  
63          verifier.assertFilePresent( "repo-f/org/apache/maven/its/mng3885/sub/0.2-SNAPSHOT/sub-0.2-SNAPSHOT.jar" );
64      }
65  
66      /**
67       * Test that uniqueVersion=false defined by a parent profile is effective for child modules when building
68       * the child in isolation.
69       *
70       * @throws Exception in case of failure
71       */
72      public void testitNonUniqueVersionStandalone()
73          throws Exception
74      {
75          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3885" );
76  
77          Verifier verifier = newVerifier( new File( testDir, "sub" ).getAbsolutePath() );
78          verifier.setLogFileName( "log-f.txt" );
79          verifier.setAutoclean( false );
80          verifier.deleteDirectory( "repo-f" );
81          verifier.filterFile( "../pom-template.xml", "../pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
82          verifier.addCliOption( "-Pnon-unique-version" );
83          verifier.executeGoal( "validate" );
84          verifier.verifyErrorFreeLog();
85          verifier.resetStreams();
86  
87          verifier.assertFilePresent( "repo-f/org/apache/maven/its/mng3885/sub/0.2-SNAPSHOT/sub-0.2-SNAPSHOT.jar" );
88      }
89  
90      /**
91       * Test that uniqueVersion=true defined by a parent profile is effective for child modules when building
92       * from the parent.
93       *
94       * @throws Exception in case of failure
95       */
96      public void testitUniqueVersionReactor()
97          throws Exception
98      {
99          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3885" );
100 
101         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
102         verifier.setLogFileName( "log-t.txt" );
103         verifier.setAutoclean( false );
104         verifier.deleteDirectory( "repo-t" );
105         verifier.filterFile( "pom-template.xml", "pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
106         verifier.addCliOption( "-Punique-version" );
107         verifier.executeGoal( "validate" );
108         verifier.verifyErrorFreeLog();
109         verifier.resetStreams();
110 
111         verifier.assertFileNotPresent( "repo-t/org/apache/maven/its/mng3885/sub/0.2-SNAPSHOT/sub-0.2-SNAPSHOT.jar" );
112         verifier.assertFilePresent( "repo-t/org/apache/maven/its/mng3885/sub/0.2-SNAPSHOT/sub-0.2-*-1.jar" );
113     }
114 
115     /**
116      * Test that uniqueVersion=true defined by a parent profile is effective for child modules when building
117      * the child in isolation.
118      *
119      * @throws Exception in case of failure
120      */
121     public void testitUniqueVersionStandalone()
122         throws Exception
123     {
124         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3885" );
125 
126         Verifier verifier = newVerifier( new File( testDir, "sub" ).getAbsolutePath() );
127         verifier.setLogFileName( "log-t.txt" );
128         verifier.setAutoclean( false );
129         verifier.deleteDirectory( "repo-t" );
130         verifier.filterFile( "../pom-template.xml", "../pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
131         verifier.addCliOption( "-Punique-version" );
132         verifier.executeGoal( "validate" );
133         verifier.verifyErrorFreeLog();
134         verifier.resetStreams();
135 
136         verifier.assertFileNotPresent( "repo-t/org/apache/maven/its/mng3885/sub/0.2-SNAPSHOT/sub-0.2-SNAPSHOT.jar" );
137         verifier.assertFilePresent( "repo-t/org/apache/maven/its/mng3885/sub/0.2-SNAPSHOT/sub-0.2-*-1.jar" );
138     }
139 
140 }