Fix meter-id overlap
[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 import org.opendaylight.yangtools.yang.common.Uint32;
19
20 public class OutboundQueueProviderImplTest extends TestCase {
21
22     private static final Long DUMMY_ENTRY_NUMBER = 44L;
23     private static final Uint32 DUMMY_XID = Uint32.valueOf(55L);
24
25     private final OutboundQueueProviderImpl outboundQueueProvider =
26             new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3);
27
28     @Test
29     public void testReserveEntry() {
30
31         outboundQueueProvider.onConnectionQueueChanged(null);
32         Long returnValue = outboundQueueProvider.reserveEntry();
33         assertEquals(null, returnValue);
34
35         OutboundQueue mockedQueue = mock(OutboundQueue.class);
36         when(mockedQueue.reserveEntry()).thenReturn(DUMMY_ENTRY_NUMBER);
37         outboundQueueProvider.onConnectionQueueChanged(mockedQueue);
38         returnValue = outboundQueueProvider.reserveEntry();
39         assertEquals(DUMMY_ENTRY_NUMBER, returnValue);
40     }
41
42     @Test
43     public void testCreateBarrierRequest() {
44         final BarrierInput barrierRequest = outboundQueueProvider.createBarrierRequest(DUMMY_XID.toJava());
45         assertNotNull(barrierRequest);
46         assertEquals(OFConstants.OFP_VERSION_1_3, barrierRequest.getVersion().toJava());
47         assertEquals(DUMMY_XID, barrierRequest.getXid());
48     }
49 }