Coverage Report - org.apache.maven.scm.provider.cvslib.command.checkout.CvsCheckoutCommandTest
 
Classes in this File Line Coverage Branch Coverage Complexity
CvsCheckoutCommandTest
0 %
0/35
0 %
0/8
2,5
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.checkout;
 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 org.apache.maven.scm.ScmFile;
 23  
 import org.apache.maven.scm.ScmFileStatus;
 24  
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 25  
 import org.apache.maven.scm.manager.ScmManager;
 26  
 import org.apache.maven.scm.provider.cvslib.AbstractCvsScmTest;
 27  
 import org.apache.maven.scm.provider.cvslib.CvsScmTestUtils;
 28  
 
 29  
 import java.io.File;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
 34  
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
 35  
  * @version $Id: CvsCheckoutCommandTest.java 1057015 2011-01-09 20:10:42Z olamy $
 36  
  */
 37  0
 public class CvsCheckoutCommandTest
 38  
     extends AbstractCvsScmTest
 39  
 {
 40  
     /** {@inheritDoc} */
 41  
     protected String getModule()
 42  
     {
 43  0
         return "test-repo/checkout";
 44  
     }
 45  
 
 46  
     /**
 47  
      * @todo move this test to the TCK.
 48  
      */
 49  
     public void testCheckOutWithoutTag()
 50  
         throws Exception
 51  
     {
 52  0
         if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
 53  
         {
 54  0
             System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
 55  
                 + getName() + "." );
 56  0
             return;
 57  
         }
 58  
 
 59  0
         ScmManager scmManager = getScmManager();
 60  
 
 61  0
         CheckOutScmResult result = scmManager.checkOut( getScmRepository(), getScmFileSet() );
 62  
 
 63  0
         if ( !result.isSuccess() )
 64  
         {
 65  0
             fail( result.getProviderMessage() + "\n" + result.getCommandOutput() + "\n" + result.getCommandLine() );
 66  
         }
 67  
 
 68  0
         List<ScmFile> files = result.getCheckedOutFiles();
 69  
 
 70  0
         assertNotNull( files );
 71  
 
 72  0
         assertEquals( 3, files.size() );
 73  
 
 74  0
         assertCheckedOutFile( files, 0, "/Foo.java", ScmFileStatus.UPDATED );
 75  
 
 76  0
         assertCheckedOutFile( files, 1, "/Readme.txt", ScmFileStatus.UPDATED );
 77  
 
 78  0
         assertCheckedOutFile( files, 2, "/src/java/org/apache/maven/MavenUtils.java", ScmFileStatus.UPDATED );
 79  0
     }
 80  
 
 81  
     /**
 82  
      * @todo move this test to the TCK - checkout with "revision", then have one for tag as well.
 83  
      */
 84  
     public void testCheckOutWithTag()
 85  
         throws Exception
 86  
     {
 87  0
         if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
 88  
         {
 89  0
             System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
 90  
                 + getName() + "." );
 91  0
             return;
 92  
         }
 93  
 
 94  0
         ScmManager scmManager = getScmManager();
 95  
 
 96  
         @SuppressWarnings( "deprecation" )
 97  0
         CheckOutScmResult result = scmManager.getProviderByRepository( getScmRepository() ).checkOut(
 98  
             getScmRepository(), getScmFileSet(), "MAVEN_1_0" );
 99  
 
 100  0
         if ( !result.isSuccess() )
 101  
         {
 102  0
             fail( result.getProviderMessage() + "\n" + result.getCommandOutput() );
 103  
         }
 104  
 
 105  0
         List<ScmFile> files = result.getCheckedOutFiles();
 106  
 
 107  0
         assertNotNull( files );
 108  
 
 109  0
         assertEquals( 1, files.size() );
 110  
 
 111  0
         File mavenUtils =
 112  
             assertCheckedOutFile( files, 0, "/src/java/org/apache/maven/MavenUtils.java", ScmFileStatus.UPDATED );
 113  
 
 114  0
         assertBetween( 38403, 39511, mavenUtils.length() );
 115  0
     }
 116  
 
 117  
     // ----------------------------------------------------------------------
 118  
     //
 119  
     // ----------------------------------------------------------------------
 120  
 
 121  
     private File assertCheckedOutFile( List<ScmFile> files, int i, String fileName, ScmFileStatus status )
 122  
         throws Exception
 123  
     {
 124  0
         File file = new File( getWorkingDirectory(), fileName );
 125  
 
 126  0
         assertTrue( file.getAbsolutePath() + " file doesn't exist.", file.exists() );
 127  
 
 128  0
         ScmFile coFile = files.get( i );
 129  
 
 130  0
         assertSame( status, coFile.getStatus() );
 131  
 
 132  0
         assertPath( fileName, coFile.getPath() );
 133  
 
 134  0
         return file;
 135  
     }
 136  
 }