blob: 40458e518dd552d5906eb46682ddea4e3b5e53aa [file] [log] [blame]
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.rpc.impl;
17
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080018import static org.junit.Assert.*;
19
20import java.net.URI;
21
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080022import org.junit.After;
23import org.junit.Before;
24import org.junit.Test;
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080025import org.onosproject.incubator.rpc.RemoteServiceContext;
26import org.onosproject.incubator.rpc.RemoteServiceDirectory;
27import org.onosproject.incubator.rpc.impl.LocalRemoteServiceProvider.SomeOtherService;
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080028
29/**
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080030 * Set of tests of the RemoteServiceManager component.
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080031 */
32public class RemoteServiceManagerTest {
33
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080034 private static final URI LOCAL_URI = URI.create("local://whateverIgnored");
35
36 private RemoteServiceManager rpcManager;
37 private RemoteServiceDirectory rpcDirectory;
38
39 private LocalRemoteServiceProvider rpcProvider;
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080040
41 @Before
42 public void setUp() {
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080043 rpcManager = new RemoteServiceManager();
44 rpcManager.activate();
45 rpcDirectory = rpcManager;
46
47 rpcProvider = new LocalRemoteServiceProvider();
48 rpcProvider.rpcRegistry = rpcManager;
49 rpcProvider.activate();
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080050
51 }
52
53 @After
54 public void tearDown() {
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080055 rpcProvider.deactivate();
56
57 rpcManager.deactivate();
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080058 }
59
60 @Test
61 public void basics() {
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080062 RemoteServiceContext remoteServiceContext = rpcDirectory.get(LOCAL_URI);
63 assertNotNull("Expecting valid RPC context", remoteServiceContext);
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080064
HIGUCHI Yuta59e64002015-11-17 16:27:50 -080065 SomeOtherService someService = remoteServiceContext.get(SomeOtherService.class);
66 assertNotNull("Expecting reference to sample service", someService);
67
68 assertEquals("Goodbye", someService.hello());
HIGUCHI Yuta279b8d12015-11-04 10:58:06 -080069 }
70
71}