Search in sources :

Example 36 with VirtualNetwork

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)));
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) DeviceService(org.onosproject.net.device.DeviceService) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 37 with VirtualNetwork

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));
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Device(org.onosproject.net.Device) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 38 with VirtualNetwork

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);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 39 with VirtualNetwork

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);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 40 with VirtualNetwork

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);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Aggregations

VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)98 Test (org.junit.Test)82 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)38 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)24 ConnectPoint (org.onosproject.net.ConnectPoint)24 TopologyService (org.onosproject.net.topology.TopologyService)24 Topology (org.onosproject.net.topology.Topology)23 DeviceService (org.onosproject.net.device.DeviceService)15 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 DisjointPath (org.onosproject.net.DisjointPath)11 LinkService (org.onosproject.net.link.LinkService)10 ArrayList (java.util.ArrayList)8 HostService (org.onosproject.net.host.HostService)8 TenantId (org.onosproject.net.TenantId)7 Path (org.onosproject.net.Path)6 PathService (org.onosproject.net.topology.PathService)5 TopologyCluster (org.onosproject.net.topology.TopologyCluster)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)4 Link (org.onosproject.net.Link)4