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  
26  /**
27   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3983">MNG-3983</a>.
28   *
29   * @author Benjamin Bentmann
30   *
31   */
32  public class MavenITmng3983PluginResolutionFromProfileReposTest
33      extends AbstractMavenIntegrationTestCase
34  {
35  
36      public MavenITmng3983PluginResolutionFromProfileReposTest()
37      {
38          super( ALL_MAVEN_VERSIONS );
39      }
40  
41      /**
42       * Test that plugins can be resolved from remote plugin repositories defined by (active) profiles in the POM.
43       *
44       * @throws Exception in case of failure
45       */
46      public void testitFromPom()
47          throws Exception
48      {
49          requiresMavenVersion( "[2.0,3.0-alpha-1),[3.0-alpha-3,)" );
50  
51          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3983/test-1" );
52  
53          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
54          verifier.setForkJvm( true ); // Don't lock up plugin files in class loader within current JVM
55          verifier.setAutoclean( false );
56          verifier.deleteDirectory( "target" );
57          verifier.deleteArtifacts( "org.apache.maven.its.mng3983" );
58          verifier.filterFile( "pom.xml", "pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
59          verifier.executeGoal( "validate" );
60          verifier.verifyErrorFreeLog();
61          verifier.resetStreams();
62  
63          verifier.assertArtifactPresent( "org.apache.maven.its.mng3983", "p", "0.1", "jar" );
64      }
65  
66      /**
67       * Test that plugins can be resolved from remote plugin repositories defined by (active) profiles in profiles.xml.
68       *
69       * @throws Exception in case of failure
70       */
71      public void testitFromProfilesXml()
72          throws Exception
73      {
74          // support for profiles.xml removed from 3.x (see MNG-4060)
75          requiresMavenVersion( "[2.0,3.0-alpha-1)" );
76  
77          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3983/test-2" );
78  
79          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
80          verifier.setForkJvm( true ); // Don't lock up plugin files in class loader within current JVM
81          verifier.setAutoclean( false );
82          verifier.deleteDirectory( "target" );
83          verifier.deleteArtifacts( "org.apache.maven.its.mng3983" );
84          verifier.filterFile( "profiles.xml", "profiles.xml", "UTF-8", verifier.newDefaultFilterProperties() );
85          verifier.executeGoal( "validate" );
86          verifier.verifyErrorFreeLog();
87          verifier.resetStreams();
88  
89          verifier.assertArtifactPresent( "org.apache.maven.its.mng3983", "p", "0.1", "jar" );
90      }
91  
92      /**
93       * Test that plugins can be resolved from remote plugin repositories defined by (active) profiles in settings.xml.
94       *
95       * @throws Exception in case of failure
96       */
97      public void testitFromSettings()
98          throws Exception
99      {
100         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3983/test-3" );
101 
102         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
103         verifier.setForkJvm( true ); // Don't lock up plugin files in class loader within current JVM
104         verifier.setAutoclean( false );
105         verifier.deleteDirectory( "target" );
106         verifier.deleteArtifacts( "org.apache.maven.its.mng3983" );
107         verifier.filterFile( "settings.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
108         verifier.addCliOption( "--settings" );
109         verifier.addCliOption( "settings.xml" );
110         verifier.executeGoal( "validate" );
111         verifier.verifyErrorFreeLog();
112         verifier.resetStreams();
113 
114         verifier.assertArtifactPresent( "org.apache.maven.its.mng3983", "p", "0.1", "jar" );
115     }
116 
117 }