use of org.eclipse.californium.core.coap.CoAP.Code in project californium by eclipse.
the class MappingProperties method initCoapMethod.
/**
* Initialize {@link #coapCodes} from raw property.
*
* @param key key for entry to load
*/
protected void initCoapMethod(String key) {
String httpMethod = getString(key);
String tag = getTag(KEY_COAP_METHOD, key);
Code code = Code.valueOfText(tag);
if (code != null && httpMethod != null) {
coapCodes.put(code, httpMethod);
}
}
use of org.eclipse.californium.core.coap.CoAP.Code in project mule-coap-connector by teslanet-nl.
the class AbstractSecureClientTestCase method testInbound.
@Test(timeout = 60000L)
public void testInbound() throws Exception {
expectException();
MuleEventSpy spy = spyMessage();
String payload = "test-payload";
for (Code call : inboundCalls) {
spy.clear();
client.useLateNegotiation();
Request request = new Request(call);
request.setURI(uri.resolve(getPath(call)));
switch(call) {
case DELETE:
case GET:
request.setUnintendedPayload();
break;
default:
break;
}
request.setPayload(payload);
CoapResponse response = client.advanced(request);
assertNotNull("get gave no response", response);
assertTrue("response indicates failure: " + response.getCode() + " msg: " + response.getResponseText(), response.isSuccess());
assertEquals("Spy has collected wrong number of events", 1, spy.getEvents().size());
assertEquals("payload has wrong class", payload.getBytes().getClass(), spy.getEvents().get(0).getContent().getClass());
assertArrayEquals("property has wrong value", payload.getBytes(), (byte[]) spy.getEvents().get(0).getContent());
client.shutdown();
}
}
use of org.eclipse.californium.core.coap.CoAP.Code in project mule-coap-connector by teslanet-nl.
the class AbstractSecureClientTestCase method setUpClass.
@BeforeClass
public static void setUpClass() throws Exception {
inboundCalls = new ArrayList<Code>();
inboundCalls.add(Code.GET);
inboundCalls.add(Code.PUT);
inboundCalls.add(Code.POST);
inboundCalls.add(Code.DELETE);
outboundCalls = new ArrayList<Code>();
outboundCalls.add(Code.GET);
outboundCalls.add(Code.PUT);
outboundCalls.add(Code.POST);
outboundCalls.add(Code.DELETE);
paths = new HashMap<Code, String>();
paths.put(Code.GET, "/service/get_me");
paths.put(Code.PUT, "/service/put_me");
paths.put(Code.POST, "/service/post_me");
paths.put(Code.DELETE, "/service/delete_me");
uri = new URI("coaps", "127.0.0.1", null, null, null);
}
use of org.eclipse.californium.core.coap.CoAP.Code in project mule-coap-connector by teslanet-nl.
the class InsecureClientTest method testInsecureClientGet.
@Test(timeout = 15000)
public void testInsecureClientGet() throws Exception {
MuleEventSpy spy = spyMessage();
Code call = Code.GET;
CoapClient client = getClient(getPath(call));
Request request = new Request(call);
CoapResponse response = client.advanced(request);
assertNull("should not receive a response", response);
assertSpy(spy);
client.shutdown();
}
use of org.eclipse.californium.core.coap.CoAP.Code in project mule-coap-connector by teslanet-nl.
the class InsecureClientTest method testInsecureClientPut.
@Test()
public void testInsecureClientPut() throws Exception {
MuleEventSpy spy = spyMessage();
Code call = Code.PUT;
CoapClient client = getClient(getPath(call));
Request request = new Request(call);
request.setPayload("nothing important");
CoapResponse response = client.advanced(request);
assertNull("should not receive a response", response);
assertSpy(spy);
client.shutdown();
}
Aggregations