View Javadoc

1   package org.apache.maven.scm.provider.cvslib;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import junit.framework.Assert;
23  import org.apache.maven.scm.ScmTestCase;
24  import org.codehaus.plexus.PlexusTestCase;
25  import org.codehaus.plexus.util.FileUtils;
26  
27  import java.io.File;
28  import java.io.IOException;
29  
30  /**
31   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
32   *
33   */
34  public final class CvsScmTestUtils
35  {
36      /** 'cvs' command line */
37      public static final String CVS_COMMAND_LINE = "cvs";
38  
39      private CvsScmTestUtils()
40      {
41      }
42  
43      public static String getScmUrl( File repository, String module )
44      {
45          return "scm:cvs|local|" + repository + "|" + module;
46      }
47  
48      public static void executeCVS( File workingDirectory, String arguments )
49          throws Exception
50      {
51          ScmTestCase.execute( workingDirectory, CVS_COMMAND_LINE, arguments );
52      }
53  
54      public static void initRepo( File repository, File workingDirectory, File assertionDirectory )
55          throws IOException
56      {
57          initRepo( "src/test/repository/", repository, workingDirectory );
58  
59          FileUtils.deleteDirectory( assertionDirectory );
60  
61          Assert.assertTrue( assertionDirectory.mkdirs() );
62      }
63  
64      public static void initRepo( String source, File repository, File workingDirectory )
65          throws IOException
66      {
67          // Copy the repository to target
68          File src = PlexusTestCase.getTestFile( source );
69  
70          FileUtils.deleteDirectory( repository );
71  
72          Assert.assertTrue( repository.mkdirs() );
73  
74          FileUtils.copyDirectoryStructure( src, repository );
75  
76          FileUtils.deleteDirectory( workingDirectory );
77  
78          Assert.assertTrue( workingDirectory.mkdirs() );
79      }
80  }