use of org.opengrok.indexer.web.EftarFileReader in project OpenGrok by OpenGrok.
the class SystemControllerTest method testDtagsEftarReload.
@Test
public void testDtagsEftarReload() throws IOException {
// The output file will be located in a directory under data root so create it first.
Path dataRoot = Files.createTempDirectory("api_dtags_test");
env.setDataRoot(dataRoot.toString());
Paths.get(dataRoot.toString(), "index").toFile().mkdir();
// Create path descriptions string.
StringBuilder sb = new StringBuilder();
PathDescription[] descriptions = { new PathDescription("/path1", "foo foo"), new PathDescription("/path2", "bar bar") };
// Reload the contents via API call.
Response r = target("system").path("pathdesc").request().post(Entity.json(descriptions));
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), r.getStatus());
// Check
Path eftarPath = env.getDtagsEftarPath();
assertTrue(eftarPath.toFile().exists());
try (EftarFileReader er = new EftarFileReader(eftarPath.toString())) {
for (PathDescription description : descriptions) {
assertEquals(description.getDescription(), er.get(description.getPath()));
}
}
// Cleanup
IOUtils.removeRecursive(dataRoot);
}
use of org.opengrok.indexer.web.EftarFileReader in project OpenGrok by OpenGrok.
the class DirectoryListingTest method directoryListingWithEftarException.
@Test
public void directoryListingWithEftarException() throws IOException, HistoryException {
EftarFileReader mockReader = mock(EftarFileReader.class);
when(mockReader.getNode(anyString())).thenThrow(IOException.class);
DirectoryListing instance = new DirectoryListing(mockReader);
File file = new File(directory, "foo");
StringWriter mockWriter = spy(StringWriter.class);
instance.extraListTo("ctx", directory, mockWriter, directory.getPath(), Collections.singletonList(new DirectoryEntry(file)));
verify(mockWriter, atLeast(20)).write(anyString());
}
Aggregations