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.io.IOException;
26  import java.util.Properties;
27  
28  /**
29   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4254">MNG-4254</a>.
30   *
31   * @author John Casey
32   *
33   */
34  public class MavenITmng4254SelectableWagonProvidersTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng4254SelectableWagonProvidersTest()
39      {
40          // not supported in 3.x, there will be a single HTTP wagon
41          super( "(2.2.0,3.0-alpha-1)" );
42      }
43  
44      public void testCliUsage()
45          throws IOException, VerificationException
46      {
47          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4254" );
48  
49          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
50          verifier.setAutoclean( false );
51          verifier.deleteDirectory( "target" );
52  
53          verifier.addCliOption( "-Dmaven.wagon.provider.http=coreit" );
54          verifier.addCliOption( "-V" );
55  
56          verifier.setLogFileName( "log-cli.txt" );
57          verifier.executeGoal( "validate" );
58  
59          verifier.verifyErrorFreeLog();
60          verifier.resetStreams();
61  
62          Properties props = verifier.loadProperties( "target/wagon-impl.properties" );
63          assertEquals( "org.apache.maven.wagon.providers.coreit.CoreItHttpWagon", props.getProperty( "wagon.class" ) );
64      }
65  
66      public void testSettingsUsage()
67          throws IOException, VerificationException
68      {
69          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4254" );
70  
71          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
72          verifier.setAutoclean( false );
73          verifier.deleteDirectory( "target" );
74  
75          verifier.addCliOption( "--settings" );
76          verifier.addCliOption( "settings.xml" );
77          verifier.addCliOption( "-V" );
78  
79          verifier.setLogFileName( "log-settings.txt" );
80          verifier.executeGoal( "validate" );
81  
82          verifier.verifyErrorFreeLog();
83          verifier.resetStreams();
84  
85          Properties props = verifier.loadProperties( "target/wagon-impl.properties" );
86          assertEquals( "org.apache.maven.wagon.providers.coreit.CoreItHttpWagon", props.getProperty( "wagon.class" ) );
87      }
88  
89      public void testDefaultHttpWagon()
90          throws IOException, VerificationException
91      {
92          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4254" );
93  
94          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
95          verifier.setAutoclean( false );
96          verifier.deleteDirectory( "target" );
97  
98          verifier.addCliOption( "-V" );
99  
100         verifier.setLogFileName( "log-default-http.txt" );
101         verifier.executeGoal( "validate" );
102 
103         verifier.verifyErrorFreeLog();
104         verifier.resetStreams();
105 
106         Properties props = verifier.loadProperties( "target/wagon-impl.properties" );
107         assertEquals( "org.apache.maven.wagon.providers.http.LightweightHttpWagon", props.getProperty( "wagon.class" ) );
108     }
109 
110     public void testDefaultHttpsWagon()
111         throws IOException, VerificationException
112     {
113         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4254" );
114 
115         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
116         verifier.setAutoclean( false );
117         verifier.deleteDirectory( "target" );
118 
119         verifier.addCliOption( "-V" );
120         verifier.addCliOption( "-DwagonProtocol=https" );
121 
122         verifier.setLogFileName( "log-default-https.txt" );
123         verifier.executeGoal( "validate" );
124 
125         verifier.verifyErrorFreeLog();
126         verifier.resetStreams();
127 
128         Properties props = verifier.loadProperties( "target/wagon-impl.properties" );
129         assertEquals( "org.apache.maven.wagon.providers.http.LightweightHttpsWagon", props.getProperty( "wagon.class" ) );
130     }
131 
132 }