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.util.ResourceExtractor;
23  
24  import java.io.File;
25  import java.util.List;
26  
27  /**
28   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3220">MNG-3220</a>.
29   *
30   *
31   */
32  public class MavenITmng3220ImportScopeTest
33      extends AbstractMavenIntegrationTestCase
34  {
35      public MavenITmng3220ImportScopeTest()
36      {
37          super( "(2.0.8,3.0-alpha-1),[3.0-alpha-3,)" );
38      }
39  
40      public void testitMNG3220a()
41          throws Exception
42      {
43          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3220" );
44  
45          testDir = new File( testDir, "imported-pom-depMgmt" );
46  
47          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48          verifier.setAutoclean( false );
49          verifier.deleteDirectory( "target" );
50          verifier.deleteArtifacts( "org.apache.maven.its.mng3220" );
51          verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
52                               verifier.newDefaultFilterProperties() );
53          verifier.addCliOption( "--settings" );
54          verifier.addCliOption( "settings.xml" );
55          verifier.executeGoal( "validate" );
56          verifier.verifyErrorFreeLog();
57          verifier.resetStreams();
58      }
59  
60      public void testitMNG3220b()
61          throws Exception
62      {
63          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3220" );
64  
65          testDir = new File( testDir, "depMgmt-pom-module-notImported" );
66  
67          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
68          verifier.setAutoclean( false );
69          verifier.deleteDirectory( "target" );
70          verifier.deleteArtifacts( "org.apache.maven.its.mng3220" );
71          verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
72                               verifier.newDefaultFilterProperties() );
73          verifier.addCliOption( "--settings" );
74          verifier.addCliOption( "settings.xml" );
75  
76          try
77          {
78              verifier.executeGoal( "validate" );
79              verifier.verifyErrorFreeLog();
80              fail( "Should fail to build with missing junit version." );
81          }
82          catch ( VerificationException e )
83          {
84              // expected
85          }
86  
87          verifier.resetStreams();
88  
89          List<String> lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
90  
91          boolean found = false;
92          for ( String line : lines )
93          {
94              if ( line.contains( "\'dependencies.dependency.version\' is missing for junit:junit" ) || line.contains(
95                  "\'dependencies.dependency.version\' for junit:junit:jar is missing" ) )
96              {
97                  found = true;
98                  break;
99              }
100         }
101 
102         assertTrue( "Should have found validation error line in output.", found );
103     }
104 
105 }