Search in sources :

Example 11 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder 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 12 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder 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)

Example 13 with HelloMessageBuilder

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

the class HandshakeManagerImplTest method testVersionNegotiation10InBitmapSwitchStarts.

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

Example 14 with HelloMessageBuilder

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

the class HandshakeManagerImplTest method testVersionNegotiation10InBitmap.

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

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

the class ConnectionAdapterImplStatisticsTest method testMessagePassCounter.

/**
 * Test counter for pass messages to consumer (counter US_MESSAGE_PASS has to be enabled).
 */
@Test
public void testMessagePassCounter() {
    if (!statCounters.isCounterEnabled(CounterEventTypes.US_MESSAGE_PASS)) {
        Assert.fail("Counter " + CounterEventTypes.US_MESSAGE_PASS + " is not enabled");
    }
    when(channel.pipeline()).thenReturn(pipeline);
    adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true, CHANNEL_OUTBOUND_QUEUE_SIZE);
    adapter.setMessageListener(messageListener);
    adapter.setSystemListener(systemListener);
    adapter.setConnectionReadyListener(readyListener);
    cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES).removalListener(REMOVAL_LISTENER).build();
    adapter.setResponseCache(cache);
    when(channel.disconnect()).thenReturn(channelFuture);
    DataObject message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    message = new ErrorMessageBuilder().build();
    adapter.consume(message);
    message = new ExperimenterMessageBuilder().build();
    adapter.consume(message);
    message = new FlowRemovedMessageBuilder().build();
    adapter.consume(message);
    message = new HelloMessageBuilder().build();
    adapter.consume(message);
    message = new MultipartReplyMessageBuilder().build();
    adapter.consume(message);
    message = new PacketInMessageBuilder().build();
    adapter.consume(message);
    message = new PortStatusMessageBuilder().build();
    adapter.consume(message);
    message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl consume method", 9, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue());
    adapter.disconnect();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Aggregations

HelloMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)15 Test (org.junit.Test)13 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 HelloMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage)4 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)2 EchoRequestMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)2 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)2 ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)2 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)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 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 PacketInMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder)2 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)2 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Elements (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements)1