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 MavenITmng4367LayoutAwareMirrorSelectionTest
33 extends AbstractMavenIntegrationTestCase
34 {
35
36 public MavenITmng4367LayoutAwareMirrorSelectionTest()
37 {
38 super( "[3.0-alpha-3,)" );
39 }
40
41
42
43
44
45
46
47 public void testitNoLayout()
48 throws Exception
49 {
50 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4367" );
51
52 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
53 verifier.setAutoclean( false );
54 verifier.deleteArtifacts( "org.apache.maven.its.mng4367" );
55
56 Properties filterProps = verifier.newDefaultFilterProperties();
57 filterProps.setProperty( "@repourl@", filterProps.getProperty( "@baseurl@" ) + "/void" );
58 filterProps.setProperty( "@mirrorurl@", filterProps.getProperty( "@baseurl@" ) + "/repo" );
59 filterProps.setProperty( "@layouts@", "" );
60
61 verifier.addCliOption( "-s" );
62 verifier.addCliOption( "settings-a.xml" );
63 verifier.filterFile( "settings-template.xml", "settings-a.xml", "UTF-8", filterProps );
64 verifier.setLogFileName( "log-a.txt" );
65 verifier.executeGoal( "validate" );
66 verifier.verifyErrorFreeLog();
67 verifier.resetStreams();
68
69 verifier.assertArtifactPresent( "org.apache.maven.its.mng4367", "dep", "0.1", "jar" );
70 }
71
72
73
74
75
76
77 public void testitSpecificLayouts()
78 throws Exception
79 {
80 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4367" );
81
82 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
83 verifier.setAutoclean( false );
84 verifier.deleteArtifacts( "org.apache.maven.its.mng4367" );
85
86 Properties filterProps = verifier.newDefaultFilterProperties();
87 filterProps.setProperty( "@repourl@", filterProps.getProperty( "@baseurl@" ) + "/void" );
88 filterProps.setProperty( "@mirrorurl@", filterProps.getProperty( "@baseurl@" ) + "/repo" );
89 filterProps.setProperty( "@layouts@", "default,legacy" );
90
91 verifier.addCliOption( "-s" );
92 verifier.addCliOption( "settings-b.xml" );
93 verifier.filterFile( "settings-template.xml", "settings-b.xml", "UTF-8", filterProps );
94 verifier.setLogFileName( "log-b.txt" );
95 verifier.executeGoal( "validate" );
96 verifier.verifyErrorFreeLog();
97 verifier.resetStreams();
98
99 verifier.assertArtifactPresent( "org.apache.maven.its.mng4367", "dep", "0.1", "jar" );
100 }
101
102
103
104
105
106
107 public void testitNonMatchingLayout()
108 throws Exception
109 {
110 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4367" );
111
112 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
113 verifier.setAutoclean( false );
114 verifier.deleteArtifacts( "org.apache.maven.its.mng4367" );
115
116 Properties filterProps = verifier.newDefaultFilterProperties();
117 filterProps.setProperty( "@repourl@", filterProps.getProperty( "@baseurl@" ) + "/repo" );
118 filterProps.setProperty( "@mirrorurl@", filterProps.getProperty( "@baseurl@" ) + "/void" );
119 filterProps.setProperty( "@layouts@", "foo" );
120
121 verifier.addCliOption( "-s" );
122 verifier.addCliOption( "settings-c.xml" );
123 verifier.filterFile( "settings-template.xml", "settings-c.xml", "UTF-8", filterProps );
124 verifier.setLogFileName( "log-c.txt" );
125 verifier.executeGoal( "validate" );
126 verifier.verifyErrorFreeLog();
127 verifier.resetStreams();
128
129 verifier.assertArtifactPresent( "org.apache.maven.its.mng4367", "dep", "0.1", "jar" );
130 }
131
132 }