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
24 import org.apache.maven.it.util.ResourceExtractor;
25
26
27
28
29
30 public class MavenITmng5640LifecycleParticipantAfterSessionEnd
31 extends AbstractMavenIntegrationTestCase
32 {
33 public MavenITmng5640LifecycleParticipantAfterSessionEnd()
34 {
35 super( "[3.2.2,)" );
36 }
37
38
39
40
41
42
43 public void testBuildFailureUTFail()
44 throws Exception
45 {
46 File testDir =
47 ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" );
48 File extensionDir = new File( testDir, "extension" );
49 File projectDir = new File( testDir, "buildfailure-utfail" );
50
51 Verifier verifier;
52
53
54 verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
55 verifier.executeGoal( "install" );
56 verifier.resetStreams();
57 verifier.verifyErrorFreeLog();
58
59
60 verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
61 try
62 {
63 verifier.executeGoal( "package" );
64 fail( "The build should fail" );
65 }
66 catch (VerificationException e)
67 {
68
69 }
70 verifier.resetStreams();
71 verifier.verifyTextInLog("testApp(org.apache.maven.its.mng5640.FailingTest)");
72
73 verifier.assertFilePresent( "target/afterProjectsRead.txt" );
74
75
76 verifier.assertFilePresent( "target/afterSessionEnd.txt" );
77 }
78
79
80
81
82
83
84 public void testBuildFailureMissingDependency()
85 throws Exception
86 {
87 File testDir =
88 ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" );
89 File extensionDir = new File( testDir, "extension" );
90 File projectDir = new File( testDir, "buildfailure-depmissing" );
91
92 Verifier verifier;
93
94
95 verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
96 verifier.executeGoal( "install" );
97 verifier.resetStreams();
98 verifier.verifyErrorFreeLog();
99
100
101 verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
102 try
103 {
104 verifier.executeGoal( "package" );
105 fail( "The build should fail" );
106 }
107 catch (VerificationException e)
108 {
109
110 }
111 verifier.resetStreams();
112
113 verifier.assertFilePresent( "target/afterProjectsRead.txt" );
114
115
116 verifier.assertFilePresent( "target/afterSessionEnd.txt" );
117 }
118
119
120
121
122
123
124 public void testBuildError()
125 throws Exception
126 {
127 File testDir =
128 ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" );
129 File extensionDir = new File( testDir, "extension" );
130 File pluginDir = new File( testDir, "badplugin" );
131 File projectDir = new File( testDir, "builderror-mojoex" );
132
133 Verifier verifier;
134
135
136 verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
137 verifier.executeGoal( "install" );
138 verifier.resetStreams();
139 verifier.verifyErrorFreeLog();
140
141
142 verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
143 verifier.executeGoal( "install" );
144 verifier.resetStreams();
145 verifier.verifyErrorFreeLog();
146
147
148 verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
149 try
150 {
151 verifier.executeGoal( "package" );
152 fail( "The build should fail" );
153 }
154 catch ( VerificationException e )
155 {
156
157 }
158 verifier.resetStreams();
159
160 verifier.assertFilePresent( "target/afterProjectsRead.txt" );
161
162
163 verifier.assertFilePresent( "target/afterSessionEnd.txt" );
164 }
165
166
167
168
169
170
171 public void testBuildErrorRt()
172 throws Exception
173 {
174 File testDir =
175 ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" );
176 File extensionDir = new File( testDir, "extension" );
177 File pluginDir = new File( testDir, "badplugin" );
178 File projectDir = new File( testDir, "builderror-runtimeex" );
179
180 Verifier verifier;
181
182
183 verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
184 verifier.executeGoal( "install" );
185 verifier.resetStreams();
186 verifier.verifyErrorFreeLog();
187
188
189 verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
190 verifier.executeGoal( "install" );
191 verifier.resetStreams();
192 verifier.verifyErrorFreeLog();
193
194
195 verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
196 try
197 {
198 verifier.executeGoal( "package" );
199 fail( "The build should fail" );
200 }
201 catch ( VerificationException e )
202 {
203
204 }
205 verifier.resetStreams();
206
207 verifier.assertFilePresent( "target/afterProjectsRead.txt" );
208
209
210 verifier.assertFilePresent( "target/afterSessionEnd.txt" );
211 }
212 }