aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/protocol/KhdProtocolDecoderTest.java
blob: 9f6aecf371db3e90db20f3fa3fb717f9d885f144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.traccar.protocol;

import org.traccar.helper.TestDataManager;
import org.jboss.netty.buffer.ChannelBuffers;
import static org.traccar.helper.DecoderVerifier.verify;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.traccar.helper.ChannelBufferTools;

public class KhdProtocolDecoderTest {

    @Test
    public void testDecode() throws Exception {

        KhdProtocolDecoder decoder = new KhdProtocolDecoder(new TestDataManager());

        assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0xb1,0x00,0x06,0x05,0x16,0x29,0x35,0xb8,0x0d}))));

        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x80,0x00,0x28,0x05,0x16,0x29,0x35,0x14,0x01,0x08,0x07,0x47,0x27,0x80,0x11,0x29,0x67,0x03,0x65,0x33,0x69,0x00,0x00,0x01,0x03,0xff,0xff,0x00,0x00,0x82,0xfc,0x00,0x00,0x00,0x1e,0x78,0x09,0x1b,0x00,0x00,0x00,0x36,0x0d}))));
        
        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x81,0x00,0x28,0x0A,0x9F,0x95,0x38,0x08,0x12,0x28,0x16,0x01,0x31,0x02,0x23,0x94,0x30,0x11,0x40,0x37,0x25,0x00,0x00,0x03,0x30,0xFF,0x00,0x00,0x00,0x7F,0xFC,0x0F,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x34,0x29,0x0D}))));
        
        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x80,0x00,0x28,0x0A,0x81,0x85,0x0A,0x12,0x03,0x10,0x09,0x57,0x50,0x00,0x52,0x81,0x37,0x00,0x61,0x19,0x08,0x00,0x00,0x02,0x32,0xF8,0x48,0xFF,0xBB,0xFF,0xFF,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0xED,0x0D}))));
        
        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x8E,0x00,0x28,0x0F,0x80,0x81,0x5A,0x12,0x12,0x18,0x20,0x31,0x16,0x02,0x23,0x18,0x46,0x11,0x40,0x22,0x70,0x00,0x72,0x02,0x62,0xFB,0x00,0x07,0x7C,0x7F,0xBF,0x56,0x00,0x00,0x1E,0x3C,0x32,0x00,0x00,0x00,0x00,0x85,0x0D}))));
        
        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x82,0x00,0x23,0x0A,0xA2,0xCC,0x39,0x12,0x05,0x03,0x05,0x05,0x22,0x02,0x85,0x94,0x79,0x03,0x10,0x95,0x50,0x00,0x80,0x02,0x07,0x84,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x75,0x0D}))));
        
        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x85,0x00,0x08,0x1D,0xD0,0x8C,0x22,0x12,0x03,0x12,0x17,0x40,0x26,0x02,0x65,0x45,0x71,0x03,0x12,0x54,0x17,0x00,0x00,0x00,0x00,0xF8,0x19,0xC8,0x39,0xFF,0xFF,0x1D,0x00,0x00,0x1E,0x00,0x50,0x00,0x00,0x00,0x3A,0xF9,0x0D}))));
        
        verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
                new int[] {0x29,0x29,0x80,0x00,0x28,0x22,0x83,0x66,0x65,0x14,0x08,0x25,0x14,0x20,0x37,0x04,0x53,0x43,0x77,0x01,0x93,0x87,0x92,0x00,0x00,0x00,0x50,0xff,0xff,0x00,0x00,0x82,0xfc,0x00,0x00,0x04,0xb0,0x78,0x0b,0x17,0x00,0x00,0x00,0x2a,0x0d}))));

    }

}