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.gates.impl;
10 import org.junit.Assert;
11 import org.junit.Test;
14 * Tests the data holder class DOCSISServiceClassNameTrafficProfile to ensure both construction and byte parsing result
15 * in correct object creation.
17 public class DOCSISServiceClassNameTrafficProfileTest {
19 @Test(expected = IllegalArgumentException.class)
20 public void constructor1NullSCN() {
21 new DOCSISServiceClassNameTrafficProfile(null);
24 @Test(expected = IllegalArgumentException.class)
25 public void constructor1ShortSCN() {
26 new DOCSISServiceClassNameTrafficProfile("1");
29 @Test(expected = IllegalArgumentException.class)
30 public void constructor1LongSCN() {
31 new DOCSISServiceClassNameTrafficProfile("01234567891234567");
34 @Test(expected = IllegalArgumentException.class)
35 public void constructor2NullSCN() {
36 new DOCSISServiceClassNameTrafficProfile((byte)1, null);
39 @Test(expected = IllegalArgumentException.class)
40 public void constructor2ShortSCN() {
41 new DOCSISServiceClassNameTrafficProfile((byte)1, "1");
44 @Test(expected = IllegalArgumentException.class)
45 public void constructor2LongSCN() {
46 new DOCSISServiceClassNameTrafficProfile((byte)1, "01234567891234567");
50 public void construction() {
51 final DOCSISServiceClassNameTrafficProfile profile =
52 new DOCSISServiceClassNameTrafficProfile((byte)5, "0123456789123456");
53 Assert.assertEquals((byte)5, profile.getEnvelop());
54 Assert.assertEquals("0123456789123456", profile.getScnName());
58 public void byteParsingWithoutPadding() {
59 // Name length % 4 == 0
60 final DOCSISServiceClassNameTrafficProfile profile =
61 new DOCSISServiceClassNameTrafficProfile((byte)25, "1234");
62 final DOCSISServiceClassNameTrafficProfile parsed =
63 DOCSISServiceClassNameTrafficProfile.parse(profile.getBytes());
64 Assert.assertEquals(profile, parsed);
68 public void byteParsingWithOnePaddedChar() {
69 // Name length % 4 == 1
70 final DOCSISServiceClassNameTrafficProfile profile =
71 new DOCSISServiceClassNameTrafficProfile((byte)25, "123");
72 final DOCSISServiceClassNameTrafficProfile parsed =
73 DOCSISServiceClassNameTrafficProfile.parse(profile.getBytes());
74 Assert.assertEquals(profile, parsed);
78 public void byteParsingWithThreePaddedChar() {
79 // Name length % 4 == 3
80 final DOCSISServiceClassNameTrafficProfile profile =
81 new DOCSISServiceClassNameTrafficProfile((byte)25, "12345");
82 final DOCSISServiceClassNameTrafficProfile parsed =
83 DOCSISServiceClassNameTrafficProfile.parse(profile.getBytes());
84 Assert.assertEquals(profile, parsed);