use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.
the class HandshakeManagerImplTest method testVersionNegotiation10InBitmapSwitchStarts.
/**
* Test of version negotiation Where bitmap version {0x05,0x01}.
*/
@Test
public void testVersionNegotiation10InBitmapSwitchStarts() throws Exception {
LOG.debug("testVersionNegotiation10InBitmap-ss");
Short version = OFConstants.OFP_VERSION_1_0;
handshakeManager.setUseVersionBitmap(true);
HelloMessageBuilder helloMessage = createHelloMessage(version, helloXid);
addVersionBitmap(Lists.newArrayList((short) 0x05, OFConstants.OFP_VERSION_1_0), helloMessage);
Mockito.when(adapter.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(Futures.immediateFuture(resultFeatures));
handshakeManager.shake(null);
handshakeManager.shake(helloMessage.build());
Mockito.verify(handshakeListener).onHandshakeSuccessful(resultFeatures.getResult(), version);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.
the class HandshakeManagerImplTest method testVersionNegotiation10InBitmap.
/**
* Test of version negotiation Where bitmap version {0x05,0x01}.
*/
@Test
public void testVersionNegotiation10InBitmap() throws Exception {
LOG.debug("testVersionNegotiation10InBitmap");
Short version = OFConstants.OFP_VERSION_1_0;
handshakeManager.setUseVersionBitmap(true);
HelloMessageBuilder helloMessage = createHelloMessage(version, helloXid);
addVersionBitmap(Lists.newArrayList((short) 0x05, OFConstants.OFP_VERSION_1_0), helloMessage);
Mockito.when(adapter.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(Futures.immediateFuture(resultFeatures));
handshakeManager.shake(helloMessage.build());
Mockito.verify(handshakeListener).onHandshakeSuccessful(resultFeatures.getResult(), version);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.
the class HelloMessageFactoryTest method testBadType.
/**
* Testing {@link HelloMessageFactory} if incorrect version is set.
*/
@Test
public void testBadType() {
ByteBuf bb = BufferHelper.buildBuffer(// type
"00 02 " + // length
"00 0c " + // bitmap 1
"00 00 00 11 " + // bitmap 2
"00 00 00 00 " + // padding
"00 00 00 00");
HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertEquals("Wrong - no element has been expected", 0, builtByFactory.getElements().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.
the class HelloMessageFactoryTest method testWithPadding.
/**
* Testing {@link HelloMessageFactory} for correct length with padding.
*/
@Test
public void testWithPadding() {
ByteBuf bb = BufferHelper.buildBuffer(// type
"00 01 " + // length
"00 0c " + // bitmap 1
"00 00 00 11 " + // bitmap 2
"00 00 00 00 " + // padding
"00 00 00 00");
HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb);
List<Elements> element = createElement(8, HelloElementType.VERSIONBITMAP.getIntValue());
Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType());
Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerInitialImplTest method testOnHelloMessage.
@Test
public void testOnHelloMessage() throws Exception {
HelloMessageBuilder helloMessageBld = new HelloMessageBuilder().setXid(42L).setVersion(OFConstants.OFP_VERSION_1_3);
openflowProtocolListenerInitial.onHelloMessage(helloMessageBld.build());
Mockito.verify(handshakeManager).shake(Matchers.<HelloMessage>any());
}
Aggregations