use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy 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 nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy 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 nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy 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();
}
use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.
the class InsecureClientTest method spyMessage.
/**
* Create spy for requests with a message replacement
* @return the spy
*/
private MuleEventSpy spyMessage(byte[] replacement) {
MuleEventSpy spy = new MuleEventSpy("securityTest", null, replacement);
spy.clear();
return spy;
}
use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.
the class InsecureClientTest method testInsecureClientPost.
@Test(timeout = 15000)
public void testInsecureClientPost() throws Exception {
MuleEventSpy spy = spyMessage();
Code call = Code.POST;
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