Search in sources :

Example 1 with DiscoveredResource

use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.

the class DiscoveryTest method testWellKnownCore.

@Test
public void testWellKnownCore() throws Exception {
    String flowName = "discover";
    Event result = flowRunner(flowName).withPayload("nothing_important").run();
    Message response = result.getMessage();
    @SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
    assertEquals("wrong number of weblinks", 8, links.size());
    DiscoveredResource link = links.get("/.well-known/core");
    assertNotNull("/.well-known/core is missing", link);
}
Also used : DiscoveredResource(nl.teslanet.mule.connectors.coap.api.DiscoveredResource) Message(org.mule.runtime.api.message.Message) Event(org.mule.runtime.api.event.Event) Test(org.junit.Test)

Example 2 with DiscoveredResource

use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.

the class DiscoveryTest method testObs.

@Test
public void testObs() throws Exception {
    String flowName = "discover";
    Event result = flowRunner(flowName).withPayload("nothing_important").run();
    Message response = result.getMessage();
    @SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
    DiscoveredResource link = links.get("/service/resource_with_obs");
    assertNotNull("/service/resource_with_obs is missing", link);
    assertTrue("obs not true", link.isObs());
    // check other attributes are not there
    assertEquals("ct length unexpected", 0, link.getCt().size());
    assertEquals("if length unexpected", 0, link.getIf().size());
    assertEquals("rt length unexpected", 0, link.getRt().size());
    assertEquals("sz unexpected", "", link.getSz());
    assertNull("title unexpected", link.getTitle());
}
Also used : DiscoveredResource(nl.teslanet.mule.connectors.coap.api.DiscoveredResource) Message(org.mule.runtime.api.message.Message) Event(org.mule.runtime.api.event.Event) Test(org.junit.Test)

Example 3 with DiscoveredResource

use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.

the class DiscoveryTest method testIf.

@Test
public void testIf() throws Exception {
    String flowName = "discover";
    Event result = flowRunner(flowName).withPayload("nothing_important").run();
    Message response = result.getMessage();
    @SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
    DiscoveredResource link = links.get("/service/resource_with_if");
    assertNotNull("/service/resource_with_if is missing", link);
    assertEquals("wrong number of ifdesc", 2, link.getIf().size());
    assertEquals("ifdesc does not contain 0", "if1", link.getIf().get(0));
    assertEquals("ifdesc does not contain 41", "if2", link.getIf().get(1));
    // check other attributes are not there
    assertEquals("ct length unexpected", 0, link.getCt().size());
    assertFalse("obs unexpected", link.isObs());
    assertEquals("rt length unexpected", 0, link.getRt().size());
    assertEquals("sz unexpected", "", link.getSz());
    assertNull("title unexpected", link.getTitle());
}
Also used : DiscoveredResource(nl.teslanet.mule.connectors.coap.api.DiscoveredResource) Message(org.mule.runtime.api.message.Message) Event(org.mule.runtime.api.event.Event) Test(org.junit.Test)

Example 4 with DiscoveredResource

use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.

the class DiscoveryTest method testRt.

@Test
public void testRt() throws Exception {
    String flowName = "discover";
    Event result = flowRunner(flowName).withPayload("nothing_important").run();
    Message response = result.getMessage();
    @SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
    DiscoveredResource link = links.get("/service/resource_with_rt");
    assertNotNull("/service/resource_with_rt is missing", link);
    assertEquals("wrong number of rt", 2, link.getRt().size());
    assertEquals("rt does not contain rt1", "rt1", link.getRt().get(0));
    assertEquals("rt does not contain rt2", "rt2", link.getRt().get(1));
    // check other attributes are not there
    assertEquals("ct length unexpected", 0, link.getCt().size());
    assertEquals("if length unexpected", 0, link.getIf().size());
    assertFalse("obs unexpected", link.isObs());
    assertEquals("sz unexpected", "", link.getSz());
    assertNull("title unexpected", link.getTitle());
}
Also used : DiscoveredResource(nl.teslanet.mule.connectors.coap.api.DiscoveredResource) Message(org.mule.runtime.api.message.Message) Event(org.mule.runtime.api.event.Event) Test(org.junit.Test)

Example 5 with DiscoveredResource

use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.

the class DiscoveryTest method testSz.

@Test
public void testSz() throws Exception {
    String flowName = "discover";
    Event result = flowRunner(flowName).withPayload("nothing_important").run();
    Message response = result.getMessage();
    @SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
    DiscoveredResource link = links.get("/service/resource_with_sz");
    assertNotNull("/service/resource_with_sz is missing", link);
    assertEquals("sz has wrong value", "123456", link.getSz());
    // check other attributes are not there
    assertEquals("ct length unexpected", 0, link.getCt().size());
    assertEquals("if length unexpected", 0, link.getIf().size());
    assertFalse("obs unexpected", link.isObs());
    assertEquals("rt length unexpected", 0, link.getRt().size());
    assertNull("title unexpected", link.getTitle());
}
Also used : DiscoveredResource(nl.teslanet.mule.connectors.coap.api.DiscoveredResource) Message(org.mule.runtime.api.message.Message) Event(org.mule.runtime.api.event.Event) Test(org.junit.Test)

Aggregations

DiscoveredResource (nl.teslanet.mule.connectors.coap.api.DiscoveredResource)19 Test (org.junit.Test)18 Event (org.mule.runtime.api.event.Event)8 Message (org.mule.runtime.api.message.Message)8 IOException (java.io.IOException)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 CoAPResponseAttributes (nl.teslanet.mule.connectors.coap.api.CoAPResponseAttributes)1 ClientErrorResponseException (nl.teslanet.mule.connectors.coap.api.error.ClientErrorResponseException)1 EndpointException (nl.teslanet.mule.connectors.coap.api.error.EndpointException)1 InvalidRequestCodeException (nl.teslanet.mule.connectors.coap.api.error.InvalidRequestCodeException)1 NoResponseException (nl.teslanet.mule.connectors.coap.api.error.NoResponseException)1 RequestException (nl.teslanet.mule.connectors.coap.api.error.RequestException)1 ResponseException (nl.teslanet.mule.connectors.coap.api.error.ResponseException)1 ServerErrorResponseException (nl.teslanet.mule.connectors.coap.api.error.ServerErrorResponseException)1 UriException (nl.teslanet.mule.connectors.coap.api.error.UriException)1 InternalClientErrorResponseException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalClientErrorResponseException)1 InternalEndpointException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalEndpointException)1 InternalInvalidRequestCodeException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidRequestCodeException)1 InternalInvalidResponseCodeException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidResponseCodeException)1