Favor adapter classes over service interfaces in unit tests
In unit tests that are mocking an entire interface, instead extend the Adapter class so the unused method overrides are no longer needed. Change-Id: I6e332cc5cb59410f163deea223fbc94e73d83917
Showing
8 changed files
with
62 additions
and
219 deletions
... | @@ -20,10 +20,10 @@ import java.util.Set; | ... | @@ -20,10 +20,10 @@ import java.util.Set; |
20 | import org.junit.After; | 20 | import org.junit.After; |
21 | import org.junit.Before; | 21 | import org.junit.Before; |
22 | import org.junit.Test; | 22 | import org.junit.Test; |
23 | -import org.onosproject.cluster.ClusterEventListener; | 23 | +import org.onlab.packet.IpAddress; |
24 | import org.onosproject.cluster.ClusterService; | 24 | import org.onosproject.cluster.ClusterService; |
25 | +import org.onosproject.cluster.ClusterServiceAdapter; | ||
25 | import org.onosproject.cluster.ControllerNode; | 26 | import org.onosproject.cluster.ControllerNode; |
26 | -import org.onosproject.cluster.ControllerNode.State; | ||
27 | import org.onosproject.cluster.DefaultControllerNode; | 27 | import org.onosproject.cluster.DefaultControllerNode; |
28 | import org.onosproject.cluster.NodeId; | 28 | import org.onosproject.cluster.NodeId; |
29 | import org.onosproject.event.impl.TestEventDispatcher; | 29 | import org.onosproject.event.impl.TestEventDispatcher; |
... | @@ -32,13 +32,14 @@ import org.onosproject.mastership.MastershipStore; | ... | @@ -32,13 +32,14 @@ import org.onosproject.mastership.MastershipStore; |
32 | import org.onosproject.mastership.MastershipTermService; | 32 | import org.onosproject.mastership.MastershipTermService; |
33 | import org.onosproject.net.DeviceId; | 33 | import org.onosproject.net.DeviceId; |
34 | import org.onosproject.store.trivial.impl.SimpleMastershipStore; | 34 | import org.onosproject.store.trivial.impl.SimpleMastershipStore; |
35 | -import org.onlab.packet.IpAddress; | ||
36 | 35 | ||
37 | import com.google.common.collect.Sets; | 36 | import com.google.common.collect.Sets; |
38 | 37 | ||
39 | import static org.junit.Assert.assertEquals; | 38 | import static org.junit.Assert.assertEquals; |
40 | import static org.junit.Assert.assertNull; | 39 | import static org.junit.Assert.assertNull; |
41 | -import static org.onosproject.net.MastershipRole.*; | 40 | +import static org.onosproject.net.MastershipRole.MASTER; |
41 | +import static org.onosproject.net.MastershipRole.NONE; | ||
42 | +import static org.onosproject.net.MastershipRole.STANDBY; | ||
42 | 43 | ||
43 | /** | 44 | /** |
44 | * Test codifying the mastership service contracts. | 45 | * Test codifying the mastership service contracts. |
... | @@ -151,7 +152,7 @@ public class MastershipManagerTest { | ... | @@ -151,7 +152,7 @@ public class MastershipManagerTest { |
151 | assertEquals("inconsistent terms: ", 3, ts.getMastershipTerm(DEV_MASTER).termNumber()); | 152 | assertEquals("inconsistent terms: ", 3, ts.getMastershipTerm(DEV_MASTER).termNumber()); |
152 | } | 153 | } |
153 | 154 | ||
154 | - private final class TestClusterService implements ClusterService { | 155 | + private final class TestClusterService extends ClusterServiceAdapter { |
155 | 156 | ||
156 | ControllerNode local = new DefaultControllerNode(NID_LOCAL, LOCALHOST); | 157 | ControllerNode local = new DefaultControllerNode(NID_LOCAL, LOCALHOST); |
157 | 158 | ||
... | @@ -165,24 +166,6 @@ public class MastershipManagerTest { | ... | @@ -165,24 +166,6 @@ public class MastershipManagerTest { |
165 | return Sets.newHashSet(); | 166 | return Sets.newHashSet(); |
166 | } | 167 | } |
167 | 168 | ||
168 | - @Override | ||
169 | - public ControllerNode getNode(NodeId nodeId) { | ||
170 | - return null; | ||
171 | - } | ||
172 | - | ||
173 | - @Override | ||
174 | - public State getState(NodeId nodeId) { | ||
175 | - return null; | ||
176 | - } | ||
177 | - | ||
178 | - @Override | ||
179 | - public void addListener(ClusterEventListener listener) { | ||
180 | - } | ||
181 | - | ||
182 | - @Override | ||
183 | - public void removeListener(ClusterEventListener listener) { | ||
184 | - } | ||
185 | - | ||
186 | } | 169 | } |
187 | 170 | ||
188 | private final class TestSimpleMastershipStore extends SimpleMastershipStore | 171 | private final class TestSimpleMastershipStore extends SimpleMastershipStore | ... | ... |
... | @@ -15,42 +15,15 @@ | ... | @@ -15,42 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.core.impl; | 16 | package org.onosproject.core.impl; |
17 | 17 | ||
18 | -import org.onosproject.core.ApplicationId; | 18 | +import org.onosproject.core.CoreServiceAdapter; |
19 | -import org.onosproject.core.CoreService; | ||
20 | import org.onosproject.core.IdGenerator; | 19 | import org.onosproject.core.IdGenerator; |
21 | -import org.onosproject.core.Version; | ||
22 | 20 | ||
23 | -import java.util.Set; | 21 | +public class TestCoreManager extends CoreServiceAdapter { |
24 | - | ||
25 | -public class TestCoreManager implements CoreService { | ||
26 | - @Override | ||
27 | - public Version version() { | ||
28 | - return null; | ||
29 | - } | ||
30 | - | ||
31 | - @Override | ||
32 | - public Set<ApplicationId> getAppIds() { | ||
33 | - return null; | ||
34 | - } | ||
35 | - | ||
36 | - @Override | ||
37 | - public ApplicationId getAppId(Short id) { | ||
38 | - return null; | ||
39 | - } | ||
40 | - | ||
41 | - @Override | ||
42 | - public ApplicationId getAppId(String name) { | ||
43 | - return null; | ||
44 | - } | ||
45 | - | ||
46 | - @Override | ||
47 | - public ApplicationId registerApplication(String identifier) { | ||
48 | - return null; | ||
49 | - } | ||
50 | 22 | ||
51 | @Override | 23 | @Override |
52 | public IdGenerator getIdGenerator(String topic) { | 24 | public IdGenerator getIdGenerator(String topic) { |
53 | IdBlockAllocator idBlockAllocator = new DummyIdBlockAllocator(); | 25 | IdBlockAllocator idBlockAllocator = new DummyIdBlockAllocator(); |
54 | return new BlockAllocatorBasedIdGenerator(idBlockAllocator); | 26 | return new BlockAllocatorBasedIdGenerator(idBlockAllocator); |
55 | } | 27 | } |
28 | + | ||
56 | } | 29 | } | ... | ... |
... | @@ -15,17 +15,20 @@ | ... | @@ -15,17 +15,20 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.device.impl; | 16 | package org.onosproject.net.device.impl; |
17 | 17 | ||
18 | -import com.google.common.collect.Sets; | 18 | +import java.util.ArrayList; |
19 | +import java.util.Iterator; | ||
20 | +import java.util.List; | ||
21 | +import java.util.Set; | ||
19 | 22 | ||
20 | import org.junit.After; | 23 | import org.junit.After; |
21 | import org.junit.Before; | 24 | import org.junit.Before; |
22 | import org.junit.Test; | 25 | import org.junit.Test; |
23 | -import org.onosproject.cluster.ClusterEventListener; | 26 | +import org.onlab.packet.ChassisId; |
24 | -import org.onosproject.cluster.ClusterService; | 27 | +import org.onlab.packet.IpAddress; |
28 | +import org.onosproject.cluster.ClusterServiceAdapter; | ||
25 | import org.onosproject.cluster.ControllerNode; | 29 | import org.onosproject.cluster.ControllerNode; |
26 | import org.onosproject.cluster.DefaultControllerNode; | 30 | import org.onosproject.cluster.DefaultControllerNode; |
27 | import org.onosproject.cluster.NodeId; | 31 | import org.onosproject.cluster.NodeId; |
28 | -import org.onosproject.cluster.ControllerNode.State; | ||
29 | import org.onosproject.event.Event; | 32 | import org.onosproject.event.Event; |
30 | import org.onosproject.event.impl.TestEventDispatcher; | 33 | import org.onosproject.event.impl.TestEventDispatcher; |
31 | import org.onosproject.mastership.MastershipServiceAdapter; | 34 | import org.onosproject.mastership.MastershipServiceAdapter; |
... | @@ -51,18 +54,22 @@ import org.onosproject.net.device.PortDescription; | ... | @@ -51,18 +54,22 @@ import org.onosproject.net.device.PortDescription; |
51 | import org.onosproject.net.provider.AbstractProvider; | 54 | import org.onosproject.net.provider.AbstractProvider; |
52 | import org.onosproject.net.provider.ProviderId; | 55 | import org.onosproject.net.provider.ProviderId; |
53 | import org.onosproject.store.trivial.impl.SimpleDeviceStore; | 56 | import org.onosproject.store.trivial.impl.SimpleDeviceStore; |
54 | -import org.onlab.packet.ChassisId; | ||
55 | -import org.onlab.packet.IpAddress; | ||
56 | 57 | ||
57 | -import java.util.ArrayList; | 58 | +import com.google.common.collect.Sets; |
58 | -import java.util.Iterator; | ||
59 | -import java.util.List; | ||
60 | -import java.util.Set; | ||
61 | 59 | ||
62 | -import static org.junit.Assert.*; | 60 | +import static org.junit.Assert.assertEquals; |
61 | +import static org.junit.Assert.assertFalse; | ||
62 | +import static org.junit.Assert.assertNotNull; | ||
63 | +import static org.junit.Assert.assertNull; | ||
64 | +import static org.junit.Assert.assertTrue; | ||
63 | import static org.onosproject.net.Device.Type.SWITCH; | 65 | import static org.onosproject.net.Device.Type.SWITCH; |
64 | import static org.onosproject.net.DeviceId.deviceId; | 66 | import static org.onosproject.net.DeviceId.deviceId; |
65 | -import static org.onosproject.net.device.DeviceEvent.Type.*; | 67 | +import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; |
68 | +import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED; | ||
69 | +import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_UPDATED; | ||
70 | +import static org.onosproject.net.device.DeviceEvent.Type.PORT_ADDED; | ||
71 | +import static org.onosproject.net.device.DeviceEvent.Type.PORT_REMOVED; | ||
72 | +import static org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED; | ||
66 | 73 | ||
67 | /** | 74 | /** |
68 | * Test codifying the device service & device provider service contracts. | 75 | * Test codifying the device service & device provider service contracts. |
... | @@ -310,7 +317,7 @@ public class DeviceManagerTest { | ... | @@ -310,7 +317,7 @@ public class DeviceManagerTest { |
310 | } | 317 | } |
311 | 318 | ||
312 | // code clone | 319 | // code clone |
313 | - private final class TestClusterService implements ClusterService { | 320 | + private final class TestClusterService extends ClusterServiceAdapter { |
314 | 321 | ||
315 | ControllerNode local = new DefaultControllerNode(NID_LOCAL, LOCALHOST); | 322 | ControllerNode local = new DefaultControllerNode(NID_LOCAL, LOCALHOST); |
316 | 323 | ||
... | @@ -319,28 +326,6 @@ public class DeviceManagerTest { | ... | @@ -319,28 +326,6 @@ public class DeviceManagerTest { |
319 | return local; | 326 | return local; |
320 | } | 327 | } |
321 | 328 | ||
322 | - @Override | ||
323 | - public Set<ControllerNode> getNodes() { | ||
324 | - return null; | ||
325 | - } | ||
326 | - | ||
327 | - @Override | ||
328 | - public ControllerNode getNode(NodeId nodeId) { | ||
329 | - return null; | ||
330 | - } | ||
331 | - | ||
332 | - @Override | ||
333 | - public State getState(NodeId nodeId) { | ||
334 | - return null; | ||
335 | - } | ||
336 | - | ||
337 | - @Override | ||
338 | - public void addListener(ClusterEventListener listener) { | ||
339 | - } | ||
340 | - | ||
341 | - @Override | ||
342 | - public void removeListener(ClusterEventListener listener) { | ||
343 | - } | ||
344 | } | 329 | } |
345 | 330 | ||
346 | private final class TestClockProviderService implements | 331 | private final class TestClockProviderService implements | ... | ... |
... | @@ -32,10 +32,9 @@ import org.junit.After; | ... | @@ -32,10 +32,9 @@ import org.junit.After; |
32 | import org.junit.Before; | 32 | import org.junit.Before; |
33 | import org.junit.Test; | 33 | import org.junit.Test; |
34 | import org.onosproject.core.ApplicationId; | 34 | import org.onosproject.core.ApplicationId; |
35 | -import org.onosproject.core.CoreService; | 35 | +import org.onosproject.core.CoreServiceAdapter; |
36 | import org.onosproject.core.DefaultApplicationId; | 36 | import org.onosproject.core.DefaultApplicationId; |
37 | import org.onosproject.core.IdGenerator; | 37 | import org.onosproject.core.IdGenerator; |
38 | -import org.onosproject.core.Version; | ||
39 | import org.onosproject.event.impl.TestEventDispatcher; | 38 | import org.onosproject.event.impl.TestEventDispatcher; |
40 | import org.onosproject.net.DefaultDevice; | 39 | import org.onosproject.net.DefaultDevice; |
41 | import org.onosproject.net.Device; | 40 | import org.onosproject.net.Device; |
... | @@ -219,14 +218,14 @@ public class FlowRuleManagerTest { | ... | @@ -219,14 +218,14 @@ public class FlowRuleManagerTest { |
219 | FlowRule r3 = flowRule(3, 3); | 218 | FlowRule r3 = flowRule(3, 3); |
220 | 219 | ||
221 | assertTrue("store should be empty", | 220 | assertTrue("store should be empty", |
222 | - Sets.newHashSet(service.getFlowEntries(DID)).isEmpty()); | 221 | + Sets.newHashSet(service.getFlowEntries(DID)).isEmpty()); |
223 | mgr.applyFlowRules(r1, r2, r3); | 222 | mgr.applyFlowRules(r1, r2, r3); |
224 | assertEquals("3 rules should exist", 3, flowCount()); | 223 | assertEquals("3 rules should exist", 3, flowCount()); |
225 | assertTrue("Entries should be pending add.", | 224 | assertTrue("Entries should be pending add.", |
226 | - validateState(ImmutableMap.of( | 225 | + validateState(ImmutableMap.of( |
227 | - r1, FlowEntryState.PENDING_ADD, | 226 | + r1, FlowEntryState.PENDING_ADD, |
228 | - r2, FlowEntryState.PENDING_ADD, | 227 | + r2, FlowEntryState.PENDING_ADD, |
229 | - r3, FlowEntryState.PENDING_ADD))); | 228 | + r3, FlowEntryState.PENDING_ADD))); |
230 | } | 229 | } |
231 | 230 | ||
232 | @Test | 231 | @Test |
... | @@ -248,10 +247,10 @@ public class FlowRuleManagerTest { | ... | @@ -248,10 +247,10 @@ public class FlowRuleManagerTest { |
248 | validateEvents(RULE_REMOVE_REQUESTED, RULE_REMOVE_REQUESTED); | 247 | validateEvents(RULE_REMOVE_REQUESTED, RULE_REMOVE_REQUESTED); |
249 | assertEquals("3 rule should exist", 3, flowCount()); | 248 | assertEquals("3 rule should exist", 3, flowCount()); |
250 | assertTrue("Entries should be pending remove.", | 249 | assertTrue("Entries should be pending remove.", |
251 | - validateState(ImmutableMap.of( | 250 | + validateState(ImmutableMap.of( |
252 | - f1, FlowEntryState.PENDING_REMOVE, | 251 | + f1, FlowEntryState.PENDING_REMOVE, |
253 | - f2, FlowEntryState.PENDING_REMOVE, | 252 | + f2, FlowEntryState.PENDING_REMOVE, |
254 | - f3, FlowEntryState.ADDED))); | 253 | + f3, FlowEntryState.ADDED))); |
255 | 254 | ||
256 | mgr.removeFlowRules(f1); | 255 | mgr.removeFlowRules(f1); |
257 | assertEquals("3 rule should still exist", 3, flowCount()); | 256 | assertEquals("3 rule should still exist", 3, flowCount()); |
... | @@ -277,7 +276,7 @@ public class FlowRuleManagerTest { | ... | @@ -277,7 +276,7 @@ public class FlowRuleManagerTest { |
277 | 276 | ||
278 | 277 | ||
279 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, | 278 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, |
280 | - RULE_ADDED, RULE_REMOVE_REQUESTED, RULE_REMOVED); | 279 | + RULE_ADDED, RULE_REMOVE_REQUESTED, RULE_REMOVED); |
281 | 280 | ||
282 | providerService.flowRemoved(fe1); | 281 | providerService.flowRemoved(fe1); |
283 | validateEvents(); | 282 | validateEvents(); |
... | @@ -317,7 +316,7 @@ public class FlowRuleManagerTest { | ... | @@ -317,7 +316,7 @@ public class FlowRuleManagerTest { |
317 | f3, FlowEntryState.PENDING_ADD))); | 316 | f3, FlowEntryState.PENDING_ADD))); |
318 | 317 | ||
319 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, | 318 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, |
320 | - RULE_ADDED, RULE_ADDED); | 319 | + RULE_ADDED, RULE_ADDED); |
321 | } | 320 | } |
322 | 321 | ||
323 | @Test | 322 | @Test |
... | @@ -374,7 +373,7 @@ public class FlowRuleManagerTest { | ... | @@ -374,7 +373,7 @@ public class FlowRuleManagerTest { |
374 | mgr.applyFlowRules(f1, f2); | 373 | mgr.applyFlowRules(f1, f2); |
375 | 374 | ||
376 | assertTrue("should have two rules", | 375 | assertTrue("should have two rules", |
377 | - Lists.newLinkedList(mgr.getFlowRulesById(appId)).size() == 2); | 376 | + Lists.newLinkedList(mgr.getFlowRulesById(appId)).size() == 2); |
378 | } | 377 | } |
379 | 378 | ||
380 | @Test | 379 | @Test |
... | @@ -583,31 +582,7 @@ public class FlowRuleManagerTest { | ... | @@ -583,31 +582,7 @@ public class FlowRuleManagerTest { |
583 | } | 582 | } |
584 | } | 583 | } |
585 | 584 | ||
586 | - private class TestCoreService implements CoreService { | 585 | + private class TestCoreService extends CoreServiceAdapter { |
587 | - @Override | ||
588 | - public Version version() { | ||
589 | - return null; | ||
590 | - } | ||
591 | - | ||
592 | - @Override | ||
593 | - public Set<ApplicationId> getAppIds() { | ||
594 | - return null; | ||
595 | - } | ||
596 | - | ||
597 | - @Override | ||
598 | - public ApplicationId getAppId(Short id) { | ||
599 | - return null; | ||
600 | - } | ||
601 | - | ||
602 | - @Override | ||
603 | - public ApplicationId getAppId(String name) { | ||
604 | - return null; | ||
605 | - } | ||
606 | - | ||
607 | - @Override | ||
608 | - public ApplicationId registerApplication(String identifier) { | ||
609 | - return null; | ||
610 | - } | ||
611 | 586 | ||
612 | @Override | 587 | @Override |
613 | public IdGenerator getIdGenerator(String topic) { | 588 | public IdGenerator getIdGenerator(String topic) { | ... | ... |
... | @@ -23,14 +23,13 @@ import org.onosproject.net.DeviceId; | ... | @@ -23,14 +23,13 @@ import org.onosproject.net.DeviceId; |
23 | import org.onosproject.net.flow.DefaultFlowEntry; | 23 | import org.onosproject.net.flow.DefaultFlowEntry; |
24 | import org.onosproject.net.flow.FlowEntry; | 24 | import org.onosproject.net.flow.FlowEntry; |
25 | import org.onosproject.net.flow.FlowRule; | 25 | import org.onosproject.net.flow.FlowRule; |
26 | -import org.onosproject.net.flow.FlowRuleListener; | ||
27 | import org.onosproject.net.flow.FlowRuleOperations; | 26 | import org.onosproject.net.flow.FlowRuleOperations; |
28 | -import org.onosproject.net.flow.FlowRuleService; | 27 | +import org.onosproject.net.flow.FlowRuleServiceAdapter; |
29 | 28 | ||
30 | import com.google.common.collect.Sets; | 29 | import com.google.common.collect.Sets; |
31 | 30 | ||
32 | 31 | ||
33 | -public class MockFlowRuleService implements FlowRuleService { | 32 | +public class MockFlowRuleService extends FlowRuleServiceAdapter { |
34 | 33 | ||
35 | final Set<FlowRule> flows = Sets.newHashSet(); | 34 | final Set<FlowRule> flows = Sets.newHashSet(); |
36 | boolean success; | 35 | boolean success; |
... | @@ -62,16 +61,6 @@ public class MockFlowRuleService implements FlowRuleService { | ... | @@ -62,16 +61,6 @@ public class MockFlowRuleService implements FlowRuleService { |
62 | } | 61 | } |
63 | 62 | ||
64 | @Override | 63 | @Override |
65 | - public void addListener(FlowRuleListener listener) { | ||
66 | - //TODO not implemented | ||
67 | - } | ||
68 | - | ||
69 | - @Override | ||
70 | - public void removeListener(FlowRuleListener listener) { | ||
71 | - //TODO not implemented | ||
72 | - } | ||
73 | - | ||
74 | - @Override | ||
75 | public int getFlowRuleCount() { | 64 | public int getFlowRuleCount() { |
76 | return flows.size(); | 65 | return flows.size(); |
77 | } | 66 | } |
... | @@ -99,11 +88,6 @@ public class MockFlowRuleService implements FlowRuleService { | ... | @@ -99,11 +88,6 @@ public class MockFlowRuleService implements FlowRuleService { |
99 | } | 88 | } |
100 | 89 | ||
101 | @Override | 90 | @Override |
102 | - public void removeFlowRulesById(ApplicationId appId) { | ||
103 | - //TODO not implemented | ||
104 | - } | ||
105 | - | ||
106 | - @Override | ||
107 | public Iterable<FlowRule> getFlowRulesById(ApplicationId id) { | 91 | public Iterable<FlowRule> getFlowRulesById(ApplicationId id) { |
108 | return flows.stream() | 92 | return flows.stream() |
109 | .filter(flow -> flow.appId() == id.id()) | 93 | .filter(flow -> flow.appId() == id.id()) | ... | ... |
... | @@ -19,15 +19,14 @@ import java.util.HashMap; | ... | @@ -19,15 +19,14 @@ import java.util.HashMap; |
19 | import java.util.Map; | 19 | import java.util.Map; |
20 | import java.util.Set; | 20 | import java.util.Set; |
21 | 21 | ||
22 | -import org.onosproject.cluster.ClusterEventListener; | 22 | +import org.onosproject.cluster.ClusterServiceAdapter; |
23 | -import org.onosproject.cluster.ClusterService; | ||
24 | import org.onosproject.cluster.ControllerNode; | 23 | import org.onosproject.cluster.ControllerNode; |
25 | -import org.onosproject.cluster.NodeId; | ||
26 | import org.onosproject.cluster.ControllerNode.State; | 24 | import org.onosproject.cluster.ControllerNode.State; |
25 | +import org.onosproject.cluster.NodeId; | ||
27 | 26 | ||
28 | import com.google.common.collect.Sets; | 27 | import com.google.common.collect.Sets; |
29 | 28 | ||
30 | -public abstract class StaticClusterService implements ClusterService { | 29 | +public abstract class StaticClusterService extends ClusterServiceAdapter { |
31 | 30 | ||
32 | protected final Map<NodeId, ControllerNode> nodes = new HashMap<>(); | 31 | protected final Map<NodeId, ControllerNode> nodes = new HashMap<>(); |
33 | protected final Map<NodeId, ControllerNode.State> nodeStates = new HashMap<>(); | 32 | protected final Map<NodeId, ControllerNode.State> nodeStates = new HashMap<>(); |
... | @@ -53,11 +52,4 @@ public abstract class StaticClusterService implements ClusterService { | ... | @@ -53,11 +52,4 @@ public abstract class StaticClusterService implements ClusterService { |
53 | return nodeStates.get(nodeId); | 52 | return nodeStates.get(nodeId); |
54 | } | 53 | } |
55 | 54 | ||
56 | - @Override | ||
57 | - public void addListener(ClusterEventListener listener) { | ||
58 | - } | ||
59 | - | ||
60 | - @Override | ||
61 | - public void removeListener(ClusterEventListener listener) { | ||
62 | - } | ||
63 | } | 55 | } | ... | ... |
... | @@ -15,10 +15,6 @@ | ... | @@ -15,10 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.mastership.impl; | 16 | package org.onosproject.store.mastership.impl; |
17 | 17 | ||
18 | -import static org.junit.Assert.assertEquals; | ||
19 | -import static org.junit.Assert.assertNull; | ||
20 | -import static org.junit.Assert.assertTrue; | ||
21 | -import static org.onosproject.net.MastershipRole.*; | ||
22 | import java.util.Map; | 18 | import java.util.Map; |
23 | import java.util.Set; | 19 | import java.util.Set; |
24 | import java.util.concurrent.CountDownLatch; | 20 | import java.util.concurrent.CountDownLatch; |
... | @@ -30,26 +26,31 @@ import org.junit.Before; | ... | @@ -30,26 +26,31 @@ import org.junit.Before; |
30 | import org.junit.BeforeClass; | 26 | import org.junit.BeforeClass; |
31 | import org.junit.Ignore; | 27 | import org.junit.Ignore; |
32 | import org.junit.Test; | 28 | import org.junit.Test; |
33 | -import org.onosproject.cluster.ClusterEventListener; | 29 | +import org.onlab.packet.IpAddress; |
34 | -import org.onosproject.cluster.ClusterService; | 30 | +import org.onosproject.cluster.ClusterServiceAdapter; |
35 | import org.onosproject.cluster.ControllerNode; | 31 | import org.onosproject.cluster.ControllerNode; |
36 | -import org.onosproject.cluster.ControllerNode.State; | ||
37 | import org.onosproject.cluster.DefaultControllerNode; | 32 | import org.onosproject.cluster.DefaultControllerNode; |
38 | import org.onosproject.cluster.NodeId; | 33 | import org.onosproject.cluster.NodeId; |
39 | import org.onosproject.mastership.MastershipEvent; | 34 | import org.onosproject.mastership.MastershipEvent; |
35 | +import org.onosproject.mastership.MastershipEvent.Type; | ||
40 | import org.onosproject.mastership.MastershipStoreDelegate; | 36 | import org.onosproject.mastership.MastershipStoreDelegate; |
41 | import org.onosproject.mastership.MastershipTerm; | 37 | import org.onosproject.mastership.MastershipTerm; |
42 | -import org.onosproject.mastership.MastershipEvent.Type; | ||
43 | import org.onosproject.net.DeviceId; | 38 | import org.onosproject.net.DeviceId; |
44 | import org.onosproject.net.MastershipRole; | 39 | import org.onosproject.net.MastershipRole; |
45 | import org.onosproject.store.hz.StoreManager; | 40 | import org.onosproject.store.hz.StoreManager; |
46 | import org.onosproject.store.hz.StoreService; | 41 | import org.onosproject.store.hz.StoreService; |
47 | import org.onosproject.store.hz.TestStoreManager; | 42 | import org.onosproject.store.hz.TestStoreManager; |
48 | import org.onosproject.store.serializers.KryoSerializer; | 43 | import org.onosproject.store.serializers.KryoSerializer; |
49 | -import org.onlab.packet.IpAddress; | ||
50 | 44 | ||
51 | import com.google.common.collect.Sets; | 45 | import com.google.common.collect.Sets; |
52 | 46 | ||
47 | +import static org.junit.Assert.assertEquals; | ||
48 | +import static org.junit.Assert.assertNull; | ||
49 | +import static org.junit.Assert.assertTrue; | ||
50 | +import static org.onosproject.net.MastershipRole.MASTER; | ||
51 | +import static org.onosproject.net.MastershipRole.NONE; | ||
52 | +import static org.onosproject.net.MastershipRole.STANDBY; | ||
53 | + | ||
53 | /** | 54 | /** |
54 | * Test of the Hazelcast-based distributed MastershipStore implementation. | 55 | * Test of the Hazelcast-based distributed MastershipStore implementation. |
55 | */ | 56 | */ |
... | @@ -300,7 +301,7 @@ public class DistributedMastershipStoreTest { | ... | @@ -300,7 +301,7 @@ public class DistributedMastershipStoreTest { |
300 | } | 301 | } |
301 | } | 302 | } |
302 | 303 | ||
303 | - private class TestClusterService implements ClusterService { | 304 | + private class TestClusterService extends ClusterServiceAdapter { |
304 | 305 | ||
305 | protected ControllerNode current; | 306 | protected ControllerNode current; |
306 | 307 | ||
... | @@ -314,24 +315,6 @@ public class DistributedMastershipStoreTest { | ... | @@ -314,24 +315,6 @@ public class DistributedMastershipStoreTest { |
314 | return Sets.newHashSet(CN1, CN2); | 315 | return Sets.newHashSet(CN1, CN2); |
315 | } | 316 | } |
316 | 317 | ||
317 | - @Override | ||
318 | - public ControllerNode getNode(NodeId nodeId) { | ||
319 | - return null; | ||
320 | - } | ||
321 | - | ||
322 | - @Override | ||
323 | - public State getState(NodeId nodeId) { | ||
324 | - return null; | ||
325 | - } | ||
326 | - | ||
327 | - @Override | ||
328 | - public void addListener(ClusterEventListener listener) { | ||
329 | - } | ||
330 | - | ||
331 | - @Override | ||
332 | - public void removeListener(ClusterEventListener listener) { | ||
333 | - } | ||
334 | - | ||
335 | } | 318 | } |
336 | 319 | ||
337 | } | 320 | } | ... | ... |
... | @@ -27,27 +27,24 @@ import org.onosproject.codec.impl.CodecManager; | ... | @@ -27,27 +27,24 @@ import org.onosproject.codec.impl.CodecManager; |
27 | import org.onosproject.net.ConnectPoint; | 27 | import org.onosproject.net.ConnectPoint; |
28 | import org.onosproject.net.DeviceId; | 28 | import org.onosproject.net.DeviceId; |
29 | import org.onosproject.net.Link; | 29 | import org.onosproject.net.Link; |
30 | -import org.onosproject.net.Path; | ||
31 | import org.onosproject.net.provider.ProviderId; | 30 | import org.onosproject.net.provider.ProviderId; |
32 | import org.onosproject.net.topology.ClusterId; | 31 | import org.onosproject.net.topology.ClusterId; |
33 | import org.onosproject.net.topology.DefaultTopologyCluster; | 32 | import org.onosproject.net.topology.DefaultTopologyCluster; |
34 | import org.onosproject.net.topology.DefaultTopologyVertex; | 33 | import org.onosproject.net.topology.DefaultTopologyVertex; |
35 | -import org.onosproject.net.topology.LinkWeight; | ||
36 | import org.onosproject.net.topology.Topology; | 34 | import org.onosproject.net.topology.Topology; |
37 | import org.onosproject.net.topology.TopologyCluster; | 35 | import org.onosproject.net.topology.TopologyCluster; |
38 | -import org.onosproject.net.topology.TopologyGraph; | ||
39 | -import org.onosproject.net.topology.TopologyListener; | ||
40 | import org.onosproject.net.topology.TopologyService; | 36 | import org.onosproject.net.topology.TopologyService; |
37 | +import org.onosproject.net.topology.TopologyServiceAdapter; | ||
41 | 38 | ||
42 | import com.eclipsesource.json.JsonArray; | 39 | import com.eclipsesource.json.JsonArray; |
43 | import com.eclipsesource.json.JsonObject; | 40 | import com.eclipsesource.json.JsonObject; |
44 | import com.google.common.collect.ImmutableSet; | 41 | import com.google.common.collect.ImmutableSet; |
45 | import com.sun.jersey.api.client.WebResource; | 42 | import com.sun.jersey.api.client.WebResource; |
46 | 43 | ||
44 | +import static org.hamcrest.Matchers.containsString; | ||
47 | import static org.hamcrest.Matchers.hasSize; | 45 | import static org.hamcrest.Matchers.hasSize; |
48 | import static org.hamcrest.Matchers.is; | 46 | import static org.hamcrest.Matchers.is; |
49 | import static org.hamcrest.Matchers.notNullValue; | 47 | import static org.hamcrest.Matchers.notNullValue; |
50 | -import static org.hamcrest.Matchers.containsString; | ||
51 | import static org.junit.Assert.assertThat; | 48 | import static org.junit.Assert.assertThat; |
52 | import static org.onosproject.net.NetTestTools.did; | 49 | import static org.onosproject.net.NetTestTools.did; |
53 | import static org.onosproject.net.NetTestTools.link; | 50 | import static org.onosproject.net.NetTestTools.link; |
... | @@ -89,7 +86,7 @@ public class TopologyResourceTest extends ResourceTest { | ... | @@ -89,7 +86,7 @@ public class TopologyResourceTest extends ResourceTest { |
89 | } | 86 | } |
90 | } | 87 | } |
91 | 88 | ||
92 | - private static class MockTopologyService implements TopologyService { | 89 | + private static class MockTopologyService extends TopologyServiceAdapter { |
93 | final DefaultTopologyVertex root = new DefaultTopologyVertex(did("rootnode")); | 90 | final DefaultTopologyVertex root = new DefaultTopologyVertex(did("rootnode")); |
94 | final Topology topology = new MockTopology(); | 91 | final Topology topology = new MockTopology(); |
95 | final TopologyCluster cluster1 = | 92 | final TopologyCluster cluster1 = |
... | @@ -105,16 +102,6 @@ public class TopologyResourceTest extends ResourceTest { | ... | @@ -105,16 +102,6 @@ public class TopologyResourceTest extends ResourceTest { |
105 | } | 102 | } |
106 | 103 | ||
107 | @Override | 104 | @Override |
108 | - public boolean isLatest(Topology topology) { | ||
109 | - return true; | ||
110 | - } | ||
111 | - | ||
112 | - @Override | ||
113 | - public TopologyGraph getGraph(Topology topology) { | ||
114 | - return null; | ||
115 | - } | ||
116 | - | ||
117 | - @Override | ||
118 | public Set<TopologyCluster> getClusters(Topology topology) { | 105 | public Set<TopologyCluster> getClusters(Topology topology) { |
119 | return ImmutableSet.of(cluster1, cluster2); | 106 | return ImmutableSet.of(cluster1, cluster2); |
120 | } | 107 | } |
... | @@ -141,16 +128,6 @@ public class TopologyResourceTest extends ResourceTest { | ... | @@ -141,16 +128,6 @@ public class TopologyResourceTest extends ResourceTest { |
141 | } | 128 | } |
142 | 129 | ||
143 | @Override | 130 | @Override |
144 | - public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) { | ||
145 | - return null; | ||
146 | - } | ||
147 | - | ||
148 | - @Override | ||
149 | - public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) { | ||
150 | - return null; | ||
151 | - } | ||
152 | - | ||
153 | - @Override | ||
154 | public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) { | 131 | public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) { |
155 | return connectPoint.elementId().toString().equals("dev2"); | 132 | return connectPoint.elementId().toString().equals("dev2"); |
156 | } | 133 | } |
... | @@ -160,15 +137,6 @@ public class TopologyResourceTest extends ResourceTest { | ... | @@ -160,15 +137,6 @@ public class TopologyResourceTest extends ResourceTest { |
160 | return connectPoint.elementId().toString().equals("dev1"); | 137 | return connectPoint.elementId().toString().equals("dev1"); |
161 | } | 138 | } |
162 | 139 | ||
163 | - @Override | ||
164 | - public void addListener(TopologyListener listener) { | ||
165 | - | ||
166 | - } | ||
167 | - | ||
168 | - @Override | ||
169 | - public void removeListener(TopologyListener listener) { | ||
170 | - | ||
171 | - } | ||
172 | } | 140 | } |
173 | 141 | ||
174 | /** | 142 | /** | ... | ... |
-
Please register or login to post a comment