use of org.eclipse.californium.core.CoapResponse in project camel by apache.
the class CoAPRestVerbTest method testGetAll.
@Test
public void testGetAll() throws Exception {
NetworkConfig.createStandardWithoutFile();
CoapClient client = new CoapClient("coap://localhost:" + coapport + "/users");
client.setTimeout(1000000);
CoapResponse rsp = client.get();
assertEquals("[{ \"id\":\"1\", \"name\":\"Scott\" },{ \"id\":\"2\", \"name\":\"Claus\" }]", rsp.getResponseText());
}
use of org.eclipse.californium.core.CoapResponse in project camel by apache.
the class CoAPRestVerbTest method testGetOne.
@Test
public void testGetOne() throws Exception {
NetworkConfig.createStandardWithoutFile();
CoapClient client = new CoapClient("coap://localhost:" + coapport + "/users/1");
client.setTimeout(1000000);
CoapResponse rsp = client.get();
assertEquals("{ \"id\":\"1\", \"name\":\"Scott\" }", rsp.getResponseText());
}
use of org.eclipse.californium.core.CoapResponse in project camel by apache.
the class CoAPRestVerbTest method testPost.
@Test
public void testPost() throws Exception {
NetworkConfig.createStandardWithoutFile();
final String body = "{ \"id\":\"1\", \"name\":\"Scott\" }";
MockEndpoint mock = getMockEndpoint("mock:create");
mock.expectedBodiesReceived(body);
CoapClient client = new CoapClient("coap://localhost:" + coapport + "/users");
client.setTimeout(1000000);
CoapResponse rsp = client.post(body, MediaTypeRegistry.APPLICATION_JSON);
assertMockEndpointsSatisfied();
}
Aggregations