| 1 | |
package org.apache.maven.scm.provider.cvslib.command.checkout; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 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 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 0 | public class CvsCheckoutCommandTest |
| 38 | |
extends AbstractCvsScmTest |
| 39 | |
{ |
| 40 | |
|
| 41 | |
protected String getModule() |
| 42 | |
{ |
| 43 | 0 | return "test-repo/checkout"; |
| 44 | |
} |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 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 | |
|
| 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 | |
} |