blob: 1f7f363cd3aef2047b8b30cce7471a4cd9ab7645 [file] [log] [blame]
Hesam Rahimi4a409b42016-08-12 18:37:33 -04001/*
2 * Copyright 2016-present 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.restconf.ctl;
18
19import static org.junit.Assert.assertEquals;
20import static org.junit.Assert.assertFalse;
21import static org.junit.Assert.assertTrue;
22
23import java.util.concurrent.ExecutorService;
24import java.util.concurrent.Executors;
25
26import org.junit.Before;
27import org.junit.Test;
28import org.onlab.packet.IpAddress;
29import org.onosproject.protocol.rest.DefaultRestSBDevice;
30import org.onosproject.protocol.rest.RestSBDevice;
31
32/**
33 * Basic testing for RestSBController.
34 */
35public class RestConfSBControllerImplTest {
36
37 RestConfSBControllerImpl restConfController;
38
39 RestSBDevice device3;
40
41 ExecutorService executor = Executors.newSingleThreadExecutor();
42
43 @Before
44 public void setUp() {
45 restConfController = new RestConfSBControllerImpl();
46 restConfController.activate();
47 device3 = new DefaultRestSBDevice(IpAddress.valueOf("127.0.0.1"), 8181,
48 "", "", "http", null, true);
49 restConfController.addDevice(device3);
50
51 }
52
53 @Test
54 public void basics() {
55 assertTrue("Device3 non added",
56 restConfController.getDevices().containsValue(device3));
57 assertEquals("Device3 added but with wrong key",
58 restConfController.getDevices().get(device3.deviceId()),
59 device3);
60 assertEquals("Incorrect Get Device by ID",
61 restConfController.getDevice(device3.deviceId()), device3);
62 assertEquals("Incorrect Get Device by IP, Port",
63 restConfController.getDevice(device3.ip(), device3.port()),
64 device3);
65 restConfController.removeDevice(device3.deviceId());
66 assertFalse("Device3 not removed",
67 restConfController.getDevices().containsValue(device3));
68 }
69}