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-2339">MNG-2339</a>.
28   *
29   *
30   */
31  public class MavenITmng2339BadProjectInterpolationTest
32      extends AbstractMavenIntegrationTestCase
33  {
34      public MavenITmng2339BadProjectInterpolationTest()
35      {
36          super( "(2.0.8,)" ); // 2.0.9+
37      }
38  
39      public void testitMNG2339a()
40          throws Exception
41      {
42          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2339/a" );
43  
44          Verifier verifier;
45  
46          verifier = newVerifier( testDir.getAbsolutePath() );
47          verifier.setAutoclean( false );
48  
49          verifier.addCliOption( "-Dversion=foo" );
50          verifier.executeGoal( "validate" );
51  
52          verifier.verifyErrorFreeLog();
53          verifier.resetStreams();
54      }
55  
56      // test that -Dversion=1.0 is still available for interpolation.
57      public void testitMNG2339b()
58          throws Exception
59      {
60          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2339/b" );
61  
62          Verifier verifier;
63  
64          verifier = newVerifier( testDir.getAbsolutePath() );
65          verifier.setAutoclean( false );
66          verifier.deleteDirectory( "target" );
67  
68          verifier.setLogFileName( "log-pom-specified.txt" );
69          verifier.executeGoal( "initialize" );
70  
71          assertTrue( "Touchfile using ${project.version} for ${version} does not exist.",
72                      new File( testDir, "target/touch-1.txt" ).exists() );
73  
74          verifier.verifyErrorFreeLog();
75          verifier.resetStreams();
76  
77          verifier = newVerifier( testDir.getAbsolutePath() );
78          verifier.setAutoclean( false );
79          verifier.deleteDirectory( "target" );
80  
81          verifier.addCliOption( "-Dversion=2" );
82          verifier.setLogFileName( "log-cli-specified.txt" );
83          verifier.executeGoal( "initialize" );
84  
85          verifier.verifyErrorFreeLog();
86          verifier.resetStreams();
87  
88          assertTrue( "Touchfile using CLI-specified ${version} does not exist.",
89                      new File( testDir, "target/touch-2.txt" ).exists() );
90      }
91  
92  }