Search in sources :

Example 1 with EchoInput

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

the class EchoInputMessageFactoryTest method testData.

/**
 * Testing of {@link EchoInputMessageFactory} for correct data serialization.
 */
@Test
public void testData() throws Exception {
    byte[] dataToTest = new byte[] { 91, 92, 93, 94, 95, 96, 97, 98 };
    EchoInputBuilder eib = new EchoInputBuilder();
    BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);
    eib.setData(dataToTest);
    EchoInput ei = eib.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    echoFactory.serialize(ei, out);
    BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8 + dataToTest.length);
    byte[] outData = new byte[dataToTest.length];
    out.readBytes(outData);
    Assert.assertArrayEquals("Wrong - different output data.", dataToTest, outData);
    out.release();
}
Also used : EchoInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput) EchoInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with EchoInput

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

the class EchoInputMessageFactoryTest method testV13.

/**
 * Testing of {@link EchoInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testV13() throws Exception {
    EchoInputBuilder eib = new EchoInputBuilder();
    BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);
    EchoInput ei = eib.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    echoFactory.serialize(ei, out);
    BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
}
Also used : EchoInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput) EchoInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with EchoInput

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

the class EchoInputMessageFactoryTest method testV10.

/**
 * Testing of {@link EchoInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testV10() throws Exception {
    EchoInputBuilder eib = new EchoInputBuilder();
    BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID);
    EchoInput ei = eib.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    echoFactory.serialize(ei, out);
    BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
}
Also used : EchoInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput) EchoInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with EchoInput

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

the class EchoServiceTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    EchoInputBuilder sendEchoInput = new EchoInputBuilder().setData(DUMMY_DATA);
    final OfHeader request = this.echoService.buildRequest(new Xid(DUMMY_XID_VALUE), sendEchoInput);
    assertEquals(DUMMY_XID_VALUE, request.getXid());
    assertTrue(request instanceof EchoInput);
    final byte[] data = ((EchoInput) request).getData();
    assertArrayEquals(DUMMY_DATA, data);
    assertEquals(OFConstants.OFP_VERSION_1_3, request.getVersion().shortValue());
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) EchoInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) EchoInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 EchoInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput)4 EchoInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder)4 ByteBuf (io.netty.buffer.ByteBuf)3 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)1 OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)1