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.io.IOException;
26 import java.util.List;
27 import java.util.regex.Pattern;
28
29
30
31
32
33
34
35
36
37 public class MavenITmng5482AetherNotFoundTest
38 extends AbstractMavenIntegrationTestCase
39 {
40
41 public MavenITmng5482AetherNotFoundTest()
42 {
43 super( "[3.1-A,)" );
44 }
45
46 public void testPluginDependency()
47 throws IOException, VerificationException
48 {
49 check( "plugin-dependency" );
50 }
51
52 public void testPluginSite()
53 throws IOException, VerificationException
54 {
55 check( "plugin-site" );
56 }
57
58
59
60
61
62
63
64 public void check( String dir )
65 throws IOException, VerificationException
66 {
67 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5482/" + dir );
68
69 Verifier verifier = newVerifier( testDir.getAbsolutePath(), "remote" );
70 verifier.setAutoclean( false );
71
72 try
73 {
74 verifier.executeGoal( "validate" );
75
76 fail( "should throw an error during execution." );
77 }
78 catch ( VerificationException e )
79 {
80
81 }
82 finally
83 {
84 verifier.resetStreams();
85 }
86
87 List<String> lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
88
89 int msg = indexOf( lines, "Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.+" );
90 assertTrue( "ClassNotFoundException message was not found in output.", msg >= 0 );
91
92 int url = indexOf( lines, ".*http://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound.*" );
93 assertTrue( "Url to ClassNotFoundAether was not found in output.", url >= 0 );
94 }
95
96 private int indexOf( List<String> logLines, String regex )
97 {
98 Pattern pattern = Pattern.compile( regex );
99
100 for ( int i = 0; i < logLines.size(); i++ )
101 {
102 String logLine = logLines.get( i );
103
104 if ( pattern.matcher( logLine ).matches() )
105 {
106 return i;
107 }
108 }
109
110 return -1;
111 }
112
113 }