use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerFullImplTest method testOnExperimenterMessage.
/**
* Test method for
* {@link OpenflowProtocolListenerFullImpl#onExperimenterMessage(
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage)}.
*/
@Test
public void testOnExperimenterMessage() {
ExperimenterMessage experimenterMessage = new ExperimenterMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
ofProtocolListener.onExperimenterMessage(experimenterMessage);
Mockito.verify(deviceReplyProcessor).processExperimenterMessage(Matchers.<ExperimenterMessage>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder in project openflowplugin by opendaylight.
the class ConnectionAdapterImplTest method testConsume.
/**
* Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications.
*/
@Test
public void testConsume() {
DataObject message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
message = new ErrorMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message);
message = new ExperimenterMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message);
message = new FlowRemovedMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message);
message = new HelloMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onHelloMessage((HelloMessage) message);
message = new MultipartReplyMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message);
message = new PacketInMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message);
message = new PortStatusMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message);
message = new SwitchIdleEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message);
message = new DisconnectEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message);
message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder in project openflowplugin by opendaylight.
the class VendorMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public ExperimenterMessage deserialize(ByteBuf message) {
Objects.requireNonNull(deserializerRegistry);
final long xid = message.readUnsignedInt();
final long expId = message.readUnsignedInt();
OFDeserializer<ExperimenterDataOfChoice> deserializer = deserializerRegistry.getDeserializer(ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey(EncodeConstants.OF10_VERSION_ID, expId));
final ExperimenterDataOfChoice vendorData = deserializer.deserialize(message);
final ExperimenterMessageBuilder messageBld = new ExperimenterMessageBuilder().setVersion((short) EncodeConstants.OF10_VERSION_ID).setXid(xid).setExperimenter(new ExperimenterId(expId)).setExperimenterDataOfChoice(vendorData);
return messageBld.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder in project openflowplugin by opendaylight.
the class ExperimenterMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public ExperimenterMessage deserialize(ByteBuf message) {
Objects.requireNonNull(deserializerRegistry);
final long xid = message.readUnsignedInt();
final long expId = message.readUnsignedInt();
final long expType = message.readUnsignedInt();
OFDeserializer<ExperimenterDataOfChoice> deserializer = deserializerRegistry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
final ExperimenterDataOfChoice vendorData = deserializer.deserialize(message);
ExperimenterMessageBuilder messageBld = new ExperimenterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(xid).setExperimenter(new ExperimenterId(expId)).setExpType(expType).setExperimenterDataOfChoice(vendorData);
return messageBld.build();
}
Aggregations