Search in sources :

Example 1 with PathDescription

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);
}
Also used : Path(java.nio.file.Path) Response(jakarta.ws.rs.core.Response) PathDescription(org.opengrok.indexer.web.PathDescription) EftarFileReader(org.opengrok.indexer.web.EftarFileReader) Test(org.junit.jupiter.api.Test)

Aggregations

Response (jakarta.ws.rs.core.Response)1 Path (java.nio.file.Path)1 Test (org.junit.jupiter.api.Test)1 EftarFileReader (org.opengrok.indexer.web.EftarFileReader)1 PathDescription (org.opengrok.indexer.web.PathDescription)1