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  import java.util.Properties;
24  
25  import org.apache.maven.it.util.ResourceExtractor;
26  
27  /**
28   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4189">MNG-4189</a>.
29   *
30   *
31   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
32   */
33  public class MavenITmng4189UniqueVersionSnapshotTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng4189UniqueVersionSnapshotTest()
38      {
39          super( "[2.2.1,),[3.0-alpha-3,)" );
40      }
41  
42      public void testit()
43          throws Exception
44      {
45          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4189" );
46  
47          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48          verifier.setAutoclean( false );
49          verifier.deleteDirectory( "target" );
50          verifier.deleteArtifacts( "org.apache.maven.its.mng4189" );
51          verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
52          verifier.addCliOption( "--settings" );
53          verifier.addCliOption( "settings.xml" );
54  
55          // depend on org.apache.maven.its.mng4189:dep:1.0-20090608.090416-1:jar
56          verifier.setLogFileName( "log-1.txt" );
57          verifier.executeGoal( "validate" );
58          verifier.verifyErrorFreeLog();
59  
60          Properties checksums = verifier.loadProperties( "target/checksum.properties" );
61          assertEquals( "da2e54f69a9ba120f9211c476029f049967d840c", checksums.getProperty( "dep-1.0-SNAPSHOT.jar" ) );
62  
63          // depend on org.apache.maven.its.mng4189:dep:1.0-20090608.090416-2:jar
64          verifier.deleteDirectory( "target" );
65          verifier.addCliOption( "-f" );
66          verifier.addCliOption( "dependent-on-newer-timestamp-pom.xml" );
67          verifier.setLogFileName( "log-2.txt" );
68          verifier.executeGoal( "validate" );
69          verifier.verifyErrorFreeLog();
70  
71          checksums = verifier.loadProperties( "target/checksum.properties" );
72          assertEquals( "835979c28041014c5fd55daa15302d92976924a7", checksums.getProperty( "dep-1.0-SNAPSHOT.jar" ) );
73  
74          // revert back to org.apache.maven.its.mng4189:dep:1.0-20090608.090416-1:jar
75          verifier.deleteDirectory( "target" );
76          verifier.getCliOptions().remove( "-f" );
77          verifier.getCliOptions().remove( "dependent-on-newer-timestamp-pom.xml" );
78          verifier.setLogFileName( "log-3.txt" );
79          verifier.executeGoal( "validate" );
80          verifier.verifyErrorFreeLog();
81          verifier.resetStreams();
82  
83          checksums = verifier.loadProperties( "target/checksum.properties" );
84          assertEquals( "da2e54f69a9ba120f9211c476029f049967d840c", checksums.getProperty( "dep-1.0-SNAPSHOT.jar" ) );
85      }
86  
87  }