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