Search in sources :

Example 11 with HelloMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.

the class OF10HelloMessageFactoryTest method testWithElements.

/**
 * Testing {@link OF10HelloMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithElements() {
    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(helloFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertNull("Wrong elements", builtByFactory.getElements());
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 12 with HelloMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.

the class HelloMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    HelloMessageBuilder builder = new HelloMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    HelloMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 13 with HelloMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.

the class HandshakeManagerImplTest method testVersionNegotiationNoCommonVersionInBitmap.

/**
 * Test of version negotiation Where bitmap version {0x05,0x02}.
 */
@Test
public void testVersionNegotiationNoCommonVersionInBitmap() throws Exception {
    LOG.debug("testVersionNegotiationNoCommonVersionInBitmap");
    Short version = (short) 0x05;
    expectedErrors = 1;
    handshakeManager.setUseVersionBitmap(true);
    HelloMessageBuilder helloMessage = createHelloMessage(version, helloXid);
    addVersionBitmap(Lists.newArrayList((short) 0x05, (short) 0x02), helloMessage);
    handshakeManager.shake(helloMessage.build());
    Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) Test(org.junit.Test)

Example 14 with HelloMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.

the class HandshakeManagerImplTest method testVersionNegotiation13InBitmap.

/**
 * Test of version negotiation Where bitmap version {0x05,0x04}.
 */
@Test
public void testVersionNegotiation13InBitmap() throws Exception {
    LOG.debug("testVersionNegotiation13InBitmap");
    Short version = OFConstants.OFP_VERSION_1_3;
    handshakeManager.setUseVersionBitmap(true);
    HelloMessageBuilder helloMessage = createHelloMessage(version, helloXid);
    addVersionBitmap(Lists.newArrayList((short) 0x05, OFConstants.OFP_VERSION_1_3), 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 15 with HelloMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage in project openflowplugin by opendaylight.

the class HandshakeManagerImplTest method testVersionNegotiation13InBitmapSwitchFirst.

/**
 * Test of version negotiation Where bitmap version {0x05,0x04}.
 */
@Test
public void testVersionNegotiation13InBitmapSwitchFirst() throws Exception {
    LOG.debug("testVersionNegotiation13InBitmap-ss");
    Short version = OFConstants.OFP_VERSION_1_3;
    handshakeManager.setUseVersionBitmap(true);
    HelloMessageBuilder helloMessage = createHelloMessage(version, helloXid);
    addVersionBitmap(Lists.newArrayList((short) 0x05, OFConstants.OFP_VERSION_1_3), 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)

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