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