1 package org.apache.maven.scm.provider.git.gitexe.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.ScmFileSet;
23 import org.apache.maven.scm.ScmTestCase;
24 import org.apache.maven.scm.ScmVersion;
25 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
26 import org.apache.maven.scm.repository.ScmRepository;
27 import org.codehaus.plexus.util.FileUtils;
28 import org.codehaus.plexus.util.Os;
29
30 import java.io.File;
31
32
33
34
35
36 public class GitExeCheckOutCommandNoBranchTest
37 extends ScmTestCase
38 {
39 private File workingDirectory;
40
41 private File repo;
42
43 private ScmRepository scmRepository;
44
45 public void setUp()
46 throws Exception
47 {
48 super.setUp();
49
50 workingDirectory = new File( "target/checkin-nobranch" );
51 FileUtils.deleteDirectory( workingDirectory );
52 repo = new File( "src/test/resources/repository_no_branch" );
53
54 scmRepository = getScmManager().makeScmRepository( "scm:git:file:///" + repo.getAbsolutePath() );
55 }
56
57 public void testCheckoutNoBranch()
58 throws Exception
59 {
60 if ( !ScmTestCase.isSystemCmd( "git" ) )
61 {
62 System.out.println( "skip test which git native executable in path" );
63 return;
64 }
65 CheckOutScmResult result = checkoutRepo();
66 assertEquals( 0, result.getCheckedOutFiles().size() );
67 }
68
69 public void testDoubleCheckoutNoBranch()
70 throws Exception
71 {
72 if ( !ScmTestCase.isSystemCmd( "git" ) )
73 {
74 System.out.println( "skip test which git native executable in path" );
75 return;
76 }
77 CheckOutScmResult result = checkoutRepo();
78 assertEquals( 0, result.getCheckedOutFiles().size() );
79 CheckOutScmResult result2 = checkoutRepo();
80 assertEquals( 0, result2.getCheckedOutFiles().size() );
81 }
82
83 protected CheckOutScmResult checkoutRepo()
84 throws Exception
85 {
86 CheckOutScmResult result =
87 getScmManager().checkOut( scmRepository, new ScmFileSet( workingDirectory ), (ScmVersion) null );
88
89 assertResultIsSuccess( result );
90 return result;
91 }
92 }