Search in sources :

Example 76 with DeviceEvent

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

the class MQEventHandlerTest method switchAdd.

@Test
public void switchAdd() {
    DeviceEvent de = deviceEvent(DEVICE_ADDED, DID1);
    deviceListener.event(de);
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Example 77 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project fabric-tna by stratum.

the class IntManagerTest method testAddDevice.

/**
 * Test sending new device event to trigger device config update.
 */
@Test
public void testAddDevice() {
    testActivateWithConfig();
    DeviceListener listener = deviceListener.getValue();
    CompletableFuture<Void> completableFuture = new CompletableFuture<>();
    Device newDevice = createMock(Device.class);
    IntProgrammable newIntProgrammable = createMock(IntProgrammable.class);
    expect(newDevice.id()).andReturn(DEVICE_ID_2).anyTimes();
    expect(newDevice.is(IntProgrammable.class)).andReturn(true).anyTimes();
    expect(newDevice.as(IntProgrammable.class)).andReturn(newIntProgrammable).anyTimes();
    expect(newIntProgrammable.init()).andReturn(true).once();
    expect(newIntProgrammable.setUpIntConfig(INT_CONFIG_1)).andAnswer(() -> {
        completableFuture.complete(null);
        return true;
    }).once();
    replay(newDevice, newIntProgrammable);
    DeviceEvent deviceEvent = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, newDevice);
    listener.event(deviceEvent);
    try {
        completableFuture.get(1, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        fail("Didn't get expected call within 1 second.");
    }
    verifyAll();
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceListener(org.onosproject.net.device.DeviceListener) CompletableFuture(java.util.concurrent.CompletableFuture) Device(org.onosproject.net.Device) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

DeviceEvent (org.onosproject.net.device.DeviceEvent)77 Test (org.junit.Test)42 Device (org.onosproject.net.Device)26 DefaultDevice (org.onosproject.net.DefaultDevice)17 DefaultPort (org.onosproject.net.DefaultPort)17 PortDescription (org.onosproject.net.device.PortDescription)14 PortNumber (org.onosproject.net.PortNumber)11 Port (org.onosproject.net.Port)10 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)10 ProviderId (org.onosproject.net.provider.ProviderId)10 ArrayList (java.util.ArrayList)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 Timestamp (org.onosproject.store.Timestamp)8 MessageSubject (org.onosproject.store.cluster.messaging.MessageSubject)8 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)8 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)8 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)8 BiFunction (java.util.function.BiFunction)7 Function (java.util.function.Function)7 DeviceDescription (org.onosproject.net.device.DeviceDescription)7