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;
19 public class OutboundQueueProviderImplTest extends TestCase {
21 private static final Long DUMMY_ENTRY_NUMBER = 44L;
22 private static final Long DUMMY_XID = 55L;
24 private final OutboundQueueProviderImpl outboundQueueProvider = new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3);
27 public void testReserveEntry() throws Exception {
29 outboundQueueProvider.onConnectionQueueChanged(null);
30 Long returnValue = outboundQueueProvider.reserveEntry();
31 assertEquals(null, returnValue);
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);
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());