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 public class MavenITmng5581LifecycleMappingDelegate
28 extends AbstractMavenIntegrationTestCase
29 {
30 public MavenITmng5581LifecycleMappingDelegate()
31 {
32 super( "[3.2.1,)" );
33 }
34
35 public void testCustomLifecycle()
36 throws Exception
37 {
38
39
40
41
42
43
44
45
46 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5581-lifecycle-mapping-delegate" );
47 File extensionDir = new File( testDir, "extension" );
48 File projectDir = new File( testDir, "basic" );
49
50 Verifier verifier;
51
52
53 verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
54 verifier.executeGoal( "install" );
55 verifier.resetStreams();
56 verifier.verifyErrorFreeLog();
57
58
59 verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
60 verifier.executeGoal( "compile" );
61 verifier.resetStreams();
62 verifier.verifyErrorFreeLog();
63
64
65 verifier.setForkJvm( true );
66 verifier.setMavenDebug( true );
67 verifier.executeGoal( "test-only" );
68 verifier.resetStreams();
69 verifier.verifyErrorFreeLog();
70 verifier.verifyTextInLog( "maven-surefire-plugin" );
71 verifyTextNotInLog( verifier, "maven-compiler-plugin" );
72 }
73
74 private void verifyTextNotInLog( Verifier verifier, String text )
75 throws VerificationException
76 {
77 List<String> lines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
78
79 boolean textFound = false;
80 for ( String line : lines )
81 {
82 if ( line.contains( text ) )
83 {
84 textFound = true;
85 break;
86 }
87 }
88 if ( textFound )
89 {
90 throw new VerificationException( "Text found in log: " + text );
91 }
92 }
93
94 }