View Javadoc
1   package org.apache.maven.scm.provider.svn.svnexe;
2   
3   import static org.junit.Assert.assertFalse;
4   import static org.mockito.Mockito.mock;
5   import static org.mockito.Mockito.verify;
6   import static org.mockito.Mockito.when;
7   
8   import java.io.File;
9   
10  import org.apache.maven.scm.ScmException;
11  import org.apache.maven.scm.log.ScmLogger;
12  import org.codehaus.plexus.util.Os;
13  import org.junit.Assume;
14  import org.junit.Before;
15  import org.junit.Test;
16  
17  /*
18   * Licensed to the Apache Software Foundation (ASF) under one
19   * or more contributor license agreements.  See the NOTICE file
20   * distributed with this work for additional information
21   * regarding copyright ownership.  The ASF licenses this file
22   * to you under the Apache License, Version 2.0 (the
23   * "License"); you may not use this file except in compliance
24   * with the License.  You may obtain a copy of the License at
25   *
26   * http://www.apache.org/licenses/LICENSE-2.0
27   *
28   * Unless required by applicable law or agreed to in writing,
29   * software distributed under the License is distributed on an
30   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
31   * KIND, either express or implied.  See the License for the
32   * specific language governing permissions and limitations
33   * under the License.
34   */
35  
36  public class SvnExeScmProviderTest
37  {
38      private SvnExeScmProvider scmProvider;
39      
40      @Before
41      public void onSetup() 
42      {
43          scmProvider = new SvnExeScmProvider();
44      }
45      
46      // SCM-435
47      @Test 
48      public void testGetRepositoryURL_Windows()
49          throws Exception
50      {
51          Assume.assumeTrue( Os.isFamily( Os.FAMILY_WINDOWS ) );
52          
53          // prepare
54          ScmLogger logger = mock( ScmLogger.class );
55          when( logger.isInfoEnabled() ).thenReturn( Boolean.TRUE );
56          scmProvider.addListener( logger );
57          File workingDirectory = new File( "." );
58          
59          // test
60          // Since SCM-project has moved from svn to GIT, we can't verify the URL of this project 
61          String url;
62          try
63          {
64              url = scmProvider.getRepositoryURL( workingDirectory );
65              
66              // verify
67              assertFalse( url.startsWith( "file://" ) );
68          }
69          catch ( ScmException e )
70          {
71          }
72          
73          // verify
74          verify( logger ).info( "Executing: cmd.exe /X /C \"svn --non-interactive info .\"" );
75          verify( logger ).info( "Working directory: " + workingDirectory.getCanonicalPath() );
76      }
77  }
78