Wiring message processing to deviceContext
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / device / listener / OpenflowProtocolListenerFullImplTest.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. 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
9 package org.opendaylight.openflowplugin.impl.device.listener;
10
11 import static org.junit.Assert.fail;
12 import org.junit.Before;
13 import org.junit.Ignore;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.Mock;
17 import org.mockito.Mockito;
18 import org.mockito.runners.MockitoJUnitRunner;
19 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
20 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
21 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
22 import org.opendaylight.openflowplugin.impl.connection.listener.OpenflowProtocolListenerInitialImpl;
23 import org.opendaylight.openflowplugin.impl.connection.testutil.MsgGeneratorTestUtils;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
26
27 /**
28  * openflowplugin-impl
29  * org.opendaylight.openflowplugin.impl.connection.listener
30  * <p/>
31  * test of {@link OpenflowProtocolListenerInitialImpl} - lightweight version, using basic ways (TDD)
32  *
33  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
34  *         <p/>
35  *         Created: Mar 26, 2015
36  */
37 @RunWith(MockitoJUnitRunner.class)
38 public class OpenflowProtocolListenerFullImplTest {
39
40
41     private OpenflowProtocolListenerFullImpl ofProtocolListener;
42
43     @Mock
44     private DeviceReplyProcessor deviceReplyProcessor;
45     @Mock
46     private ConnectionAdapter connectionAdapter;
47
48     @Before
49     public void setUp() {
50         // place for mocking method's general behavior for HandshakeContext and ConnectionContext
51         ofProtocolListener = new OpenflowProtocolListenerFullImpl(connectionAdapter, deviceReplyProcessor);
52     }
53
54     /**
55      * Test method for {@link OpenflowProtocolListenerInitialImpl#OpenflowProtocolListenerInitialImpl(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext, org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext)}.
56      */
57     @Test
58     @Ignore
59     public void testOpenflowProtocolListenerImpl() {
60         fail("Not yet implemented");
61     }
62
63     /**
64      * Test method for {@link OpenflowProtocolListenerInitialImpl#onEchoRequestMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage)}.
65      */
66     @Test
67     @Ignore
68     public void testOnEchoRequestMessage() {
69         fail("Not yet implemented");
70     }
71
72     /**
73      * Test method for {@link OpenflowProtocolListenerInitialImpl#onErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage)}.
74      */
75     @Test
76     @Ignore
77     public void testOnErrorMessage() {
78         fail("Not yet implemented");
79     }
80
81     /**
82      * Test method for {@link OpenflowProtocolListenerInitialImpl#onExperimenterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage)}.
83      */
84     @Test
85     @Ignore
86     public void testOnExperimenterMessage() {
87         fail("Not yet implemented");
88     }
89
90     /**
91      * Test method for {@link OpenflowProtocolListenerInitialImpl#onFlowRemovedMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage)}.
92      */
93     @Test
94     @Ignore
95     public void testOnFlowRemovedMessage() {
96         fail("Not yet implemented");
97     }
98
99     /**
100      * Test method for {@link OpenflowProtocolListenerInitialImpl#onHelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage)}.
101      */
102     @Test
103     @Ignore
104     public void testOnHelloMessage() {
105         fail("Not yet implemented");
106     }
107
108     /**
109      * Test method for {@link OpenflowProtocolListenerInitialImpl#onMultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)}.
110      */
111     @Test
112     public void testOnMultipartReplyMessage() {
113         final long xid = 1l;
114         ofProtocolListener.registerMultipartMsg(xid);
115         final MultipartReply multipartReply = MsgGeneratorTestUtils.makeMultipartDescReply(xid, "test-val", false);
116         ofProtocolListener.onMultipartReplyMessage((MultipartReplyMessage) multipartReply);
117         Mockito.verify(deviceReplyProcessor, Mockito.times(1)).processReply(Mockito.any(Xid.class), Mockito.anyListOf(MultipartReply.class));
118     }
119
120     /**
121      * Test method for {@link OpenflowProtocolListenerInitialImpl#onPacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage)}.
122      */
123     @Test
124     @Ignore
125     public void testOnPacketInMessage() {
126         fail("Not yet implemented");
127     }
128
129     /**
130      * Test method for {@link OpenflowProtocolListenerInitialImpl#onPortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)}.
131      */
132     @Test
133     @Ignore
134     public void testOnPortStatusMessage() {
135         fail("Not yet implemented");
136     }
137
138     /**
139      * Test method for {@link OpenflowProtocolListenerInitialImpl#checkState(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext.CONNECTION_STATE)}.
140      */
141     @Test
142     @Ignore
143     public void testCheckState() {
144         fail("Not yet implemented");
145     }
146
147 }