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 public class CvsCheckoutCommandTest
38 extends AbstractCvsScmTest
39 {
40
41 protected String getModule()
42 {
43 return "test-repo/checkout";
44 }
45
46
47
48
49 public void testCheckOutWithoutTag()
50 throws Exception
51 {
52 if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
53 {
54 System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
55 + getName() + "." );
56 return;
57 }
58
59 ScmManager scmManager = getScmManager();
60
61 CheckOutScmResult result = scmManager.checkOut( getScmRepository(), getScmFileSet() );
62
63 if ( !result.isSuccess() )
64 {
65 fail( result.getProviderMessage() + "\n" + result.getCommandOutput() + "\n" + result.getCommandLine() );
66 }
67
68 List<ScmFile> files = result.getCheckedOutFiles();
69
70 assertNotNull( files );
71
72 assertEquals( 3, files.size() );
73
74 assertCheckedOutFile( files, 0, "/Foo.java", ScmFileStatus.UPDATED );
75
76 assertCheckedOutFile( files, 1, "/Readme.txt", ScmFileStatus.UPDATED );
77
78 assertCheckedOutFile( files, 2, "/src/java/org/apache/maven/MavenUtils.java", ScmFileStatus.UPDATED );
79 }
80
81
82
83
84 public void testCheckOutWithTag()
85 throws Exception
86 {
87 if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
88 {
89 System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
90 + getName() + "." );
91 return;
92 }
93
94 ScmManager scmManager = getScmManager();
95
96 @SuppressWarnings( "deprecation" )
97 CheckOutScmResult result = scmManager.getProviderByRepository( getScmRepository() ).checkOut(
98 getScmRepository(), getScmFileSet(), "MAVEN_1_0" );
99
100 if ( !result.isSuccess() )
101 {
102 fail( result.getProviderMessage() + "\n" + result.getCommandOutput() );
103 }
104
105 List<ScmFile> files = result.getCheckedOutFiles();
106
107 assertNotNull( files );
108
109 assertEquals( 1, files.size() );
110
111 File mavenUtils =
112 assertCheckedOutFile( files, 0, "/src/java/org/apache/maven/MavenUtils.java", ScmFileStatus.UPDATED );
113
114 assertBetween( 38403, 39511, mavenUtils.length() );
115 }
116
117
118
119
120
121 private File assertCheckedOutFile( List<ScmFile> files, int i, String fileName, ScmFileStatus status )
122 throws Exception
123 {
124 File file = new File( getWorkingDirectory(), fileName );
125
126 assertTrue( file.getAbsolutePath() + " file doesn't exist.", file.exists() );
127
128 ScmFile coFile = files.get( i );
129
130 assertSame( status, coFile.getStatus() );
131
132 assertPath( fileName, coFile.getPath() );
133
134 return file;
135 }
136 }