From 06bf26a3f90cc2787a3b373cd8731f19a39a7c2f Mon Sep 17 00:00:00 2001 From: Lorand Jakab Date: Wed, 20 Sep 2017 14:09:23 +0300 Subject: [PATCH] Prepare for odlparent 3.0.0 checkstyle rules Odlparent 3.0.0 will have updated checkstyle rules, see [0] for details. This patch makes sure the code base will pass those new rules when we upgrade. [0] https://lists.opendaylight.org/pipermail/release/2017-September/012353.html Change-Id: I5d8165f21a276468a2e2262fb106792b0e670885 Signed-off-by: Lorand Jakab --- .../implementation/LispMappingService.java | 18 +-- .../implementation/MappingSystem.java | 4 +- .../implementation/lisp/MapServer.java | 10 +- .../implementation/MappingSystemTest.java | 15 +- .../implementation/lisp/MapResolverTest.java | 56 +++---- .../implementation/lisp/MapServerTest.java | 32 ++-- .../lisp/MappingServiceTest.java | 3 +- .../util/MappingMergeUtilTest.java | 6 +- .../lispflowmapping/inmemorydb/HashMapDb.java | 10 +- .../inmemorydb/radixtrie/RadixTrie.java | 28 ++-- .../inmemorydb/radixtrie/RadixTrieTest.java | 46 +++--- .../mapcache/SimpleMapCache.java | 16 +- .../lisp/LispMapCacheStringifier.java | 6 +- .../mapcache/SimpleMapCacheTest.java | 13 +- .../IntentHandlerAsyncExecutorProvider.java | 4 +- .../exception/RlocNotFoundOnVppNode.java | 8 +- .../neutron/intenthandler/util/InfoUtil.java | 4 +- .../intenthandler/util/LispNeutronUtil.java | 5 +- .../util/VppNetconfTrasaction.java | 5 +- .../intenthandler/util/VppNodeReader.java | 2 +- .../HostInformationManager.java | 8 +- .../neutron/PortDataProcessorTest.java | 6 +- .../southbound/LispSouthboundPlugin.java | 12 +- .../southbound/LispSouthboundPluginTest.java | 4 +- .../lisp/LispSouthboundHandlerTest.java | 138 ++++++++++-------- .../lisp/MapRegisterCacheTestUtil.java | 65 +++++---- 26 files changed, 299 insertions(+), 225 deletions(-) diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java index 874a8150b..1168243b8 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java @@ -101,15 +101,15 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle return this.smr; } - public void setShouldUseSmr(boolean smr) { - this.smr = smr; + public void setShouldUseSmr(boolean shouldUseSmr) { + this.smr = shouldUseSmr; if (mapServer != null) { - mapServer.setSubscriptionService(smr); + mapServer.setSubscriptionService(shouldUseSmr); } if (mapResolver != null) { - mapResolver.setSubscriptionService(smr); + mapResolver.setSubscriptionService(shouldUseSmr); } - ConfigIni.getInstance().setSmr(smr); + ConfigIni.getInstance().setSmr(shouldUseSmr); } public NotificationService getNotificationService() { @@ -257,15 +257,15 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle } @Override - public void handleSMR(MapRequest smr, Rloc subscriber) { + public void handleSMR(MapRequest smrMapRequest, Rloc subscriber) { if (LOG.isDebugEnabled()) { LOG.debug("Sending SMR Map-Request to {} with Source-EID {} and EID Record {} (reversed)", LispAddressStringifier.getString(subscriber), - LispAddressStringifier.getString(smr.getSourceEid().getEid()), - LispAddressStringifier.getString(smr.getEidItem().get(0).getEid())); + LispAddressStringifier.getString(smrMapRequest.getSourceEid().getEid()), + LispAddressStringifier.getString(smrMapRequest.getEidItem().get(0).getEid())); } SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder(); - smrib.setMapRequest(new MapRequestBuilder(smr).build()); + smrib.setMapRequest(new MapRequestBuilder(smrMapRequest).build()); smrib.setTransportAddress(LispNotificationHelper.getTransportAddressFromRloc(subscriber)); getLispSB().sendMapRequest(smrib.build()); diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingSystem.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingSystem.java index b7ee94c5c..5a75a814b 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingSystem.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingSystem.java @@ -112,8 +112,8 @@ public class MappingSystem implements IMappingSystem { this); } - public void setDataStoreBackEnd(DataStoreBackEnd dsbe) { - this.dsbe = dsbe; + public void setDataStoreBackEnd(DataStoreBackEnd dataStoreBackEnd) { + this.dsbe = dataStoreBackEnd; } @Override diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java index 924c1c434..65e659ccc 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java @@ -503,16 +503,16 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS executionCount++; } - private void cancelAndRemove(Subscriber subscriber, Eid eid) { + private void cancelAndRemove(Subscriber sub, Eid eid) { final Map> subscriberFutureMap = eidFutureMap.get(eid); if (subscriberFutureMap == null) { - LOG.warn("Couldn't find subscriber {} in SMR scheduler internal list", subscriber); + LOG.warn("Couldn't find subscriber {} in SMR scheduler internal list", sub); return; } - if (subscriberFutureMap.containsKey(subscriber)) { - ScheduledFuture eidFuture = subscriberFutureMap.get(subscriber); - subscriberFutureMap.remove(subscriber); + if (subscriberFutureMap.containsKey(sub)) { + ScheduledFuture eidFuture = subscriberFutureMap.get(sub); + subscriberFutureMap.remove(sub); eidFuture.cancel(false); } if (subscriberFutureMap.isEmpty()) { diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java index ebb5d71fc..9e7e85ce6 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java @@ -104,8 +104,9 @@ public class MappingSystemTest { private static final Eid EID_IPV4_1 = LispAddressUtil.asIpv4Eid(IPV4_STRING_1); private static final Eid EID_IPV4_2 = LispAddressUtil.asIpv4Eid(IPV4_STRING_2); private static final Eid EID_SERVICE_PATH = new EidBuilder().setAddress(getDefaultServicePath((short) 253)).build(); + // with index out of bounds private static final Eid EID_SERVICE_PATH_INDEX_OOB = new EidBuilder() - .setAddress(getDefaultServicePath((short) 200)).build(); // with index out of bounds + .setAddress(getDefaultServicePath((short) 200)).build(); public static final SimpleAddress SIMPLE_ADDR_1 = new SimpleAddress(new IpAddress(new Ipv4Address(IPV4_STRING_1))); public static final SimpleAddress SIMPLE_ADDR_2 = new SimpleAddress(new IpAddress(new Ipv4Address(IPV4_STRING_2))); @@ -203,7 +204,8 @@ public class MappingSystemTest { public void getMappingTest_NbFirst_withServicePathDestinationAddress_multipleLocatorRecords() { final MappingRecord mappingRecord = getDefaultMappingRecordBuilder() .setLocatorRecord(Lists.newArrayList( - getDefaultLocatorRecordBuilder().build(), // set two locators + // set two locators + getDefaultLocatorRecordBuilder().build(), getDefaultLocatorRecordBuilder().build())).build(); final MappingData mappingData = getDefaultMappingData(mappingRecord); Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData); @@ -219,7 +221,8 @@ public class MappingSystemTest { public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleIpv4LocatorRecord() { final MappingRecord mappingRecord = getDefaultMappingRecordBuilder() .setLocatorRecord(Lists.newArrayList( - getDefaultLocatorRecordBuilder().build())).build(); // Ipv4 type Rloc + // Ipv4 type Rloc + getDefaultLocatorRecordBuilder().build())).build(); final MappingData mappingData = getDefaultMappingData(mappingRecord); Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData); @@ -314,7 +317,8 @@ public class MappingSystemTest { setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB); final MappingRecord mappingRecord = getDefaultMappingRecordBuilder() .setLocatorRecord(Lists.newArrayList( - getDefaultLocatorRecordBuilder().build())).build(); // Ipv4 type Rloc + // Ipv4 type Rloc + getDefaultLocatorRecordBuilder().build())).build(); final MappingData mappingData = getDefaultMappingData(mappingRecord); Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData); @@ -332,7 +336,8 @@ public class MappingSystemTest { final MappingRecord mappingRecord = getDefaultMappingRecordBuilder() .setLocatorRecord(Lists.newArrayList( - getDefaultLocatorRecordBuilder().build())).build(); // Ipv4 type Rloc + // Ipv4 type Rloc + getDefaultLocatorRecordBuilder().build())).build(); MappingData nbMappingData = getDefaultMappingData(mappingRecord); MappingData sbMappingData = getDefaultMappingData(mappingRecord); sbMappingData.setTimestamp(EXPIRED_DATE); diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolverTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolverTest.java index 09feab567..d1b64a73b 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolverTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolverTest.java @@ -349,8 +349,10 @@ public class MapResolverTest { mapResolver = new MapResolver(mapServiceMock, true, "both", lispMappingServiceMock); final List ipAddressList = new ArrayList<>(); - ipAddressList.add(IPV4_ADDRESS_1); // hop 1 - ipAddressList.add(IPV4_ADDRESS_2); // hop 2 + // hop 1 + ipAddressList.add(IPV4_ADDRESS_1); + // hop 2 + ipAddressList.add(IPV4_ADDRESS_2); final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList); final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder(); @@ -362,30 +364,31 @@ public class MapResolverTest { mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build()); final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build()); - final MapRequestBuilder mapRequestBuilder = getDefaultMapRequestBuilder(); - mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)) - .build()); - mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)) - .build()); + final MapRequestBuilder mrb = getDefaultMapRequestBuilder(); + mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build()); + mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build()); - Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)) - .thenReturn(mappingData); + Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData); // result final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder() - .setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).setPriority((short) 1); // priority increased by 1 + // priority increased by 1 + .setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).setPriority((short) 1); final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder(); - resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build()); // as Ipv4 - resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build()); // as ELP - resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build()); // added to the result + // as Ipv4 + resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build()); + // as ELP + resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build()); + // added to the result + resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build()); final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder(); mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder() .setMappingRecord(resultMappingRecordBuilder.build()).build()); // invocation - mapResolver.handleMapRequest(mapRequestBuilder.build()); + mapResolver.handleMapRequest(mrb.build()); Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build()); } @@ -397,8 +400,10 @@ public class MapResolverTest { mapResolver = new MapResolver(mapServiceMock, true, "replace", lispMappingServiceMock); final List ipAddressList = new ArrayList<>(); - ipAddressList.add(IPV4_ADDRESS_1); // hop 1 - ipAddressList.add(IPV4_ADDRESS_2); // hop 2 + // hop 1 + ipAddressList.add(IPV4_ADDRESS_1); + // hop 2 + ipAddressList.add(IPV4_ADDRESS_2); final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList); final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder(); @@ -410,29 +415,28 @@ public class MapResolverTest { mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build()); final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build()); - final MapRequestBuilder mapRequestBuilder = getDefaultMapRequestBuilder(); - mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)) - .build()); - mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)) - .build()); + final MapRequestBuilder mrb = getDefaultMapRequestBuilder(); + mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build()); + mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build()); - Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)) - .thenReturn(mappingData); + Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData); // result final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder() .setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)); final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder(); - resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build()); // as Ipv4 - resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build()); // added to the result + // as Ipv4 + resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build()); + // added to the result + resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build()); final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder(); mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder() .setMappingRecord(resultMappingRecordBuilder.build()).build()); // invocation - mapResolver.handleMapRequest(mapRequestBuilder.build()); + mapResolver.handleMapRequest(mrb.build()); Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build()); } diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java index 928a41e34..160fef23e 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java @@ -116,20 +116,26 @@ public class MapServerTest { private static final long TWO_DAYS = 86400000L * 2; - private static final Subscriber SUBSCRIBER_RLOC_1 = new Subscriber(RLOC_1, // timedOut() == true + // timedOut() == true + private static final Subscriber SUBSCRIBER_RLOC_1 = new Subscriber(RLOC_1, IPV4_SOURCE_EID_1, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT, new Date(System.currentTimeMillis() - TWO_DAYS)); - private static final Subscriber SUBSCRIBER_RLOC_2 = new Subscriber(RLOC_2, // timedOut() == false + // timedOut() == false + private static final Subscriber SUBSCRIBER_RLOC_2 = new Subscriber(RLOC_2, IPV4_SOURCE_EID_2, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT); - private static final Subscriber SUBSCRIBER_RLOC_3 = new Subscriber(RLOC_3, // timedOut() == true + // timedOut() == true + private static final Subscriber SUBSCRIBER_RLOC_3 = new Subscriber(RLOC_3, IPV4_SOURCE_EID_3, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT, new Date(System.currentTimeMillis() - TWO_DAYS)); - private static final Subscriber SUBSCRIBER_RLOC_4 = new Subscriber(RLOC_4, // timedOut() == false + // timedOut() == false + private static final Subscriber SUBSCRIBER_RLOC_4 = new Subscriber(RLOC_4, IPV4_SOURCE_EID_4, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT); - private static final Subscriber SUBSCRIBER_RLOC_5 = new Subscriber(RLOC_5, // timedOut() == true + // timedOut() == true + private static final Subscriber SUBSCRIBER_RLOC_5 = new Subscriber(RLOC_5, IPV4_SOURCE_EID_5, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT, new Date(System.currentTimeMillis() - TWO_DAYS)); - private static final Subscriber SUBSCRIBER_RLOC_6 = new Subscriber(RLOC_6, // timedOut() == false + // timedOut() == false + private static final Subscriber SUBSCRIBER_RLOC_6 = new Subscriber(RLOC_6, IPV4_SOURCE_EID_6, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT); private static final Eid SOURCE_DEST_KEY_EID = LispAddressUtil @@ -539,14 +545,14 @@ public class MapServerTest { .setEid(eid); } - private static MapNotifyBuilder getDefaultMapNotifyBuilder(MapRegister mapRegister) { + private static MapNotifyBuilder getDefaultMapNotifyBuilder(MapRegister mr) { final MapNotifyBuilder mapNotifyBuilder = new MapNotifyBuilder() - .setXtrSiteIdPresent(mapRegister.isXtrSiteIdPresent()) - .setSiteId(mapRegister.getSiteId()) - .setXtrId(mapRegister.getXtrId()) - .setNonce(mapRegister.getNonce()) - .setKeyId(mapRegister.getKeyId()) - .setMergeEnabled(mapRegister.isMergeEnabled()) + .setXtrSiteIdPresent(mr.isXtrSiteIdPresent()) + .setSiteId(mr.getSiteId()) + .setXtrId(mr.getXtrId()) + .setNonce(mr.getNonce()) + .setKeyId(mr.getKeyId()) + .setMergeEnabled(mr.isMergeEnabled()) .setMappingRecordItem(new ArrayList<>()) .setAuthenticationData(new byte[]{}); mapNotifyBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder().build()); diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java index 8eb516b0f..83d9c2f38 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java @@ -116,7 +116,8 @@ public class MappingServiceTest { // input final RpcResult rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-exists", "Key already exists! Please use update-key if you want to change it.").build(); - final RpcError error = rpc.getErrors().iterator().next(); // equals() not implemented int RpcError + // equals() not implemented int RpcError + final RpcError error = rpc.getErrors().iterator().next(); // result final Future> result = mappingService.addKey(addKeyInput); diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtilTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtilTest.java index 263eb2d38..386201000 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtilTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtilTest.java @@ -244,10 +244,12 @@ public class MappingMergeUtilTest { assertEquals(2, result.getRecord().getLocatorRecord().size()); assertEquals("NB-locator-id", resultLocator_1.getLocatorId()); - assertEquals(255, (short) resultLocator_1.getPriority()); // priority changed to 255 + // priority changed to 255 + assertEquals(255, (short) resultLocator_1.getPriority()); assertEquals("NB-locator-id", resultLocator_2.getLocatorId()); - assertEquals(1, (short) resultLocator_2.getPriority()); // priority remains original + // priority remains original + assertEquals(1, (short) resultLocator_2.getPriority()); } private static MappingData getDefaultMappingData() { diff --git a/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/HashMapDb.java b/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/HashMapDb.java index 0df70387a..df27cd8f9 100644 --- a/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/HashMapDb.java +++ b/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/HashMapDb.java @@ -107,17 +107,17 @@ public class HashMapDb implements ILispDAO, AutoCloseable { @Override public SimpleImmutableEntry> getBestPair(Object key) { - Map data = null; + Map result = null; if (key instanceof Eid) { Eid eid = (Eid) key; RadixTrie.TrieNode node = lookupBestNode(eid); if (node == null) { - data = get(key); - return (data == null) ? null : new SimpleImmutableEntry<>((Eid)key, data); + result = get(key); + return (result == null) ? null : new SimpleImmutableEntry<>((Eid)key, result); } - data = get(node.data()); - return (data == null) ? null : new SimpleImmutableEntry<>((Eid)node.data(), data); + result = get(node.data()); + return (result == null) ? null : new SimpleImmutableEntry<>((Eid)node.data(), result); } return null; } diff --git a/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrie.java b/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrie.java index 744bfe605..ef14492fe 100644 --- a/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrie.java +++ b/mappingservice/inmemorydb/src/main/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrie.java @@ -400,7 +400,8 @@ public class RadixTrie { this.bit = prefixlen; this.prefix = prefix; this.data = data; - left = right = null; + left = null; + right = null; } public byte[] prefix() { @@ -418,15 +419,15 @@ public class RadixTrie { /** * Finds closest prefix NOT the longest prefix match. * - * @param prefix Searched prefix + * @param pref Searched prefix * @param preflen Searched prefix length * @return The node found */ - public TrieNode findClosest(byte[] prefix, int preflen) { + public TrieNode findClosest(byte[] pref, int preflen) { TrieNode node = this; while (node.prefix == null || node.bit < preflen) { - if (testBitInPrefixByte(prefix, node.bit)) { + if (testBitInPrefixByte(pref, node.bit)) { if (node.right == null) { break; } @@ -449,18 +450,19 @@ public class RadixTrie { /** * Compares prefix to node's prefix and returns position of first different bit. * - * @param prefix Prefix to be compared. + * @param pref Prefix to be compared. * @param preflen Prefix length. * @return Position of first different bit. */ - public int firstDifferentBit(byte[] prefix, int preflen) { + public int firstDifferentBit(byte[] pref, int preflen) { int bitxor; int maxbit = (bit < preflen) ? bit : preflen; int diffbit = 0; for (int i = 0; i * 8 < maxbit; i++) { + bitxor = ((toUnsignedInt(this.prefix[i])) ^ toUnsignedInt(pref[i])); // if match, move to next byte - if ((bitxor = ((toUnsignedInt(this.prefix[i])) ^ toUnsignedInt(prefix[i]))) == 0) { + if (bitxor == 0) { diffbit = (i + 1) * 8; continue; } @@ -515,10 +517,10 @@ public class RadixTrie { * @param pref Prefix to be inserted. * @param preflen Prefix length of the prefix to be inserted. * @param diffbit Bit index of the first different bit between prefix and current node - * @param data Data to be stored together with the prefix + * @param prefdata Data to be stored together with the prefix * @return The trie node created or current node if it's an overwrite. */ - public TrieNode insert(byte[] pref, int preflen, int diffbit, T data, byte[] closest) { + public TrieNode insert(byte[] pref, int preflen, int diffbit, T prefdata, byte[] closest) { TrieNode parent; // same node, check if prefix needs saving @@ -527,12 +529,12 @@ public class RadixTrie { return this; } this.prefix = pref; - this.data = data; + this.data = prefdata; nbActiveNodes++; return this; } - TrieNode newNode = new TrieNode(pref, preflen, data); + TrieNode newNode = new TrieNode(pref, preflen, prefdata); // node is more specific, add new prefix as parent if (preflen == diffbit) { @@ -660,7 +662,9 @@ public class RadixTrie { return false; } } - if ((remainder = bit % 8) != 0) { + + remainder = bit % 8; + if (remainder != 0) { int mask = (0xFF << (8 - remainder)) & 0xFF; return ((prefix[iterator] & mask) == (pref[iterator] & mask)); } diff --git a/mappingservice/inmemorydb/src/test/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrieTest.java b/mappingservice/inmemorydb/src/test/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrieTest.java index 6b17a2974..ccd259b24 100644 --- a/mappingservice/inmemorydb/src/test/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrieTest.java +++ b/mappingservice/inmemorydb/src/test/java/org/opendaylight/lispflowmapping/inmemorydb/radixtrie/RadixTrieTest.java @@ -452,63 +452,63 @@ public class RadixTrieTest { @Test public void testClearIntermediariesToRoot() { - RadixTrie radixTrie4 = new RadixTrie<>(32); + RadixTrie stringRadixTrie4 = new RadixTrie<>(32); // Add prefixes - radixTrie4.insert(IP4_BYTES22, 32, "1.1.1.1"); - radixTrie4.insert(IP4_BYTES23, 32, "2.2.2.2"); - radixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10"); - radixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20"); + stringRadixTrie4.insert(IP4_BYTES22, 32, "1.1.1.1"); + stringRadixTrie4.insert(IP4_BYTES23, 32, "2.2.2.2"); + stringRadixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10"); + stringRadixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20"); // Remove 10.10.10.10 & 20.20.20.20 (root should be updated) - radixTrie4.remove(IP4_BYTES24, 32); - radixTrie4.remove(IP4_BYTES25, 32); + stringRadixTrie4.remove(IP4_BYTES24, 32); + stringRadixTrie4.remove(IP4_BYTES25, 32); // Re-add 10.10.10.10 & 20.20.20.20 - radixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10"); - radixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20"); + stringRadixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10"); + stringRadixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20"); // Make sure 10.10.10.10 & 20.20.20.20 lookup succeeds - RadixTrie.TrieNode res2 = radixTrie4.lookupBest(IP4_BYTES24, 32); + RadixTrie.TrieNode res2 = stringRadixTrie4.lookupBest(IP4_BYTES24, 32); assertTrue("Lookup 10.10.10.10 result is NULL", res2 != null); assertTrue("Lookup Result for 10.10.10.10 is not right", res2.data().equals("10.10.10.10")); - RadixTrie.TrieNode res3 = radixTrie4.lookupBest(IP4_BYTES25, 32); + RadixTrie.TrieNode res3 = stringRadixTrie4.lookupBest(IP4_BYTES25, 32); assertTrue("Lookup 20.20.20.20 result is NULL", res3 != null); assertTrue("Lookup Result for 20.20.20.20 is not right", res3.data().equals("20.20.20.20")); // Remove 10.10.10.10 & 20.20.20.20 (root should be updated) - radixTrie4.remove(IP4_BYTES24, 32); - radixTrie4.remove(IP4_BYTES25, 32); + stringRadixTrie4.remove(IP4_BYTES24, 32); + stringRadixTrie4.remove(IP4_BYTES25, 32); // Add 10.10.10.0 & 20.20.20.0 - radixTrie4.insert(IP4_BYTES25, 24, "20.20.20.0"); - radixTrie4.insert(IP4_BYTES24, 24, "10.10.10.0"); + stringRadixTrie4.insert(IP4_BYTES25, 24, "20.20.20.0"); + stringRadixTrie4.insert(IP4_BYTES24, 24, "10.10.10.0"); - RadixTrie.TrieNode res4 = radixTrie4.lookupBest(IP4_BYTES23, 32); + RadixTrie.TrieNode res4 = stringRadixTrie4.lookupBest(IP4_BYTES23, 32); assertTrue("Lookup 2.2.2.2 result is NULL", res4 != null); assertTrue("Lookup Result for 2.2.2.2 is not right", res4.data().equals("2.2.2.2")); - RadixTrie.TrieNode res5 = radixTrie4.lookupBest(IP4_BYTES22, 32); + RadixTrie.TrieNode res5 = stringRadixTrie4.lookupBest(IP4_BYTES22, 32); assertTrue("Lookup 1.1.1.1 result is NULL", res5 != null); assertTrue("Lookup Result for 1.1.1.1 is not right", res5.data().equals("1.1.1.1")); - RadixTrie.TrieNode res6 = radixTrie4.lookupBest(IP4_BYTES25, 24); + RadixTrie.TrieNode res6 = stringRadixTrie4.lookupBest(IP4_BYTES25, 24); assertTrue("Lookup 20.20.20.20 result is NULL", res6 != null); assertTrue("Lookup Result for 20.20.20.0 is not right", res6.data().equals("20.20.20.0")); - RadixTrie.TrieNode res7 = radixTrie4.lookupBest(IP4_BYTES24, 24); + RadixTrie.TrieNode res7 = stringRadixTrie4.lookupBest(IP4_BYTES24, 24); assertTrue("Lookup 10.10.10.10 result is NULL", res7 != null); assertTrue("Lookup Result for 10.10.10.0 is not right", res7.data().equals("10.10.10.0")); } @Test public void testLookupExact() { - RadixTrie radixTrie4 = new RadixTrie<>(32); + RadixTrie stringRadixTrie4 = new RadixTrie<>(32); - radixTrie4.insert(IP4_BYTES1, 16, "192.168.0.0"); + stringRadixTrie4.insert(IP4_BYTES1, 16, "192.168.0.0"); - RadixTrie.TrieNode res1 = radixTrie4.lookupExact(IP4_BYTES4, 24); + RadixTrie.TrieNode res1 = stringRadixTrie4.lookupExact(IP4_BYTES4, 24); assertTrue("Lookup for 192.168.1.0 is not NULL", res1 == null); - RadixTrie.TrieNode res2 = radixTrie4.lookupExact(IP4_BYTES1, 16); + RadixTrie.TrieNode res2 = stringRadixTrie4.lookupExact(IP4_BYTES1, 16); assertTrue("Lookup for 192.168.0.0 is NULL", res2 != null); } diff --git a/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCache.java b/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCache.java index 562cd3fa1..e7a5753d0 100644 --- a/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCache.java +++ b/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCache.java @@ -66,10 +66,10 @@ public class SimpleMapCache implements ILispMapCache { return table; } - private ILispDAO getOrInstantiateXtrIdTable(Eid eid, ILispDAO dao) { - ILispDAO table = (ILispDAO) dao.getSpecific(eid, SubKeys.XTRID_RECORDS); + private ILispDAO getOrInstantiateXtrIdTable(Eid eid, ILispDAO lispDAO) { + ILispDAO table = (ILispDAO) lispDAO.getSpecific(eid, SubKeys.XTRID_RECORDS); if (table == null) { - table = dao.putNestedTable(eid, SubKeys.XTRID_RECORDS); + table = lispDAO.putNestedTable(eid, SubKeys.XTRID_RECORDS); } return table; } @@ -99,8 +99,8 @@ public class SimpleMapCache implements ILispMapCache { // Returns the mapping corresponding to the longest prefix match for eid. eid must be a simple (maskable or not) // address - private Object getMappingLpmEid(Eid eid, XtrId xtrId, ILispDAO dao) { - SimpleImmutableEntry> daoEntry = dao.getBestPair(MaskUtil.normalize(eid)); + private Object getMappingLpmEid(Eid eid, XtrId xtrId, ILispDAO lispDAO) { + SimpleImmutableEntry> daoEntry = lispDAO.getBestPair(MaskUtil.normalize(eid)); if (daoEntry != null) { if (xtrId != null) { ILispDAO xtrIdTable = (ILispDAO) daoEntry.getValue().get(SubKeys.XTRID_RECORDS); @@ -134,10 +134,10 @@ public class SimpleMapCache implements ILispMapCache { } // Returns the list of mappings stored in an xTR-ID DAO - private List getXtrIdMappingList(ILispDAO dao) { - if (dao != null) { + private List getXtrIdMappingList(ILispDAO lispDAO) { + if (lispDAO != null) { final List records = new ArrayList<>(); - dao.getAll(new IRowVisitor() { + lispDAO.getAll(new IRowVisitor() { public void visitRow(Object keyId, String valueKey, Object value) { if (valueKey.equals(SubKeys.RECORD)) { records.add(value); diff --git a/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/lisp/LispMapCacheStringifier.java b/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/lisp/LispMapCacheStringifier.java index cb80a1049..96c38c161 100644 --- a/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/lisp/LispMapCacheStringifier.java +++ b/mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/lisp/LispMapCacheStringifier.java @@ -20,7 +20,11 @@ import org.opendaylight.lispflowmapping.lisp.util.Stringifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey; -public class LispMapCacheStringifier { +public final class LispMapCacheStringifier { + // Utility class, should not be instantiated + private LispMapCacheStringifier() { + } + public static String printKeys(ILispDAO dao) { final StringBuilder sb = new StringBuilder(); sb.append("Keys\tValues\n"); diff --git a/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCacheTest.java b/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCacheTest.java index 2fcd1477d..4694debde 100644 --- a/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCacheTest.java +++ b/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCacheTest.java @@ -189,8 +189,8 @@ public class SimpleMapCacheTest { Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock); Mockito.when(tableMock.getBestPair(NORMALIZED_EID_IPV4_PREFIX_DST)).thenReturn(mapPair); Mockito.when(mapMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock); - Mockito.when(xtrIdDaoMock.getSpecific(XTR_ID, SubKeys.RECORD)) - .thenReturn(mappingData); // second invocation + // second invocation + Mockito.when(xtrIdDaoMock.getSpecific(XTR_ID, SubKeys.RECORD)).thenReturn(mappingData); // with non-expired mapping record assertEquals(mappingData, simpleMapCache.getMapping(EID_IPV4_PREFIX_DST, XTR_ID)); @@ -375,7 +375,8 @@ public class SimpleMapCacheTest { Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock); Mockito.when(tableMock.getSpecific(NORMALIZED_EID_2, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock); - simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock); // Eid VNI_100 == null + // Eid VNI_100 == null + simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock); Mockito.verify(daoMock).getSpecific(VNI_0, SubKeys.VNI); Mockito.verify(daoMock, Mockito.never()).putNestedTable(VNI_0, SubKeys.VNI); } @@ -389,7 +390,8 @@ public class SimpleMapCacheTest { Mockito.when(tableMock.getSpecific(NORMALIZED_EID_2, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock); Mockito.when(daoMock.putNestedTable(VNI_0, SubKeys.VNI)).thenReturn(tableMock); - simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock); // Eid VNI_100 == null + // Eid VNI_100 == null + simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock); Mockito.verify(daoMock).putNestedTable(VNI_0, SubKeys.VNI); } @@ -402,7 +404,8 @@ public class SimpleMapCacheTest { Mockito.when(tableMock.getSpecific(NORMALIZED_EID_1, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock); Mockito.when(daoMock.putNestedTable(VNI_100, SubKeys.VNI)).thenReturn(tableMock); - simpleMapCache.addMapping(EID_IPV4_PREFIX_1_VNI, mappingDataMock); // Eid VNI_100 == null + // Eid VNI_100 == null + simpleMapCache.addMapping(EID_IPV4_PREFIX_1_VNI, mappingDataMock); Mockito.verify(daoMock).putNestedTable(VNI_100, SubKeys.VNI); } diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/IntentHandlerAsyncExecutorProvider.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/IntentHandlerAsyncExecutorProvider.java index 7e0a94b49..f4da63f4c 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/IntentHandlerAsyncExecutorProvider.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/IntentHandlerAsyncExecutorProvider.java @@ -15,7 +15,7 @@ import java.util.concurrent.Executors; /** * Created by Shakib Ahmed on 1/24/17. */ -public class IntentHandlerAsyncExecutorProvider { +public final class IntentHandlerAsyncExecutorProvider { private static ListeningExecutorService listeningExecutorService; private static final int EXTRA_THREADS_TO_HANDLE_VPP_LISTENER = 1; @@ -41,4 +41,4 @@ public class IntentHandlerAsyncExecutorProvider { public void close() { listeningExecutorService.shutdown(); } -} \ No newline at end of file +} diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/exception/RlocNotFoundOnVppNode.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/exception/RlocNotFoundOnVppNode.java index d053da17f..6bf8a10fe 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/exception/RlocNotFoundOnVppNode.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/exception/RlocNotFoundOnVppNode.java @@ -11,7 +11,13 @@ package org.opendaylight.lispflowmapping.neutron.intenthandler.exception; * Created by Shakib Ahmed on 1/12/17. */ public class RlocNotFoundOnVppNode extends RuntimeException { + private static final String MESSAGE = "No available interface found on node "; + public RlocNotFoundOnVppNode(String hostId) { - super("No available interface found on node " + hostId); + super(MESSAGE + hostId); + } + + public RlocNotFoundOnVppNode(String hostId, Throwable cause) { + super(MESSAGE + hostId, cause); } } diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/InfoUtil.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/InfoUtil.java index b48f51250..d1c32f904 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/InfoUtil.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/InfoUtil.java @@ -16,10 +16,8 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; /** * Created by Shakib Ahmed on 1/23/17. */ -public class InfoUtil { - +public final class InfoUtil { private InfoUtil() { - } public static String topology(final KeyedInstanceIdentifier topoIID) { diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/LispNeutronUtil.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/LispNeutronUtil.java index 820d76a88..b4b96c081 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/LispNeutronUtil.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/LispNeutronUtil.java @@ -19,10 +19,11 @@ import org.slf4j.LoggerFactory; /** * Created by Shakib Ahmed on 1/12/17. */ -public class LispNeutronUtil { +public final class LispNeutronUtil { protected static final Logger LOG = LoggerFactory.getLogger(LispNeutronUtil.class); - private LispNeutronUtil(){} + private LispNeutronUtil() { + } public static DataBroker resolveDataBrokerForMountPoint(InstanceIdentifier iiToMountPoint, MountPointService mountService) { diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNetconfTrasaction.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNetconfTrasaction.java index 9a3debb20..bd7b51b2a 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNetconfTrasaction.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNetconfTrasaction.java @@ -25,11 +25,14 @@ import org.slf4j.LoggerFactory; /** * Created by Shakib Ahmed on 1/12/17. */ -public class VppNetconfTrasaction { +public final class VppNetconfTrasaction { private static final Logger LOG = LoggerFactory.getLogger(VppNetconfTrasaction.class); public static final byte RETRY_COUNT = 5; + private VppNetconfTrasaction() { + } + public static synchronized Optional read(DataBroker dataBroker, LogicalDatastoreType datastoreType, InstanceIdentifier instanceIdentifier) { diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNodeReader.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNodeReader.java index dad2cff0d..031178bcc 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNodeReader.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/intenthandler/util/VppNodeReader.java @@ -60,7 +60,7 @@ public class VppNodeReader { } catch (final InterruptedException | ExecutionException ex) { LOG.warn("Got exception while reading IP addresses from nodes {}", InfoUtil.node(instanceIdentifierToVppNode)); - throw new RlocNotFoundOnVppNode(InfoUtil.node(instanceIdentifierToVppNode)); + throw new RlocNotFoundOnVppNode(InfoUtil.node(instanceIdentifierToVppNode), ex); } } diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/mappingmanager/HostInformationManager.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/mappingmanager/HostInformationManager.java index 516c45aa4..62bfdf072 100644 --- a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/mappingmanager/HostInformationManager.java +++ b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/mappingmanager/HostInformationManager.java @@ -36,7 +36,7 @@ public class HostInformationManager { private static HostInformationManager instance; - private HostInformationManager() { + HostInformationManager() { hostIdToPortDataMapper = new HostIdToPortDataMapper(); hostIdToRlocMapper = new HostIdToRlocMapper(); neutronTenantToVniMapper = new NeutronTenantToVniMapper(); @@ -53,8 +53,8 @@ public class HostInformationManager { return neutronTenantToVniMapper.getVni(tenantUuid); } - public void setOdlMappingserviceService(OdlMappingserviceService lfmDbService) { - this.lfmDbService = lfmDbService; + public void setOdlMappingserviceService(OdlMappingserviceService mappingservice) { + this.lfmDbService = mappingservice; } public synchronized void addHostRelatedInfo(String hostId, Object data) { @@ -107,4 +107,4 @@ public class HostInformationManager { lfmDbService.removeMapping(removeMappingInput); uuidToEidMapper.deleteProcessedPortData(portUuid); } -} \ No newline at end of file +} diff --git a/mappingservice/neutron/src/test/java/org/opendaylight/lispflowmapping/neutron/PortDataProcessorTest.java b/mappingservice/neutron/src/test/java/org/opendaylight/lispflowmapping/neutron/PortDataProcessorTest.java index 4e5cd1a5d..5b5058677 100644 --- a/mappingservice/neutron/src/test/java/org/opendaylight/lispflowmapping/neutron/PortDataProcessorTest.java +++ b/mappingservice/neutron/src/test/java/org/opendaylight/lispflowmapping/neutron/PortDataProcessorTest.java @@ -69,7 +69,8 @@ public class PortDataProcessorTest { future = Mockito.mock(Future.class); rpcResult = Mockito.mock(RpcResult.class); Whitebox.setInternalState(portDataProcessor, "hostInformationManager", hostInformationManager); - commonStubbing(); // common stubbing is called before invocation of each test + // common stubbing is called before invocation of each test + commonStubbing(); } /** @@ -94,7 +95,8 @@ public class PortDataProcessorTest { */ @Test public void createTest_nullHostId() throws ExecutionException, InterruptedException { - Mockito.when(augmentationMock.getHostId()).thenReturn(null); // overriding default stubbing + // overriding default stubbing + Mockito.when(augmentationMock.getHostId()).thenReturn(null); portDataProcessor.create(portMock); diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java index 6977e6077..229d94c26 100644 --- a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java +++ b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java @@ -117,11 +117,11 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl this.dsbe = new DataStoreBackEnd(dataBroker); restoreDaoFromDatastore(); - LispSouthboundHandler lispSouthboundHandler = new LispSouthboundHandler(this); - this.lispSouthboundHandler = lispSouthboundHandler; + LispSouthboundHandler lsbh = new LispSouthboundHandler(this); + this.lispSouthboundHandler = lsbh; - LispXtrSouthboundHandler lispXtrSouthboundHandler = new LispXtrSouthboundHandler(this); - this.lispXtrSouthboundHandler = lispXtrSouthboundHandler; + LispXtrSouthboundHandler lxsbh = new LispXtrSouthboundHandler(this); + this.lispXtrSouthboundHandler = lxsbh; if (Epoll.isAvailable()) { eventLoopGroup = new EpollEventLoopGroup(numChannels, threadFactory); @@ -137,11 +137,11 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl bootstrap.group(eventLoopGroup); bootstrap.channel(channelType); - bootstrap.handler(lispSouthboundHandler); + bootstrap.handler(lsbh); xtrBootstrap.group(eventLoopGroup); xtrBootstrap.channel(channelType); - xtrBootstrap.handler(lispXtrSouthboundHandler); + xtrBootstrap.handler(lxsbh); start(); startXtr(); diff --git a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java index 843b6d4e4..0f201d7bc 100644 --- a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java +++ b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java @@ -207,8 +207,8 @@ public class LispSouthboundPluginTest { Mockito.verify(handlerMock).close(); assertNull(getField("lispSouthboundHandler")); assertNull(getField("lispXtrSouthboundHandler")); - Channel[] channel = getField("channel"); - assertNull(channel[0]); + Channel[] channels = getField("channel"); + assertNull(channels[0]); } private static void injectChannel() throws NoSuchFieldException, IllegalAccessException { diff --git a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandlerTest.java b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandlerTest.java index b600dade1..aae6e3d8e 100644 --- a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandlerTest.java +++ b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandlerTest.java @@ -169,14 +169,14 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // Nonce: 0x3d8d2acd39c8d608 // ITR-RLOC AFI=1 Address=192.168.136.10 // Record 1: 1.2.3.4/32 - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " + "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 " + "0030 00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 " + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d " + "0050 2a cd 39 c8 d6 08 00 01 01 02 03 04 00 01 c0 a8 88 0a 00 20 " - + "0060 00 01 01 02 03 04")); + + "0060 00 01 01 02 03 04"); mapReplyBuilder = new MapReplyBuilder(); mapReplyBuilder.setMappingRecordItem(new ArrayList()); mapReplyBuilder.setNonce((long) 0); @@ -209,14 +209,14 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // 255/0 // - mapRegisterPacket = extractWSUdpByteArray(new String( + mapRegisterPacket = extractWSUdpByteArray( "0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 " + "0040 71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 " + "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " - + "0060 ff 00 00 05 00 01 c0 a8 88 0a")); + + "0060 ff 00 00 05 00 01 c0 a8 88 0a"); mapNotifyBuilder = new MapNotifyBuilder(); mapNotifyBuilder.setAuthenticationData(new byte[0]); } @@ -231,31 +231,31 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test(expected = LispMalformedPacketException.class) public void mapRegister__IllegalPacket() throws Exception { - mapRegisterPacket = extractWSUdpByteArray(new String( + mapRegisterPacket = extractWSUdpByteArray( "0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 " + "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " - + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 ")); + + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 "); handleMapRegisterPacket(mapRegisterPacket); } @Test(expected = LispMalformedPacketException.class) public void mapRequest__IllegalPacket() throws Exception { - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " + "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 " + "0030 00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 " - + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d ")); + + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d "); handleMapRequestPacket(mapRequestPacket); } @Test(expected = LispMalformedPacketException.class) public void mapRequest__IllegalEncapsulatedPacket() throws Exception { - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " + "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " - + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 ")); + + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "); handleMapRequestPacket(mapRequestPacket); } @@ -267,7 +267,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // Priority/Weight: 255/0 // Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100, // Multicast Priority/Weight: 255/0 - mapRegisterPacket = extractWSUdpByteArray(new String( + mapRegisterPacket = extractWSUdpByteArray( "0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 " + "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 " @@ -275,7 +275,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { + "0040 e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 " + "0050 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 " + "0060 ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 " - + "0070 00 01 c0 a8 88 33")); + + "0070 00 01 c0 a8 88 33"); ArgumentCaptor captor = ArgumentCaptor.forClass(AddMapping.class); handleMapRegisterPacket(mapRegisterPacket); @@ -303,7 +303,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast // Priority/Weight: 255/0 - mapRegisterPacket = extractWSUdpByteArray(new String( + mapRegisterPacket = extractWSUdpByteArray( "0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " + "0010 00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 " + "0020 01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 " @@ -311,7 +311,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { + "0040 0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 " + "0050 00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff " + "0060 01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 " - + "0070 00 01 0a 00 3a 9c")); + + "0070 00 01 0a 00 3a 9c"); ArgumentCaptor captor = ArgumentCaptor.forClass(AddMapping.class); handleMapRegisterPacket(mapRegisterPacket); @@ -347,14 +347,14 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister__NonSetMBit() throws Exception { - byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String( + byte[] registerWithNonSetMBit = extractWSUdpByteArray( "0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 00 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 79 d1 44 66 19 99 " + "0040 83 63 a7 79 6e f0 40 97 54 26 3a 44 b4 eb 00 00 " + "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " - + "0060 ff 00 00 05 00 01 c0 a8 88 0a")); + + "0060 ff 00 00 05 00 01 c0 a8 88 0a"); ArgumentCaptor captor = ArgumentCaptor.forClass(AddMapping.class); handleMapRegisterPacket(registerWithNonSetMBit); @@ -364,14 +364,14 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister__NonSetMBitWithNonZeroReservedBits() throws Exception { - byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String( + byte[] registerWithNonSetMBit = extractWSUdpByteArray( "0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 02 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 c0 c7 c5 2f 57 f6 " + "0040 e7 20 25 3d e8 b2 07 e2 63 de 62 2b 7a 20 00 00 " + "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " - + "0060 ff 00 00 05 00 01 c0 a8 88 0a")); + + "0060 ff 00 00 05 00 01 c0 a8 88 0a"); ArgumentCaptor captor = ArgumentCaptor.forClass(AddMapping.class); handleMapRegisterPacket(registerWithNonSetMBit); @@ -381,14 +381,14 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister__SetMBitWithNonZeroReservedBits() throws Exception { - byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String( + byte[] registerWithNonSetMBit = extractWSUdpByteArray( "0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 03 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 a2 72 40 7b 1a ae " + "0040 4e 6b e2 e5 e1 01 40 8a c9 e1 d1 80 cb 72 00 00 " + "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " - + "0060 ff 00 00 05 00 01 c0 a8 88 0a")); + + "0060 ff 00 00 05 00 01 c0 a8 88 0a"); ArgumentCaptor captor = ArgumentCaptor.forClass(AddMapping.class); handleMapRegisterPacket(registerWithNonSetMBit); @@ -403,11 +403,13 @@ public class LispSouthboundHandlerTest extends BaseTestCase { public void mapRegister_isMappingKeepAliveAndMapNotifyGenerated() throws InterruptedException, UnknownHostException { byte[] eidPrefixAfi = new byte[] { - 0x00, 0x01 //eid-prefix-afi + //eid-prefix-afi + 0x00, 0x01 }; byte[] eidPrefix = new byte[] { - 0x0a, 0x0a, 0x0a, 0x0a //ipv4 address + //ipv4 address + 0x0a, 0x0a, 0x0a, 0x0a }; //send stream of byte -> map register message @@ -446,11 +448,13 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister_cacheWithEidPrefixIpv4Test() throws InterruptedException { byte[] eidPrefixAfi = new byte[] { - 0x00, 0x01 //eid-prefix-afi + //eid-prefix-afi + 0x00, 0x01 }; byte[] eidPrefix = new byte[] { - 0x0a, 0x0a, 0x0a, 0x0a //ipv4 address + //ipv4 address + 0x0a, 0x0a, 0x0a, 0x0a }; cacheTest(eidPrefixAfi, eidPrefix, MapRegisterCacheTestUtil.AUTH_DATA); @@ -462,17 +466,22 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister_cacheWithEidPrefixIpv6Test() throws InterruptedException { byte[] eidPrefixAfi = new byte[] { - 0x00, 0x02 //eid-prefix-afi + //eid-prefix-afi + 0x00, 0x02 }; byte[] eidPrefix = new byte[] { - 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address - 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address - 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address - 0x0f, 0x0f, 0x0f, 0x0f //ipv6 address + //ipv6 address + 0x0f, 0x0f, 0x0f, 0x0f, + //ipv6 address + 0x0f, 0x0f, 0x0f, 0x0f, + //ipv6 address + 0x0f, 0x0f, 0x0f, 0x0f, + //ipv6 address + 0x0f, 0x0f, 0x0f, 0x0f }; - byte[] authenticationData = new byte[]{ + byte[] authenticationData = new byte[] { 0x00, 0x14, 0x41,(byte)0x83,0x13,0x7C, 0x48,(byte)0xEE,0x75,(byte)0x9A, @@ -490,14 +499,16 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister_cacheWithEidPrefixMac48Test() throws InterruptedException { byte[] eidPrefixAfi = new byte[] { - 0x40, 0x05 //eid-prefix-afi + //eid-prefix-afi + 0x40, 0x05 }; byte[] eidPrefix = new byte[] { - 0x0a, 0x0b, 0x0c, 0x0d, //mac address - 0x0e, 0x0f //mac address + //mac address + 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; - byte[] authenticationData = new byte[]{ + + byte[] authenticationData = new byte[] { 0x00, 0x14, (byte)0xB2,(byte)0x8E,0x6,(byte)0x9D, 0x61,(byte)0xD8,0xC,0x24, @@ -514,7 +525,8 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test public void mapRegister_cacheWithEidPrefixLcafTest() throws InterruptedException { byte[] eidPrefixAfi = new byte[] { - 0x40, 0x03 //eid-prefix-afi + //eid-prefix-afi + 0x40, 0x03 }; //following lcaf prefixed variables are defined according to https://tools.ietf @@ -531,13 +543,19 @@ public class LispSouthboundHandlerTest extends BaseTestCase { byte[] eidPrefix = joinArrays(lcafRsvd1, lcafFlags, lcafType, lcafIIDMaskLength, lcafLength, lcafInstanceId, lcafAfi, lcafAddress); - byte[] authenticationData = new byte[]{ - 0x00, 0x14, //authentication data length - 0x68, 0x1d, (byte) 0x9e, 0x6e, //auth data - 0x5e, 0x32, (byte) 0x88, 0x1a, //auth data - (byte) 0xae, 0x6b, (byte) 0xe3, 0x40, //auth data - 0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0, //auth data - 0x71, (byte) 0xf4, (byte) 0x8c, 0x5f //auth data + byte[] authenticationData = new byte[] { + //authentication data length + 0x00, 0x14, + //auth data + 0x68, 0x1d, (byte) 0x9e, 0x6e, + //auth data + 0x5e, 0x32, (byte) 0x88, 0x1a, + //auth data + (byte) 0xae, 0x6b, (byte) 0xe3, 0x40, + //auth data + 0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0, + //auth data + 0x71, (byte) 0xf4, (byte) 0x8c, 0x5f }; @@ -715,7 +733,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // Map-Reply Record: EID prefix: 2610:d0:ffff:192::1/128, TTL: 10, // Authoritative, No-Action - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " + "0010 00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 " + "0020 01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 " @@ -727,7 +745,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { + "0080 3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 " + "0090 00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 " + "00a0 00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 " - + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c")); + + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"); ArgumentCaptor captor = ArgumentCaptor.forClass(RequestMapping.class); handleMapRequestAsByteArray(mapRequestPacket); @@ -746,7 +764,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // (2610:d0:ffff:192::2) // encapsulated UDP source port: 4342 - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " + "0010 00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 " + "0020 01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 " @@ -758,7 +776,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { + "0080 3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 " + "0090 00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 " + "00a0 00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 " - + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c")); + + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"); ArgumentCaptor captor = ArgumentCaptor.forClass(RequestMapping.class); DatagramPacket replyPacket = handleMapRequestPacket(mapRequestPacket); @@ -771,7 +789,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // encapsulated LISP packet // Source EID = 153.16.254.1 - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 0c 29 7a ce 83 00 15 17 c6 4a c9 08 00 45 00 " + "0010 00 78 00 00 40 00 3e 11 ec b1 0a 00 01 26 0a 00 " + "0020 3a 9e 10 f6 10 f6 00 64 c3 a5 80 00 00 00 45 00 " @@ -780,7 +798,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { + "0050 ff 53 27 36 38 3a 00 01 99 10 fe 01 00 01 0a 00 " + "0060 01 26 00 20 00 01 0a 00 14 c8 00 00 00 0a 01 20 " + "0070 10 00 00 00 00 01 99 10 fe 01 01 64 ff 00 00 05 " - + "0080 00 01 0a 00 01 26")); + + "0080 00 01 0a 00 01 26"); ArgumentCaptor captor = ArgumentCaptor.forClass(RequestMapping.class); handleMapRequestAsByteArray(mapRequestPacket); @@ -930,14 +948,14 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // UDP: 49289 -> 4342 // LISP(Type = 14 UNKNOWN!!!, P=1, M=1 - byte[] unknownTypePacket = extractWSUdpByteArray(new String( + byte[] unknownTypePacket = extractWSUdpByteArray( "0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020 9c 23 d6 40 10 f6 00 48 59 a4 F8 00 01 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 " + "0040 b0 21 27 a8 21 41 04 f3 46 5a a5 68 89 ec 00 00 " + "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " - + "0060 ff 00 00 05 00 01 c0 a8 88 0a")); + + "0060 ff 00 00 05 00 01 c0 a8 88 0a"); assertNull(handlePacket(unknownTypePacket)); } @@ -948,7 +966,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { // ITR-RLOC 1: 10.1.0.111 // ITR-RLOC 2: 192.168.136.51 // - mapRequestPacket = extractWSUdpByteArray(new String( + mapRequestPacket = extractWSUdpByteArray( "0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 " + "0010 00 8a 00 00 40 00 40 11 25 f2 0a 01 00 6f 0a 01 " + "0020 00 01 10 f6 10 f6 00 76 06 1f 80 00 00 00 45 00 " @@ -958,7 +976,7 @@ public class LispSouthboundHandlerTest extends BaseTestCase { + "0060 00 6f 00 01 c0 a8 88 33 00 20 00 01 08 08 08 08 " + "0070 00 00 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 " + "0080 01 64 ff 00 00 05 00 01 0a 01 00 6f 06 64 ff 00 " - + "0090 00 05 00 01 c0 a8 88 33")); + + "0090 00 05 00 01 c0 a8 88 33"); handleMapRequestAsByteArray(mapRequestPacket); Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(Mockito.any(RequestMapping.class)); @@ -1033,12 +1051,16 @@ public class LispSouthboundHandlerTest extends BaseTestCase { @Test(expected = LispMalformedPacketException.class) public void mapRequest__NoIpItrRloc() throws Exception { - mapRequestPacket = hexToByteBuffer("10 00 " // - + "02 " // This means 3 ITR - RLOCs - + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " // - + "40 05 c0 a8 88 0a 01 02 " // MAC (ITR-RLOC #1 of 3) - + "40 05 00 00 00 00 00 00 " // MAC (ITR-RLOC #2 of 3) - + "40 05 11 22 34 56 78 90 " // MAC (ITR-RLOC #3 of 3) + mapRequestPacket = hexToByteBuffer("10 00 " + // This means 3 ITR - RLOCs + + "02 " + + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " + // MAC (ITR-RLOC #1 of 3) + + "40 05 c0 a8 88 0a 01 02 " + // MAC (ITR-RLOC #2 of 3) + + "40 05 00 00 00 00 00 00 " + // MAC (ITR-RLOC #3 of 3) + + "40 05 11 22 34 56 78 90 " + "00 20 00 01 01 02 03 04").array(); handleMapRequestPacket(mapRequestPacket); } diff --git a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/MapRegisterCacheTestUtil.java b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/MapRegisterCacheTestUtil.java index 966441400..89838d3cd 100644 --- a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/MapRegisterCacheTestUtil.java +++ b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/MapRegisterCacheTestUtil.java @@ -24,49 +24,61 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.ma final class MapRegisterCacheTestUtil { static final byte[] DATA1 = new byte[] { - 0x33, 0x00, 0x01, 0x01 //Type, P, I, R, Reserved, M, Record Count + //Type, P, I, R, Reserved, M, Record Count + 0x33, 0x00, 0x01, 0x01 }; static final byte[] NONCE = new byte[] { - 0x00, 0x00, 0x00, 0x00, //nonce - 0x00, 0x00, 0x00, 0x00 //nonce + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }; static final byte[] KEY_ID = new byte[] { - 0x00, 0x01 //key ID + 0x00, 0x01 }; - static final byte[] AUTH_DATA = new byte[]{ - 0x00, 0x14, //authentication data length - (byte)0xfa, 0x50, 0x1d, (byte)0xd6, //auth data - 0x63, 0x53, 0x67, 0x6c, //auth data - 0x00, 0x3c, 0x61, 0x67, //auth data - 0x35, (byte) 0xb8, (byte) 0xcf, 0x16, //auth data - (byte) 0x91, (byte) 0xcd, 0x6b, (byte) 0x95 //auth data + static final byte[] AUTH_DATA = new byte[] { + //authentication data length + 0x00, 0x14, + //auth data + (byte)0xfa, 0x50, 0x1d, (byte)0xd6, + //auth data + 0x63, 0x53, 0x67, 0x6c, + //auth data + 0x00, 0x3c, 0x61, 0x67, + //auth data + 0x35, (byte) 0xb8, (byte) 0xcf, 0x16, + //auth data + (byte) 0x91, (byte) 0xcd, 0x6b, (byte) 0x95 }; - static final byte[] DATA2 = new byte[]{ - 0x00, 0x00, 0x00, 0x6f, //TTL + static final byte[] DATA2 = new byte[] { + //TTL + 0x00, 0x00, 0x00, 0x6f, + //Rsvd, Map-Version Number 0x01, 0x08, 0x00, 0x00, - 0x00, 0x01 //Rsvd, Map-Version Number + 0x00, 0x01 }; static final byte[] DATA3 = new byte[] { - 0x01, 0x0c, 0x0d, 0x0b, //Priority, Weight, M Priority, M Weight - 0x00, 0x00, 0x00, 0x01, //Unused Flags, L, p, R, Loc-Afi - 0x0c, 0x0c, 0x0c, 0x0c //Locator + //Priority, Weight, M Priority, M Weight + 0x01, 0x0c, 0x0d, 0x0b, + //Unused Flags, L, p, R, Loc-Afi + 0x00, 0x00, 0x00, 0x01, + //Locator + 0x0c, 0x0c, 0x0c, 0x0c }; - static final byte[] XTR_ID = new byte[]{ - 0x53, 0x61, 0x6e, 0x20, //xTR id - 0x4a, 0x6f, 0x73, 0x65, //xTR id - 0x2c, 0x20, 0x32, 0x66, //xTR id - 0x33, 0x72, 0x32, 0x64 //xTR id + static final byte[] XTR_ID = new byte[] { + 0x53, 0x61, 0x6e, 0x20, + 0x4a, 0x6f, 0x73, 0x65, + 0x2c, 0x20, 0x32, 0x66, + 0x33, 0x72, 0x32, 0x64 }; - static final byte[] SITE_ID = new byte[]{ - 0x33, 0x2c, 0x31, 0x34, //site id - 0x31, 0x35, 0x39, 0x32 //site id + static final byte[] SITE_ID = new byte[] { + 0x33, 0x2c, 0x31, 0x34, + 0x31, 0x35, 0x39, 0x32 }; @@ -90,7 +102,8 @@ final class MapRegisterCacheTestUtil { }; final byte[] newAuthenticationData = new byte [] { - (byte) 0x00, (byte) 0x14, // authentication data length + // authentication data length + (byte) 0x00, (byte) 0x14, (byte) 0x7A, (byte) 0x53, (byte) 0x7F, (byte) 0xF6, (byte) 0xB8, (byte) 0x91, (byte) 0x33, (byte) 0x7F, (byte) 0xB1, (byte) 0x41, (byte) 0xC3, (byte) 0x51, -- 2.36.6