Package de.uniluebeck.itm.ncoap.communication.dispatching.client

Examples of de.uniluebeck.itm.ncoap.communication.dispatching.client.Token


    @Test
    public void testSameRequests() throws Exception {
        URI targetUri = new URI("coap", null, "localhost", 5683, "/path/to/service", null, null);

        CoapRequest coapRequest1 = new CoapRequest(MessageType.Name.NON, MessageCode.Name.GET, targetUri);
        coapRequest1.setToken(new Token(new byte[0]));
        coapRequest1.setMessageID(12345);

        CoapRequest coapRequest2 = new CoapRequest(MessageType.Name.NON, MessageCode.Name.GET, targetUri);
        coapRequest2.setToken(new Token(new byte[0]));
        coapRequest2.setMessageID(12345);

        Assert.assertEquals(coapRequest1, coapRequest2);
    }
View Full Code Here


        URI targetUri1 = new URI("coap", null, "localhost", 5683, path1, null, null);
        URI targetUri2 = new URI("coap", null, "localhost", 5683, path2, null, null);

        CoapRequest coapRequest1 = new CoapRequest(MessageType.Name.NON, MessageCode.Name.GET, targetUri1);
        coapRequest1.setToken(new Token(new byte[0]));
        coapRequest1.setMessageID(12345);

        CoapRequest coapRequest2 = new CoapRequest(MessageType.Name.NON, MessageCode.Name.GET, targetUri2);
        coapRequest2.setToken(new Token(new byte[0]));
        coapRequest2.setMessageID(12345);

        Assert.assertFalse("Requests with different order of URI path options must not equal!",
                coapRequest1.equals(coapRequest2));
    }
View Full Code Here

    @Test
    public void testResponsesWitDifferentMessageIDs() throws Exception {

        CoapResponse coapResponse1 = new CoapResponse(MessageType.Name.NON, MessageCode.Name.CONTENT_205);
        coapResponse1.setContent("Test123".getBytes(CoapMessage.CHARSET), ContentFormat.TEXT_PLAIN_UTF8);
        coapResponse1.setToken(new Token(new byte[0]));
        coapResponse1.setMessageID(12346);

        CoapResponse coapResponse2 = new CoapResponse(MessageType.Name.NON, MessageCode.Name.CONTENT_205);
        coapResponse2.setContent("Test123".getBytes(CoapMessage.CHARSET), ContentFormat.TEXT_PLAIN_UTF8);
        coapResponse2.setToken(new Token(new byte[0]));
        coapResponse2.setMessageID(12345);

        Assert.assertFalse("Requests with different message IDs must not equal!",
                coapResponse1.equals(coapResponse2));
    }
View Full Code Here

    @Test
    public void testResponsesWitDifferentTokens() throws Exception {

        CoapResponse coapResponse1 = new CoapResponse(MessageType.Name.NON, MessageCode.Name.CONTENT_205);
        coapResponse1.setContent("Test123".getBytes(CoapMessage.CHARSET), ContentFormat.TEXT_PLAIN_UTF8);
        coapResponse1.setToken(new Token(new byte[0]));
        coapResponse1.setMessageID(12345);

        CoapResponse coapResponse2 = new CoapResponse(MessageType.Name.NON, MessageCode.Name.CONTENT_205);
        coapResponse2.setContent("Test123".getBytes(CoapMessage.CHARSET), ContentFormat.TEXT_PLAIN_UTF8);
        coapResponse2.setToken(new Token(new byte[1]));
        coapResponse2.setMessageID(12345);

        Assert.assertFalse("Requests with different tokens must not equal!",
                coapResponse1.equals(coapResponse2));
    }
View Full Code Here

    @Test
    public void testRequestsWithDifferentOrderOfAcceptOptions() throws Exception {
        URI targetUri = new URI("coap", null, "localhost", 5683, "/path/to/service", null, null);

        CoapRequest coapRequest1 = new CoapRequest(MessageType.Name.NON, MessageCode.Name.GET, targetUri);
        coapRequest1.setToken(new Token(new byte[0]));
        coapRequest1.setMessageID(12345);
        coapRequest1.setAccept(ContentFormat.TEXT_PLAIN_UTF8, ContentFormat.APP_XML);

        CoapRequest coapRequest2 = new CoapRequest(MessageType.Name.NON, MessageCode.Name.GET, targetUri);
        coapRequest2.setToken(new Token(new byte[0]));
        coapRequest2.setMessageID(12345);
        coapRequest1.setAccept(ContentFormat.APP_XML, ContentFormat.TEXT_PLAIN_UTF8);

        Assert.assertFalse("Requests with different order of accept options must not equal!",
                coapRequest1.equals(coapRequest2));
View Full Code Here

        URI targetURI = new URI("coap://localhost:" + server.getPort() + PATH_TO_SERVICE);

        request1 = new CoapRequest(MessageType.Name.CON, MessageCode.Name.GET, targetURI);
        request1.setMessageID(1);
        request1.setToken(new Token(new byte[]{1,2,3,4}));
        request1.setObserve(0);

        request2 = new CoapRequest(MessageType.Name.CON, MessageCode.Name.GET, targetURI);
        request2.setMessageID(2);
        request2.setToken(new Token(new byte[]{1,2,3,4}));
        request2.setObserve(1);

        request3 = new CoapRequest(MessageType.Name.CON, MessageCode.Name.GET, targetURI);
        request3.setMessageID(3);
        request3.setToken(new Token(new byte[]{2,3,4,5,6}));
        request3.setObserve(0);
    }
View Full Code Here

        endpoint = new DummyEndpoint();

        serverSocket = new InetSocketAddress("localhost", server.getPort());

        URI serviceURI = new URI("coap", null, "localhost", server.getPort(), PATH, null, null);
        token = new Token(new byte[]{1, 2, 3, 4});
        messageID = 1;

        coapRequest1 = new CoapRequest(MessageType.Name.CON, MessageCode.Name.GET, serviceURI);
        coapRequest1.setMessageID(messageID);
        coapRequest1.setToken(token);
View Full Code Here

     * @param messageCode the number representing the {@link MessageCode} for this {@link CoapMessage}
     *
     * @throws IllegalArgumentException if one of the given arguments is invalid
     */
    protected CoapMessage(int messageType, int messageCode) throws IllegalArgumentException {
        this(messageType, messageCode, UNDEFINED_MESSAGE_ID, new Token(new byte[0]));
    }
View Full Code Here

     *
     * @throws IllegalArgumentException if the given message ID is out of the allowed range
     */
    public static CoapMessage createEmptyReset(int messageID) throws IllegalArgumentException {
        return new CoapMessage(MessageType.Name.RST.getNumber(), MessageCode.Name.EMPTY.getNumber(), messageID,
                new Token(new byte[0])){};
    }
View Full Code Here

     *
     * @throws IllegalArgumentException if the given message ID is out of the allowed range
     */
    public static CoapMessage createEmptyAcknowledgement(int messageID) throws IllegalArgumentException {
        return new CoapMessage(MessageType.Name.ACK.getNumber(), MessageCode.Name.EMPTY.getNumber(), messageID,
                new Token(new byte[0])){};
    }
View Full Code Here

TOP

Related Classes of de.uniluebeck.itm.ncoap.communication.dispatching.client.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.