Search in sources :

Example 16 with HelloMessage

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);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) Test(org.junit.Test)

Example 17 with HelloMessage

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);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) Test(org.junit.Test)

Example 18 with HelloMessage

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());
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) ByteBuf(io.netty.buffer.ByteBuf) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 19 with HelloMessage

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());
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) ByteBuf(io.netty.buffer.ByteBuf) Elements(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 20 with HelloMessage

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());
}
Also used : HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 HelloMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)14 HelloMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage)10 ByteBuf (io.netty.buffer.ByteBuf)6 GetFeaturesInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput)6 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)4 DefaultDeserializerFactoryTest (org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest)3 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)2 GetFeaturesOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder)2 HelloInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput)2 Elements (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 List (java.util.List)1 EchoRequestMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)1 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)1 ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)1 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1 PacketInMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder)1 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)1