Search in sources :

Example 6 with RestSchemaClient

use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.

the class ProtobufResourceTest method putAndGetWrongProtobuf.

@Test
public void putAndGetWrongProtobuf() throws Exception {
    RestSchemaClient schemaClient = client.schemas();
    String errorProto = getResourceAsString("error.proto", getClass().getClassLoader());
    RestResponse response = join(schemaClient.post("error", errorProto));
    String cause = "java.lang.IllegalStateException:" + " Syntax error in error.proto at 3:8: unexpected label: messoge";
    ResponseAssertion.assertThat(response).isOk();
    Json jsonNode = Json.read(response.getBody());
    assertEquals("error.proto", jsonNode.at("name").asString());
    assertEquals("Schema error.proto has errors", jsonNode.at("error").at("message").asString());
    assertEquals(cause, jsonNode.at("error").at("cause").asString());
    // Read adding .proto should also work
    response = join(schemaClient.get("error"));
    ResponseAssertion.assertThat(response).isOk();
    ResponseAssertion.assertThat(response).hasContentEqualToFile("error.proto");
    checkListProtobufEndpointUrl("error.proto", cause);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Json(org.infinispan.commons.dataconversion.internal.Json) RestSchemaClient(org.infinispan.client.rest.RestSchemaClient) Test(org.testng.annotations.Test)

Example 7 with RestSchemaClient

use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.

the class ProtobufResourceTest method createTwiceSchema.

@Test
public void createTwiceSchema() throws Exception {
    RestSchemaClient schemaClient = client.schemas();
    String personProto = getResourceAsString("person.proto", getClass().getClassLoader());
    CompletionStage<RestResponse> response = schemaClient.post("person", personProto);
    ResponseAssertion.assertThat(response).isOk();
    response = schemaClient.post("person", personProto);
    ResponseAssertion.assertThat(response).isConflicted();
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) RestSchemaClient(org.infinispan.client.rest.RestSchemaClient) Test(org.testng.annotations.Test)

Aggregations

RestResponse (org.infinispan.client.rest.RestResponse)7 RestSchemaClient (org.infinispan.client.rest.RestSchemaClient)7 Json (org.infinispan.commons.dataconversion.internal.Json)4 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)4 Test (org.testng.annotations.Test)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1