Add missing license headers
[packetcable.git] / packetcable-driver / src / test / java / org / pcmm / gates / impl / GateIDTest.java
1 /*
2  * Copyright (c) 2015 Cable Television Laboratories, Inc and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.pcmm.gates.impl;
9
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.umu.cops.stack.COPSMsgParser;
13
14 /**
15  * Tests the data holder class GateId to ensure both construction and byte parsing result in correct object creation.
16  */
17 public class GateIDTest {
18
19     @Test
20     public void construction() {
21         final GateID gateID = new GateID(9);
22
23         // Check the object's bytes
24         final byte[] dataBytes = gateID.getBytes();
25         Assert.assertEquals(9, gateID.getGateID());
26         Assert.assertEquals(4, dataBytes.length);
27         Assert.assertEquals(9, COPSMsgParser.bytesToInt(dataBytes[0], dataBytes[1], dataBytes[2], dataBytes[3]));
28
29         // Check the byte parsing
30         final GateID parsed = GateID.parse(dataBytes);
31         Assert.assertEquals(gateID, parsed);
32     }
33
34     @Test
35     public void byteParsing() {
36         final GateID gateID = new GateID(10);
37         final GateID parsed = GateID.parse(gateID.getBytes());
38         Assert.assertEquals(gateID, parsed);
39     }
40
41 }