1 package org.apache.maven.archiva.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import java.net.MalformedURLException;
24 import junit.framework.TestCase;
29 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
32 public class RepositoryURLTest
35 private void assertURL( String actualURL, String protocol, String username, String password, String hostname,
36 String port, String path )
38 RepositoryURL url = new RepositoryURL( actualURL );
40 assertEquals( protocol, url.getProtocol() );
41 assertEquals( username, url.getUsername() );
42 assertEquals( password, url.getPassword() );
43 assertEquals( hostname, url.getHost() );
44 assertEquals( port, url.getPort() );
45 assertEquals( path, url.getPath() );
48 public void testProtocolHttp()
49 throws MalformedURLException
51 assertURL( "http://localhost/path/to/resource.txt", "http", null, null, "localhost", null,
52 "/path/to/resource.txt" );
55 public void testProtocolWagonWebdav()
56 throws MalformedURLException
58 assertURL( "dav:http://localhost/path/to/resource.txt", "dav:http", null, null, "localhost", null,
59 "/path/to/resource.txt" );
62 public void testProtocolHttpWithPort()
63 throws MalformedURLException
65 assertURL( "http://localhost:9090/path/to/resource.txt", "http", null, null, "localhost", "9090",
66 "/path/to/resource.txt" );
69 public void testProtocolHttpWithUsername()
70 throws MalformedURLException
72 assertURL( "http://user@localhost/path/to/resource.txt", "http", "user", null, "localhost", null,
73 "/path/to/resource.txt" );
76 public void testProtocolHttpWithUsernamePassword()
77 throws MalformedURLException
79 assertURL( "http://user:pass@localhost/path/to/resource.txt", "http", "user", "pass", "localhost", null,
80 "/path/to/resource.txt" );
83 public void testProtocolHttpWithUsernamePasswordPort()
84 throws MalformedURLException
86 assertURL( "http://user:pass@localhost:9090/path/to/resource.txt", "http", "user", "pass", "localhost", "9090",
87 "/path/to/resource.txt" );