1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Properties;
24
25 import org.apache.maven.it.util.ResourceExtractor;
26 import org.apache.maven.shared.utils.io.FileUtils;
27
28 import static org.junit.Assert.assertNotEquals;
29
30
31
32
33
34
35 public class MavenITmng1751ForcedMetadataUpdateDuringDeploymentTest
36 extends AbstractMavenIntegrationTestCase
37 {
38
39 public MavenITmng1751ForcedMetadataUpdateDuringDeploymentTest()
40 {
41 super( "[3.0-beta-1,)" );
42 }
43
44
45
46
47
48
49
50 public void testit()
51 throws Exception
52 {
53 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-1751" );
54
55 File dir = new File( testDir, "repo/org/apache/maven/its/mng1751/dep/0.1-SNAPSHOT" );
56 File templateMetadataFile = new File( dir, "template-metadata.xml" );
57 File metadataFile = new File( dir, "maven-metadata.xml" );
58 FileUtils.copyFile( templateMetadataFile, metadataFile );
59 String checksum = ItUtils.calcHash( metadataFile, "SHA-1" );
60 FileUtils.fileWrite( metadataFile.getPath() + ".sha1", checksum );
61
62
63 Verifier verifier = newVerifier( new File( testDir, "dep" ).getAbsolutePath() );
64 verifier.setAutoclean( false );
65 verifier.deleteArtifacts( "org.apache.maven.its.mng1751" );
66 verifier.executeGoal( "validate" );
67 verifier.verifyErrorFreeLog();
68 verifier.resetStreams();
69
70
71 verifier = newVerifier( new File( testDir, "test" ).getAbsolutePath() );
72 verifier.setAutoclean( false );
73 verifier.deleteArtifacts( "org.apache.maven.its.mng1751" );
74 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
75 verifier.addCliOption( "--settings" );
76 verifier.addCliOption( "settings.xml" );
77 verifier.executeGoal( "validate" );
78 verifier.verifyErrorFreeLog();
79 verifier.resetStreams();
80
81 Properties checksums = verifier.loadProperties( "target/checksum.properties" );
82 String sha1 = checksums.getProperty( "dep-0.1-SNAPSHOT.jar", "" ).toLowerCase( java.util.Locale.ENGLISH );
83 assertEquals( sha1, 40, sha1.length() );
84 assertNotEquals( "fc081cd365b837dcb01eb9991f21c409b155ea5c", sha1 );
85 }
86
87 }