Cleanup RequestContextStack
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / api / openflow / device / RpcContextImplTest.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.api.openflow.device;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertNull;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.mockito.Mock;
16 import org.mockito.runners.MockitoJUnitRunner;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
18 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
19 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
20 import org.opendaylight.openflowplugin.impl.rpc.RpcContextImpl;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
27
28 /**
29  * @author joe
30  */
31 @RunWith(MockitoJUnitRunner.class)
32 public class RpcContextImplTest {
33
34     @Mock
35     private BindingAwareBroker.ProviderContext mockedRpcProviderRegistry;
36
37     @Mock
38     private DeviceContext deviceContext;
39     @Mock
40     private MessageSpy messageSpy;
41
42     private KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
43
44     @Before
45     public void setup() {
46         NodeId nodeId = new NodeId("openflow:1");
47         nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
48     }
49
50     @Test
51     public void invokeRpcTest() {
52
53     }
54
55     @Test
56     public void testStoreOrFail() throws Exception {
57         final RpcContext rpcContext = new RpcContextImpl(messageSpy, mockedRpcProviderRegistry, nodeInstanceIdentifier, 100);
58         RequestContext requestContext = rpcContext.createRequestContext();
59         assertNotNull(requestContext);
60
61     }
62
63     @Test
64     public void testStoreOrFailThatFails() throws Exception {
65         final RpcContext rpcContext = new RpcContextImpl(messageSpy, mockedRpcProviderRegistry, nodeInstanceIdentifier, 0);
66         RequestContext requestContext = rpcContext.createRequestContext();
67         assertNull(requestContext);
68     }
69 }