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