1 package org.apache.maven.it;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.maven.it.util.ResourceExtractor;
23
24 import java.io.File;
25
26 /**
27 * This is a test case for <a href="https://issues.apache.org/jira/browse/MNG-4660">MNG-4660</a>.
28 *
29 * @author Maarten Mulders
30 * @author Martin Kanters
31 */
32 public class MavenITmng4660ResumeFromTest extends AbstractMavenIntegrationTestCase {
33 public MavenITmng4660ResumeFromTest()
34 {
35 super( "[4.0.0-alpha-1,)" );
36 }
37
38 /**
39 * Test that the --resume-from flag resolves dependencies inside the same Maven project
40 * without having them installed first.
41 * This test case uses the target/classes directory of module-a, for the situation where
42 * module-a has not been packaged.
43 *
44 * @throws Exception in case of failure
45 */
46 public void testShouldResolveOutputDirectoryFromEarlierBuild() throws Exception
47 {
48 final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4660-resume-from" );
49
50 final Verifier verifier1 = newVerifier( testDir.getAbsolutePath() );
51 verifier1.deleteDirectory( "target" );
52 verifier1.deleteArtifacts( "org.apache.maven.its.mng4660" );
53
54 try
55 {
56 verifier1.executeGoal( "test" ); // The test goal will not create a packaged artifact
57 fail( "Expected this invocation to fail" ); // See TestCase.java
58 }
59 catch ( final VerificationException ve )
60 {
61 verifier1.verifyTextInLog( "Deliberately fail test case" );
62 }
63 finally
64 {
65 verifier1.resetStreams();
66 }
67
68 final Verifier verifier2 = newVerifier( testDir.getAbsolutePath() );
69 verifier2.setAutoclean( false );
70 verifier2.addCliOption( "--resume-from" );
71 verifier2.addCliOption( ":module-b" );
72 verifier2.executeGoal( "compile" ); // to prevent the unit test from failing (again)
73
74 verifier2.verifyErrorFreeLog();
75 verifier2.resetStreams();
76 }
77
78 /**
79 * Test that the --resume-from flag resolves dependencies inside the same Maven project
80 * without having them installed first.
81 * This test case uses the packaged artifact of module-a.
82 *
83 * @throws Exception in case of failure
84 */
85 public void testShouldResolvePackagedArtifactFromEarlierBuild() throws Exception
86 {
87 final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4660-resume-from" );
88
89 final Verifier verifier1 = newVerifier( testDir.getAbsolutePath() );
90 verifier1.deleteDirectory( "target" );
91 verifier1.deleteArtifacts( "org.apache.maven.its.mng4660" );
92
93 try
94 {
95 verifier1.executeGoal( "verify" ); // The verify goal will create a packaged artifact
96 fail( "Expected this invocation to fail" ); // See TestCase.java
97 }
98 catch ( final VerificationException ve )
99 {
100 verifier1.verifyTextInLog( "Deliberately fail test case" );
101 }
102 finally
103 {
104 verifier1.resetStreams();
105 }
106
107 final Verifier verifier2 = newVerifier( testDir.getAbsolutePath() );
108 verifier2.setAutoclean( false );
109 verifier2.addCliOption( "--resume-from" );
110 verifier2.addCliOption( ":module-b" );
111 verifier2.executeGoal( "compile" ); // to prevent the unit test from failing (again)
112
113 verifier2.verifyErrorFreeLog();
114 verifier2.resetStreams();
115 }
116 }