use of org.opengrok.indexer.web.PathDescription 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);
}
Aggregations