View Javadoc
1   package org.apache.maven.scm.provider.svn;
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.scm.ScmTestCase;
23  
24  /**
25   * @author <a href="mailto:jerome@coffeebreaks.org">Jerome Lacoste</a>
26   *
27   */
28  public class SvnCommandUtilsTest
29      extends ScmTestCase
30  {
31      // ----------------------------------------------------------------------
32      // appendPath
33      // ----------------------------------------------------------------------
34  
35      public void testFixUrlHttpUrlsAreIgnored()
36          throws Exception
37      {
38          String unchanged = "http://foo.com/svn/myproject/tags/foo";
39          assertEquals( unchanged, SvnCommandUtils.fixUrl( unchanged, null ) );
40          assertEquals( unchanged, SvnCommandUtils.fixUrl( unchanged, "" ) );
41          assertEquals( unchanged, SvnCommandUtils.fixUrl( unchanged, "user" ) );
42      }
43  
44      public void testFixUrlNPEifNullURL()
45          throws Exception
46      {
47          try
48          {
49              SvnCommandUtils.fixUrl( null, "user" );
50              fail( "expected NPE" );
51          }
52          catch ( NullPointerException e )
53          {
54              assertTrue( true ); // expected
55          }
56      }
57  
58      public void testFixUrlSvnSshUrlsUsernameIsAddedWhenUserSpecified()
59          throws Exception
60      {
61          assertEquals( "svn+ssh://foo.com/svn/myproject",
62                        SvnCommandUtils.fixUrl( "svn+ssh://foo.com/svn/myproject", null ) );
63          assertEquals( "svn+ssh://foo.com/svn/myproject",
64                        SvnCommandUtils.fixUrl( "svn+ssh://foo.com/svn/myproject", "" ) );
65          assertEquals( "svn+ssh://user@foo.com/svn/myproject",
66                        SvnCommandUtils.fixUrl( "svn+ssh://foo.com/svn/myproject", "user" ) );
67      }
68  
69      public void testFixUrlSvnSshUrlsUsernameIsOverridenWhenUserSpecified()
70          throws Exception
71      {
72          assertEquals( "svn+ssh://user1@foo.com/svn/myproject",
73                        SvnCommandUtils.fixUrl( "svn+ssh://user1@foo.com/svn/myproject", null ) );
74          assertEquals( "svn+ssh://user1@foo.com/svn/myproject",
75                        SvnCommandUtils.fixUrl( "svn+ssh://user1@foo.com/svn/myproject", "" ) );
76          assertEquals( "svn+ssh://user2@foo.com/svn/myproject",
77                        SvnCommandUtils.fixUrl( "svn+ssh://user1@foo.com/svn/myproject", "user2" ) );
78      }
79  }