use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkDeviceManagerTest method testGetPort.
/**
* Tests querying the port of a device by device identifier and port number.
*/
@Test
public void testGetPort() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
manager.createVirtualDevice(virtualNetwork.id(), DID2);
DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1));
VirtualPort virtualPort1 = manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(1), cp);
manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(2), cp);
// test the getPort() method
assertEquals("The port did not match as expected.", virtualPort1, deviceService.getPort(DID1, PortNumber.portNumber(1)));
assertNotEquals("The port did not match as expected.", virtualPort1, deviceService.getPort(DID1, PortNumber.portNumber(3)));
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkDeviceManagerTest method testGetDeviceType.
/**
* Tests querying for a device and available devices by device type.
*/
@Test
public void testGetDeviceType() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
manager.createVirtualDevice(virtualNetwork.id(), DID1);
manager.createVirtualDevice(virtualNetwork.id(), DID2);
DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
// test the getDevices(Type) method.
Iterator<Device> it = deviceService.getDevices(Device.Type.VIRTUAL).iterator();
assertEquals("The device set size did not match.", 2, Iterators.size(it));
Iterator<Device> it2 = deviceService.getDevices(Device.Type.SWITCH).iterator();
assertEquals("The device set size did not match.", 0, Iterators.size(it2));
// test the getAvailableDevices(Type) method.
Iterator<Device> it3 = deviceService.getAvailableDevices(Device.Type.VIRTUAL).iterator();
assertEquals("The device set size did not match.", 2, Iterators.size(it3));
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkDeviceManagerTest method testGetPortsByNullId.
/**
* Tests querying the ports of a device by null device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetPortsByNullId() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
// test the getPorts() method using a null device identifier
deviceService.getPorts(null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkDeviceManagerTest method testGetDeviceByNullId.
/**
* Tests querying for a device using a null device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetDeviceByNullId() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
// test the getDevice() method with null device id value.
deviceService.getDevice(null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkDeviceManagerTest method testGetRoleByNullId.
/**
* Tests querying the role of a device by null device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetRoleByNullId() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
// test the getRole() method using a null device identifier
deviceService.getRole(null);
}
Aggregations