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.Iterator;
24 import java.util.List;
25 import java.util.Properties;
26
27 import org.apache.maven.it.util.ResourceExtractor;
28
29
30
31
32
33 public class MavenITmng4091BadPluginDescriptorTest
34 extends AbstractMavenIntegrationTestCase
35 {
36
37 public MavenITmng4091BadPluginDescriptorTest()
38 {
39 super( "[2.1.0,)" );
40 }
41
42 public void testitMNG4091_InvalidDescriptor()
43 throws Exception
44 {
45 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4091/invalid" );
46
47 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48 verifier.setAutoclean( false );
49
50 try
51 {
52 verifier.executeGoal( "validate" );
53
54 fail( "should throw an error during execution." );
55 }
56 catch ( VerificationException e )
57 {
58
59 }
60 finally
61 {
62 verifier.resetStreams();
63 }
64
65
66 List logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
67
68 String msg = "Plugin's descriptor contains the wrong version: 2.0-SNAPSHOT";
69
70 boolean foundMessage = false;
71 for ( Iterator it = logFile.iterator(); it.hasNext(); )
72 {
73 String line = (String) it.next();
74 if ( line.indexOf( msg ) > -1 )
75 {
76 foundMessage = true;
77 break;
78 }
79 }
80
81 assertTrue( "User-friendly message was not found in output.", foundMessage );
82 }
83
84 public void testitMNG4091_PluginDependency()
85 throws Exception
86 {
87 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4091/plugin-dependency" );
88
89 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
90 verifier.setAutoclean( false );
91
92 verifier.executeGoal( "validate" );
93 verifier.verifyErrorFreeLog();
94 verifier.resetStreams();
95
96 Properties props = verifier.loadProperties( "target/plugin-dependency.properties" );
97 assertTrue( props.isEmpty() );
98 }
99 }
100