View Javadoc

1   package org.apache.maven.plugins.site;
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.artifact.manager.WagonManager;
23  import org.apache.maven.wagon.proxy.ProxyInfo;
24  import org.apache.maven.wagon.repository.Repository;
25  import org.codehaus.plexus.PlexusTestCase;
26  
27  /**
28   * @author <a href="mailto:cleclerc@xebia.fr">Cyrille Le Clerc</a>
29   */
30  public class SiteDeployMojoTest
31      extends PlexusTestCase
32  {
33      private WagonManager wagonManager;
34  
35      private Repository repository;
36  
37      @Override
38      protected void setUp()
39          throws Exception
40      {
41          super.setUp();
42          wagonManager = (WagonManager) getContainer().lookup( WagonManager.ROLE );
43          repository = new Repository( "my-repository", "scp://repository-host/var/maven2" );
44      }
45  
46      public void testGetProxyInfoNoProxyForRepositoryProtocol()
47      {
48          wagonManager.addProxy( "http", "proxy-host", 8080, "my-user", "my-password", null );
49          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
50          assertNull( "ProxyInfo must be null because http != scp", proxyInfo );
51      }
52  
53      public void testGetProxyInfoForRepositoryHostExactlyMatchesNonProxyHosts()
54      {
55          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password",
56                                 "a-host,repository-host;another-host" );
57          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
58          assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
59      }
60  
61      public void testGetProxyInfoForRepositoryHostWildcardMatchNonProxyHosts1()
62      {
63          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "a-host|repository*|another-host" );
64          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
65          assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
66      }
67  
68      public void testGetProxyInfoForRepositoryHostWildcardMatchNonProxyHosts2()
69      {
70          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "*host" );
71          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
72          assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
73      }
74  
75      public void testGetProxyInfoForRepositoryHostWildcardMatchNonProxyHosts3()
76      {
77          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "repository*host" );
78          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
79          assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
80      }
81  
82      public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts1()
83      {
84          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "mycompany*" );
85          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
86          assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
87      }
88  
89      public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts2()
90      {
91          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "*mycompany" );
92          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
93          assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
94      }
95  
96      public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts3()
97      {
98          wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "repository*mycompany" );
99          ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
100         assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
101     }
102 
103     public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts4()
104     {
105         wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "mycompany*host" );
106         ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
107         assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
108     }
109 
110     public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts5()
111     {
112         wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "mycompany*mycompany" );
113         ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
114         assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
115     }
116 
117     public void testGetProxyInfoFound()
118     {
119         wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "an-host|another-host" );
120         ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
121         assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
122     }
123 }