Add missing license headers
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / connection / OutboundQueueProviderImplTest.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 package org.opendaylight.openflowplugin.impl.connection;
9
10 import static org.mockito.Mockito.mock;
11 import static org.mockito.Mockito.when;
12
13 import junit.framework.TestCase;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
16 import org.opendaylight.openflowplugin.api.OFConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
18
19 public class OutboundQueueProviderImplTest extends TestCase {
20
21     private static final Long DUMMY_ENTRY_NUMBER = 44L;
22     private static final Long DUMMY_XID = 55L;
23
24     private final OutboundQueueProviderImpl outboundQueueProvider = new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3);
25
26     @Test
27     public void testReserveEntry() throws Exception {
28
29         outboundQueueProvider.onConnectionQueueChanged(null);
30         Long returnValue = outboundQueueProvider.reserveEntry();
31         assertEquals(null, returnValue);
32
33         OutboundQueue mockedQueue = mock(OutboundQueue.class);
34         when(mockedQueue.reserveEntry()).thenReturn(DUMMY_ENTRY_NUMBER);
35         outboundQueueProvider.onConnectionQueueChanged(mockedQueue);
36         returnValue = outboundQueueProvider.reserveEntry();
37         assertEquals(DUMMY_ENTRY_NUMBER, returnValue);
38     }
39
40     @Test
41     public void testCreateBarrierRequest() {
42         final BarrierInput barrierRequest = outboundQueueProvider.createBarrierRequest(DUMMY_XID);
43         assertNotNull(barrierRequest);;
44         assertEquals((short)OFConstants.OFP_VERSION_1_3, (short)barrierRequest.getVersion());
45         assertEquals(DUMMY_XID, barrierRequest.getXid());
46     }
47 }