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-4690">MNG-4690</a>.
30   * 
31   * @author Benjamin Bentmann
32   */
33  public class MavenITmng4690InterdependentConflictResolutionTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng4690InterdependentConflictResolutionTest()
38      {
39          super( "[2.0.9,)" );
40      }
41  
42      // Ideally, all six permutations of the three direct dependencies should yield the same result...
43  
44      public void testitADX()
45          throws Exception
46      {
47          requiresMavenVersion( "[3.0-beta-3,)" );
48          testit( "test-adx" );
49      }
50  
51      public void testitAXD()
52          throws Exception
53      {
54          testit( "test-axd" );
55      }
56  
57      public void testitDAX()
58          throws Exception
59      {
60          requiresMavenVersion( "[3.0-beta-3,)" );
61          testit( "test-dax" );
62      }
63  
64      public void testitDXA()
65          throws Exception
66      {
67          testit( "test-dxa" );
68      }
69  
70      public void testitXAD()
71          throws Exception
72      {
73          testit( "test-xad" );
74      }
75  
76      public void testitXDA()
77          throws Exception
78      {
79          testit( "test-xda" );
80      }
81  
82      /**
83       * Verify that conflict resolution doesn't depend on the declaration order of dependencies (from distinct tree
84       * levels) when the resolution of one conflict influences another conflict.
85       */
86      private void testit( String test )
87          throws Exception
88      {
89          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4690" );
90  
91          Verifier verifier = newVerifier( new File( testDir, test ).getAbsolutePath() );
92          verifier.setAutoclean( false );
93          verifier.deleteDirectory( "target" );
94          verifier.deleteArtifacts( "org.apache.maven.its.mng4690" );
95          verifier.getCliOptions().add( "-s" );
96          verifier.getCliOptions().add( "settings.xml" );
97          verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
98          verifier.executeGoal( "validate" );
99          verifier.verifyErrorFreeLog();
100         verifier.resetStreams();
101 
102         List classpath = verifier.loadLines( "target/classpath.txt", "UTF-8" );
103 
104         assertTrue( test + " > " + classpath.toString(), classpath.contains( "a-1.jar" ) );
105         assertTrue( test + " > " + classpath.toString(), classpath.contains( "b-1.jar" ) );
106         assertTrue( test + " > " + classpath.toString(), classpath.contains( "c-1.jar" ) );
107         assertTrue( test + " > " + classpath.toString(), classpath.contains( "d-1.jar" ) );
108 
109         assertTrue( test + " > " + classpath.toString(), classpath.contains( "x-1.jar" ) );
110         assertTrue( test + " > " + classpath.toString(), classpath.contains( "y-2.jar" ) );
111     }
112 
113 }