Package de.uniluebeck.itm.ncoap.message

Examples of de.uniluebeck.itm.ncoap.message.CoapMessage$LinkedHashSetSupplier


        Thread.sleep(3000);

        endpoint.writeMessage(coapRequest2, serverSocket);
        Thread.sleep(3500);

        CoapMessage emptyACK = CoapMessage.createEmptyAcknowledgement(endpoint.getReceivedMessage(2).getMessageID());
        endpoint.writeMessage(emptyACK, serverSocket);

        Thread.sleep(2000);
    }
View Full Code Here


        assertEquals(3, endpoint.getReceivedCoapMessages().size());
    }

    @Test
    public void testFirstMessageisEmptyAck(){
        CoapMessage message1 = endpoint.getReceivedMessage(0);

        assertEquals("First message is not empty!", MessageCode.Name.EMPTY, message1.getMessageCodeName());
        assertEquals("First message has wrong ID!", messageID, message1.getMessageID());
        assertEquals("First message is no ACK!", MessageType.Name.ACK, message1.getMessageTypeName());
    }
View Full Code Here

        assertEquals("First message is no ACK!", MessageType.Name.ACK, message1.getMessageTypeName());
    }

    @Test
    public void testSecondMessageisEmptyAck(){
        CoapMessage message2 = endpoint.getReceivedMessage(1);

        assertEquals("Second message is not empty!", MessageCode.Name.EMPTY, message2.getMessageCodeName());
        assertEquals("Second message has wrong ID!", messageID, message2.getMessageID());
        assertEquals("Second message is no ACK!", MessageType.Name.ACK, message2.getMessageTypeName());
    }
View Full Code Here

        assertEquals("Second message is no ACK!", MessageType.Name.ACK, message2.getMessageTypeName());
    }

    @Test
    public void testThirdMessage(){
        CoapMessage message3 = endpoint.getReceivedMessage(2);

        assertEquals("Third message has wrong message code!", MessageCode.Name.CONTENT_205,
                message3.getMessageCodeName());

        assertEquals("3rd message has wrong message type!", MessageType.Name.CON, message3.getMessageTypeName());
    }
View Full Code Here

        //let testEndpoint write empty ACK to acknowledge seperate response
        int messageID = endpoint.getReceivedCoapMessages()
                                .get(endpoint.getReceivedCoapMessages().lastKey())
                                .getMessageID();

        CoapMessage emptyACK = CoapMessage.createEmptyAcknowledgement(messageID);
        endpoint.writeMessage(emptyACK, new InetSocketAddress("localhost", server.getPort()));

        //Wait some time to let the server receive the ACK and ensure there is no retransmission
        Thread.sleep(3000);
    }
View Full Code Here

        long emptyAckReceptionTime = receivedMessages.firstKey();
        long delay = requestSentTime - emptyAckReceptionTime;

        assertTrue("Empty ACK was too late (delay: " + delay + "ms.", delay < 2000);

        CoapMessage receivedMessage = receivedMessages.get(emptyAckReceptionTime);
        String message = "First received message is not an EMPTY ACK";

        assertEquals(message, MessageType.Name.ACK, receivedMessage.getMessageTypeName());
        assertEquals(message, MessageCode.Name.EMPTY, receivedMessage.getMessageCodeName());
    }
View Full Code Here

    }

    @Test
    public void test2ndReceivedMessageIsResponse() {
        SortedMap<Long, CoapMessage> receivedMessages = endpoint.getReceivedCoapMessages();
        CoapMessage receivedMessage = receivedMessages.get(receivedMessages.lastKey());

        String message = "Endpoint received more than one message";
        assertTrue(message, receivedMessage instanceof CoapResponse);
    }
View Full Code Here

    }

    @Test
    public void test2ndReceivedMessageHasSameToken() {
        SortedMap<Long, CoapMessage> receivedMessages = endpoint.getReceivedCoapMessages();
        CoapMessage receivedMessage = receivedMessages.get(receivedMessages.lastKey());
        String message = "Response token does not match with request token";
        assertEquals(message, request.getToken(), receivedMessage.getToken());
    }
View Full Code Here

    }

    @Test
    public void test2ndReceivedMessageHasCodeContent() {
        SortedMap<Long, CoapMessage> receivedMessages = endpoint.getReceivedCoapMessages();
        CoapMessage receivedMessage = receivedMessages.get(receivedMessages.lastKey());
        String message = "Response code is not CONTENT 205";
        assertEquals(message, MessageCode.Name.CONTENT_205, receivedMessage.getMessageCodeName());
    }
View Full Code Here

    }

    @Test
    public void test2ndReceivedMessageHasUnmodifiedPayload() {
        SortedMap<Long, CoapMessage> receivedMessages = endpoint.getReceivedCoapMessages();
        CoapMessage receivedMessage = receivedMessages.get(receivedMessages.lastKey());
        String message = "Response payload was modified by testServer";
        assertEquals(message, PAYLOAD, receivedMessage.getContent().toString(Charset.forName("UTF-8")));
    }
View Full Code Here

TOP

Related Classes of de.uniluebeck.itm.ncoap.message.CoapMessage$LinkedHashSetSupplier

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.