|
32 | 32 | import java.io.IOException;
|
33 | 33 | import java.net.URISyntaxException;
|
34 | 34 | import java.nio.file.Files;
|
| 35 | +import java.nio.file.Paths; |
| 36 | +import java.util.Date; |
| 37 | +import java.util.List; |
35 | 38 | import java.util.Set;
|
36 | 39 |
|
37 | 40 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 41 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
38 | 42 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
39 | 43 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
40 | 44 | import static org.opengrok.indexer.condition.RepositoryInstalled.Type.SCCS;
|
|
47 | 51 | class SCCSRepositoryTest {
|
48 | 52 |
|
49 | 53 | private static TestRepository repository;
|
| 54 | + private static SCCSRepository sccsRepository; |
| 55 | + private static File repositoryRoot; |
50 | 56 |
|
51 | 57 | @BeforeAll
|
52 |
| - public static void setup() throws IOException, URISyntaxException { |
| 58 | + public static void setup() throws Exception { |
53 | 59 | repository = new TestRepository();
|
54 | 60 | repository.create(SCCSRepositoryTest.class.getResource("/repositories"));
|
| 61 | + |
| 62 | + repositoryRoot = new File(repository.getSourceRoot(), "teamware"); |
| 63 | + assertTrue(repositoryRoot.isDirectory()); |
| 64 | + sccsRepository = (SCCSRepository) RepositoryFactory.getRepository(repositoryRoot); |
| 65 | + assertNotNull(sccsRepository); |
55 | 66 | }
|
56 | 67 |
|
57 | 68 | @AfterAll
|
@@ -100,15 +111,34 @@ void testIsRepositoryForCodemgrNot() throws IOException {
|
100 | 111 | */
|
101 | 112 | @Test
|
102 | 113 | void testAnnotation() throws Exception {
|
103 |
| - File repositoryRoot = new File(repository.getSourceRoot(), "teamware"); |
104 |
| - assertTrue(repositoryRoot.isDirectory()); |
105 |
| - SCCSRepository sccsRepository = (SCCSRepository) RepositoryFactory.getRepository(repositoryRoot); |
106 |
| - assertNotNull(sccsRepository); |
107 | 114 | File file = new File(repositoryRoot, "main.c");
|
108 | 115 | assertTrue(file.isFile());
|
109 | 116 | Annotation annotation = sccsRepository.annotate(file, null);
|
110 | 117 | assertNotNull(annotation);
|
111 | 118 | Set<String> revSet = Set.of("1.2", "1.1");
|
112 | 119 | assertEquals(revSet, annotation.getRevisions());
|
113 | 120 | }
|
| 121 | + |
| 122 | + @Test |
| 123 | + void testHasHistoryForDirectories() { |
| 124 | + assertFalse(sccsRepository.hasHistoryForDirectories()); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Test of {@link SCCSRepository#getHistory(File)}. |
| 129 | + */ |
| 130 | + @Test |
| 131 | + void testGetHistory() throws Exception { |
| 132 | + File file = new File(repositoryRoot, "main.c"); |
| 133 | + assertTrue(file.isFile()); |
| 134 | + History history = sccsRepository.getHistory(file); |
| 135 | + assertNotNull(history); |
| 136 | + List<HistoryEntry> entries = List.of( |
| 137 | + new HistoryEntry("1.2", new Date(1218492000000L), |
| 138 | + "trond", "Fixed lint warnings\n", true), |
| 139 | + new HistoryEntry("1.1", new Date(1218492000000L), |
| 140 | + "trond", "date and time created 08/08/12 22:09:23 by trond\n\n", true)); |
| 141 | + History expectedHistory = new History(entries); |
| 142 | + assertEquals(expectedHistory, history); |
| 143 | + } |
114 | 144 | }
|
0 commit comments