2 * Copyright (c) 2016 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.yangtools.yang.binding.util;
10 import static org.junit.Assert.assertNotNull;
11 import static org.mockito.Mockito.mock;
13 import com.google.common.collect.ImmutableMap;
15 import java.util.Date;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.binding.RpcService;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.common.QNameModule;
22 public class LocalNameRpcServiceInvokerTest {
24 private static RpcServiceInvoker rpcServiceInvoker;
25 private static final QNameModule Q_NAME_MODULE =
26 QNameModule.create(URI.create("testURI"), new Date(System.currentTimeMillis()));
27 private static final RpcService RPC_SERVICE = mock(RpcService.class);
30 public static void setUp() throws Exception {
31 rpcServiceInvoker = LocalNameRpcServiceInvoker.instanceFor(
32 Q_NAME_MODULE, ImmutableMap.of(QName.create("test"), Object.class.getDeclaredMethod("hashCode")));
34 assertNotNull(rpcServiceInvoker);
37 @Test(expected = IllegalArgumentException.class)
38 public void qnameToKeyTest() throws Exception {
39 rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create(Q_NAME_MODULE, "test"), null);
42 @Test(expected = IllegalArgumentException.class)
43 public void qnameToKeyWithNullTest() throws Exception {
44 rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create("test"), null);