2 * Copyright (c) 2015 Cisco Systems, Inc. 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.openflowplugin.impl.connection;
10 import static org.mockito.Mockito.mock;
11 import static org.mockito.Mockito.when;
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;
20 public class OutboundQueueProviderImplTest extends TestCase {
22 private static final Long DUMMY_ENTRY_NUMBER = 44L;
23 private static final Uint32 DUMMY_XID = Uint32.valueOf(55L);
25 private final OutboundQueueProviderImpl outboundQueueProvider =
26 new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3);
29 public void testReserveEntry() {
31 outboundQueueProvider.onConnectionQueueChanged(null);
32 Long returnValue = outboundQueueProvider.reserveEntry();
33 assertEquals(null, returnValue);
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);
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());