Remove reliance on org.opendaylight.controller.sal.core.api.Broker
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / AbstractRpcTest.java
index 02dd857716b31ea1d297e372436d47254663e1e5..32b54c4a8cf5470e2fa11060f17e48f88f7cff41 100644 (file)
@@ -16,19 +16,16 @@ import static org.junit.Assert.assertTrue;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.testkit.JavaTestKit;
-import java.io.InputStream;
 import java.net.URI;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.mockito.Mockito;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
@@ -70,15 +67,17 @@ public class AbstractRpcTest {
     static RemoteRpcProviderConfig config1;
     static RemoteRpcProviderConfig config2;
 
-    protected ActorRef rpcBroker1;
+    protected ActorRef rpcInvoker1;
     protected JavaTestKit rpcRegistry1Probe;
-    protected ActorRef rpcBroker2;
+    protected ActorRef rpcInvoker2;
     protected JavaTestKit rpcRegistry2Probe;
-    protected Broker.ProviderSession brokerSession;
     protected SchemaContext schemaContext;
     protected RemoteRpcImplementation remoteRpcImpl1;
     protected RemoteRpcImplementation remoteRpcImpl2;
+
+    @Mock
     protected DOMRpcService domRpcService1;
+    @Mock
     protected DOMRpcService domRpcService2;
 
     @BeforeClass
@@ -98,25 +97,17 @@ public class AbstractRpcTest {
     }
 
     @Before
-    public void setUp() throws Exception {
-        final List<InputStream> sources = Collections.singletonList(
-            AbstractRpcTest.this.getClass().getResourceAsStream("/test-rpc.yang"));
-
-        try {
-            schemaContext = YangParserTestUtils.parseYangStreams(sources);
-        } catch (ReactorException e) {
-            throw new RuntimeException("Unable to build schema context from " + sources, e);
-        }
+    public void setUp() throws ReactorException {
+        schemaContext = YangParserTestUtils.parseYangResources(AbstractRpcTest.class, "/test-rpc.yang");
+
+        MockitoAnnotations.initMocks(this);
 
-        domRpcService1 = Mockito.mock(DOMRpcService.class);
-        domRpcService2 = Mockito.mock(DOMRpcService.class);
         rpcRegistry1Probe = new JavaTestKit(node1);
-        rpcBroker1 = node1.actorOf(RpcBroker.props(domRpcService1));
+        rpcInvoker1 = node1.actorOf(RpcInvoker.props(domRpcService1));
         rpcRegistry2Probe = new JavaTestKit(node2);
-        rpcBroker2 = node2.actorOf(RpcBroker.props(domRpcService2));
-        remoteRpcImpl1 = new RemoteRpcImplementation(rpcRegistry1Probe.getRef(), config1);
-        remoteRpcImpl2 = new RemoteRpcImplementation(rpcRegistry2Probe.getRef(), config2);
-
+        rpcInvoker2 = node2.actorOf(RpcInvoker.props(domRpcService2));
+        remoteRpcImpl1 = new RemoteRpcImplementation(rpcInvoker2, config1);
+        remoteRpcImpl2 = new RemoteRpcImplementation(rpcInvoker1, config2);
     }
 
     static void assertRpcErrorEquals(final RpcError rpcError, final ErrorSeverity severity,