7e243ee81ea9dcd1634aef51dee309a656cbd425
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / core / OFDatagramPacketDecoderTest.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowjava.protocol.impl.core;
9
10 import static org.mockito.Mockito.times;
11 import static org.mockito.Mockito.verify;
12
13 import io.netty.buffer.ByteBuf;
14 import io.netty.channel.ChannelHandlerContext;
15 import java.net.InetSocketAddress;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
21 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
22
23 /**
24  * Unit tests for OFDatagramPacketDecoder.
25  *
26  * @author madamjak
27  */
28 public class OFDatagramPacketDecoderTest {
29     @Mock DeserializationFactory deserializationFactory;
30     @Mock ChannelHandlerContext ctx;
31     @Mock ByteBuf messageBufferMock;
32
33     private VersionMessageUdpWrapper msgWrapper;
34
35     @Before
36     public void startUp() {
37         MockitoAnnotations.initMocks(this);
38     }
39
40     @Test
41     public void test() {
42         OFDatagramPacketDecoder decoder = new OFDatagramPacketDecoder();
43         decoder.setDeserializationFactory(deserializationFactory);
44         msgWrapper = new VersionMessageUdpWrapper(EncodeConstants.OF_VERSION_1_3, messageBufferMock,
45                 new InetSocketAddress("10.0.0.1", 6653));
46
47         decoder.channelRead0(ctx, msgWrapper);
48         verify(messageBufferMock, times(1)).release();
49     }
50 }