Merge "Removed original Hydrogen demo from repo."
[packetcable.git] / packetcable-driver / src / test / java / org / pcmm / gates / impl / AMIDTest.java
1 /*
2  * (c) 2015 Cable Television Laboratories, Inc.  All rights reserved.
3  */
4
5 package org.pcmm.gates.impl;
6
7 import org.junit.Assert;
8 import org.junit.Test;
9 import org.umu.cops.stack.COPSMsgParser;
10
11 /**
12  * Tests the data holder class AMID to ensure both construction and byte parsing result in correct object creation.
13  */
14 public class AMIDTest {
15
16     @Test
17     public void construction() {
18         final AMID amid = new AMID((short)5, (short)6);
19         final byte[] dataBytes = amid.getBytes();
20         Assert.assertEquals((short)5, amid.getApplicationType());
21         Assert.assertEquals((short)6, amid.getApplicationMgrTag());
22         Assert.assertEquals(4, dataBytes.length);
23         Assert.assertEquals(5, COPSMsgParser.bytesToShort(dataBytes[0], dataBytes[1]));
24         Assert.assertEquals(6, COPSMsgParser.bytesToShort(dataBytes[2], dataBytes[3]));
25     }
26
27     @Test
28     public void byteParsing() {
29         final AMID amid = new AMID((short)7, (short)8);
30         final AMID parsed = AMID.parse(amid.getBytes());
31         Assert.assertEquals(amid, parsed);
32     }
33
34 }