log.info("-----REST-----");
repositoryService.setCurrentRepositoryName("db1");
DummyContainerResponseWriter wr = new DummyContainerResponseWriter();
URI reqUri = new URI(baseUri.toString() + "/registry/");
ContainerResponse cres =
request(handler, wr, "GET", reqUri, baseUri, null, new InputHeadersMap(new MultivaluedMapImpl()));
assertEquals(200, cres.getStatus());
log.info(new String(wr.getBody()));
// request to exo:services/exo_service
// response status should be 404 (NOT_FOUND)
wr.reset();
reqUri = new URI(baseUri.toString() + "/registry/" + RegistryService.EXO_SERVICES + "/exo_service");
cres = request(handler, wr, "GET", reqUri, baseUri, null, new InputHeadersMap(new MultivaluedMapImpl()));
assertEquals(404, cres.getStatus());
assertNull(wr.getBody());
// create exo:services/exo_service
wr.reset();
reqUri = new URI(baseUri.toString() + "/registry/" + RegistryService.EXO_SERVICES);
cres =
request(handler, wr, "POST", reqUri, baseUri, SERVICE_XML.getBytes(), new InputHeadersMap(
new MultivaluedMapImpl()));
assertEquals(201, cres.getStatus());
assertEquals(new URI(reqUri + "/exo_service"), wr.getHeaders().getFirst(HttpHeaders.LOCATION));
// request to exo:services/exo_service
wr.reset();
reqUri = new URI(baseUri.toString() + "/registry/" + RegistryService.EXO_SERVICES + "/exo_service");
cres = request(handler, wr, "GET", reqUri, baseUri, null, new InputHeadersMap(new MultivaluedMapImpl()));
assertEquals(200, cres.getStatus());
log.info(new String(wr.getBody()));
// recreate exo:services/exo_service
wr.reset();
reqUri = new URI(baseUri.toString() + "/registry/" + RegistryService.EXO_SERVICES);
cres =
request(handler, wr, "PUT", reqUri, baseUri, SERVICE_XML.getBytes(), new InputHeadersMap(
new MultivaluedMapImpl()));
assertEquals(201, cres.getStatus());
assertEquals(new URI(reqUri + "/exo_service"), wr.getHeaders().getFirst(HttpHeaders.LOCATION));
// delete exo:services/exo_service
wr.reset();
reqUri = new URI(baseUri.toString() + "/registry/" + RegistryService.EXO_SERVICES + "/exo_service");
cres = request(handler, wr, "DELETE", reqUri, baseUri, null, new InputHeadersMap(new MultivaluedMapImpl()));
assertEquals(204, cres.getStatus());
// request to exo:services/exo_service
// request status should be 404 (NOT_FOUND)
wr.reset();
reqUri = new URI(baseUri.toString() + "/registry/" + RegistryService.EXO_SERVICES + "/exo_service");
cres = request(handler, wr, "GET", reqUri, baseUri, null, new InputHeadersMap(new MultivaluedMapImpl()));
assertEquals(404, cres.getStatus());
assertNull(wr.getBody());
}