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.Locale;
24  
25  import org.apache.maven.it.util.ResourceExtractor;
26  import org.apache.maven.shared.utils.io.FileUtils;
27  
28  /**
29   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3892">MNG-3892</a>.
30   *
31   * @author Benjamin Bentmann
32   *
33   */
34  public class MavenITmng3892ReleaseDeploymentTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng3892ReleaseDeploymentTest()
39      {
40          super( ALL_MAVEN_VERSIONS );
41      }
42  
43      /**
44       * Test that a bunch of release artifacts can be deployed without the deployer erroneously complaining about
45       * already deployed artifacts.
46       *
47       * @throws Exception in case of failure
48       */
49      public void testitMNG3892()
50          throws Exception
51      {
52          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3892" );
53  
54          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
55          verifier.setAutoclean( false );
56          verifier.deleteDirectory( "repo" );
57          verifier.deleteArtifacts( "org.apache.maven.its.mng3892" );
58          verifier.executeGoal( "validate" );
59          verifier.verifyErrorFreeLog();
60          verifier.resetStreams();
61  
62          verifier.assertArtifactPresent( "org.apache.maven.its.mng3892", "test", "1.0", "pom" );
63          verifier.assertArtifactPresent( "org.apache.maven.its.mng3892", "test", "1.0", "jar" );
64  
65          String groupDir = "repo/org/apache/maven/its/mng3892/test/";
66          verifier.assertFilePresent( groupDir + "maven-metadata.xml" );
67          verifier.assertFilePresent( groupDir + "maven-metadata.xml.md5" );
68          verifier.assertFilePresent( groupDir + "maven-metadata.xml.sha1" );
69          verifier.assertFilePresent( groupDir + "1.0/test-1.0.pom" );
70          verifier.assertFilePresent( groupDir + "1.0/test-1.0.pom.md5" );
71          verifier.assertFilePresent( groupDir + "1.0/test-1.0.pom.sha1" );
72          verifier.assertFilePresent( groupDir + "1.0/test-1.0.jar" );
73          verifier.assertFilePresent( groupDir + "1.0/test-1.0.jar.md5" );
74          verifier.assertFilePresent( groupDir + "1.0/test-1.0.jar.sha1" );
75          verifier.assertFilePresent( groupDir + "1.0/test-1.0-it.jar" );
76          verifier.assertFilePresent( groupDir + "1.0/test-1.0-it.jar.md5" );
77          verifier.assertFilePresent( groupDir + "1.0/test-1.0-it.jar.sha1" );
78  
79          verify( testDir, groupDir + "1.0/test-1.0.jar.md5", "dd89c30cc71c3cd8a729622243c76770" );
80          verify( testDir, groupDir + "1.0/test-1.0.jar.sha1", "0b0717ff89d3cbadc3564270bf8930163753bf71" );
81          verify( testDir, groupDir + "1.0/test-1.0-it.jar.md5", "dd89c30cc71c3cd8a729622243c76770" );
82          verify( testDir, groupDir + "1.0/test-1.0-it.jar.sha1", "0b0717ff89d3cbadc3564270bf8930163753bf71" );
83      }
84  
85      private void verify( File testDir, String file, String checksum )
86          throws Exception
87      {
88          assertEquals( file, checksum, readChecksum( new File( testDir, file ) ) );
89      }
90  
91      private String readChecksum( File checksumFile )
92          throws Exception
93      {
94          String checksum = FileUtils.fileRead( checksumFile, "UTF-8" ).trim();
95          if ( checksum.indexOf( ' ' ) >= 0 )
96          {
97              checksum = checksum.substring( 0, checksum.indexOf( ' ' ) );
98          }
99          return checksum.toLowerCase( Locale.ENGLISH );
100     }
101 
102 }