use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testXrefGeneration.
@Test
void testXrefGeneration() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(false);
Indexer.getInstance().prepareIndexer(env, true, true, false, null, null);
Indexer.getInstance().doIndexerExecution(true, null, null);
// There should be certain number of xref files produced.
List<String> result = null;
try (Stream<Path> walk = Files.walk(Paths.get(env.getDataRootPath(), IndexDatabase.XREF_DIR))) {
result = walk.filter(Files::isRegularFile).filter(f -> f.toString().endsWith(".gz")).map(Path::toString).collect(Collectors.toList());
}
assertNotNull(result);
assertTrue(result.size() > 50);
// Some files would have empty xref so the file should not be present.
assertFalse(Paths.get(env.getDataRootPath(), IndexDatabase.XREF_DIR, "data", "Logo.png", ".gz").toFile().exists());
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testDefaultProjectsSingleProject.
/**
* Should include the existing project.
* @throws Exception
*/
@Test
void testDefaultProjectsSingleProject() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(false);
Indexer.getInstance().prepareIndexer(env, true, true, false, null, null);
env.setDefaultProjectsFromNames(new TreeSet<>(Collections.singletonList("/c")));
assertEquals(1, env.getDefaultProjects().size());
assertEquals(new TreeSet<>(Collections.singletonList("c")), env.getDefaultProjects().stream().map(Project::getName).collect(Collectors.toSet()));
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testBug11896.
/**
* Test that named pipes are not indexed.
* @throws Exception
*/
@Test
@EnabledIf("mkfifoInPath")
void testBug11896() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
Executor executor;
executor = new Executor(new String[] { "mkdir", "-p", repository.getSourceRoot() + "/testBug11896" });
executor.exec(true);
executor = new Executor(new String[] { "mkfifo", repository.getSourceRoot() + "/testBug11896/FIFO" });
executor.exec(true);
Project project = new Project("testBug11896");
project.setPath("/testBug11896");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
System.out.println("Trying to index a special file - FIFO in this case.");
idb.update();
assertEquals(0, listener.files.size());
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method setUpClass.
@BeforeAll
public static void setUpClass() {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
RepositoryFactory.initializeIgnoredNames(env);
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testBug3430.
@Test
void testBug3430() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
Project project = new Project("bug3430");
project.setPath("/bug3430");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(1, listener.files.size());
}
Aggregations