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 BestEffortService to ensure both construction and byte parsing result in correct object
17 public class BestEffortServiceTest {
19 @Test(expected = IllegalArgumentException.class)
20 public void nullAllEnvelopes() {
21 new BestEffortService(null, null, null);
25 public void requiredEnvelopeOnly() {
26 final BEEnvelop auth = new BEEnvelop((byte)0, 1, 2, 3, 4, (short)5, (short)6, 7, 8, 9, 0, 1, 2, 3);
27 final BestEffortService service = new BestEffortService(auth, null, null);
28 Assert.assertNotNull(service.getAuthorizedEnvelop());
29 Assert.assertNull(service.getReservedEnvelop());
30 Assert.assertNull(service.getCommittedEnvelop());
31 // TODO - add more validation here
35 public void authAndReservedEnvelopes() {
36 final BEEnvelop auth = new BEEnvelop((byte)0, 1, 2, 3, 4, (short)5, (short)6, 7, 8, 9, 0, 1, 2, 3);
37 final BEEnvelop resv = new BEEnvelop((byte)10, 11, 12, 13, 14, (short)15, (short)16, 17, 18, 19, 10, 11, 12, 13);
38 final BestEffortService service = new BestEffortService(auth, resv, null);
39 Assert.assertNotNull(service.getAuthorizedEnvelop());
40 Assert.assertNotNull(service.getReservedEnvelop());
41 Assert.assertNull(service.getCommittedEnvelop());
42 // TODO - add more validation here
46 public void allEnvelopes() {
47 final BEEnvelop auth = new BEEnvelop((byte)0, 1, 2, 3, 4, (short)5, (short)6, 7, 8, 9, 0, 1, 2, 3);
48 final BEEnvelop resv = new BEEnvelop((byte)10, 11, 12, 13, 14, (short)15, (short)16, 17, 18, 19, 10, 11, 12, 13);
49 final BEEnvelop cmmt = new BEEnvelop((byte)20, 21, 22, 23, 24, (short)25, (short)26, 27, 28, 29, 20, 21, 22, 23);
50 final BestEffortService service = new BestEffortService(auth, resv, cmmt);
51 Assert.assertNotNull(service.getAuthorizedEnvelop());
52 Assert.assertNotNull(service.getReservedEnvelop());
53 Assert.assertNotNull(service.getCommittedEnvelop());
54 // TODO - add more validation here
58 public void byteParsingAuth() {
59 final BEEnvelop auth = new BEEnvelop((byte)0, 1, 2, 3, 4, (short)5, (short)6, 7, 8, 9, 0, 1, 2, 3);
60 final BestEffortService service = new BestEffortService(auth, null, null);
61 final BestEffortService parsed = BestEffortService.parse(service.getBytes());
62 Assert.assertEquals(service, parsed);
66 public void byteParsingAuthReserved() {
67 final BEEnvelop auth = new BEEnvelop((byte)0, 1, 2, 3, 4, (short)5, (short)6, 7, 8, 9, 0, 1, 2, 3);
68 final BEEnvelop resv = new BEEnvelop((byte)10, 11, 12, 13, 14, (short)15, (short)16, 17, 18, 19, 10, 11, 12, 13);
69 final BestEffortService service = new BestEffortService(auth, resv, null);
70 final BestEffortService parsed = BestEffortService.parse(service.getBytes());
71 Assert.assertEquals(service, parsed);
75 public void byteParsingAll() {
76 final BEEnvelop auth = new BEEnvelop((byte)0, 1, 2, 3, 4, (short)5, (short)6, 7, 8, 9, 0, 1, 2, 3);
77 final BEEnvelop resv = new BEEnvelop((byte)10, 11, 12, 13, 14, (short)15, (short)16, 17, 18, 19, 10, 11, 12, 13);
78 final BEEnvelop cmmt = new BEEnvelop((byte)20, 21, 22, 23, 24, (short)25, (short)26, 27, 28, 29, 20, 21, 22, 23);
79 final BestEffortService service = new BestEffortService(auth, resv, cmmt);
80 final BestEffortService parsed = BestEffortService.parse(service.getBytes());
81 Assert.assertEquals(service, parsed);