blob: ab01cac779ae5d7ab37e944a3fc95b469d139fb5 [file] [log] [blame]
Andrea Campanellace279ee2016-01-25 10:21:45 -08001/*
2 * Copyright 2016 Open Networking Laboratory
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 */
16
17package org.onosproject.protocol.rest.ctl;
18
19import org.junit.Before;
20import org.junit.Test;
21import org.onlab.packet.IpAddress;
22import org.onosproject.protocol.rest.DefaultRestSBDevice;
23import org.onosproject.protocol.rest.RestSBDevice;
24
25import static org.junit.Assert.*;
26
27/**
28 * Basic testing for RestSBController.
29 */
30public class RestSBControllerImplTest {
31
32 RestSBControllerImpl controller;
33
34 RestSBDevice device1;
35 RestSBDevice device2;
36
37
38 @Before
39 public void setUp() {
40 controller = new RestSBControllerImpl();
41 controller.activate();
42 device1 = new DefaultRestSBDevice(IpAddress.valueOf("127.0.0.1"), 8080, "foo", "bar", "http", true);
43 device2 = new DefaultRestSBDevice(IpAddress.valueOf("127.0.0.2"), 8080, "foo1", "bar2", "http", true);
44 controller.addDevice(device1);
45 }
46
47 @Test
48 public void basics() {
49 assertTrue("Device1 non added", controller.getDevices().containsValue(device1));
50 assertEquals("Device1 added but with wrong key", controller.getDevices()
51 .get(device1.deviceId()), device1);
52 assertEquals("Incorrect Get Device by ID", controller.getDevice(device1.deviceId()), device1);
53 assertEquals("Incorrect Get Device by IP, Port", controller.getDevice(device1.ip(), device1.port()), device1);
54 controller.addDevice(device2);
55 assertTrue("Device2 non added", controller.getDevices().containsValue(device2));
56 controller.removeDevice(device2);
57 assertFalse("Device2 not removed", controller.getDevices().containsValue(device2));
58 }
59}