|
27 | 27 | import static org.junit.Assert.assertEquals;
|
28 | 28 | import static org.junit.Assert.assertFalse;
|
29 | 29 | import static org.junit.Assert.assertNotNull;
|
| 30 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
30 | 31 |
|
31 | 32 | import java.io.BufferedWriter;
|
32 | 33 | import java.io.File;
|
33 | 34 | import java.io.FileReader;
|
34 | 35 | import java.io.FileWriter;
|
35 | 36 | import java.io.IOException;
|
36 | 37 | import java.io.StringWriter;
|
| 38 | +import java.nio.file.Files; |
| 39 | +import java.nio.file.Path; |
37 | 40 | import java.nio.file.Paths;
|
38 | 41 | import java.util.ArrayList;
|
39 | 42 | import java.util.Arrays;
|
|
46 | 49 | import java.util.TreeSet;
|
47 | 50 | import java.util.concurrent.ConcurrentLinkedQueue;
|
48 | 51 | import java.util.stream.Collectors;
|
| 52 | +import java.util.stream.Stream; |
49 | 53 |
|
50 | 54 | import org.junit.After;
|
51 | 55 | import org.junit.Assert;
|
@@ -97,21 +101,28 @@ public void tearDown() {
|
97 | 101 | repository.destroy();
|
98 | 102 | }
|
99 | 103 |
|
100 |
| - /** |
101 |
| - * Test of doIndexerExecution method, of class Indexer. |
102 |
| - * @throws java.lang.Exception |
103 |
| - */ |
104 | 104 | @Test
|
105 |
| - public void testIndexGeneration() throws Exception { |
106 |
| - System.out.println("Generating index by using the class methods"); |
| 105 | + public void testXrefGeneration() throws Exception { |
107 | 106 | RuntimeEnvironment env = RuntimeEnvironment.getInstance();
|
108 | 107 | env.setSourceRoot(repository.getSourceRoot());
|
109 | 108 | env.setDataRoot(repository.getDataRoot());
|
110 | 109 | env.setHistoryEnabled(false);
|
111 | 110 | Indexer.getInstance().prepareIndexer(env, true, true,
|
112 | 111 | false, null, null);
|
113 |
| - env.setDefaultProjectsFromNames(new TreeSet<>(Collections.singletonList("/c"))); |
114 | 112 | Indexer.getInstance().doIndexerExecution(true, null, null);
|
| 113 | + |
| 114 | + // There should be certain number of xref files produced. |
| 115 | + List<String> result = null; |
| 116 | + try (Stream<Path> walk = Files.walk(Paths.get(env.getDataRootPath(), IndexDatabase.XREF_DIR))) { |
| 117 | + result = walk.filter(Files::isRegularFile).filter(f -> f.toString().endsWith(".gz")). |
| 118 | + map(x -> x.toString()).collect(Collectors.toList()); |
| 119 | + } |
| 120 | + assertNotNull(result); |
| 121 | + assertTrue(result.size() > 50); |
| 122 | + |
| 123 | + // Some files would have empty xref so the file should not be present. |
| 124 | + assertFalse(Paths.get(env.getDataRootPath(), IndexDatabase.XREF_DIR, "data", "Logo.png", ".gz"). |
| 125 | + toFile().exists()); |
115 | 126 | }
|
116 | 127 |
|
117 | 128 | /**
|
|
0 commit comments