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
29 import java.io.File;
30
31
32
33
34
35 public class GitExeCheckOutCommandNoBranchTest
36 extends ScmTestCase
37 {
38 private File workingDirectory;
39
40 private File repo;
41
42 private ScmRepository scmRepository;
43
44 public void setUp()
45 throws Exception
46 {
47 super.setUp();
48
49 workingDirectory = new File( "target/checkin-nobranch" );
50 FileUtils.deleteDirectory( workingDirectory );
51 repo = new File( "src/test/resources/repository_no_branch" );
52
53 scmRepository = getScmManager().makeScmRepository( "scm:git:" +
54 repo.toPath().toAbsolutePath().toUri().toASCIIString() );
55 }
56
57 public void testCheckoutNoBranch()
58 throws Exception
59 {
60 if ( !ScmTestCase.isSystemCmd( "git" ) )
61 {
62 ScmTestCase.printSystemCmdUnavail( "git", getName() );
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 ScmTestCase.printSystemCmdUnavail( "git", getName() );
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 }