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