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.command.export; 020 021import java.io.File; 022 023import org.apache.maven.scm.ScmTestCase; 024import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; 025import org.apache.maven.scm.repository.ScmRepository; 026import org.codehaus.plexus.util.cli.Commandline; 027import org.junit.Test; 028 029public class SvnExportCommandTest extends ScmTestCase { 030 031 @Test 032 public void testGetExportCommandLineWithImplicitExportDirectory() throws Exception { 033 File exportDirectory = new File(getBasedir()); 034 035 testCommandLine( 036 "scm:svn:http://foo.com/svn/trunk", 037 exportDirectory, 038 null, 039 "svn --non-interactive export --force http://foo.com/svn/trunk@"); 040 } 041 042 @Test 043 public void testGetExportCommandLineWithExplicitExportDirectory() throws Exception { 044 File exportDirectory = new File(getBasedir()); 045 046 testCommandLine( 047 "scm:svn:http://foo.com/svn/trunk", 048 exportDirectory, 049 exportDirectory, 050 "svn --non-interactive export --force http://foo.com/svn/trunk@ " + exportDirectory + "@"); 051 } 052 053 private void testCommandLine(String scmUrl, File workingDirectory, File exportDirectory, String commandLine) 054 throws Exception { 055 ScmRepository repository = getScmManager().makeScmRepository(scmUrl); 056 057 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); 058 059 Commandline cl = SvnExeExportCommand.createCommandLine( 060 svnRepository, 061 exportDirectory, 062 null, 063 svnRepository.getUrl(), 064 exportDirectory != null ? exportDirectory.getAbsolutePath() : null); 065 066 assertCommandLine(commandLine, exportDirectory, cl); 067 } 068}