View Javadoc
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.List;
26  
27  /**
28   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3775">MNG-3775</a>.
29   *
30   * @author Benjamin Bentmann
31   */
32  public class MavenITmng3775ConflictResolutionBacktrackingTest
33      extends AbstractMavenIntegrationTestCase
34  {
35  
36      public MavenITmng3775ConflictResolutionBacktrackingTest()
37      {
38          super( "[3.0,)" );
39      }
40  
41      public void testitABC()
42          throws Exception
43      {
44          testit( "test-abc" );
45      }
46  
47      public void testitACB()
48          throws Exception
49      {
50          testit( "test-acb" );
51      }
52  
53      public void testitBAC()
54          throws Exception
55      {
56          testit( "test-bac" );
57      }
58  
59      public void testitBCA()
60          throws Exception
61      {
62          testit( "test-bca" );
63      }
64  
65      public void testitCAB()
66          throws Exception
67      {
68          testit( "test-cab" );
69      }
70  
71      public void testitCBA()
72          throws Exception
73      {
74          testit( "test-cba" );
75      }
76  
77      /**
78       * Verify that conflict resolution doesn't select nodes which are children of eventually disabled nodes.
79       * In other words, when a sub tree gets disabled, all previously selected winners among the children need to
80       * be revised.
81       */
82      private void testit( String project )
83          throws Exception
84      {
85          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3775" );
86  
87          Verifier verifier = newVerifier( new File( testDir, project ).getAbsolutePath() );
88          verifier.setAutoclean( false );
89          verifier.deleteDirectory( "target" );
90          verifier.deleteArtifacts( "org.apache.maven.its.mng3775" );
91          verifier.addCliOption( "-s" );
92          verifier.addCliOption( "settings.xml" );
93          verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
94          verifier.executeGoal( "validate" );
95          verifier.verifyErrorFreeLog();
96          verifier.resetStreams();
97  
98          List<String> test = verifier.loadLines( "target/test.txt", "UTF-8" );
99  
100         assertTrue( project + " > " + test.toString(), test.contains( "a-0.1.jar" ) );
101         assertTrue( project + " > " + test.toString(), test.contains( "b-0.1.jar" ) );
102         assertTrue( project + " > " + test.toString(), test.contains( "x-0.1.jar" ) );
103         assertTrue( project + " > " + test.toString(), test.contains( "c-0.1.jar" ) );
104     }
105 
106 }