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-4800">MNG-4800</a>.
30   * 
31   * @author Benjamin Bentmann
32   */
33  public class MavenITmng4800NearestWinsVsScopeWideningTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng4800NearestWinsVsScopeWideningTest()
38      {
39          super( "[3.0-beta-4,)" );
40      }
41  
42      public void testitAB()
43          throws Exception
44      {
45          testit( "test-ab" );
46      }
47  
48      public void testitBA()
49          throws Exception
50      {
51          testit( "test-ba" );
52      }
53  
54      /**
55       * Verify that nearest-wins conflict resolution doesn't get confused when a farther conflicting dependency has
56       * a wider scope than the nearer dependency, i.e. one should still end up with the nearer dependency (s:1) and
57       * its sub tree (x) but in the wider scope (compile).
58       */
59      private void testit( String test )
60          throws Exception
61      {
62          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4800" );
63  
64          Verifier verifier = newVerifier( new File( testDir, test ).getAbsolutePath() );
65          verifier.setAutoclean( false );
66          verifier.deleteDirectory( "target" );
67          verifier.deleteArtifacts( "org.apache.maven.its.mng4800" );
68          verifier.getCliOptions().add( "-s" );
69          verifier.getCliOptions().add( "settings.xml" );
70          verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
71          verifier.executeGoal( "validate" );
72          verifier.verifyErrorFreeLog();
73          verifier.resetStreams();
74  
75          List compile = verifier.loadLines( "target/compile.txt", "UTF-8" );
76  
77          assertTrue( test + " > " + compile.toString(), compile.contains( "b-0.1.jar" ) );
78          assertTrue( test + " > " + compile.toString(), compile.contains( "c-0.1.jar" ) );
79          assertTrue( test + " > " + compile.toString(), compile.contains( "s-0.1.jar" ) );
80          assertTrue( test + " > " + compile.toString(), compile.contains( "x-0.1.jar" ) );
81          assertFalse( test + " > " + compile.toString(), compile.contains( "a-0.1.jar" ) );
82          assertFalse( test + " > " + compile.toString(), compile.contains( "s-0.2.jar" ) );
83          assertFalse( test + " > " + compile.toString(), compile.contains( "y-0.1.jar" ) );
84  
85          List runtime = verifier.loadLines( "target/runtime.txt", "UTF-8" );
86  
87          assertTrue( test + " > " + runtime.toString(), runtime.contains( "b-0.1.jar" ) );
88          assertTrue( test + " > " + runtime.toString(), runtime.contains( "c-0.1.jar" ) );
89          assertTrue( test + " > " + runtime.toString(), runtime.contains( "s-0.1.jar" ) );
90          assertTrue( test + " > " + runtime.toString(), runtime.contains( "x-0.1.jar" ) );
91          assertTrue( test + " > " + runtime.toString(), runtime.contains( "a-0.1.jar" ) );
92          assertFalse( test + " > " + runtime.toString(), runtime.contains( "s-0.2.jar" ) );
93          assertFalse( test + " > " + runtime.toString(), runtime.contains( "y-0.1.jar" ) );
94      }
95  
96  }