001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm.provider.svn.svnexe; 020 021import java.io.File; 022 023import org.apache.maven.scm.ScmException; 024import org.codehaus.plexus.util.Os; 025import org.junit.Assume; 026import org.junit.Before; 027import org.junit.Ignore; 028import org.junit.Test; 029import org.slf4j.Logger; 030 031import static org.junit.Assert.assertFalse; 032import static org.mockito.Mockito.mock; 033import static org.mockito.Mockito.verify; 034import static org.mockito.Mockito.when; 035 036public class SvnExeScmProviderTest { 037 private SvnExeScmProvider scmProvider; 038 039 @Before 040 public void onSetup() { 041 scmProvider = new SvnExeScmProvider(); 042 } 043 044 // SCM-435 045 @Test 046 @Ignore("This test is for now ignore: it mock Logger and then asserts against it") 047 public void testGetRepositoryURL_Windows() throws Exception { 048 Assume.assumeTrue(Os.isFamily(Os.FAMILY_WINDOWS)); 049 050 // prepare 051 Logger logger = mock(Logger.class); 052 when(logger.isInfoEnabled()).thenReturn(Boolean.TRUE); 053 // scmProvider.addListener( logger ); 054 File workingDirectory = new File("."); 055 056 // test 057 // Since SCM-project has moved from svn to GIT, we can't verify the URL of this project 058 String url; 059 try { 060 url = scmProvider.getRepositoryURL(workingDirectory); 061 062 // verify 063 assertFalse(url.startsWith("file://")); 064 } catch (ScmException e) { 065 } 066 067 // verify 068 verify(logger).info("Executing: cmd.exe /X /C \"svn --non-interactive info .\""); 069 verify(logger).info("Working directory: " + workingDirectory.getCanonicalPath()); 070 } 071}