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  import java.util.List;
27  
28  /**
29   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2486">MNG-2486</a>.
30   * 
31   * @author Benjamin Bentmann
32   */
33  public class MavenITmng2486TimestampedDependencyVersionInterpolationTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng2486TimestampedDependencyVersionInterpolationTest()
38      {
39          super( "[2.0.5,)" );
40      }
41  
42      /**
43       * Verify that the expression ${project.version} gets resolved to X-SNAPSHOT and not the actual timestamp
44       * during transitive dependency resolution. In part, this depends on the deployed SNAPSHOT POMs to retain their
45       * X-SNAPSHOT project version and not having it replaced with the timestamp version.
46       */
47      public void testit()
48          throws Exception
49      {
50          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2486" );
51  
52          Verifier verifier;
53  
54          verifier = newVerifier( new File( testDir, "dep-a" ).getAbsolutePath() );
55          verifier.setAutoclean( false );
56          verifier.deleteDirectory( "target" );
57          verifier.deleteArtifacts( "org.apache.maven.its.mng2486" );
58          verifier.executeGoal( "validate" );
59          verifier.verifyErrorFreeLog();
60          verifier.resetStreams();
61  
62          verifier = newVerifier( new File( testDir, "parent" ).getAbsolutePath() );
63          verifier.setAutoclean( false );
64          verifier.deleteDirectory( "target" );
65          verifier.executeGoal( "validate" );
66          verifier.verifyErrorFreeLog();
67          verifier.resetStreams();
68  
69          verifier = newVerifier( new File( testDir, "dep-b" ).getAbsolutePath() );
70          verifier.setAutoclean( false );
71          verifier.deleteDirectory( "target" );
72          verifier.executeGoal( "validate" );
73          verifier.verifyErrorFreeLog();
74          verifier.resetStreams();
75  
76          verifier = newVerifier( new File( testDir, "test" ).getAbsolutePath() );
77          verifier.setAutoclean( false );
78          verifier.deleteDirectory( "target" );
79          // enforce remote resolution
80          verifier.deleteArtifacts( "org.apache.maven.its.mng2486" );
81          verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
82          verifier.getCliOptions().add( "--settings" );
83          verifier.getCliOptions().add( "settings.xml" );
84          verifier.executeGoal( "validate" );
85          verifier.verifyErrorFreeLog();
86          verifier.resetStreams();
87  
88          List files = verifier.loadLines( "target/classpath.txt", "UTF-8" );
89          assertTrue( files.toString(), files.contains( "dep-a-0.1-SNAPSHOT.jar" ) );
90      }
91  
92  }