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.List;
26
27
28
29
30
31
32
33
34 public class MavenITmng2739RequiredRepositoryElementsTest
35 extends AbstractMavenIntegrationTestCase
36 {
37 public MavenITmng2739RequiredRepositoryElementsTest()
38 {
39 super( "(2.0.9,)" );
40 }
41
42 public void testitMNG2739_RepositoryId()
43 throws Exception
44 {
45 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2739/repo-id" );
46
47 Verifier verifier;
48
49 verifier = newVerifier( testDir.getAbsolutePath() );
50 verifier.setAutoclean( false );
51
52 try
53 {
54 verifier.executeGoal( "validate" );
55
56 fail(
57 "POM should NOT validate: repository <id/> element is missing in: " + new File( testDir, "pom.xml" ) );
58 }
59 catch ( VerificationException e )
60 {
61
62 }
63
64 verifier.resetStreams();
65
66 List<String> listing = verifier.loadFile( new File( testDir, "log.txt" ), false );
67 boolean foundNpe = false;
68 for ( String line : listing )
69 {
70 if ( line.contains( "NullPointerException" ) )
71 {
72 foundNpe = true;
73 break;
74 }
75 }
76
77 assertFalse( "Missing repository-id should not result in a NullPointerException.", foundNpe );
78 }
79
80 public void testitMNG2739_RepositoryUrl()
81 throws Exception
82 {
83
84
85 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2739/repo-url" );
86
87 Verifier verifier;
88
89 verifier = newVerifier( testDir.getAbsolutePath() );
90 verifier.setAutoclean( false );
91
92 try
93 {
94 verifier.executeGoal( "validate" );
95
96 fail(
97 "POM should NOT validate: repository <url/> element is missing in: " + new File( testDir, "pom.xml" ) );
98 }
99 catch ( VerificationException e )
100 {
101
102 }
103
104 verifier.resetStreams();
105
106 List<String> listing = verifier.loadFile( new File( testDir, "log.txt" ), false );
107 boolean foundNpe = false;
108 for ( String line : listing )
109 {
110 if ( line.contains( "NullPointerException" ) )
111 {
112 foundNpe = true;
113 break;
114 }
115 }
116
117 assertFalse( "Missing repository-url should not result in a NullPointerException.", foundNpe );
118 }
119 }