Search in sources :

Example 1 with GetAsyncOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder in project openflowplugin by opendaylight.

the class SalAsyncConfigServiceImplTest method testGetAsyncTest.

@Test
public void testGetAsyncTest() throws Exception {
    final GetAsyncOutput getAsyncOutput = new GetAsyncOutputBuilder().build();
    final RpcResult<GetAsyncOutput> replyRpcResult = RpcResultBuilder.success(getAsyncOutput).build();
    final ListenableFuture<RpcResult<GetAsyncOutput>> replyFuture = Futures.immediateFuture(replyRpcResult);
    Mockito.when(mockedRequestContext.getFuture()).thenReturn(replyFuture);
    final Future<RpcResult<GetAsyncOutput>> getAsyncResult = salAsyncConfigService.getAsync(new GetAsyncInputBuilder().build());
    Assert.assertNotNull(getAsyncResult);
    Assert.assertTrue(getAsyncResult.isDone());
    Assert.assertTrue(getAsyncResult.get().isSuccessful());
    verify(mockedRequestContextStack).createRequestContext();
    verify(mockedOutboundQueue).commitEntry(Matchers.eq(ServiceMocking.DUMMY_XID_VALUE), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
}
Also used : GetAsyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncInputBuilder) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAsyncOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder) GetAsyncOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutput) Test(org.junit.Test)

Example 2 with GetAsyncOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactory method deserialize.

@Override
public GetAsyncOutput deserialize(ByteBuf rawMessage) {
    GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
    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 : GetAsyncOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder)

Example 3 with GetAsyncOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPacketInMask(createPacketInMask());
    builder.setPortStatusMask(createPortStatusMask());
    builder.setFlowRemovedMask(createFlowRemowedMask());
    GetAsyncOutput message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32);
    Assert.assertEquals("Wrong packetInMask", 7, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong packetInMask", 0, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 7, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong portStatusMask", 0, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 15, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong flowRemovedMask", 0, serializedBuffer.readUnsignedInt());
}
Also used : GetAsyncOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder) GetAsyncOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with GetAsyncOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactoryTest method testSetAsyncInputWithNullMasks.

@Test
public void testSetAsyncInputWithNullMasks() throws Exception {
    GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPacketInMask(null);
    builder.setPortStatusMask(null);
    builder.setFlowRemovedMask(null);
    GetAsyncOutput message = builder.build();
    GetAsyncReplyMessageFactory serializer = new GetAsyncReplyMessageFactory();
    SerializerRegistry registry = new SerializerRegistryImpl();
    registry.init();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
    Assert.assertTrue("Unexpected data", serializedBuffer.readableBytes() == 0);
}
Also used : SerializerRegistry(org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry) GetAsyncOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder) SerializerRegistryImpl(org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl) GetAsyncOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 GetAsyncOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 GetAsyncOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput)2 SerializerRegistry (org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry)1 SerializerRegistryImpl (org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl)1 GetAsyncInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncInputBuilder)1 GetAsyncOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutput)1 GetAsyncOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder)1 OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1