Add ability to administratively remove ports of an offline device.
Change-Id: Iaee085be1cd53f783ed80e7c277403eb65ef6d8f
diff --git a/core/net/src/test/java/org/onosproject/net/device/impl/DeviceManagerTest.java b/core/net/src/test/java/org/onosproject/net/device/impl/DeviceManagerTest.java
index 601e6c3..3e1e4d1 100644
--- a/core/net/src/test/java/org/onosproject/net/device/impl/DeviceManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/device/impl/DeviceManagerTest.java
@@ -246,7 +246,31 @@
assertNotNull("device should be found", service.getDevice(DID2));
assertEquals("incorrect device count", 1, service.getDeviceCount());
assertEquals("incorrect available device count", 1, service.getAvailableDeviceCount());
+ }
+ @Test
+ public void removeDevicePorts() {
+ connectDevice(DID1, SW1);
+ List<PortDescription> pds = new ArrayList<>();
+ pds.add(DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).build());
+ pds.add(DefaultPortDescription.builder().withPortNumber(P2).isEnabled(true).build());
+ pds.add(DefaultPortDescription.builder().withPortNumber(P3).isEnabled(true).build());
+ providerService.updatePorts(DID1, pds);
+ validateEvents(DEVICE_ADDED, PORT_ADDED, PORT_ADDED, PORT_ADDED);
+
+ // Try removing ports while device is available/connected; it should be a no-op.
+ admin.removeDevicePorts(DID1);
+ assertEquals("wrong port count", 3, service.getPorts(DID1).size());
+
+ // Disconnect device
+ providerService.deviceDisconnected(DID1);
+ assertFalse("device should not be available", service.isAvailable(DID1));
+ validateEvents(DEVICE_AVAILABILITY_CHANGED);
+
+ // Now remove ports for real
+ admin.removeDevicePorts(DID1);
+ validateEvents(PORT_REMOVED, PORT_REMOVED, PORT_REMOVED);
+ assertEquals("wrong port count", 0, service.getPorts(DID1).size());
}
protected void validateEvents(Enum... types) {