|
26 | 26 | import org.junit.jupiter.api.BeforeAll;
|
27 | 27 | import org.junit.jupiter.api.Test;
|
28 | 28 | import org.opengrok.indexer.condition.EnabledForRepository;
|
| 29 | +import org.opengrok.indexer.configuration.CommandTimeoutType; |
29 | 30 | import org.opengrok.indexer.util.TestRepository;
|
30 | 31 |
|
31 | 32 | import java.io.File;
|
32 | 33 | import java.io.IOException;
|
| 34 | +import java.io.PrintWriter; |
33 | 35 | import java.nio.file.Files;
|
34 | 36 | import java.util.Date;
|
35 | 37 | import java.util.List;
|
|
38 | 40 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
39 | 41 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
40 | 42 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
| 43 | +import static org.junit.jupiter.api.Assertions.assertNull; |
41 | 44 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
42 | 45 | import static org.opengrok.indexer.condition.RepositoryInstalled.Type.SCCS;
|
43 | 46 |
|
@@ -139,4 +142,36 @@ void testGetHistory() throws Exception {
|
139 | 142 | History expectedHistory = new History(entries);
|
140 | 143 | assertEquals(expectedHistory, history);
|
141 | 144 | }
|
| 145 | + |
| 146 | + /** |
| 147 | + * Negative test of {@link SCCSRepository#determineParent(CommandTimeoutType)}. |
| 148 | + */ |
| 149 | + @Test |
| 150 | + void testDetermineParentInvalid() throws Exception { |
| 151 | + File codemgrDir = new File(repositoryRoot, SCCSRepository.CODEMGR_WSDATA); |
| 152 | + assertTrue(codemgrDir.mkdirs()); |
| 153 | + File parentFile = new File(codemgrDir, "parent"); |
| 154 | + assertTrue(parentFile.createNewFile()); |
| 155 | + try (PrintWriter out = new PrintWriter(parentFile.toString())) { |
| 156 | + out.println("foo"); |
| 157 | + } |
| 158 | + assertNull(sccsRepository.determineParent(CommandTimeoutType.INDEXER)); |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * Test of {@link SCCSRepository#determineParent(CommandTimeoutType)}. |
| 163 | + */ |
| 164 | + @Test |
| 165 | + void testDetermineParent() throws Exception { |
| 166 | + File codemgrDir = new File(repositoryRoot, SCCSRepository.CODEMGR_WSDATA); |
| 167 | + assertTrue(codemgrDir.mkdirs()); |
| 168 | + File parentFile = new File(codemgrDir, "parent"); |
| 169 | + assertTrue(parentFile.createNewFile()); |
| 170 | + final String expectedParent = "/foo"; |
| 171 | + try (PrintWriter out = new PrintWriter(parentFile.toString())) { |
| 172 | + out.println("VERSION 1"); |
| 173 | + out.println(expectedParent); |
| 174 | + } |
| 175 | + assertEquals(expectedParent, sccsRepository.determineParent(CommandTimeoutType.INDEXER)); |
| 176 | + } |
142 | 177 | }
|
0 commit comments