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 import java.util.Arrays;
26 import java.util.List;
27
28 /**
29 * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3938">MNG-3938</a>.
30 *
31 * @author Benjamin Bentmann
32 *
33 */
34 public class MavenITmng3938MergePluginExecutionsTest
35 extends AbstractMavenIntegrationTestCase
36 {
37
38 public MavenITmng3938MergePluginExecutionsTest()
39 {
40 super( "(2.0.4,)" );
41 }
42
43 /**
44 * Test that plugin executions with the same id are merged during inheritance, especially executions using the
45 * default id, regardless whether the id is given explicitly by the user or implicitly assumed from defaults, when
46 * no {@code <pluginManagement>} is involved.
47 *
48 * @throws Exception in case of failure
49 */
50 public void testitWithoutPluginMngt()
51 throws Exception
52 {
53 testitMNG3938( "test-1" );
54 }
55
56 /**
57 * Test that plugin executions with the same id are merged during inheritance, especially executions using the
58 * default id, regardless whether the id is given explicitly by the user or implicitly assumed from defaults, when
59 * {@code <pluginManagement>} is involved.
60 *
61 * @throws Exception in case of failure
62 */
63 public void testitWithPluginMngt()
64 throws Exception
65 {
66 testitMNG3938( "test-2" );
67 }
68
69 private void testitMNG3938( String project )
70 throws Exception
71 {
72 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3938/" + project );
73
74 Verifier verifier = newVerifier( new File( testDir, "sub" ).getAbsolutePath() );
75 verifier.setAutoclean( false );
76 verifier.deleteDirectory( "target" );
77 verifier.executeGoal( "validate" );
78 verifier.verifyErrorFreeLog();
79 verifier.resetStreams();
80
81 List<String> lines = verifier.loadLines( "target/default.log", "UTF-8" );
82 assertEquals( Arrays.asList( new String[] { "child" } ), lines );
83
84 lines = verifier.loadLines( "target/non-default.log", "UTF-8" );
85 assertEquals( Arrays.asList( new String[] { "child" } ), lines );
86
87 verifier.assertFileNotPresent( "target/parent.log" );
88 }
89
90 }