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.api.openflow.device;
10 import static org.mockito.Mockito.mock;
11 import static org.mockito.Mockito.times;
12 import static org.mockito.Mockito.when;
13 import static org.mockito.Mockito.verify;
15 import org.junit.Test;
16 import org.mockito.Matchers;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
18 import org.opendaylight.openflowplugin.impl.rpc.RpcManagerImpl;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
20 import org.opendaylight.yangtools.yang.binding.RpcService;
22 public class RpcManagerImplTest {
24 private static final int AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC = 13;
26 final ProviderContext mockedProviderContext = mock(ProviderContext.class);
27 final RpcManagerImpl rpcManager = new RpcManagerImpl(mockedProviderContext);
28 final DeviceContext mockedRequestContext = mock(DeviceContext.class);
31 public void deviceConnectedTest() {
33 rpcManager.deviceConnected(mockedRequestContext);
35 verify(mockedProviderContext, times(AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC)).addRoutedRpcImplementation(
36 Matchers.any(Class.class), Matchers.any(RpcService.class));
40 * Tests behavior of RpcContextImpl when calling rpc from MD-SAL
43 public void invokeRpcTest() {
45 rpcManager.deviceConnected(mockedRequestContext);
46 // when(mockedProviderContext.getRpcService(SalFlowService.class)).thenReturn(value);
47 final SalFlowService salFlowService = mockedProviderContext.getRpcService(SalFlowService.class);