Search in sources :

Example 1 with SetAsyncInput

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

the class SalAsyncConfigServiceImplTest method testSetAsync.

@Test
public void testSetAsync() throws Exception {
    final SetAsyncInput setAsyncInput = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder().build();
    final RpcResult<SetAsyncInput> replyRpcResult = RpcResultBuilder.success(setAsyncInput).build();
    final ListenableFuture<RpcResult<SetAsyncInput>> replyFuture = Futures.immediateFuture(replyRpcResult);
    Mockito.when(mockedRequestContext.getFuture()).thenReturn(replyFuture);
    final Future<RpcResult<Void>> setAsyncResult = salAsyncConfigService.setAsync(new SetAsyncInputBuilder().build());
    Assert.assertNotNull(setAsyncResult);
    Assert.assertTrue(setAsyncResult.isDone());
    Assert.assertTrue(setAsyncResult.get().isSuccessful());
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : SetAsyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.SetAsyncInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) SetAsyncInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput) Test(org.junit.Test)

Example 2 with SetAsyncInput

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

the class SetAsyncInputMessageFactory method deserialize.

@Override
public SetAsyncInput deserialize(ByteBuf rawMessage) {
    SetAsyncInputBuilder builder = new SetAsyncInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPacketInMask(decodePacketInMask(rawMessage));
    builder.setPortStatusMask(decodePortStatusMask(rawMessage));
    builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));
    return builder.build();
}
Also used : SetAsyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder)

Example 3 with SetAsyncInput

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

the class SetAsyncInputMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 00 00 00 00 00 00 00 " + "07 00 00 00 00 00 00 00 0f 00 00 00 00");
    SetAsyncInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(deserializedMessage);
    Assert.assertEquals("Wrong packet in mask ", createPacketInMask().get(0), deserializedMessage.getPacketInMask().get(0));
    Assert.assertEquals("Wrong packet in mask ", createPacketInMask().get(1), deserializedMessage.getPacketInMask().get(1));
    Assert.assertEquals("Wrong port status mask ", createPortStatusMask().get(0), deserializedMessage.getPortStatusMask().get(0));
    Assert.assertEquals("Wrong port status mask ", createPortStatusMask().get(1), deserializedMessage.getPortStatusMask().get(1));
    Assert.assertEquals("Wrong flow removed mask ", createFlowRemowedMask().get(0), deserializedMessage.getFlowRemovedMask().get(0));
    Assert.assertEquals("Wrong flow removed mask ", createFlowRemowedMask().get(1), deserializedMessage.getFlowRemovedMask().get(1));
}
Also used : SetAsyncInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with SetAsyncInput

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

the class SetAsyncInputMessageFactoryTest method testSetAsyncInputMessage.

/**
 * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testSetAsyncInputMessage() throws Exception {
    SetAsyncInputBuilder builder = new SetAsyncInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPacketInMask(createPacketInMask());
    builder.setPortStatusMask(createPortStatusMask());
    builder.setFlowRemovedMask(createFlowRemowedMask());
    SetAsyncInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    setAsyncFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 28, 32);
    Assert.assertEquals("Wrong packetInMask", 7, out.readUnsignedInt());
    Assert.assertEquals("Wrong packetInMask", 0, out.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 7, out.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 15, out.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 0, out.readUnsignedInt());
}
Also used : SetAsyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder) SetAsyncInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with SetAsyncInput

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

the class SetAsyncInputMessageFactoryTest method testSetAsyncInputWithNullMasks.

/**
 * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testSetAsyncInputWithNullMasks() throws Exception {
    SetAsyncInputBuilder builder = new SetAsyncInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPacketInMask(null);
    builder.setPortStatusMask(null);
    builder.setFlowRemovedMask(null);
    SetAsyncInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    setAsyncFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 28, 8);
    Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
Also used : SetAsyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder) SetAsyncInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 SetAsyncInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput)4 ByteBuf (io.netty.buffer.ByteBuf)3 SetAsyncInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder)3 SetAsyncInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.SetAsyncInputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1