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  import java.util.Properties;
28  
29  /**
30   * 
31   * @author Benjamin Bentmann
32   * @version $Id: MavenIT0142DirectDependencyScopesTest.java 981712 2010-08-03 00:36:19Z bentmann $
33   */
34  public class MavenIT0142DirectDependencyScopesTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      /*
39       * NOTE: Class path ordering is another issue (MNG-1412), so we merely check set containment here.
40       */
41  
42      public MavenIT0142DirectDependencyScopesTest()
43      {
44          super( ALL_MAVEN_VERSIONS );
45      }
46  
47      /**
48       * Test that the different scopes of direct dependencies end up on the right class paths.
49       */
50      public void testit0142()
51          throws Exception
52      {
53          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0142" );
54  
55          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
56          verifier.setAutoclean( false );
57          verifier.deleteDirectory( "target" );
58          verifier.deleteArtifacts( "org.apache.maven.its.it0142" );
59          Properties filterProps = verifier.newDefaultFilterProperties();
60          verifier.filterFile( "pom-template.xml", "pom.xml", "UTF-8", filterProps );
61          verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
62          verifier.getCliOptions().add( "--settings" );
63          verifier.getCliOptions().add( "settings.xml" );
64          verifier.executeGoal( "validate" );
65          verifier.verifyErrorFreeLog();
66          verifier.resetStreams();
67  
68          List compileArtifacts = verifier.loadLines( "target/compile-artifacts.txt", "UTF-8" );
69          assertTrue( compileArtifacts.toString(), compileArtifacts.contains( "org.apache.maven.its.it0142:system:jar:0.1" ) );
70          assertTrue( compileArtifacts.toString(), compileArtifacts.contains( "org.apache.maven.its.it0142:provided:jar:0.1" ) );
71          assertTrue( compileArtifacts.toString(), compileArtifacts.contains( "org.apache.maven.its.it0142:compile:jar:0.1" ) );
72          assertEquals( 3, compileArtifacts.size() );
73  
74          List compileClassPath = verifier.loadLines( "target/compile-cp.txt", "UTF-8" );
75          assertTrue( compileClassPath.toString(), compileClassPath.contains( "classes" ) );
76          assertTrue( compileClassPath.toString(), compileClassPath.contains( "system-0.1.jar" ) );
77          assertTrue( compileClassPath.toString(), compileClassPath.contains( "provided-0.1.jar" ) );
78          assertTrue( compileClassPath.toString(), compileClassPath.contains( "compile-0.1.jar" ) );
79          assertEquals( 4, compileClassPath.size() );
80  
81          List runtimeArtifacts = verifier.loadLines( "target/runtime-artifacts.txt", "UTF-8" );
82          assertTrue( runtimeArtifacts.toString(), runtimeArtifacts.contains( "org.apache.maven.its.it0142:compile:jar:0.1" ) );
83          assertTrue( runtimeArtifacts.toString(), runtimeArtifacts.contains( "org.apache.maven.its.it0142:runtime:jar:0.1" ) );
84          assertTrue( runtimeArtifacts.toString(), runtimeArtifacts.contains( "org.apache.maven.its.it0142:runtime:jar:retro:0.1" ) );
85          assertEquals( 3, runtimeArtifacts.size() );
86  
87          List runtimeClassPath = verifier.loadLines( "target/runtime-cp.txt", "UTF-8" );
88          assertTrue( runtimeClassPath.toString(), runtimeClassPath.contains( "classes" ) );
89          assertTrue( runtimeClassPath.toString(), runtimeClassPath.contains( "compile-0.1.jar" ) );
90          assertTrue( runtimeClassPath.toString(), runtimeClassPath.contains( "runtime-0.1.jar" ) );
91          assertTrue( runtimeClassPath.toString(), runtimeClassPath.contains( "runtime-0.1-retro.jar" ) );
92          assertEquals( 4, runtimeClassPath.size() );
93  
94          List testArtifacts = verifier.loadLines( "target/test-artifacts.txt", "UTF-8" );
95          assertTrue( testArtifacts.toString(), testArtifacts.contains( "org.apache.maven.its.it0142:system:jar:0.1" ) );
96          assertTrue( testArtifacts.toString(), testArtifacts.contains( "org.apache.maven.its.it0142:provided:jar:0.1" ) );
97          assertTrue( testArtifacts.toString(), testArtifacts.contains( "org.apache.maven.its.it0142:compile:jar:0.1" ) );
98          assertTrue( testArtifacts.toString(), testArtifacts.contains( "org.apache.maven.its.it0142:runtime:jar:0.1" ) );
99          assertTrue( testArtifacts.toString(), testArtifacts.contains( "org.apache.maven.its.it0142:runtime:jar:retro:0.1" ) );
100         assertTrue( testArtifacts.toString(), testArtifacts.contains( "org.apache.maven.its.it0142:test:jar:0.1" ) );
101         assertEquals( 6, testArtifacts.size() );
102 
103         List testClassPath = verifier.loadLines( "target/test-cp.txt", "UTF-8" );
104         assertTrue( testClassPath.toString(), testClassPath.contains( "classes" ) );
105         assertTrue( testClassPath.toString(), testClassPath.contains( "test-classes" ) );
106         assertTrue( testClassPath.toString(), testClassPath.contains( "system-0.1.jar" ) );
107         assertTrue( testClassPath.toString(), testClassPath.contains( "provided-0.1.jar" ) );
108         assertTrue( testClassPath.toString(), testClassPath.contains( "compile-0.1.jar" ) );
109         assertTrue( testClassPath.toString(), testClassPath.contains( "runtime-0.1.jar" ) );
110         assertTrue( testClassPath.toString(), testClassPath.contains( "runtime-0.1-retro.jar" ) );
111         assertTrue( testClassPath.toString(), testClassPath.contains( "test-0.1.jar" ) );
112         assertEquals( 8, testClassPath.size() );
113     }
114 
115 }