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.List;
24
25 import org.apache.maven.it.util.ResourceExtractor;
26
27
28
29
30
31
32
33
34
35
36 public class MavenITmng3748BadSettingsXmlTest
37 extends AbstractMavenIntegrationTestCase
38 {
39
40 public MavenITmng3748BadSettingsXmlTest()
41 {
42 super( "(2.0.8,)" );
43 }
44
45 public void testit()
46 throws Exception
47 {
48 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3748" );
49
50 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
51 verifier.setAutoclean( false );
52 verifier.addCliOption( "-s" );
53 verifier.addCliOption( "settings.xml" );
54
55
56 if ( matchesVersionRange( "(,3.0-alpha-3)" ) )
57 {
58 try
59 {
60 verifier.executeGoal( "validate" );
61 verifier.verifyErrorFreeLog();
62
63 fail( "build should fail if settings.xml contains unrecognized elements." );
64 }
65 catch ( VerificationException e )
66 {
67
68 }
69 }
70 else
71 {
72 verifier.executeGoal( "validate" );
73 verifier.verifyErrorFreeLog();
74
75 List<String> lines = verifier.loadLines( verifier.getLogFileName(), null );
76 boolean foundWarning = false;
77 for ( String line : lines )
78 {
79 if ( line.matches( "(?i)\\[WARNING\\].*unrecognised tag.+repositories.+2.*" ) )
80 {
81 foundWarning = true;
82 break;
83 }
84 }
85 assertTrue( foundWarning );
86 }
87
88 verifier.resetStreams();
89 }
90
91 }