HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.incubator.rpc.impl; |
| 17 | |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 18 | import static org.junit.Assert.*; |
| 19 | |
| 20 | import java.net.URI; |
| 21 | |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 22 | import org.junit.After; |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 25 | import org.onosproject.incubator.rpc.RemoteServiceContext; |
| 26 | import org.onosproject.incubator.rpc.RemoteServiceDirectory; |
| 27 | import org.onosproject.incubator.rpc.impl.LocalRemoteServiceProvider.SomeOtherService; |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 28 | |
| 29 | /** |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 30 | * Set of tests of the RemoteServiceManager component. |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 31 | */ |
| 32 | public class RemoteServiceManagerTest { |
| 33 | |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 34 | 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 Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 40 | |
| 41 | @Before |
| 42 | public void setUp() { |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 43 | rpcManager = new RemoteServiceManager(); |
| 44 | rpcManager.activate(); |
| 45 | rpcDirectory = rpcManager; |
| 46 | |
| 47 | rpcProvider = new LocalRemoteServiceProvider(); |
| 48 | rpcProvider.rpcRegistry = rpcManager; |
| 49 | rpcProvider.activate(); |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 50 | |
| 51 | } |
| 52 | |
| 53 | @After |
| 54 | public void tearDown() { |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 55 | rpcProvider.deactivate(); |
| 56 | |
| 57 | rpcManager.deactivate(); |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | @Test |
| 61 | public void basics() { |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 62 | RemoteServiceContext remoteServiceContext = rpcDirectory.get(LOCAL_URI); |
| 63 | assertNotNull("Expecting valid RPC context", remoteServiceContext); |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 64 | |
HIGUCHI Yuta | 59e6400 | 2015-11-17 16:27:50 -0800 | [diff] [blame] | 65 | SomeOtherService someService = remoteServiceContext.get(SomeOtherService.class); |
| 66 | assertNotNull("Expecting reference to sample service", someService); |
| 67 | |
| 68 | assertEquals("Goodbye", someService.hello()); |
HIGUCHI Yuta | 279b8d1 | 2015-11-04 10:58:06 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | } |