Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.incubator.net.virtual.impl; |
| 18 | |
| 19 | import com.google.common.collect.Iterators; |
| 20 | import org.junit.After; |
| 21 | import org.junit.Before; |
| 22 | import org.junit.Test; |
| 23 | import org.onlab.junit.TestUtils; |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 24 | import org.onlab.osgi.TestServiceDirectory; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 25 | import org.onosproject.common.event.impl.TestEventDispatcher; |
| 26 | import org.onosproject.core.CoreService; |
| 27 | import org.onosproject.core.CoreServiceAdapter; |
| 28 | import org.onosproject.core.IdGenerator; |
| 29 | import org.onosproject.incubator.net.virtual.TenantId; |
| 30 | import org.onosproject.incubator.net.virtual.VirtualDevice; |
| 31 | import org.onosproject.incubator.net.virtual.VirtualNetwork; |
| 32 | import org.onosproject.incubator.net.virtual.VirtualPort; |
| 33 | import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore; |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 34 | import org.onosproject.net.ConnectPoint; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 35 | import org.onosproject.net.Device; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 36 | import org.onosproject.net.MastershipRole; |
| 37 | import org.onosproject.net.NetTestTools; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 38 | import org.onosproject.net.PortNumber; |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 39 | import org.onosproject.net.TestDeviceParams; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 40 | import org.onosproject.net.device.DeviceService; |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 41 | import org.onosproject.net.intent.FakeIntentManager; |
| 42 | import org.onosproject.net.intent.TestableIntentService; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 43 | import org.onosproject.store.service.TestStorageService; |
| 44 | |
| 45 | import java.util.Iterator; |
| 46 | import java.util.concurrent.atomic.AtomicLong; |
| 47 | |
| 48 | import static org.junit.Assert.*; |
| 49 | |
| 50 | /** |
| 51 | * Junit tests for VirtualNetworkDeviceService. |
| 52 | */ |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 53 | public class VirtualNetworkDeviceManagerTest extends TestDeviceParams { |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 54 | private final String tenantIdValue1 = "TENANT_ID1"; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 55 | |
| 56 | private VirtualNetworkManager manager; |
| 57 | private DistributedVirtualNetworkStore virtualNetworkManagerStore; |
| 58 | private CoreService coreService; |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 59 | private TestableIntentService intentService = new FakeIntentManager(); |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 60 | private TestServiceDirectory testDirectory; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 61 | |
| 62 | @Before |
| 63 | public void setUp() throws Exception { |
| 64 | virtualNetworkManagerStore = new DistributedVirtualNetworkStore(); |
| 65 | |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 66 | coreService = new VirtualNetworkDeviceManagerTest.TestCoreService(); |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 67 | TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 68 | TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService()); |
| 69 | virtualNetworkManagerStore.activate(); |
| 70 | |
| 71 | manager = new VirtualNetworkManager(); |
| 72 | manager.store = virtualNetworkManagerStore; |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 73 | manager.intentService = intentService; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 74 | NetTestTools.injectEventDispatcher(manager, new TestEventDispatcher()); |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 75 | |
| 76 | testDirectory = new TestServiceDirectory(); |
| 77 | TestUtils.setField(manager, "serviceDirectory", testDirectory); |
| 78 | |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 79 | manager.activate(); |
| 80 | } |
| 81 | |
| 82 | @After |
| 83 | public void tearDown() { |
| 84 | virtualNetworkManagerStore.deactivate(); |
| 85 | manager.deactivate(); |
| 86 | NetTestTools.injectEventDispatcher(manager, null); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Tests the getDevices(), getAvailableDevices(), getDeviceCount(), getDevice(), and isAvailable() methods. |
| 91 | */ |
| 92 | @Test |
| 93 | public void testGetDevices() { |
| 94 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 95 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 96 | VirtualDevice device1 = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
| 97 | VirtualDevice device2 = manager.createVirtualDevice(virtualNetwork.id(), DID2); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 98 | |
| 99 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 100 | |
| 101 | // test the getDevices() method |
| 102 | Iterator<Device> it = deviceService.getDevices().iterator(); |
| 103 | assertEquals("The device set size did not match.", 2, Iterators.size(it)); |
| 104 | |
| 105 | // test the getAvailableDevices() method |
| 106 | Iterator<Device> it2 = deviceService.getAvailableDevices().iterator(); |
| 107 | assertEquals("The device set size did not match.", 2, Iterators.size(it2)); |
| 108 | |
| 109 | // test the getDeviceCount() method |
| 110 | assertEquals("The device set size did not match.", 2, deviceService.getDeviceCount()); |
| 111 | |
| 112 | // test the getDevice() method |
| 113 | assertEquals("The expect device did not match.", device1, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 114 | deviceService.getDevice(DID1)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 115 | assertNotEquals("The expect device should not have matched.", device1, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 116 | deviceService.getDevice(DID2)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 117 | |
| 118 | // test the isAvailable() method |
| 119 | assertTrue("The expect device availability did not match.", |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 120 | deviceService.isAvailable(DID1)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 121 | assertFalse("The expect device availability did not match.", |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 122 | deviceService.isAvailable(DID3)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Tests querying for a device using a null device identifier. |
| 127 | */ |
| 128 | @Test(expected = NullPointerException.class) |
| 129 | public void testGetDeviceByNullId() { |
| 130 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 131 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 132 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 133 | |
| 134 | // test the getDevice() method with null device id value. |
| 135 | deviceService.getDevice(null); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Tests querying for a device using a null device type. |
| 140 | */ |
| 141 | @Test(expected = NullPointerException.class) |
| 142 | public void testGetDeviceByNullType() { |
| 143 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 144 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 145 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 146 | |
| 147 | // test the getDevices() method with null type value. |
| 148 | deviceService.getDevices(null); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Tests the isAvailable method using a null device identifier. |
| 153 | */ |
| 154 | @Test(expected = NullPointerException.class) |
| 155 | public void testIsAvailableByNullId() { |
| 156 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 157 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 158 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 159 | |
| 160 | // test the isAvailable() method with null device id value. |
| 161 | deviceService.isAvailable(null); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Tests querying for a device and available devices by device type. |
| 166 | */ |
| 167 | @Test |
| 168 | public void testGetDeviceType() { |
| 169 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 170 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 171 | manager.createVirtualDevice(virtualNetwork.id(), DID1); |
| 172 | manager.createVirtualDevice(virtualNetwork.id(), DID2); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 173 | |
| 174 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 175 | |
| 176 | // test the getDevices(Type) method. |
| 177 | Iterator<Device> it = deviceService.getDevices(Device.Type.VIRTUAL).iterator(); |
| 178 | assertEquals("The device set size did not match.", 2, Iterators.size(it)); |
| 179 | Iterator<Device> it2 = deviceService.getDevices(Device.Type.SWITCH).iterator(); |
| 180 | assertEquals("The device set size did not match.", 0, Iterators.size(it2)); |
| 181 | |
| 182 | // test the getAvailableDevices(Type) method. |
| 183 | Iterator<Device> it3 = deviceService.getAvailableDevices(Device.Type.VIRTUAL).iterator(); |
| 184 | assertEquals("The device set size did not match.", 2, Iterators.size(it3)); |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Tests querying the role of a device by null device identifier. |
| 189 | */ |
| 190 | @Test(expected = NullPointerException.class) |
| 191 | public void testGetRoleByNullId() { |
| 192 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 193 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 194 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 195 | |
| 196 | // test the getRole() method using a null device identifier |
| 197 | deviceService.getRole(null); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Tests querying the role of a device by device identifier. |
| 202 | */ |
| 203 | @Test |
| 204 | public void testGetRole() { |
| 205 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 206 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 207 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 208 | |
| 209 | // test the getRole() method |
| 210 | assertEquals("The expect device role did not match.", MastershipRole.MASTER, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 211 | deviceService.getRole(DID1)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Tests querying the ports of a device by null device identifier. |
| 216 | */ |
| 217 | @Test(expected = NullPointerException.class) |
| 218 | public void testGetPortsByNullId() { |
| 219 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 220 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 221 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 222 | |
| 223 | // test the getPorts() method using a null device identifier |
| 224 | deviceService.getPorts(null); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Tests querying the ports of a device by device identifier. |
| 229 | */ |
| 230 | @Test |
| 231 | public void testGetPorts() { |
| 232 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 233 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 234 | VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
| 235 | manager.createVirtualDevice(virtualNetwork.id(), DID2); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 236 | |
| 237 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 238 | |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 239 | ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 240 | |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 241 | manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(1), cp); |
| 242 | manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(2), cp); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 243 | |
| 244 | // test the getPorts() method |
| 245 | assertEquals("The port set size did not match.", 2, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 246 | deviceService.getPorts(DID1).size()); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 247 | assertEquals("The port set size did not match.", 0, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 248 | deviceService.getPorts(DID2).size()); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Tests querying the port of a device by device identifier and port number. |
| 253 | */ |
| 254 | @Test |
| 255 | public void testGetPort() { |
| 256 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 257 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 258 | VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
| 259 | manager.createVirtualDevice(virtualNetwork.id(), DID2); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 260 | |
| 261 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 262 | |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 263 | ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1)); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 264 | |
| 265 | VirtualPort virtualPort1 = manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 266 | PortNumber.portNumber(1), cp); |
| 267 | manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(2), cp); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 268 | |
| 269 | // test the getPort() method |
| 270 | assertEquals("The port did not match as expected.", virtualPort1, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 271 | deviceService.getPort(DID1, PortNumber.portNumber(1))); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 272 | assertNotEquals("The port did not match as expected.", virtualPort1, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 273 | deviceService.getPort(DID1, PortNumber.portNumber(3))); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Tests querying the port statistics of a device by null device identifier. |
| 278 | */ |
| 279 | @Test(expected = NullPointerException.class) |
| 280 | public void testGetPortsStatisticsByNullId() { |
| 281 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 282 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 283 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 284 | |
| 285 | // test the getPortStatistics() method using a null device identifier |
| 286 | deviceService.getPortStatistics(null); |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Tests querying the port statistics of a device by device identifier. |
| 291 | */ |
| 292 | @Test |
| 293 | public void testGetPortStatistics() { |
| 294 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 295 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 296 | VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
| 297 | manager.createVirtualDevice(virtualNetwork.id(), DID2); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 298 | |
| 299 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 300 | |
| 301 | // test the getPortStatistics() method |
| 302 | assertEquals("The port statistics set size did not match.", 0, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 303 | deviceService.getPortStatistics(DID1).size()); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Tests querying the port delta statistics of a device by null device identifier. |
| 308 | */ |
| 309 | @Test(expected = NullPointerException.class) |
| 310 | public void testGetPortsDeltaStatisticsByNullId() { |
| 311 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 312 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
| 313 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 314 | |
| 315 | // test the getPortDeltaStatistics() method using a null device identifier |
| 316 | deviceService.getPortDeltaStatistics(null); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Tests querying the port delta statistics of a device by device identifier. |
| 321 | */ |
| 322 | @Test |
| 323 | public void testGetPortDeltaStatistics() { |
| 324 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
| 325 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 326 | VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
| 327 | manager.createVirtualDevice(virtualNetwork.id(), DID2); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 328 | |
| 329 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
| 330 | |
| 331 | // test the getPortDeltaStatistics() method |
| 332 | assertEquals("The port delta statistics set size did not match.", 0, |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 333 | deviceService.getPortDeltaStatistics(DID1).size()); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | /** |
| 337 | * Core service test class. |
| 338 | */ |
| 339 | private class TestCoreService extends CoreServiceAdapter { |
| 340 | |
| 341 | @Override |
| 342 | public IdGenerator getIdGenerator(String topic) { |
| 343 | return new IdGenerator() { |
| 344 | private AtomicLong counter = new AtomicLong(0); |
| 345 | |
| 346 | @Override |
| 347 | public long getNewId() { |
| 348 | return counter.getAndIncrement(); |
| 349 | } |
| 350 | }; |
| 351 | } |
| 352 | } |
| 353 | } |