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 public abstract class ListCommandTckTest extends ScmTckTestCase {
42 @Test
43 public void testListCommandTest() throws Exception {
44 ScmFileSet fileSet = new ScmFileSet(new File("."), new File("."));
45
46 List<ScmFile> files = runList(fileSet, false);
47
48 assertEquals("The result of the list command doesn't have all the files in SCM: " + files, 3, files.size());
49 }
50
51 @Test
52 public void testListCommandRecursiveTest() throws Exception {
53 ScmFileSet fileSet = new ScmFileSet(new File("."), new File("."));
54
55 List<ScmFile> files = runList(fileSet, true);
56
57 assertEquals("The result of the list command doesn't have all the files in SCM: " + files, 10, files.size());
58 }
59
60 @Test
61 public void testListCommandUnexistantFileTest() throws Exception {
62 ScmFileSet fileSet = new ScmFileSet(new File("."), new File("/void"));
63
64 ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
65
66 ListScmResult result = provider.list(getScmRepository(), fileSet, false, (ScmVersion) null);
67
68 assertFalse("Found file when shouldn't", result.isSuccess());
69 }
70
71 private List<ScmFile> runList(ScmFileSet fileSet, boolean recursive) throws Exception {
72 ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
73
74 ListScmResult result = provider.list(getScmRepository(), fileSet, recursive, (ScmVersion) null);
75
76 assertTrue(
77 "SCM command failed: " + result.getCommandLine() + " : " + result.getProviderMessage()
78 + (result.getCommandOutput() == null ? "" : ": " + result.getCommandOutput()),
79 result.isSuccess());
80
81 return result.getFiles();
82 }
83 }