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