2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.core;
11 import io.netty.channel.ChannelHandlerContext;
13 import java.util.ArrayList;
14 import java.util.List;
16 import org.junit.Assert;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mock;
21 import org.mockito.runners.MockitoJUnitRunner;
22 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
26 * @author michal.polkorab
28 @RunWith(MockitoJUnitRunner.class)
29 public class OFVersionDetectorTest {
32 ChannelHandlerContext channelHandlerContext;
34 private OFVersionDetector detector;
35 private List<Object> list = new ArrayList<>();
38 * Sets up test environment
43 detector = new OFVersionDetector();
48 * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
54 public void testDecode13ProtocolMessage() throws Exception {
55 detector.decode(channelHandlerContext,
56 ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"),
59 Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0))
60 .getMessageBuffer().readableBytes());
65 * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
71 public void testDecodeNotSupportedVersionProtocolMessage() throws Exception {
72 detector.decode(channelHandlerContext,
73 ByteBufUtils.hexStringToByteBuf("02 00 00 08 00 00 00 01"),
76 Assert.assertEquals("List is not empty", 0, list.size());