Search in sources :

Example 61 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testGetPortsStatisticsByNullId.

/**
 * Tests querying the port statistics of a device by null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetPortsStatisticsByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the getPortStatistics() method using a null device identifier
    deviceService.getPortStatistics(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 62 with DeviceService

use of org.onosproject.net.device.DeviceService 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 63 with DeviceService

use of org.onosproject.net.device.DeviceService 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 64 with DeviceService

use of org.onosproject.net.device.DeviceService 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 65 with DeviceService

use of org.onosproject.net.device.DeviceService 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)

Aggregations

DeviceService (org.onosproject.net.device.DeviceService)187 Device (org.onosproject.net.Device)75 DeviceId (org.onosproject.net.DeviceId)73 Port (org.onosproject.net.Port)59 ConnectPoint (org.onosproject.net.ConnectPoint)42 PortNumber (org.onosproject.net.PortNumber)40 List (java.util.List)30 Collectors (java.util.stream.Collectors)24 Set (java.util.Set)23 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)19 Logger (org.slf4j.Logger)19 ArrayList (java.util.ArrayList)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Optional (java.util.Optional)17 Test (org.junit.Test)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Collections (java.util.Collections)15 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)15 DriverHandler (org.onosproject.net.driver.DriverHandler)15 Collection (java.util.Collection)14