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   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4293">MNG-4293</a>.
31   * 
32   * @author Benjamin Bentmann
33   */
34  public class MavenITmng4293RequiresCompilePlusRuntimeScopeTest
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 MavenITmng4293RequiresCompilePlusRuntimeScopeTest()
43      {
44          super( "[3.0-alpha-3,)" );
45      }
46  
47      /**
48       * Test support of "@requiresDependencyResolution compile+runtime".
49       */
50      public void testit()
51          throws Exception
52      {
53          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4293" );
54  
55          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
56          verifier.setAutoclean( false );
57          verifier.deleteDirectory( "target" );
58          verifier.deleteArtifacts( "org.apache.maven.its.mng4293" );
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 compileClassPath = verifier.loadLines( "target/compile-cp.txt", "UTF-8" );
69          assertTrue( compileClassPath.toString(), compileClassPath.contains( "system-0.1.jar" ) );
70          assertTrue( compileClassPath.toString(), compileClassPath.contains( "provided-0.1.jar" ) );
71          assertTrue( compileClassPath.toString(), compileClassPath.contains( "compile-0.1.jar" ) );
72          assertFalse( compileClassPath.toString(), compileClassPath.contains( "test-0.1.jar" ) );
73  
74          List runtimeClassPath = verifier.loadLines( "target/runtime-cp.txt", "UTF-8" );
75          assertTrue( runtimeClassPath.toString(), runtimeClassPath.contains( "compile-0.1.jar" ) );
76          assertTrue( runtimeClassPath.toString(), runtimeClassPath.contains( "runtime-0.1.jar" ) );
77          assertFalse( runtimeClassPath.toString(), runtimeClassPath.contains( "test-0.1.jar" ) );
78      }
79  
80  }