2 * Copyright (c) 2015 Cable Television Laboratories, Inc and others. All rights reserved.
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
8 package org.pcmm.objects;
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.umu.cops.stack.COPSMsgParser;
15 * Tests the data holder class MMVersionInfo to ensure both construction and byte parsing result in correct object
18 public class MMVersionInfoTest {
21 public void construction() {
22 final MMVersionInfo verInfo = new MMVersionInfo((short)5, (short)6);
23 final byte[] dataBytes = verInfo.getBytes();
24 Assert.assertEquals(4, dataBytes.length);
25 Assert.assertEquals(5, COPSMsgParser.bytesToShort(dataBytes[0], dataBytes[1]));
26 Assert.assertEquals(6, COPSMsgParser.bytesToShort(dataBytes[2], dataBytes[3]));
30 public void byteParsing() {
31 final MMVersionInfo verInfo = new MMVersionInfo((short)7, (short)8);
32 final MMVersionInfo parsed = MMVersionInfo.parse(verInfo.getBytes());
33 Assert.assertEquals(verInfo, parsed);