package de.uniluebeck.itm.spitfire.nCoap.message;

import de.uniluebeck.itm.spitfire.nCoap.message.header.Code;
import org.junit.Test;

/**
 * Test of CoapMessage class.
 * @author Stefan Hueske
 */
public class CoapMessageTest {
    
    @Test(expected=MessageDoesNotAllowPayloadException.class)
    public void testSetPayloadForGET() throws Exception {
        new CoapMessage(Code.GET) {}.setPayload("testpayload".getBytes("UTF8"));
    }
    
    @Test(expected=MessageDoesNotAllowPayloadException.class)
    public void testSetPayloadForDELETE() throws Exception {
        new CoapMessage(Code.DELETE) {}.setPayload("testpayload".getBytes("UTF8"));
    }
   
}

@@ -44,16 +44,56 @@
 ssage;%0A%0A
+import com.google.common.base.Charsets;%0A
 import d
@@ -156,24 +156,233 @@
 ort 
-org.junit.Test;%0A
+java.io.UnsupportedEncodingException;%0Aimport org.apache.commons.lang.CharSet;%0Aimport org.jboss.netty.buffer.ChannelBuffer;%0Aimport org.jboss.netty.buffer.ChannelBuffers;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;
 %0A/**
@@ -905,11 +905,504 @@
    %7D%0A   
+ %0A    @Test%0A    public void testgetPayloadAsByteArray() throws MessageDoesNotAllowPayloadException %7B%0A        CoapMessage message = new CoapMessage(Code.CONTENT_205) %7B%7D;%0A        byte%5B%5D payload = %22testpayload%22.getBytes(Charsets.UTF_8);%0A        message.setPayload(ChannelBuffers.wrappedBuffer(payload));%0A        assertArrayEquals(payload, message.getPayloadAsByteArray());%0A        %0A        message = new CoapMessage(Code.CONTENT_205) %7B%7D;%0A        assertNull(message.getPayloadAsByteArray());%0A    %7D
 %0A%7D%0A

Test for CoapMessage.getPayloadAsByteArray() added