blob: 86b0a6ad40414f43ff1faf011832bd2f4882c48d [file] [log] [blame]
Ethan Tai8c18eb72017-06-26 16:44:25 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Ethan Tai8c18eb72017-06-26 16:44:25 -07003 *
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 */
16
17package org.onosproject.net.behaviour;
18
19import com.google.common.collect.Lists;
20import org.junit.Test;
21import org.onlab.packet.IpAddress;
22import org.onosproject.net.DeviceId;
23
24import java.util.List;
25
26import static org.hamcrest.Matchers.is;
Jian Li0aed0e62020-12-12 03:54:54 +090027import static org.junit.Assert.assertNull;
28import static org.junit.Assert.assertThat;
29import static org.junit.Assert.assertTrue;
Ethan Tai8c18eb72017-06-26 16:44:25 -070030
31/**
32 * Unit tests for DefaultBridgeDescription.
33 */
34
35public class DefaultBridgeDescriptionTest {
36 private final BridgeDescription.Builder build = DefaultBridgeDescription.builder();
37 private final String name = "expected";
38 private final IpAddress ip = IpAddress.valueOf("0.0.0.0");
39 private final IpAddress ip2 = IpAddress.valueOf("0.0.0.1");
40 private final IpAddress ip3 = IpAddress.valueOf("0.0.0.2");
41 private final ControllerInfo controller1 = new ControllerInfo(ip, 6653, "test");
42 private final ControllerInfo controller2 = new ControllerInfo(ip2, 6654, "test");
43 private final ControllerInfo controller3 = new ControllerInfo(ip3, 6655, "test");
44 private final List<ControllerInfo> controllers = Lists.newArrayList(controller1,
45 controller2,
46 controller3);
47 private final BridgeDescription.FailMode mode = BridgeDescription.FailMode.SECURE;
48 private final String id = "foo";
49 private final String type = "bar";
50
51 /**
52 * Tests all the getter methods in DefaultBridgeDescription.
53 */
54 @Test
55 public void testGet() {
56
57 build.name(name);
58 build.controllers(controllers);
59 build.datapathId(id);
60 build.datapathType(type);
61 build.failMode(mode);
62 build.disableInBand();
Jian Li0aed0e62020-12-12 03:54:54 +090063 build.mcastSnoopingEnable();
Ethan Tai8c18eb72017-06-26 16:44:25 -070064 build.enableLocalController();
65 BridgeDescription test;
66 test = build.build();
67
68 assertThat(test.name(), is("expected"));
69 assertThat(test.controllers(), is(controllers));
70 assertThat(test.datapathId().get(), is(id));
71 assertThat(test.datapathType().get(), is(type));
72 assertThat(test.failMode().get(), is(mode));
73 assertThat(test.disableInBand().get(), is(true));
Jian Li0aed0e62020-12-12 03:54:54 +090074 assertThat(test.mcastSnoopingEnable().get(), is(true));
Ethan Tai8c18eb72017-06-26 16:44:25 -070075 assertNull(test.annotations());
76 assertTrue(test.enableLocalController());
77 assertThat(test.deviceId().get(), is(DeviceId.deviceId("of:" + id)));
78 }
79}
80