aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
blob: f896c159399380ac3b7bfd2c1e3b4117981f27e2 (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
package org.traccar.protocol;

import org.jboss.netty.buffer.ChannelBuffers;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;

public class TeltonikaProtocolDecoderTest {

    @Test
    public void testDecode() throws Exception {

        TeltonikaProtocolDecoder decoder = new TeltonikaProtocolDecoder(null);
        decoder.setDataManager(new TestDataManager());

        byte[] buf1 = {0x00,0x0F,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x31,0x32,0x33,0x34,0x35};
        assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf1)));
        
        byte[] buf2 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xA7,0x08,0x04,0x00,0x00,0x01,0x13,(byte)0xfc,0x20,(byte)0x8d,(byte)0xff,0x00,0x0f,0x14,(byte)0xf6,0x50,0x20,(byte)0x9c,(byte)0xca,(byte)0x80,0x00,0x6f,0x00,(byte)0xd6,0x04,0x00,0x04,0x00,0x04,0x03,0x01,0x01,0x15,0x03,0x16,0x03,0x00,0x01,0x46,0x00,0x00,0x01,0x5d,0x00,0x00,0x00,0x01,0x13,(byte)0xfc,0x17,0x61,0x0b,0x00,0x0f,0x14,(byte)0xff,(byte)0xe0,0x20,(byte)0x9c,(byte)0xc5,(byte)0x80,0x00,0x6e,0x00,(byte)0xc0,0x05,0x00,0x01,0x00,0x04,0x03,0x01,0x01,0x15,0x03,0x16,0x01,0x00,0x01,0x46,0x00,0x00,0x01,0x5e,0x00,0x00,0x00,0x01,0x13,(byte)0xfc,0x28,0x49,0x45,0x00,0x0f,0x15,0x0f,0x00,0x20,(byte)0x9c,(byte)0xd2,0x00,0x00,(byte)0x95,0x01,0x08,0x04,0x00,0x00,0x00,0x04,0x03,0x01,0x01,0x15,0x00,0x16,0x03,0x00,0x01,0x46,0x00,0x00,0x01,0x5d,0x00,0x00,0x00,0x01,0x13,(byte)0xfc,0x26,0x7c,0x5b,0x00,0x0f,0x15,0x0a,0x50,0x20,(byte)0x9c,(byte)0xcc,(byte)0xc0,0x00,(byte)0x93,0x00,0x68,0x04,0x00,0x00,0x00,0x04,0x03,0x01,0x01,0x15,0x00,0x16,0x03,0x00,0x01,0x46,0x00,0x00,0x01,0x5b,0x00,0x04,0x00,0x00};
        assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf2)));

    }

}