Search in sources :

Example 1 with BarrierOutputBuilder

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

the class ConnectionManagerImplTest method setUp.

@Before
public void setUp() {
    final ThreadPoolLoggingExecutor threadPool = new ThreadPoolLoggingExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), "ofppool");
    connectionManagerImpl = new ConnectionManagerImpl(new OpenflowProviderConfigBuilder().setEchoReplyTimeout(new NonZeroUint32Type(ECHO_REPLY_TIMEOUT)).build(), threadPool);
    connectionManagerImpl.setDeviceConnectedHandler(deviceConnectedHandler);
    final InetSocketAddress deviceAddress = InetSocketAddress.createUnresolved("yahoo", 42);
    Mockito.when(connection.getRemoteAddress()).thenReturn(deviceAddress);
    Mockito.when(connection.isAlive()).thenReturn(true);
    Mockito.when(connection.barrier(Matchers.<BarrierInput>any())).thenReturn(RpcResultBuilder.success(new BarrierOutputBuilder().build()).buildFuture());
}
Also used : OpenflowProviderConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder) InetSocketAddress(java.net.InetSocketAddress) NonZeroUint32Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type) ThreadPoolLoggingExecutor(org.opendaylight.openflowplugin.impl.util.ThreadPoolLoggingExecutor) BarrierOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder) Before(org.junit.Before)

Example 2 with BarrierOutputBuilder

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

the class ConnectionAdapterImplTest method testConsume3.

/**
 * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with expected rpc.
 */
@Test
public void testConsume3() {
    final BarrierInputBuilder inputBuilder = new BarrierInputBuilder();
    inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    inputBuilder.setXid(42L);
    final BarrierInput barrierInput = inputBuilder.build();
    final RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput");
    final ResponseExpectedRpcListener<OfHeader> listener = new ResponseExpectedRpcListener<>(barrierInput, "failure", mockCache, key);
    cache.put(key, listener);
    final BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder();
    barrierBuilder.setXid(42L);
    final BarrierOutput barrierOutput = barrierBuilder.build();
    adapter.consume(barrierOutput);
    final ResponseExpectedRpcListener<?> ifPresent = cache.getIfPresent(key);
    Assert.assertNull("Listener was not discarded", ifPresent);
}
Also used : BarrierInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) BarrierInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder) BarrierOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder) BarrierOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput) Test(org.junit.Test)

Example 3 with BarrierOutputBuilder

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

the class ConnectionAdapterImplTest method testConsume2.

/**
 * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with unexpected rpc.
 */
@Test
public void testConsume2() {
    adapter.setResponseCache(mockCache);
    final BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder();
    barrierBuilder.setXid(42L);
    final BarrierOutput barrier = barrierBuilder.build();
    adapter.consume(barrier);
    verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class));
}
Also used : BarrierOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder) BarrierOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput) Test(org.junit.Test)

Example 4 with BarrierOutputBuilder

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

the class BarrierReplyMessageFactory method deserialize.

@Override
public BarrierOutput deserialize(ByteBuf rawMessage) {
    BarrierOutputBuilder builder = new BarrierOutputBuilder();
    builder.setVersion(getVersion());
    builder.setXid(rawMessage.readUnsignedInt());
    return builder.build();
}
Also used : BarrierOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder)

Example 5 with BarrierOutputBuilder

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

the class OF10BarrierReplyMessageFactoryTest method testSerialize.

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

Aggregations

BarrierOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder)6 Test (org.junit.Test)4 BarrierOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput)4 ByteBuf (io.netty.buffer.ByteBuf)2 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1 ThreadPoolLoggingExecutor (org.opendaylight.openflowplugin.impl.util.ThreadPoolLoggingExecutor)1 BarrierInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput)1 BarrierInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder)1 OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)1 NonZeroUint32Type (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type)1 OpenflowProviderConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder)1