1   package org.apache.maven.wagon.repository;
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 junit.framework.TestCase;
23  
24  import org.apache.maven.wagon.WagonConstants;
25  
26  /**
27   * @author <a href="mailto:jvanzyl@maven.org">Jason van Zyl</a>
28   * @version $Id: RepositoryTest.java 655761 2008-05-13 07:29:32Z brett $
29   */
30  public class RepositoryTest
31      extends TestCase
32  {
33      public RepositoryTest( final String name )
34      {
35          super( name );
36      }
37  
38      public void setUp()
39          throws Exception
40      {
41          super.setUp();
42      }
43  
44      public void tearDown()
45          throws Exception
46      {
47          super.tearDown();
48      }
49  
50      public void testRepositoryProperties()
51          throws Exception
52      {
53          Repository repository = new Repository();
54  
55          repository.setBasedir( "directory" );
56  
57          assertEquals( "directory", repository.getBasedir() );
58  
59          repository.setName( "name" );
60  
61          assertEquals( "name", repository.getName() );
62  
63          repository.setPort( 0 );
64  
65          assertEquals( 0, repository.getPort() );
66  
67          assertEquals( "localhost", repository.getHost() );
68  
69          repository.setUrl( "http://www.ibiblio.org" );
70  
71          assertEquals( "http://www.ibiblio.org", repository.getUrl() );
72  
73          assertEquals( "http", repository.getProtocol() );
74  
75          assertEquals( "www.ibiblio.org", repository.getHost() );
76  
77          assertEquals( "/", repository.getBasedir() );
78  
79          assertEquals( WagonConstants.UNKNOWN_PORT, repository.getPort() );
80  
81          repository.setUrl( "https://www.ibiblio.org:100/maven" );
82  
83          assertEquals( "https://www.ibiblio.org:100/maven", repository.getUrl() );
84  
85          assertEquals( "https", repository.getProtocol() );
86  
87          assertEquals( "www.ibiblio.org", repository.getHost() );
88  
89          assertEquals( "/maven", repository.getBasedir() );
90  
91          assertEquals( 100, repository.getPort() );
92  
93          assertEquals( "www.ibiblio.org", repository.getHost() );
94  
95          repository.setBasedir( "basedir" );
96  
97          assertEquals( "basedir", repository.getBasedir() );
98  
99          repository.setUrl( "http://brett:porter@www.ibiblio.org" );
100 
101         assertEquals( "http://www.ibiblio.org", repository.getUrl() );
102 
103         repository.setUrl( "http://brett@www.ibiblio.org" );
104 
105         assertEquals( "http://www.ibiblio.org", repository.getUrl() );
106 
107     }
108 }