Committed by
Gerrit Code Review
Fix the SDN-IP unit tests after changing the Intent IDs to use
explicit ID assignment. Change-Id: I50bc20188922193cfa47bf0ec324a69929744745
Showing
6 changed files
with
101 additions
and
93 deletions
... | @@ -36,12 +36,12 @@ import org.onlab.onos.net.flow.TrafficTreatment; | ... | @@ -36,12 +36,12 @@ import org.onlab.onos.net.flow.TrafficTreatment; |
36 | import org.onlab.onos.net.host.HostListener; | 36 | import org.onlab.onos.net.host.HostListener; |
37 | import org.onlab.onos.net.host.HostService; | 37 | import org.onlab.onos.net.host.HostService; |
38 | import org.onlab.onos.net.host.InterfaceIpAddress; | 38 | import org.onlab.onos.net.host.InterfaceIpAddress; |
39 | +import org.onlab.onos.net.intent.AbstractIntentTest; | ||
39 | import org.onlab.onos.net.intent.Intent; | 40 | import org.onlab.onos.net.intent.Intent; |
40 | import org.onlab.onos.net.intent.IntentOperations; | 41 | import org.onlab.onos.net.intent.IntentOperations; |
41 | import org.onlab.onos.net.intent.IntentService; | 42 | import org.onlab.onos.net.intent.IntentService; |
42 | import org.onlab.onos.net.intent.IntentState; | 43 | import org.onlab.onos.net.intent.IntentState; |
43 | import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; | 44 | import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; |
44 | -import org.onlab.onos.net.intent.AbstractIntentTest; | ||
45 | import org.onlab.onos.net.provider.ProviderId; | 45 | import org.onlab.onos.net.provider.ProviderId; |
46 | import org.onlab.onos.sdnip.config.Interface; | 46 | import org.onlab.onos.sdnip.config.Interface; |
47 | import org.onlab.packet.Ethernet; | 47 | import org.onlab.packet.Ethernet; | ... | ... |
... | @@ -30,11 +30,11 @@ import org.onlab.onos.net.flow.DefaultTrafficTreatment; | ... | @@ -30,11 +30,11 @@ import org.onlab.onos.net.flow.DefaultTrafficTreatment; |
30 | import org.onlab.onos.net.flow.TrafficSelector; | 30 | import org.onlab.onos.net.flow.TrafficSelector; |
31 | import org.onlab.onos.net.flow.TrafficTreatment; | 31 | import org.onlab.onos.net.flow.TrafficTreatment; |
32 | import org.onlab.onos.net.host.InterfaceIpAddress; | 32 | import org.onlab.onos.net.host.InterfaceIpAddress; |
33 | +import org.onlab.onos.net.intent.AbstractIntentTest; | ||
33 | import org.onlab.onos.net.intent.Intent; | 34 | import org.onlab.onos.net.intent.Intent; |
34 | import org.onlab.onos.net.intent.IntentOperations; | 35 | import org.onlab.onos.net.intent.IntentOperations; |
35 | import org.onlab.onos.net.intent.IntentService; | 36 | import org.onlab.onos.net.intent.IntentService; |
36 | import org.onlab.onos.net.intent.PointToPointIntent; | 37 | import org.onlab.onos.net.intent.PointToPointIntent; |
37 | -import org.onlab.onos.net.intent.AbstractIntentTest; | ||
38 | import org.onlab.onos.sdnip.bgp.BgpConstants; | 38 | import org.onlab.onos.sdnip.bgp.BgpConstants; |
39 | import org.onlab.onos.sdnip.config.BgpPeer; | 39 | import org.onlab.onos.sdnip.config.BgpPeer; |
40 | import org.onlab.onos.sdnip.config.BgpSpeaker; | 40 | import org.onlab.onos.sdnip.config.BgpSpeaker; | ... | ... |
... | @@ -31,7 +31,6 @@ import java.util.Map; | ... | @@ -31,7 +31,6 @@ import java.util.Map; |
31 | import java.util.Set; | 31 | import java.util.Set; |
32 | 32 | ||
33 | import org.junit.Before; | 33 | import org.junit.Before; |
34 | -import org.junit.Ignore; | ||
35 | import org.junit.Test; | 34 | import org.junit.Test; |
36 | import org.onlab.junit.TestUtils; | 35 | import org.onlab.junit.TestUtils; |
37 | import org.onlab.junit.TestUtils.TestUtilsException; | 36 | import org.onlab.junit.TestUtils.TestUtilsException; |
... | @@ -50,10 +49,12 @@ import org.onlab.onos.net.flow.TrafficTreatment; | ... | @@ -50,10 +49,12 @@ import org.onlab.onos.net.flow.TrafficTreatment; |
50 | import org.onlab.onos.net.host.HostListener; | 49 | import org.onlab.onos.net.host.HostListener; |
51 | import org.onlab.onos.net.host.HostService; | 50 | import org.onlab.onos.net.host.HostService; |
52 | import org.onlab.onos.net.host.InterfaceIpAddress; | 51 | import org.onlab.onos.net.host.InterfaceIpAddress; |
52 | +import org.onlab.onos.net.intent.Intent; | ||
53 | import org.onlab.onos.net.intent.IntentService; | 53 | import org.onlab.onos.net.intent.IntentService; |
54 | import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; | 54 | import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; |
55 | import org.onlab.onos.net.intent.AbstractIntentTest; | 55 | import org.onlab.onos.net.intent.AbstractIntentTest; |
56 | import org.onlab.onos.net.provider.ProviderId; | 56 | import org.onlab.onos.net.provider.ProviderId; |
57 | +import org.onlab.onos.sdnip.IntentSynchronizer.IntentKey; | ||
57 | import org.onlab.onos.sdnip.config.BgpPeer; | 58 | import org.onlab.onos.sdnip.config.BgpPeer; |
58 | import org.onlab.onos.sdnip.config.Interface; | 59 | import org.onlab.onos.sdnip.config.Interface; |
59 | import org.onlab.onos.sdnip.config.SdnIpConfigService; | 60 | import org.onlab.onos.sdnip.config.SdnIpConfigService; |
... | @@ -232,7 +233,7 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -232,7 +233,7 @@ public class RouterTest extends AbstractIntentTest { |
232 | /** | 233 | /** |
233 | * This method tests adding a route entry. | 234 | * This method tests adding a route entry. |
234 | */ | 235 | */ |
235 | - @Test @Ignore("needs fix from intents") | 236 | + @Test |
236 | public void testProcessRouteAdd() throws TestUtilsException { | 237 | public void testProcessRouteAdd() throws TestUtilsException { |
237 | // Construct a route entry | 238 | // Construct a route entry |
238 | RouteEntry routeEntry = new RouteEntry( | 239 | RouteEntry routeEntry = new RouteEntry( |
... | @@ -260,7 +261,7 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -260,7 +261,7 @@ public class RouterTest extends AbstractIntentTest { |
260 | 261 | ||
261 | // Set up test expectation | 262 | // Set up test expectation |
262 | reset(intentService); | 263 | reset(intentService); |
263 | - intentService.submit(intent); | 264 | + intentService.submit(TestIntentServiceHelper.eqExceptId(intent)); |
264 | replay(intentService); | 265 | replay(intentService); |
265 | 266 | ||
266 | // Call the processRouteAdd() method in Router class | 267 | // Call the processRouteAdd() method in Router class |
... | @@ -272,8 +273,11 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -272,8 +273,11 @@ public class RouterTest extends AbstractIntentTest { |
272 | assertEquals(router.getRoutes().size(), 1); | 273 | assertEquals(router.getRoutes().size(), 1); |
273 | assertTrue(router.getRoutes().contains(routeEntry)); | 274 | assertTrue(router.getRoutes().contains(routeEntry)); |
274 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); | 275 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
275 | - assertEquals(intentSynchronizer.getRouteIntents().iterator().next(), | 276 | + Intent firstIntent = |
276 | - intent); | 277 | + intentSynchronizer.getRouteIntents().iterator().next(); |
278 | + IntentKey firstIntentKey = new IntentKey(firstIntent); | ||
279 | + IntentKey intentKey = new IntentKey(intent); | ||
280 | + assertTrue(firstIntentKey.equals(intentKey)); | ||
277 | verify(intentService); | 281 | verify(intentService); |
278 | } | 282 | } |
279 | 283 | ||
... | @@ -282,7 +286,7 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -282,7 +286,7 @@ public class RouterTest extends AbstractIntentTest { |
282 | * | 286 | * |
283 | * @throws TestUtilsException | 287 | * @throws TestUtilsException |
284 | */ | 288 | */ |
285 | - @Test @Ignore("needs fix from intents") | 289 | + @Test |
286 | public void testRouteUpdate() throws TestUtilsException { | 290 | public void testRouteUpdate() throws TestUtilsException { |
287 | // Firstly add a route | 291 | // Firstly add a route |
288 | testProcessRouteAdd(); | 292 | testProcessRouteAdd(); |
... | @@ -339,8 +343,8 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -339,8 +343,8 @@ public class RouterTest extends AbstractIntentTest { |
339 | 343 | ||
340 | // Set up test expectation | 344 | // Set up test expectation |
341 | reset(intentService); | 345 | reset(intentService); |
342 | - intentService.withdraw(intent); | 346 | + intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent)); |
343 | - intentService.submit(intentNew); | 347 | + intentService.submit(TestIntentServiceHelper.eqExceptId(intentNew)); |
344 | replay(intentService); | 348 | replay(intentService); |
345 | 349 | ||
346 | // Call the processRouteAdd() method in Router class | 350 | // Call the processRouteAdd() method in Router class |
... | @@ -352,15 +356,18 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -352,15 +356,18 @@ public class RouterTest extends AbstractIntentTest { |
352 | assertEquals(router.getRoutes().size(), 1); | 356 | assertEquals(router.getRoutes().size(), 1); |
353 | assertTrue(router.getRoutes().contains(routeEntryUpdate)); | 357 | assertTrue(router.getRoutes().contains(routeEntryUpdate)); |
354 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); | 358 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
355 | - assertEquals(intentSynchronizer.getRouteIntents().iterator().next(), | 359 | + Intent firstIntent = |
356 | - intentNew); | 360 | + intentSynchronizer.getRouteIntents().iterator().next(); |
361 | + IntentKey firstIntentKey = new IntentKey(firstIntent); | ||
362 | + IntentKey intentNewKey = new IntentKey(intentNew); | ||
363 | + assertTrue(firstIntentKey.equals(intentNewKey)); | ||
357 | verify(intentService); | 364 | verify(intentService); |
358 | } | 365 | } |
359 | 366 | ||
360 | /** | 367 | /** |
361 | * This method tests deleting a route entry. | 368 | * This method tests deleting a route entry. |
362 | */ | 369 | */ |
363 | - @Test @Ignore("needs fix from intents") | 370 | + @Test |
364 | public void testProcessRouteDelete() throws TestUtilsException { | 371 | public void testProcessRouteDelete() throws TestUtilsException { |
365 | // Firstly add a route | 372 | // Firstly add a route |
366 | testProcessRouteAdd(); | 373 | testProcessRouteAdd(); |
... | @@ -391,7 +398,7 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -391,7 +398,7 @@ public class RouterTest extends AbstractIntentTest { |
391 | 398 | ||
392 | // Set up expectation | 399 | // Set up expectation |
393 | reset(intentService); | 400 | reset(intentService); |
394 | - intentService.withdraw(intent); | 401 | + intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent)); |
395 | replay(intentService); | 402 | replay(intentService); |
396 | 403 | ||
397 | // Call route deleting method in Router class | 404 | // Call route deleting method in Router class | ... | ... |
... | @@ -31,7 +31,6 @@ import java.util.Set; | ... | @@ -31,7 +31,6 @@ import java.util.Set; |
31 | import java.util.concurrent.ConcurrentHashMap; | 31 | import java.util.concurrent.ConcurrentHashMap; |
32 | 32 | ||
33 | import org.junit.Before; | 33 | import org.junit.Before; |
34 | -import org.junit.Ignore; | ||
35 | import org.junit.Test; | 34 | import org.junit.Test; |
36 | import org.onlab.junit.TestUtils; | 35 | import org.onlab.junit.TestUtils; |
37 | import org.onlab.junit.TestUtils.TestUtilsException; | 36 | import org.onlab.junit.TestUtils.TestUtilsException; |
... | @@ -50,10 +49,12 @@ import org.onlab.onos.net.flow.TrafficTreatment; | ... | @@ -50,10 +49,12 @@ import org.onlab.onos.net.flow.TrafficTreatment; |
50 | import org.onlab.onos.net.host.HostEvent; | 49 | import org.onlab.onos.net.host.HostEvent; |
51 | import org.onlab.onos.net.host.HostService; | 50 | import org.onlab.onos.net.host.HostService; |
52 | import org.onlab.onos.net.host.InterfaceIpAddress; | 51 | import org.onlab.onos.net.host.InterfaceIpAddress; |
52 | +import org.onlab.onos.net.intent.Intent; | ||
53 | import org.onlab.onos.net.intent.IntentService; | 53 | import org.onlab.onos.net.intent.IntentService; |
54 | import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; | 54 | import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; |
55 | import org.onlab.onos.net.intent.AbstractIntentTest; | 55 | import org.onlab.onos.net.intent.AbstractIntentTest; |
56 | import org.onlab.onos.net.provider.ProviderId; | 56 | import org.onlab.onos.net.provider.ProviderId; |
57 | +import org.onlab.onos.sdnip.IntentSynchronizer.IntentKey; | ||
57 | import org.onlab.onos.sdnip.Router.InternalHostListener; | 58 | import org.onlab.onos.sdnip.Router.InternalHostListener; |
58 | import org.onlab.onos.sdnip.config.BgpPeer; | 59 | import org.onlab.onos.sdnip.config.BgpPeer; |
59 | import org.onlab.onos.sdnip.config.Interface; | 60 | import org.onlab.onos.sdnip.config.Interface; |
... | @@ -194,7 +195,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -194,7 +195,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
194 | /** | 195 | /** |
195 | * This method tests adding a route entry. | 196 | * This method tests adding a route entry. |
196 | */ | 197 | */ |
197 | - @Test @Ignore("needs fix from intents") | 198 | + @Test |
198 | public void testProcessRouteAdd() throws TestUtilsException { | 199 | public void testProcessRouteAdd() throws TestUtilsException { |
199 | 200 | ||
200 | // Construct a route entry | 201 | // Construct a route entry |
... | @@ -213,7 +214,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -213,7 +214,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
213 | replay(hostService); | 214 | replay(hostService); |
214 | 215 | ||
215 | reset(intentService); | 216 | reset(intentService); |
216 | - intentService.submit(intent); | 217 | + intentService.submit(TestIntentServiceHelper.eqExceptId(intent)); |
217 | replay(intentService); | 218 | replay(intentService); |
218 | 219 | ||
219 | // Call the processRouteAdd() method in Router class | 220 | // Call the processRouteAdd() method in Router class |
... | @@ -234,8 +235,11 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -234,8 +235,11 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
234 | assertEquals(router.getRoutes().size(), 1); | 235 | assertEquals(router.getRoutes().size(), 1); |
235 | assertTrue(router.getRoutes().contains(routeEntry)); | 236 | assertTrue(router.getRoutes().contains(routeEntry)); |
236 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); | 237 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
237 | - assertEquals(intentSynchronizer.getRouteIntents().iterator().next(), | 238 | + Intent firstIntent = |
238 | - intent); | 239 | + intentSynchronizer.getRouteIntents().iterator().next(); |
240 | + IntentKey firstIntentKey = new IntentKey(firstIntent); | ||
241 | + IntentKey intentKey = new IntentKey(intent); | ||
242 | + assertTrue(firstIntentKey.equals(intentKey)); | ||
239 | verify(intentService); | 243 | verify(intentService); |
240 | verify(hostService); | 244 | verify(hostService); |
241 | 245 | ||
... | @@ -246,7 +250,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -246,7 +250,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
246 | * | 250 | * |
247 | * @throws TestUtilsException | 251 | * @throws TestUtilsException |
248 | */ | 252 | */ |
249 | - @Test @Ignore("needs fix from intents") | 253 | + @Test |
250 | public void testRouteUpdate() throws TestUtilsException { | 254 | public void testRouteUpdate() throws TestUtilsException { |
251 | 255 | ||
252 | // Construct the existing route entry | 256 | // Construct the existing route entry |
... | @@ -295,8 +299,8 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -295,8 +299,8 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
295 | replay(hostService); | 299 | replay(hostService); |
296 | 300 | ||
297 | reset(intentService); | 301 | reset(intentService); |
298 | - intentService.withdraw(intent); | 302 | + intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent)); |
299 | - intentService.submit(intentNew); | 303 | + intentService.submit(TestIntentServiceHelper.eqExceptId(intentNew)); |
300 | replay(intentService); | 304 | replay(intentService); |
301 | 305 | ||
302 | // Call the processRouteAdd() method in Router class | 306 | // Call the processRouteAdd() method in Router class |
... | @@ -317,8 +321,11 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -317,8 +321,11 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
317 | assertEquals(router.getRoutes().size(), 1); | 321 | assertEquals(router.getRoutes().size(), 1); |
318 | assertTrue(router.getRoutes().contains(routeEntryUpdate)); | 322 | assertTrue(router.getRoutes().contains(routeEntryUpdate)); |
319 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); | 323 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
320 | - assertEquals(intentSynchronizer.getRouteIntents().iterator().next(), | 324 | + Intent firstIntent = |
321 | - intentNew); | 325 | + intentSynchronizer.getRouteIntents().iterator().next(); |
326 | + IntentKey firstIntentKey = new IntentKey(firstIntent); | ||
327 | + IntentKey intentNewKey = new IntentKey(intentNew); | ||
328 | + assertTrue(firstIntentKey.equals(intentNewKey)); | ||
322 | verify(intentService); | 329 | verify(intentService); |
323 | verify(hostService); | 330 | verify(hostService); |
324 | } | 331 | } |
... | @@ -344,7 +351,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { | ... | @@ -344,7 +351,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest { |
344 | 351 | ||
345 | // Set up expectation | 352 | // Set up expectation |
346 | reset(intentService); | 353 | reset(intentService); |
347 | - intentService.withdraw(intent); | 354 | + intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent)); |
348 | replay(intentService); | 355 | replay(intentService); |
349 | 356 | ||
350 | // Call route deleting method in Router class | 357 | // Call route deleting method in Router class | ... | ... |
... | @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; | ... | @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; |
22 | 22 | ||
23 | import org.easymock.IAnswer; | 23 | import org.easymock.IAnswer; |
24 | import org.junit.Before; | 24 | import org.junit.Before; |
25 | -import org.junit.Ignore; | ||
26 | import org.junit.Test; | 25 | import org.junit.Test; |
27 | import org.junit.experimental.categories.Category; | 26 | import org.junit.experimental.categories.Category; |
28 | import org.onlab.junit.IntegrationTest; | 27 | import org.onlab.junit.IntegrationTest; |
... | @@ -200,7 +199,7 @@ public class SdnIpTest extends AbstractIntentTest { | ... | @@ -200,7 +199,7 @@ public class SdnIpTest extends AbstractIntentTest { |
200 | * @throws InterruptedException if interrupted while waiting on a latch | 199 | * @throws InterruptedException if interrupted while waiting on a latch |
201 | * @throws TestUtilsException if exceptions when using TestUtils | 200 | * @throws TestUtilsException if exceptions when using TestUtils |
202 | */ | 201 | */ |
203 | - @Test @Ignore("needs fix from intents") | 202 | + @Test |
204 | public void testAddRoutes() throws InterruptedException, TestUtilsException { | 203 | public void testAddRoutes() throws InterruptedException, TestUtilsException { |
205 | int numRoutes = 100; | 204 | int numRoutes = 100; |
206 | 205 | ||
... | @@ -220,7 +219,7 @@ public class SdnIpTest extends AbstractIntentTest { | ... | @@ -220,7 +219,7 @@ public class SdnIpTest extends AbstractIntentTest { |
220 | MultiPointToSinglePointIntent intent = getIntentForUpdate(update, | 219 | MultiPointToSinglePointIntent intent = getIntentForUpdate(update, |
221 | generateMacAddress(nextHopAddress), | 220 | generateMacAddress(nextHopAddress), |
222 | egressConnectPoint); | 221 | egressConnectPoint); |
223 | - intentService.submit(intent); | 222 | + intentService.submit(TestIntentServiceHelper.eqExceptId(intent)); |
224 | 223 | ||
225 | expectLastCall().andAnswer(new IAnswer<Object>() { | 224 | expectLastCall().andAnswer(new IAnswer<Object>() { |
226 | @Override | 225 | @Override |
... | @@ -262,7 +261,7 @@ public class SdnIpTest extends AbstractIntentTest { | ... | @@ -262,7 +261,7 @@ public class SdnIpTest extends AbstractIntentTest { |
262 | * @throws InterruptedException if interrupted while waiting on a latch | 261 | * @throws InterruptedException if interrupted while waiting on a latch |
263 | * @throws TestUtilsException exceptions when using TestUtils | 262 | * @throws TestUtilsException exceptions when using TestUtils |
264 | */ | 263 | */ |
265 | - @Test @Ignore("needs fix from intents") | 264 | + @Test |
266 | public void testDeleteRoutes() throws InterruptedException, TestUtilsException { | 265 | public void testDeleteRoutes() throws InterruptedException, TestUtilsException { |
267 | int numRoutes = 100; | 266 | int numRoutes = 100; |
268 | List<RouteUpdate> routeUpdates = generateRouteUpdates(numRoutes); | 267 | List<RouteUpdate> routeUpdates = generateRouteUpdates(numRoutes); |
... | @@ -281,7 +280,7 @@ public class SdnIpTest extends AbstractIntentTest { | ... | @@ -281,7 +280,7 @@ public class SdnIpTest extends AbstractIntentTest { |
281 | MultiPointToSinglePointIntent intent = getIntentForUpdate(update, | 280 | MultiPointToSinglePointIntent intent = getIntentForUpdate(update, |
282 | generateMacAddress(nextHopAddress), | 281 | generateMacAddress(nextHopAddress), |
283 | egressConnectPoint); | 282 | egressConnectPoint); |
284 | - intentService.submit(intent); | 283 | + intentService.submit(TestIntentServiceHelper.eqExceptId(intent)); |
285 | expectLastCall().andAnswer(new IAnswer<Object>() { | 284 | expectLastCall().andAnswer(new IAnswer<Object>() { |
286 | @Override | 285 | @Override |
287 | public Object answer() throws Throwable { | 286 | public Object answer() throws Throwable { |
... | @@ -289,7 +288,7 @@ public class SdnIpTest extends AbstractIntentTest { | ... | @@ -289,7 +288,7 @@ public class SdnIpTest extends AbstractIntentTest { |
289 | return null; | 288 | return null; |
290 | } | 289 | } |
291 | }).once(); | 290 | }).once(); |
292 | - intentService.withdraw(intent); | 291 | + intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent)); |
293 | expectLastCall().andAnswer(new IAnswer<Object>() { | 292 | expectLastCall().andAnswer(new IAnswer<Object>() { |
294 | @Override | 293 | @Override |
295 | public Object answer() throws Throwable { | 294 | public Object answer() throws Throwable { | ... | ... |
... | @@ -5,10 +5,10 @@ import java.util.List; | ... | @@ -5,10 +5,10 @@ import java.util.List; |
5 | 5 | ||
6 | import org.apache.commons.collections4.CollectionUtils; | 6 | import org.apache.commons.collections4.CollectionUtils; |
7 | import org.easymock.IArgumentMatcher; | 7 | import org.easymock.IArgumentMatcher; |
8 | +import org.onlab.onos.net.intent.Intent; | ||
8 | import org.onlab.onos.net.intent.IntentId; | 9 | import org.onlab.onos.net.intent.IntentId; |
9 | import org.onlab.onos.net.intent.IntentOperation; | 10 | import org.onlab.onos.net.intent.IntentOperation; |
10 | import org.onlab.onos.net.intent.IntentOperations; | 11 | import org.onlab.onos.net.intent.IntentOperations; |
11 | -import org.onlab.onos.net.intent.PointToPointIntent; | ||
12 | import org.onlab.onos.sdnip.IntentSynchronizer.IntentKey; | 12 | import org.onlab.onos.sdnip.IntentSynchronizer.IntentKey; |
13 | 13 | ||
14 | import static org.easymock.EasyMock.reportMatcher; | 14 | import static org.easymock.EasyMock.reportMatcher; |
... | @@ -24,6 +24,18 @@ public final class TestIntentServiceHelper { | ... | @@ -24,6 +24,18 @@ public final class TestIntentServiceHelper { |
24 | } | 24 | } |
25 | 25 | ||
26 | /** | 26 | /** |
27 | + * Matcher method to set the expected intent to match against | ||
28 | + * (ignoring the intent ID for the intent). | ||
29 | + * | ||
30 | + * @param intent the expected Intent | ||
31 | + * @return the submitted Intent | ||
32 | + */ | ||
33 | + static Intent eqExceptId(Intent intent) { | ||
34 | + reportMatcher(new IdAgnosticIntentMatcher(intent)); | ||
35 | + return intent; | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
27 | * Matcher method to set the expected intent operations to match against | 39 | * Matcher method to set the expected intent operations to match against |
28 | * (ignoring the intent ID for each intent). | 40 | * (ignoring the intent ID for each intent). |
29 | * | 41 | * |
... | @@ -35,18 +47,51 @@ public final class TestIntentServiceHelper { | ... | @@ -35,18 +47,51 @@ public final class TestIntentServiceHelper { |
35 | return intentOperations; | 47 | return intentOperations; |
36 | } | 48 | } |
37 | 49 | ||
38 | - | 50 | + /* |
39 | - /** | 51 | + * EasyMock matcher that matches {@link Inten} but |
40 | - * Matcher method to set an expected point-to-point intent to match | 52 | + * ignores the {@link IntentId} when matching. |
41 | - * against (ignoring the intent ID). | 53 | + * <p/> |
42 | - * | 54 | + * The normal intent equals method tests that the intent IDs are equal, |
43 | - * @param intent the expected point-to-point intent | 55 | + * however in these tests we can't know what the intent IDs will be in |
44 | - * @return the submitted point-to-point intent | 56 | + * advance, so we can't set up expected intents with the correct IDs. Thus, |
57 | + * the solution is to use an EasyMock matcher that verifies that all the | ||
58 | + * value properties of the provided intent match the expected values, but | ||
59 | + * ignores the intent ID when testing equality. | ||
45 | */ | 60 | */ |
46 | - private static PointToPointIntent eqExceptId( | 61 | + private static final class IdAgnosticIntentMatcher implements |
47 | - PointToPointIntent intent) { | 62 | + IArgumentMatcher { |
48 | - reportMatcher(new IdAgnosticPointToPointIntentMatcher(intent)); | 63 | + |
49 | - return intent; | 64 | + private final Intent intent; |
65 | + private String providedString; | ||
66 | + | ||
67 | + /** | ||
68 | + * Constructor taking the expected intent to match against. | ||
69 | + * | ||
70 | + * @param intent the expected intent | ||
71 | + */ | ||
72 | + public IdAgnosticIntentMatcher(Intent intent) { | ||
73 | + this.intent = intent; | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public void appendTo(StringBuffer strBuffer) { | ||
78 | + strBuffer.append("IntentMatcher unable to match: " | ||
79 | + + providedString); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public boolean matches(Object object) { | ||
84 | + if (!(object instanceof Intent)) { | ||
85 | + return false; | ||
86 | + } | ||
87 | + | ||
88 | + Intent providedIntent = (Intent) object; | ||
89 | + providedString = providedIntent.toString(); | ||
90 | + | ||
91 | + IntentKey thisIntentKey = new IntentKey(intent); | ||
92 | + IntentKey providedIntentKey = new IntentKey(providedIntent); | ||
93 | + return thisIntentKey.equals(providedIntentKey); | ||
94 | + } | ||
50 | } | 95 | } |
51 | 96 | ||
52 | /* | 97 | /* |
... | @@ -160,54 +205,4 @@ public final class TestIntentServiceHelper { | ... | @@ -160,54 +205,4 @@ public final class TestIntentServiceHelper { |
160 | } | 205 | } |
161 | } | 206 | } |
162 | } | 207 | } |
163 | - | ||
164 | - /* | ||
165 | - * EasyMock matcher that matches {@link PointToPointIntent}s but | ||
166 | - * ignores the {@link IntentId} when matching. | ||
167 | - * <p/> | ||
168 | - * The normal intent equals method tests that the intent IDs are equal, | ||
169 | - * however in these tests we can't know what the intent IDs will be in | ||
170 | - * advance, so we can't set up expected intents with the correct IDs. Thus, | ||
171 | - * the solution is to use an EasyMock matcher that verifies that all the | ||
172 | - * value properties of the provided intent match the expected values, but | ||
173 | - * ignores the intent ID when testing equality. | ||
174 | - */ | ||
175 | - private static final class IdAgnosticPointToPointIntentMatcher implements | ||
176 | - IArgumentMatcher { | ||
177 | - | ||
178 | - private final PointToPointIntent intent; | ||
179 | - private String providedIntentString; | ||
180 | - | ||
181 | - /** | ||
182 | - * Constructor taking the expected intent to match against. | ||
183 | - * | ||
184 | - * @param intent the expected intent | ||
185 | - */ | ||
186 | - public IdAgnosticPointToPointIntentMatcher(PointToPointIntent intent) { | ||
187 | - this.intent = intent; | ||
188 | - } | ||
189 | - | ||
190 | - @Override | ||
191 | - public void appendTo(StringBuffer strBuffer) { | ||
192 | - strBuffer.append("PointToPointIntentMatcher unable to match: " | ||
193 | - + providedIntentString); | ||
194 | - } | ||
195 | - | ||
196 | - @Override | ||
197 | - public boolean matches(Object object) { | ||
198 | - if (!(object instanceof PointToPointIntent)) { | ||
199 | - return false; | ||
200 | - } | ||
201 | - | ||
202 | - PointToPointIntent providedIntent = (PointToPointIntent) object; | ||
203 | - providedIntentString = providedIntent.toString(); | ||
204 | - | ||
205 | - PointToPointIntent matchIntent = | ||
206 | - new PointToPointIntent(providedIntent.appId(), | ||
207 | - intent.selector(), intent.treatment(), | ||
208 | - intent.ingressPoint(), intent.egressPoint()); | ||
209 | - | ||
210 | - return matchIntent.equals(providedIntent); | ||
211 | - } | ||
212 | - } | ||
213 | } | 208 | } | ... | ... |
-
Please register or login to post a comment