Committed by
Yuta HIGUCHI
ONOS-3322 Add very basic RPC Manager test
Note: LocalRemoteServiceProvider is expected to be moved under src/test scope once we have other usable Provider. Change-Id: Ic8b9f2007082038da5652bf812329d2ef2204200
Showing
1 changed file
with
31 additions
and
6 deletions
1 | /* | 1 | /* |
2 | - * Copyright 2014 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -15,32 +15,57 @@ | ... | @@ -15,32 +15,57 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.incubator.rpc.impl; | 16 | package org.onosproject.incubator.rpc.impl; |
17 | 17 | ||
18 | +import static org.junit.Assert.*; | ||
19 | + | ||
20 | +import java.net.URI; | ||
21 | + | ||
18 | import org.junit.After; | 22 | import org.junit.After; |
19 | import org.junit.Before; | 23 | import org.junit.Before; |
20 | import org.junit.Test; | 24 | import org.junit.Test; |
25 | +import org.onosproject.incubator.rpc.RemoteServiceContext; | ||
26 | +import org.onosproject.incubator.rpc.RemoteServiceDirectory; | ||
27 | +import org.onosproject.incubator.rpc.impl.LocalRemoteServiceProvider.SomeOtherService; | ||
21 | 28 | ||
22 | /** | 29 | /** |
23 | - * Set of tests of the ONOS application component. | 30 | + * Set of tests of the RemoteServiceManager component. |
24 | */ | 31 | */ |
25 | public class RemoteServiceManagerTest { | 32 | public class RemoteServiceManagerTest { |
26 | 33 | ||
27 | - private RemoteServiceManager component; | 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; | ||
28 | 40 | ||
29 | @Before | 41 | @Before |
30 | public void setUp() { | 42 | public void setUp() { |
31 | - component = new RemoteServiceManager(); | 43 | + rpcManager = new RemoteServiceManager(); |
32 | - component.activate(); | 44 | + rpcManager.activate(); |
45 | + rpcDirectory = rpcManager; | ||
46 | + | ||
47 | + rpcProvider = new LocalRemoteServiceProvider(); | ||
48 | + rpcProvider.rpcRegistry = rpcManager; | ||
49 | + rpcProvider.activate(); | ||
33 | 50 | ||
34 | } | 51 | } |
35 | 52 | ||
36 | @After | 53 | @After |
37 | public void tearDown() { | 54 | public void tearDown() { |
38 | - component.deactivate(); | 55 | + rpcProvider.deactivate(); |
56 | + | ||
57 | + rpcManager.deactivate(); | ||
39 | } | 58 | } |
40 | 59 | ||
41 | @Test | 60 | @Test |
42 | public void basics() { | 61 | public void basics() { |
62 | + RemoteServiceContext remoteServiceContext = rpcDirectory.get(LOCAL_URI); | ||
63 | + assertNotNull("Expecting valid RPC context", remoteServiceContext); | ||
64 | + | ||
65 | + SomeOtherService someService = remoteServiceContext.get(SomeOtherService.class); | ||
66 | + assertNotNull("Expecting reference to sample service", someService); | ||
43 | 67 | ||
68 | + assertEquals("Goodbye", someService.hello()); | ||
44 | } | 69 | } |
45 | 70 | ||
46 | } | 71 | } | ... | ... |
-
Please register or login to post a comment