Search in sources :

Example 21 with MuleEventSpy

use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.

the class AbstractInboundPropertyTestcase method spyMessage.

/**
 * Create spy to assert the inbound property
 * @param propertyName name of the property to inspect
 * @throws Exception
 */
private MuleEventSpy spyMessage() throws Exception {
    MuleEventSpy spy = new MuleEventSpy(getPropertyName(), getPropertyName(), getReplacementValue());
    spy.clear();
    return spy;
}
Also used : MuleEventSpy(nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy)

Example 22 with MuleEventSpy

use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.

the class AbstractInboundPropertyTestcase method testInbound.

/**
 * Test inbound property
 * @throws Exception
 */
@Test(timeout = 20000L)
public void testInbound() throws Exception {
    MuleEventSpy spy = spyMessage();
    Request request = new Request(requestCode);
    // set URI explicitly otherwise uri-options could get overwritten
    request.setURI(client.getURI());
    if (unintendedPayload)
        request.setUnintendedPayload();
    addOption(request.setPayload("<nothing_important/>").getOptions());
    client.setTimeout(20000L);
    CoapResponse response = client.advanced(request);
    assertNotNull("no response", response);
    assertTrue("response indicates failure", response.isSuccess());
    assertSpy(spy, getExpectedPropertyValue());
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) Request(org.eclipse.californium.core.coap.Request) MuleEventSpy(nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy) Test(org.junit.Test)

Example 23 with MuleEventSpy

use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.

the class PayloadTest method testOutboundRequest.

@Test(timeout = 20000L)
public void testOutboundRequest() throws URISyntaxException, ConnectorException, IOException {
    // mockResponseMessage();
    MuleEventSpy spy = new MuleEventSpy(spyId, null, Data.getContent(contentSize));
    spy.clear();
    Request request = new Request(requestCode);
    if (unintendedPayload)
        request.setUnintendedPayload();
    request.setPayload("nothing important");
    CoapResponse response = client.advanced(request);
    validateOutboundResponse(response, spy);
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) Request(org.eclipse.californium.core.coap.Request) MuleEventSpy(nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy) Test(org.junit.Test)

Example 24 with MuleEventSpy

use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.

the class PayloadTest method testInboundRequestEarlyNegotiation.

@Test(timeout = 20000L)
public void testInboundRequestEarlyNegotiation() throws Exception {
    // spyRequestMessage();
    MuleEventSpy spy = new MuleEventSpy(spyId);
    spy.clear();
    client.useEarlyNegotiation(32);
    Request request = new Request(requestCode);
    if (unintendedPayload)
        request.setUnintendedPayload();
    request.setPayload(Data.getContent(contentSize));
    CoapResponse response = client.advanced(request);
    validateInboundResponse(response, spy);
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) Request(org.eclipse.californium.core.coap.Request) MuleEventSpy(nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy) Test(org.junit.Test)

Example 25 with MuleEventSpy

use of nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy in project mule-coap-connector by teslanet-nl.

the class PayloadTest method testInboundRequest.

@Test(timeout = 20000L)
public void testInboundRequest() throws Exception {
    // spyRequestMessage();
    MuleEventSpy spy = new MuleEventSpy(spyId);
    spy.clear();
    // spyActivated.set( false );
    client.useLateNegotiation();
    Request request = new Request(requestCode);
    if (unintendedPayload)
        request.setUnintendedPayload();
    request.setPayload(Data.getContent(contentSize));
    CoapResponse response = client.advanced(request);
    validateInboundResponse(response, spy);
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) Request(org.eclipse.californium.core.coap.Request) MuleEventSpy(nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy) Test(org.junit.Test)

Aggregations

MuleEventSpy (nl.teslanet.mule.connectors.coap.test.utils.MuleEventSpy)50 Test (org.junit.Test)46 Message (org.mule.runtime.api.message.Message)30 CoAPResponseAttributes (nl.teslanet.mule.connectors.coap.api.CoAPResponseAttributes)29 Event (org.mule.runtime.api.event.Event)24 Request (org.eclipse.californium.core.coap.Request)13 CoapResponse (org.eclipse.californium.core.CoapResponse)12 LinkedList (java.util.LinkedList)10 AbstractQueryParam (nl.teslanet.mule.connectors.coap.api.query.AbstractQueryParam)10 QueryParam (nl.teslanet.mule.connectors.coap.api.query.QueryParam)10 Code (org.eclipse.californium.core.coap.CoAP.Code)6 CursorStreamProvider (org.mule.runtime.api.streaming.bytes.CursorStreamProvider)5 CoapClient (org.eclipse.californium.core.CoapClient)4 SocketException (java.net.SocketException)3 OptionSet (org.eclipse.californium.core.coap.OptionSet)3 ResponseException (nl.teslanet.mule.connectors.coap.api.error.ResponseException)2 ConditionTimeoutException (org.awaitility.core.ConditionTimeoutException)2 Instant (java.time.Instant)1 CoAPRequestAttributes (nl.teslanet.mule.connectors.coap.api.CoAPRequestAttributes)1 ClientErrorResponseException (nl.teslanet.mule.connectors.coap.api.error.ClientErrorResponseException)1