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