|
22 | 22 | */
|
23 | 23 | package org.opengrok.indexer.history;
|
24 | 24 |
|
| 25 | +import org.junit.jupiter.api.AfterAll; |
| 26 | +import org.junit.jupiter.api.BeforeAll; |
25 | 27 | import org.junit.jupiter.api.Test;
|
26 | 28 | import org.opengrok.indexer.condition.EnabledForRepository;
|
| 29 | +import org.opengrok.indexer.util.TestRepository; |
27 | 30 |
|
28 | 31 | import java.io.File;
|
29 | 32 | import java.io.IOException;
|
| 33 | +import java.net.URISyntaxException; |
30 | 34 | import java.nio.file.Files;
|
| 35 | +import java.util.Set; |
31 | 36 |
|
32 | 37 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 38 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
33 | 39 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
34 | 40 | import static org.opengrok.indexer.condition.RepositoryInstalled.Type.SCCS;
|
35 | 41 |
|
|
40 | 46 | @EnabledForRepository(SCCS)
|
41 | 47 | class SCCSRepositoryTest {
|
42 | 48 |
|
| 49 | + private static TestRepository repository; |
| 50 | + |
| 51 | + @BeforeAll |
| 52 | + public static void setup() throws IOException, URISyntaxException { |
| 53 | + repository = new TestRepository(); |
| 54 | + repository.create(SCCSRepositoryTest.class.getResource("/repositories")); |
| 55 | + } |
| 56 | + |
| 57 | + @AfterAll |
| 58 | + public static void tearDown() { |
| 59 | + if (repository != null) { |
| 60 | + repository.destroy(); |
| 61 | + repository = null; |
| 62 | + } |
| 63 | + } |
| 64 | + |
43 | 65 | /**
|
44 |
| - * Test of isRepositoryFor method, of class SCCSRepository. |
| 66 | + * Test of {@link SCCSRepository#isRepositoryFor(File)}. |
45 | 67 | */
|
46 | 68 | private void testIsRepositoryFor(final String fileName, boolean shouldPass) throws IOException {
|
47 | 69 | File tdir = Files.createTempDirectory("SCCSrepotest" + fileName).toFile();
|
@@ -72,4 +94,21 @@ void testIsRepositoryForCodemgr3() throws IOException {
|
72 | 94 | void testIsRepositoryForCodemgrNot() throws IOException {
|
73 | 95 | testIsRepositoryFor("NOT", false);
|
74 | 96 | }
|
| 97 | + |
| 98 | + /** |
| 99 | + * Test of {@link SCCSRepository#annotate(File, String)}. |
| 100 | + */ |
| 101 | + @Test |
| 102 | + 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 | + File file = new File(repositoryRoot, "main.c"); |
| 108 | + assertTrue(file.isFile()); |
| 109 | + Annotation annotation = sccsRepository.annotate(file, null); |
| 110 | + assertNotNull(annotation); |
| 111 | + Set<String> revSet = Set.of("1.2", "1.1"); |
| 112 | + assertEquals(revSet, annotation.getRevisions()); |
| 113 | + } |
75 | 114 | }
|
0 commit comments