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  
24  import org.apache.maven.it.util.ResourceExtractor;
25  
26  /**
27   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3379">MNG-3379</a>.
28   * 
29   * @author Benjamin Bentmann
30   * @version $Id: MavenITmng3379ParallelArtifactDownloadsTest.java 1050435 2010-12-17 16:06:59Z bentmann $
31   */
32  public class MavenITmng3379ParallelArtifactDownloadsTest
33      extends AbstractMavenIntegrationTestCase
34  {
35  
36      public MavenITmng3379ParallelArtifactDownloadsTest()
37      {
38          super( "[2.0.5,3.0-alpha-1),[3.0-alpha-2,)" );
39      }
40  
41      /**
42       * Tests that parallel downloads of artifacts from both the same and from different group ids don't corrupt
43       * the local repo.
44       */
45      public void testitMNG3379()
46          throws Exception
47      {
48          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3379" );
49  
50          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
51          verifier.setAutoclean( false );
52          verifier.deleteArtifacts( "org.apache.maven.its.mng3379.a" );
53          verifier.deleteArtifacts( "org.apache.maven.its.mng3379.b" );
54          verifier.deleteArtifacts( "org.apache.maven.its.mng3379.c" );
55          verifier.deleteArtifacts( "org.apache.maven.its.mng3379.d" );
56          verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
57          verifier.getCliOptions().add( "--settings" );
58          verifier.getCliOptions().add( "settings.xml" );
59          verifier.setSystemProperty( "maven.artifact.threads", "16" );
60          verifier.executeGoal( "validate" );
61          verifier.verifyErrorFreeLog();
62          verifier.resetStreams();
63  
64          String gid = "org.apache.maven.its.mng3379.";
65          assertArtifact( verifier, gid + "a", "x", "0.2-SNAPSHOT", "", "jar",
66              "69c041c12f35894230c7c23c49cd245886c6fb6f" );
67          assertArtifact( verifier, gid + "a", "x", "0.2-SNAPSHOT", "", "pom",
68              "10235b64a161e86e91cc6ff7245a4b9c6fdc7d5d" );
69          assertArtifact( verifier, gid + "a", "x", "0.2-SNAPSHOT", "tests", "jar",
70              "69c041c12f35894230c7c23c49cd245886c6fb6f" );
71          assertArtifact( verifier, gid + "a", "x", "0.2-SNAPSHOT", "sources", "jar",
72              "166f8bef02b9e92f99ec3b163d8321dd1d087e34" );
73          assertArtifact( verifier, gid + "a", "x", "0.2-SNAPSHOT", "javadoc", "jar",
74              "4d96e09f7e93870685a317c574f851b407224415" );
75          assertMetadata( verifier, gid + "a", "x", "0.2-SNAPSHOT",
76              "e1cfc3a77657fc46bb624dee25c61b290e5b4dd7" );
77          
78          assertArtifact( verifier, gid + "b", "x", "0.2-SNAPSHOT", "", "jar",
79              "efb7c4046565774cd7e44645e02f06ecdf91098d" );
80          assertArtifact( verifier, gid + "b", "x", "0.2-SNAPSHOT", "", "pom",
81              "1c816cc9eaaca1272f24887c461aa359503394f5" );
82          assertArtifact( verifier, gid + "b", "x", "0.2-SNAPSHOT", "tests", "jar",
83              "efb7c4046565774cd7e44645e02f06ecdf91098d" );
84          assertArtifact( verifier, gid + "b", "x", "0.2-SNAPSHOT", "sources", "jar",
85              "9ad231fc04ea1114987c377cc5cbccfbf83e3dbf" );
86          assertArtifact( verifier, gid + "b", "x", "0.2-SNAPSHOT", "javadoc", "jar",
87              "7807daefd3af3be73d3b92f9c5ab1b52510c0767" );
88          assertMetadata( verifier, gid + "b", "x", "0.2-SNAPSHOT",
89              "5ccc4edfb503f9a5ccadedf102dff8943250d830" );
90          assertMetadata( verifier, gid + "b", "x",
91              "8f38b1041871f22dcb031544d8a3436c335bfcdb" );
92  
93          assertArtifact( verifier, gid + "c", "x", "0.2-SNAPSHOT", "", "jar",
94              "1eb0d5a421b3074e8a69b0dcca7e325c0636a932" );
95          assertArtifact( verifier, gid + "c", "x", "0.2-SNAPSHOT", "", "pom",
96              "bd9a24117d3ce4f8ef3b8fcfe79a08e5ea141a9b" );
97          assertArtifact( verifier, gid + "c", "x", "0.2-SNAPSHOT", "tests", "jar",
98              "1eb0d5a421b3074e8a69b0dcca7e325c0636a932" );
99          assertArtifact( verifier, gid + "c", "x", "0.2-SNAPSHOT", "sources", "jar",
100             "82f9664b3a910fb861fc4ed2b79e39d8f95e3675" );
101         assertArtifact( verifier, gid + "c", "x", "0.2-SNAPSHOT", "javadoc", "jar",
102             "64a3bfe19b294f67b1c52a2514c58922b88e5f97" );
103         assertMetadata( verifier, gid + "c", "x", "0.2-SNAPSHOT",
104             "b31ef40a51bdab4e6e44bfe3f2d1da42e5e42e46" );
105         assertMetadata( verifier, gid + "c", "x",
106             "c4848e60d226ec6304df3abd9eba8fdb301b3660" );
107 
108         assertArtifact( verifier, gid + "d", "x", "0.2-SNAPSHOT", "", "jar",
109             "3d606c564625a594165bcbbe4a24c8f11b18b5a0" );
110         assertArtifact( verifier, gid + "d", "x", "0.2-SNAPSHOT", "", "pom",
111             "70a3c9795b2871fdd8a66e8fe312359f08d77c7d" );
112         assertArtifact( verifier, gid + "d", "x", "0.2-SNAPSHOT", "tests", "jar",
113             "3d606c564625a594165bcbbe4a24c8f11b18b5a0" );
114         assertArtifact( verifier, gid + "d", "x", "0.2-SNAPSHOT", "sources", "jar",
115             "35a7e140307f4bb67984dc72aa551f0faabacd36" );
116         assertArtifact( verifier, gid + "d", "x", "0.2-SNAPSHOT", "javadoc", "jar",
117             "2fe3487f496fe66f23772b1bada066ec6bd9222f" );
118         assertMetadata( verifier, gid + "d", "x", "0.2-SNAPSHOT",
119             "a0d0b5efd5d6f6a921a3f7c1a6a503359fccef04" );
120         assertMetadata( verifier, gid + "d", "x",
121             "1d2bf926862f2131f1229328e588b906b087bdb3" );
122     }
123 
124     private void assertArtifact( Verifier verifier, String gid, String aid, String ver, String cls, String ext, String sha1 )
125         throws Exception
126     {
127         File file = new File( verifier.getArtifactPath( gid, aid, ver, ext, cls ) );
128         assertTrue( file.getAbsolutePath(), file.isFile() );
129         assertEquals( sha1, ItUtils.calcHash( file, "SHA-1" ) );
130     }
131 
132     private void assertMetadata( Verifier verifier, String gid, String aid, String ver, String sha1 )
133         throws Exception
134     {
135         String name = "maven-metadata-maven-core-it.xml";
136         File file = new File( verifier.getArtifactMetadataPath( gid, aid, ver, name ) );
137         assertTrue( file.getAbsolutePath(), file.isFile() );
138         assertEquals( sha1, ItUtils.calcHash( file, "SHA-1" ) );
139     }
140 
141     private void assertMetadata( Verifier verifier, String gid, String aid, String sha1 )
142         throws Exception
143     {
144         String name = "maven-metadata-maven-core-it.xml";
145         File file = new File( verifier.getArtifactMetadataPath( gid, aid, null, name ) );
146         assertTrue( file.getAbsolutePath(), file.isFile() );
147         assertEquals( sha1, ItUtils.calcHash( file, "SHA-1" ) );
148     }
149 
150 }