1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.core;
\r
4 import io.netty.channel.ChannelHandlerContext;
\r
6 import java.util.ArrayList;
\r
7 import java.util.List;
\r
9 import org.junit.Assert;
\r
10 import org.junit.Before;
\r
11 import org.junit.Test;
\r
12 import org.junit.runner.RunWith;
\r
13 import org.mockito.Mock;
\r
14 import org.mockito.runners.MockitoJUnitRunner;
\r
15 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
\r
19 * @author michal.polkorab
\r
21 @RunWith(MockitoJUnitRunner.class)
\r
22 public class OFVersionDetectorTest {
\r
25 ChannelHandlerContext channelHandlerContext;
\r
27 private OFVersionDetector detector;
\r
28 private List<Object> list = new ArrayList<>();
\r
31 * Sets up test environment
\r
34 public void setUp() {
\r
36 detector = new OFVersionDetector();
\r
41 * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
\r
47 public void testDecode13ProtocolMessage() throws Exception {
\r
48 detector.decode(channelHandlerContext,
\r
49 ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"),
\r
52 Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0))
\r
53 .getMessageBuffer().readableBytes());
\r
58 * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
\r
64 public void testDecodeNotSupportedVersionProtocolMessage() throws Exception {
\r
65 detector.decode(channelHandlerContext,
\r
66 ByteBufUtils.hexStringToByteBuf("01 00 00 08 00 00 00 01"),
\r
69 Assert.assertEquals("List is not empty", 0, list.size());
\r