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.repository.Repository;
24 import org.codehaus.plexus.PlexusTestCase;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.JUnit4;
29
30 /**
31 * @author <a href="mailto:cleclerc@xebia.fr">Cyrille Le Clerc</a>
32 */
33 @RunWith(JUnit4.class)
34 public class SiteDeployMojoTest
35 extends PlexusTestCase
36 {
37 private WagonManager wagonManager;
38
39 private Repository repository;
40
41 @Before
42 public void setUp()
43 throws Exception
44 {
45 super.setUp();
46 wagonManager = getContainer().lookup( WagonManager.class );
47 repository = new Repository( "my-repository", "scp://repository-host/var/maven2" );
48 }
49
50 @Test
51 public void testFoo()
52 {
53 // should not fail ;-)
54 assertTrue( true );
55 }
56
57 /**
58 FIXME find a way to restore those tests as wagonManager.addProxy is not anymore available in maven 3.
59 public void testGetProxyInfoNoProxyForRepositoryProtocol()
60 {
61 wagonManager.addProxy( "http", "proxy-host", 8080, "my-user", "my-password", null );
62 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
63 assertNull( "ProxyInfo must be null because http != scp", proxyInfo );
64 }
65
66 public void testGetProxyInfoForRepositoryHostExactlyMatchesNonProxyHosts()
67 {
68 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password",
69 "a-host,repository-host;another-host" );
70 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
71 assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
72 }
73
74 public void testGetProxyInfoForRepositoryHostWildcardMatchNonProxyHosts1()
75 {
76 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "a-host|repository*|another-host" );
77 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
78 assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
79 }
80
81 public void testGetProxyInfoForRepositoryHostWildcardMatchNonProxyHosts2()
82 {
83 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "*host" );
84 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
85 assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
86 }
87
88 public void testGetProxyInfoForRepositoryHostWildcardMatchNonProxyHosts3()
89 {
90 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "repository*host" );
91 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
92 assertNull( "ProxyInfo must be null because 'repository-host' in nonProxyHosts list", proxyInfo );
93 }
94
95 public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts1()
96 {
97 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "mycompany*" );
98 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
99 assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
100 }
101
102 public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts2()
103 {
104 wagonManager.
105
106 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "*mycompany" );
107 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
108 assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
109 }
110
111 public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts3()
112 {
113 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "repository*mycompany" );
114 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
115 assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
116 }
117
118 public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts4()
119 {
120 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "mycompany*host" );
121 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
122 assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
123 }
124
125 public void testGetProxyInfoForRepositoryHostWildcardNoMatchNonProxyHosts5()
126 {
127 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "mycompany*mycompany" );
128 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
129 assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
130 }
131
132 public void testGetProxyInfoFound()
133 {
134 wagonManager.addProxy( "scp", "localhost", 8080, "my-user", "my-password", "an-host|another-host" );
135 ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
136 assertNotNull( "ProxyInfo must be found because 'repository-host' not in nonProxyHosts list", proxyInfo );
137 }
138 **/
139 }