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.Properties;
26  
27  /**
28   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-2865">MNG-2865</a>.
29   *
30   * @author Benjamin Bentmann
31   *
32   */
33  public class MavenITmng2865MirrorWildcardTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng2865MirrorWildcardTest()
38      {
39          super( "(2.0.4,)" );
40      }
41  
42      /**
43       * Test that the mirror wildcard * matches any repo, in particular file:// repos.
44       *
45       * @throws Exception in case of failure
46       */
47      public void testitFileRepo()
48          throws Exception
49      {
50          testit( "file" );
51      }
52  
53      /**
54       * Test that the mirror wildcard * matches any repo, in particular http://localhost repos.
55       *
56       * @throws Exception in case of failure
57       */
58      public void testitLocalhostRepo()
59          throws Exception
60      {
61          testit( "localhost" );
62      }
63  
64      /**
65       * Test that the mirror wildcard * matches any repo, in particular external repos.
66       *
67       * @throws Exception in case of failure
68       */
69      public void testitExternalRepo()
70          throws Exception
71      {
72          testit( "external" );
73      }
74  
75      /**
76       * Test that the mirror wildcard * matches any repo, in particular central.
77       *
78       * @throws Exception in case of failure
79       */
80      public void testitCentralRepo()
81          throws Exception
82      {
83          testit( "central" );
84      }
85  
86      private void testit( String project )
87          throws Exception
88      {
89          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2865" );
90  
91          Verifier verifier = newVerifier( new File( testDir, project ).getAbsolutePath() );
92          verifier.setAutoclean( false );
93          verifier.deleteArtifacts( "org.apache.maven.its.mng2865" );
94          Properties filterProps = verifier.newDefaultFilterProperties();
95          verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
96          verifier.addCliOption( "--settings" );
97          verifier.addCliOption( "settings.xml" );
98          verifier.executeGoal( "validate" );
99          verifier.verifyErrorFreeLog();
100         verifier.resetStreams();
101 
102         verifier.assertArtifactPresent( "org.apache.maven.its.mng2865", "a", "0.1", "jar" );
103     }
104 
105 }