Search in sources :

Example 1 with NotificationPublishService

use of org.opendaylight.controller.md.sal.binding.api.NotificationPublishService in project controller by opendaylight.

the class BackwardsCompatibleNotificationBrokerTest method initTest.

@Before
public void initTest() {
    final NotificationService notificationService = getNotificationService();
    final NotificationPublishService notificationPublishService = getNotificationPublishService();
    notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService, notificationService);
}
Also used : HeliumNotificationProviderServiceAdapter(org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter) NotificationService(org.opendaylight.controller.md.sal.binding.api.NotificationService) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Before(org.junit.Before)

Example 2 with NotificationPublishService

use of org.opendaylight.controller.md.sal.binding.api.NotificationPublishService in project controller by opendaylight.

the class OpenDaylightToasterTest method setupToaster.

@Before
public void setupToaster() {
    toaster = new OpendaylightToaster();
    toaster.setDataBroker(getDataBroker());
    toaster.init();
    // We'll mock the NotificationProviderService.
    NotificationPublishService mockNotification = mock(NotificationPublishService.class);
    toaster.setNotificationProvider(mockNotification);
}
Also used : NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Before(org.junit.Before)

Example 3 with NotificationPublishService

use of org.opendaylight.controller.md.sal.binding.api.NotificationPublishService in project openflowplugin by opendaylight.

the class DeviceContextImplTest method testProcessFlowRemovedMessage.

@Test
public void testProcessFlowRemovedMessage() throws Exception {
    // prepare translation result
    final FlowRemovedBuilder flowRemovedMdsalBld = new FlowRemovedBuilder().setTableId((short) 0).setPriority(42).setCookie(new FlowCookie(BigInteger.ONE)).setMatch(new MatchBuilder().build());
    final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
    Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(flowRemovedMdsalBld.build());
    // insert flow+flowId into local registry
    final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowRemovedMdsalBld.build());
    final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 0, new FlowId("ut-ofp:f456"));
    deviceContext.getDeviceFlowRegistry().storeDescriptor(flowRegKey, flowDescriptor);
    // prepare empty input message
    final FlowRemovedMessageBuilder flowRemovedBld = new FlowRemovedMessageBuilder();
    // prepare path to flow to be removed
    final KeyedInstanceIdentifier<Flow, FlowKey> flowToBeRemovedPath = nodeKeyIdent.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0)).child(Flow.class, new FlowKey(new FlowId("ut-ofp:f456")));
    deviceContext.setNotificationPublishService(mockedNotificationPublishService);
    deviceContext.processFlowRemovedMessage(flowRemovedBld.build());
}
Also used : FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) FlowRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Test(org.junit.Test)

Example 4 with NotificationPublishService

use of org.opendaylight.controller.md.sal.binding.api.NotificationPublishService in project openflowplugin by opendaylight.

the class DeviceContextImplTest method testProcessPacketInMessageFutureFailure.

@Test
public void testProcessPacketInMessageFutureFailure() {
    final PacketInMessage mockedPacketInMessage = mock(PacketInMessage.class);
    final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
    final ListenableFuture dummyFuture = Futures.immediateFailedFuture(new IllegalStateException());
    when(mockedNotificationPublishService.offerNotification(any(PacketReceived.class))).thenReturn(dummyFuture);
    deviceContext.setNotificationPublishService(mockedNotificationPublishService);
    deviceContext.processPacketInMessage(mockedPacketInMessage);
    verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_NOTIFICATION_REJECTED));
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Test(org.junit.Test)

Example 5 with NotificationPublishService

use of org.opendaylight.controller.md.sal.binding.api.NotificationPublishService in project openflowplugin by opendaylight.

the class DeviceContextImplTest method testProcessExperimenterMessage.

@Test
public void testProcessExperimenterMessage() {
    final ConvertorMessageFromOFJava mockedMessageConverter = mock(ConvertorMessageFromOFJava.class);
    final ExtensionConverterProvider mockedExtensionConverterProvider = mock(ExtensionConverterProvider.class);
    when(mockedExtensionConverterProvider.getMessageConverter(any(MessageTypeKey.class))).thenReturn(mockedMessageConverter);
    final ExperimenterDataOfChoice mockedExperimenterDataOfChoice = mock(ExperimenterDataOfChoice.class);
    final ExperimenterMessage experimenterMessage = new ExperimenterMessageBuilder().setExperimenterDataOfChoice(mockedExperimenterDataOfChoice).build();
    final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
    deviceContext.setNotificationPublishService(mockedNotificationPublishService);
    ((DeviceContextImpl) deviceContext).setExtensionConverterProvider(mockedExtensionConverterProvider);
    deviceContext.processExperimenterMessage(experimenterMessage);
    verify(mockedNotificationPublishService).offerNotification(any(ExperimenterMessageFromDev.class));
}
Also used : ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) ExtensionConverterProvider(org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider) ExperimenterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage) ExperimenterMessageFromDev(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDev) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MessageTypeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey) ConvertorMessageFromOFJava(org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Test(org.junit.Test)

Aggregations

NotificationPublishService (org.opendaylight.controller.md.sal.binding.api.NotificationPublishService)7 Test (org.junit.Test)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Before (org.junit.Before)2 PacketInMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage)2 PacketReceived (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived)2 NotificationService (org.opendaylight.controller.md.sal.binding.api.NotificationService)1 HeliumNotificationProviderServiceAdapter (org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter)1 MessageTypeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1 FlowDescriptor (org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor)1 FlowRegistryKey (org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey)1 ConvertorMessageFromOFJava (org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava)1 ExtensionConverterProvider (org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider)1 ExperimenterMessageFromDev (org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDev)1 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)1 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)1 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)1