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.command.export;
20  
21  import java.io.File;
22  
23  import org.apache.maven.scm.ScmTestCase;
24  import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
25  import org.apache.maven.scm.repository.ScmRepository;
26  import org.codehaus.plexus.util.cli.Commandline;
27  import org.junit.Test;
28  
29  public class SvnExportCommandTest extends ScmTestCase {
30  
31      @Test
32      public void testGetExportCommandLineWithImplicitExportDirectory() throws Exception {
33          File exportDirectory = new File(getBasedir());
34  
35          testCommandLine(
36                  "scm:svn:http://foo.com/svn/trunk",
37                  exportDirectory,
38                  null,
39                  "svn --non-interactive export --force http://foo.com/svn/trunk@");
40      }
41  
42      @Test
43      public void testGetExportCommandLineWithExplicitExportDirectory() throws Exception {
44          File exportDirectory = new File(getBasedir());
45  
46          testCommandLine(
47                  "scm:svn:http://foo.com/svn/trunk",
48                  exportDirectory,
49                  exportDirectory,
50                  "svn --non-interactive export --force http://foo.com/svn/trunk@ " + exportDirectory + "@");
51      }
52  
53      private void testCommandLine(String scmUrl, File workingDirectory, File exportDirectory, String commandLine)
54              throws Exception {
55          ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
56  
57          SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
58  
59          Commandline cl = SvnExeExportCommand.createCommandLine(
60                  svnRepository,
61                  exportDirectory,
62                  null,
63                  svnRepository.getUrl(),
64                  exportDirectory != null ? exportDirectory.getAbsolutePath() : null);
65  
66          assertCommandLine(commandLine, exportDirectory, cl);
67      }
68  }