1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.mina.coap.codec;
20
21 import static org.apache.mina.coap.codec.TestMessages.*;
22
23 import org.apache.mina.util.ByteBufferDumper;
24 import org.junit.Assert;
25 import org.junit.Test;
26
27
28
29
30 public class CoapDecoderTest {
31
32 private CoapDecoder decoder = new CoapDecoder();
33
34 @Test
35 public void some_content_no_option() {
36 Assert.assertEquals(SOME_CONTENT_NO_OPTION,
37 decoder.decode(ByteBufferDumper.fromHexString(SOME_CONTENT_NO_OPTION_HEX), null));
38 }
39
40 @Test
41 public void no_content_no_option() {
42 Assert.assertEquals(NO_CONTENT_NO_OPTION,
43 decoder.decode(ByteBufferDumper.fromHexString(NO_CONTENT_NO_OPTION_HEX), null));
44 }
45
46 @Test
47 public void payload_and_one_option() {
48 Assert.assertEquals(PAYLOAD_AND_ONE_OPTION,
49 decoder.decode(ByteBufferDumper.fromHexString(PAYLOAD_AND_ONE_OPTION_HEX), null));
50 }
51
52 @Test
53 public void payload_and_multiple_option() {
54 Assert.assertEquals(PAYLOAD_AND_MULTIPLE_OPTION,
55 decoder.decode(ByteBufferDumper.fromHexString(PAYLOAD_AND_MULTIPLE_OPTION_HEX), null));
56 }
57
58 @Test
59 public void observe_message() {
60 Assert.assertEquals(OBSERVE, decoder.decode(ByteBufferDumper.fromHexString(OBSERVE_HEX), null));
61 }
62 }