2 * Copyright (c) 2014 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
8 package org.opendaylight.openflowjava.protocol.impl.core;
10 import static org.mockito.Mockito.times;
11 import static org.mockito.Mockito.verify;
12 import io.netty.buffer.ByteBuf;
13 import io.netty.channel.ChannelHandlerContext;
15 import java.net.InetSocketAddress;
17 import org.junit.Assert;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.mockito.Mock;
21 import org.mockito.MockitoAnnotations;
22 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
23 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
29 public class OFDatagramPacketDecoderTest {
30 @Mock DeserializationFactory deserializationFactory;
31 @Mock ChannelHandlerContext ctx;
32 @Mock ByteBuf messageBufferMock;
34 private VersionMessageUdpWrapper msgWrapper;
37 public void startUp(){
38 MockitoAnnotations.initMocks(this);
43 OFDatagramPacketDecoder decoder = new OFDatagramPacketDecoder();
44 decoder.setDeserializationFactory(deserializationFactory);
45 msgWrapper = new VersionMessageUdpWrapper(EncodeConstants.OF13_VERSION_ID, messageBufferMock, new InetSocketAddress("10.0.0.1", 6653));
47 decoder.channelRead0(ctx, msgWrapper);
48 } catch (Exception e) {
49 Assert.fail("Exception occured");
51 verify(messageBufferMock, times(1)).release();