blob: 9ec1029776e6886cdab94d154fa2c25f7752c97f [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;
19
20import java.time.Duration;
21
22import org.junit.Before;
23import org.junit.Test;
24import org.onlab.packet.MacAddress;
25import org.onosproject.incubator.net.l2monitoring.cfm.RemoteMepEntry.InterfaceStatusTlvType;
26import org.onosproject.incubator.net.l2monitoring.cfm.RemoteMepEntry.PortStatusTlvType;
27import org.onosproject.incubator.net.l2monitoring.cfm.RemoteMepEntry.RemoteMepState;
28import org.onosproject.incubator.net.l2monitoring.cfm.SenderIdTlv.SenderIdTlvType;
29import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
30import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
31
32public class RemoteMepEntryTest {
33
34 RemoteMepEntry rmep1;
35
36 @Before
37 public void setUp() throws Exception, CfmConfigException {
38 rmep1 = DefaultRemoteMepEntry
39 .builder(MepId.valueOf((short) 1), RemoteMepState.RMEP_IDLE)
40 .failedOrOkTime(Duration.ofSeconds(5))
41 .macAddress(MacAddress.valueOf("AA:BB:CC:DD:EE:FF"))
42 .rdi(true)
43 .portStatusTlvType(PortStatusTlvType.PS_UP)
44 .interfaceStatusTlvType(InterfaceStatusTlvType.IS_UP)
45 .senderIdTlvType(SenderIdTlvType.SI_MAC_ADDRESS)
46 .build();
47 }
48
49 @Test
50 public void testRemoteMepId() {
51 assertEquals(1, rmep1.remoteMepId().value());
52 }
53
54 @Test
55 public void testState() {
56 assertEquals(RemoteMepState.RMEP_IDLE, rmep1.state());
57 }
58
59 @Test
60 public void testFailedOrOkTime() {
61 assertEquals(5, rmep1.failedOrOkTime().getSeconds());
62 }
63
64 @Test
65 public void testMacAddress() {
66 assertEquals("AA:BB:CC:DD:EE:FF", rmep1.macAddress().toString());
67 }
68
69 @Test
70 public void testRdi() {
71 assertEquals(true, rmep1.rdi());
72 }
73
74 @Test
75 public void testPortStatusTlvType() {
76 assertEquals(PortStatusTlvType.PS_UP, rmep1.portStatusTlvType());
77 }
78
79 @Test
80 public void testInterfaceStatusTlvType() {
81 assertEquals(InterfaceStatusTlvType.IS_UP, rmep1.interfaceStatusTlvType());
82 }
83
84 @Test
85 public void testSenderIdTlvType() {
86 assertEquals(SenderIdTlvType.SI_MAC_ADDRESS, rmep1.senderIdTlvType());
87 }
88
89}