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 org.apache.maven.it.util.ResourceExtractor;
23
24 import java.io.File;
25 import java.util.Properties;
26
27
28
29
30
31
32 public class MavenITmng4231SnapshotUpdatePolicyTest
33 extends AbstractMavenIntegrationTestCase
34 {
35
36 public MavenITmng4231SnapshotUpdatePolicyTest()
37 {
38 super( ALL_MAVEN_VERSIONS );
39 }
40
41
42
43
44
45
46 public void testitAlways()
47 throws Exception
48 {
49 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4231" );
50
51 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
52 verifier.setAutoclean( false );
53 verifier.deleteArtifacts( "org.apache.maven.its.mng4231" );
54 verifier.addCliOption( "-s" );
55 verifier.addCliOption( "settings.xml" );
56
57 Properties filterProps = verifier.newDefaultFilterProperties();
58 filterProps.setProperty( "@updates@", "always" );
59
60 filterProps.setProperty( "@repo@", "repo-1" );
61 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
62 verifier.setLogFileName( "log-always-1.txt" );
63 verifier.executeGoal( "validate" );
64 verifier.verifyErrorFreeLog();
65
66 filterProps.setProperty( "@repo@", "repo-2" );
67 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
68 verifier.setLogFileName( "log-always-2.txt" );
69 verifier.deleteDirectory( "target" );
70 verifier.executeGoal( "validate" );
71 verifier.verifyErrorFreeLog();
72
73 verifier.resetStreams();
74
75 Properties checksums = verifier.loadProperties( "target/checksum.properties" );
76 assertChecksum( "db3f17644e813af768ae6e82a6d0a2f29aef8988", "a-0.1-SNAPSHOT.jar", checksums );
77 assertChecksum( "5e3265f3ed55e8b217ff9db444fd8d888962a990", "b-0.1-SNAPSHOT.jar", checksums );
78 }
79
80
81
82
83
84
85 public void testitNever()
86 throws Exception
87 {
88 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4231" );
89
90 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
91 verifier.setAutoclean( false );
92 verifier.deleteArtifacts( "org.apache.maven.its.mng4231" );
93 verifier.addCliOption( "-s" );
94 verifier.addCliOption( "settings.xml" );
95
96 Properties filterProps = verifier.newDefaultFilterProperties();
97 filterProps.setProperty( "@updates@", "never" );
98
99 filterProps.setProperty( "@repo@", "repo-1" );
100 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
101 verifier.setLogFileName( "log-never-1.txt" );
102 verifier.executeGoal( "validate" );
103 verifier.verifyErrorFreeLog();
104
105 filterProps.setProperty( "@repo@", "repo-2" );
106 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
107 verifier.setLogFileName( "log-never-2.txt" );
108 verifier.deleteDirectory( "target" );
109 verifier.executeGoal( "validate" );
110 verifier.verifyErrorFreeLog();
111
112 verifier.resetStreams();
113
114 Properties checksums = verifier.loadProperties( "target/checksum.properties" );
115 assertChecksum( "ec6c9ea65766cc272df0ee26076240d6a93047d5", "a-0.1-SNAPSHOT.jar", checksums );
116 assertChecksum( "", "b-0.1-SNAPSHOT.jar", checksums );
117 }
118
119 private void assertChecksum( String checksum, String jar, Properties checksums )
120 {
121 assertEquals( checksum, checksums.getProperty( jar, "" ).toLowerCase( java.util.Locale.ENGLISH ) );
122 }
123
124 }