blob: e415a843805511fabac4f8a4f75a388c6697a45e [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.l2monitoring.cfm;
17
18import static org.junit.Assert.assertEquals;
19import static org.junit.Assert.assertNull;
20
21import org.junit.Before;
22import org.junit.Test;
23import org.onlab.packet.MacAddress;
24import org.onlab.util.HexString;
25import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
26import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
27
28public class MepLbCreateTest {
29
30 MepLbCreate lb1;
31 MepLbCreate lb2;
32
33 @Before
34 public void setUp() throws Exception {
35 lb1 = DefaultMepLbCreate
36 .builder(MacAddress.valueOf("aa:bb:cc:dd:ee:ff"))
37 .numberMessages(5)
38 .dataTlv(new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06})
39 .vlanPriority(Priority.PRIO3)
40 .vlanDropEligible(true)
41 .build();
42 lb2 = DefaultMepLbCreate
43 .builder(MepId.valueOf((short) 12))
44 .build();
45
46 }
47
48 @Test
49 public void testRemoteMepAddress() {
50 assertEquals("aa:bb:cc:dd:ee:ff".toUpperCase(),
51 lb1.remoteMepAddress().toString());
52 assertNull(lb1.remoteMepId());
53 }
54
55 @Test
56 public void testRemoteMepId() {
57 assertEquals(12, lb2.remoteMepId().id().intValue());
58 assertNull(lb2.remoteMepAddress());
59 }
60
61 @Test
62 public void testNumberMessages() {
63 assertEquals(5, lb1.numberMessages().intValue());
64 }
65
66 @Test
67 public void testDataTlv() {
68 assertEquals(0x06, HexString.fromHexString(lb1.dataTlvHex())[5]);
69 }
70
71 @Test
72 public void testVlanPriority() {
73 assertEquals(3, lb1.vlanPriority().ordinal());
74 }
75
76 @Test
77 public void testVlanDropElegible() {
78 assertEquals(true, lb1.vlanDropEligible());
79 }
80}