-
- static ActorSystem system;
-
-
- @BeforeClass
- public static void setup() throws InterruptedException {
- system = ActorSystem.create("odl-cluster-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
- }
-
- @AfterClass
- public static void teardown() {
- JavaTestKit.shutdownActorSystem(system);
- system = null;
- }
-
- @Test
- public void testRemoteRpcProvider() throws Exception {
- RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(RpcProvisionRegistry.class));
- Broker.ProviderSession session = mock(Broker.ProviderSession.class);
- SchemaService schemaService = mock(SchemaService.class);
- when(schemaService.getGlobalContext()). thenReturn(mock(SchemaContext.class));
- when(session.getService(SchemaService.class)).thenReturn(schemaService);
- rpcProvider.onSessionInitiated(session);
- ActorRef actorRef = Await.result(system.actorSelection(ActorConstants.RPC_MANAGER_PATH).resolveOne(Duration.create(1, TimeUnit.SECONDS)),
- Duration.create(2, TimeUnit.SECONDS));
- Assert.assertTrue(actorRef.path().toString().contains(ActorConstants.RPC_MANAGER_PATH));
- }
+ static ActorSystem system;
+ static RemoteRpcProviderConfig moduleConfig;
+
+ @BeforeClass
+ public static void setup() {
+ moduleConfig = new RemoteRpcProviderConfig.Builder("odl-cluster-rpc")
+ .withConfigReader(ConfigFactory::load).build();
+ final Config config = moduleConfig.get();
+ system = ActorSystem.create("odl-cluster-rpc", config);
+
+ }
+
+ @AfterClass
+ public static void teardown() {
+ TestKit.shutdownActorSystem(system);
+ system = null;
+ }
+
+ @Test
+ public void testRemoteRpcProvider() throws Exception {
+ try (RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(DOMRpcProviderService.class),
+ mock(DOMRpcService.class), new RemoteRpcProviderConfig(system.settings().config()))) {
+
+ rpcProvider.start();
+
+ final ActorRef actorRef = Await.result(
+ system.actorSelection(moduleConfig.getRpcManagerPath()).resolveOne(
+ Duration.create(1, TimeUnit.SECONDS)), Duration.create(2, TimeUnit.SECONDS));
+
+ Assert.assertTrue(actorRef.path().toString().contains(moduleConfig.getRpcManagerPath()));
+ }
+ }