1 package org.apache.maven.scm.tck.command.list;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.List;
24
25 import org.apache.maven.scm.ScmFile;
26 import org.apache.maven.scm.ScmFileSet;
27 import org.apache.maven.scm.ScmTckTestCase;
28 import org.apache.maven.scm.ScmVersion;
29 import org.apache.maven.scm.command.list.ListScmResult;
30 import org.apache.maven.scm.provider.ScmProvider;
31 import org.junit.Test;
32
33 import static org.junit.Assert.assertEquals;
34 import static org.junit.Assert.assertFalse;
35 import static org.junit.Assert.assertTrue;
36
37
38
39
40
41
42
43 public abstract class ListCommandTckTest
44 extends ScmTckTestCase
45 {
46 @Test
47 public void testListCommandTest()
48 throws Exception
49 {
50 ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) );
51
52 List<ScmFile> files = runList( fileSet, false );
53
54 assertEquals( "The result of the list command doesn't have all the files in SCM: " + files, 3, files.size() );
55 }
56
57 @Test
58 public void testListCommandRecursiveTest()
59 throws Exception
60 {
61 ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) );
62
63 List<ScmFile> files = runList( fileSet, true );
64
65 assertEquals( "The result of the list command doesn't have all the files in SCM: " + files, 10, files.size() );
66 }
67
68 @Test
69 public void testListCommandUnexistantFileTest()
70 throws Exception
71 {
72 ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "/void" ) );
73
74 ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
75
76 ListScmResult result = provider.list( getScmRepository(), fileSet, false, (ScmVersion) null );
77
78 assertFalse( "Found file when shouldn't", result.isSuccess() );
79 }
80
81 private List<ScmFile> runList( ScmFileSet fileSet, boolean recursive )
82 throws Exception
83 {
84 ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
85
86 ListScmResult result = provider.list( getScmRepository(), fileSet, recursive, (ScmVersion) null );
87
88 assertTrue( "SCM command failed: " + result.getCommandLine() + " : " + result.getProviderMessage()
89 + ( result.getCommandOutput() == null ? "" : ": " + result.getCommandOutput() ), result.isSuccess() );
90
91 return result.getFiles();
92 }
93 }