use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder in project openflowplugin by opendaylight.
the class RpcManagerImplTest method setUp.
@Before
public void setUp() {
final NodeKey nodeKey = new NodeKey(nodeId);
rpcManager = new RpcManagerImpl(new OpenflowProviderConfigBuilder().setRpcRequestsQuota(new NonZeroUint16Type(QUOTA_VALUE)).setIsStatisticsRpcEnabled(false).build(), rpcProviderRegistry, extensionConverterProvider, convertorExecutor, notificationPublishService);
FeaturesReply features = new GetFeaturesOutputBuilder().setVersion(OFConstants.OFP_VERSION_1_3).build();
Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeKey.getId());
Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
Mockito.when(connectionContext.getFeatures()).thenReturn(features);
Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
Mockito.when(rpcProviderRegistry.addRoutedRpcImplementation(Matchers.any(), Matchers.any(RpcService.class))).thenReturn(routedRpcRegistration);
Mockito.when(contexts.remove(deviceInfo)).thenReturn(removedContexts);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactory method deserialize.
@Override
public GetFeaturesOutput deserialize(final ByteBuf rawMessage) {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(datapathId);
builder.setDatapathId(new BigInteger(1, datapathId));
builder.setBuffers(rawMessage.readUnsignedInt());
builder.setTables(rawMessage.readUnsignedByte());
rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));
builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));
List<PhyPort> ports = new ArrayList<>();
while (rawMessage.readableBytes() > 0) {
ports.add(deserializePort(rawMessage));
}
builder.setPhyPort(ports);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder in project openflowplugin by opendaylight.
the class SwitchFeaturesUtilTest method setUp.
/**
* Initialization of
* {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
* .GetFeaturesOutputBuilder GetFeaturesOutputBuilder}
* and {@link SwitchFeaturesUtil SwitchFeaturesUtil}.
*/
@Before
public void setUp() throws Exception {
featuresOutputBuilder = new GetFeaturesOutputBuilder();
swUtil = SwitchFeaturesUtil.getInstance();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder in project openflowplugin by opendaylight.
the class ConnectionManagerImplTest method testOnSwitchConnected1.
/**
* Test method for
* {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
* org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
* invoking onConnectionReady first, scenario:
* <ol>
* <li>send hello to device (rpc with void output)</li>
* <li>receive hello from device (notification)</li>
* <li>send getFeature to device (rpc with getFeatureOutput)</li>
* <li>wait for rpc to finish with getFeatureOutput</li>
* </ol>
*
* @throws InterruptedException - interrupted exception
*/
@Test
public void testOnSwitchConnected1() throws Exception {
connectionManagerImpl.onSwitchConnected(connection);
Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
// prepare void reply (hello rpc output)
final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
// prepare getFeature reply (getFeture rpc output)
final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
// fire handshake
connectionReadyListenerAC.getValue().onConnectionReady();
// deliver hello send output (void)
Thread.sleep(100L);
final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
voidResponseFx.set(helloResponse);
// send hello reply
final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
ofpListenerAC.getValue().onHelloMessage(hello);
// deliver getFeature output
Thread.sleep(100L);
final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
featureResponseFx.set(rpcFeaturesOutput);
Mockito.verify(deviceConnectedHandler, Mockito.timeout(500)).deviceConnected(Matchers.any(ConnectionContext.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder in project openflowplugin by opendaylight.
the class ConnectionManagerImplTest method testOnSwitchConnected2.
/**
* Test method for
* {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
* org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
* invoking onHelloMessage, scenario:
* <ol>
* <li>receive hello from device (notification)</li>
* <li>send hello to device (rpc with void output)</li>
* <li>send getFeature to device (rpc with getFeatureOutput)</li>
* <li>wait for rpc to finish with getFeatureOutput</li>
* </ol>
*
* @throws InterruptedException - interrupted exception
*/
@Test
public void testOnSwitchConnected2() throws Exception {
connectionManagerImpl.onSwitchConnected(connection);
Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
// prepare void reply (hello rpc output)
final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
// prepare getFeature reply (getFeture rpc output)
final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
// fire handshake - send hello reply
final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
ofpListenerAC.getValue().onHelloMessage(hello);
// notify about connection ready
connectionReadyListenerAC.getValue().onConnectionReady();
// deliver hello send output (void)
Thread.sleep(100L);
final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
voidResponseFx.set(helloResponse);
// deliver getFeature output
Thread.sleep(100L);
final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
featureResponseFx.set(rpcFeaturesOutput);
Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(Matchers.any(ConnectionContext.class));
}
Aggregations