Repository: nifi
Updated Branches:
  refs/heads/master 8cf0662e5 -> 73a7c8c6b


NIFI-5613: Upgraded version of geoip2 library to version 2.12.0; fixed unit 
tests

Signed-off-by: Pierre Villard <pierre.villard...@gmail.com>

This closes #3013.


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/73a7c8c6
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/73a7c8c6
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/73a7c8c6

Branch: refs/heads/master
Commit: 73a7c8c6b4b5d3a774c0937b31ec6d2536c0b483
Parents: 8cf0662
Author: Mark Payne <marka...@hotmail.com>
Authored: Wed Sep 19 16:32:53 2018 -0400
Committer: Pierre Villard <pierre.villard...@gmail.com>
Committed: Thu Sep 20 13:55:13 2018 +0200

----------------------------------------------------------------------
 .../nifi-enrich-processors/pom.xml              |  2 +-
 .../apache/nifi/processors/TestISPEnrichIP.java | 20 +++++++++++---------
 2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/73a7c8c6/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/pom.xml 
b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/pom.xml
index 95c0a92..6c55cce 100644
--- a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/pom.xml
+++ b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/pom.xml
@@ -41,7 +41,7 @@
         <dependency>
             <groupId>com.maxmind.geoip2</groupId>
             <artifactId>geoip2</artifactId>
-            <version>2.1.0</version>
+            <version>2.12.0</version>
             <exclusions>
                 <exclusion>
                     <groupId>com.google.code.findbugs</groupId>

http://git-wip-us.apache.org/repos/asf/nifi/blob/73a7c8c6/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/TestISPEnrichIP.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/TestISPEnrichIP.java
 
b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/TestISPEnrichIP.java
index b1fa5ee..187d0fe 100644
--- 
a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/TestISPEnrichIP.java
+++ 
b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/TestISPEnrichIP.java
@@ -90,7 +90,7 @@ public class TestISPEnrichIP {
         testRunner.setProperty(ISPEnrichIP.GEO_DATABASE_FILE, "./");
         testRunner.setProperty(ISPEnrichIP.IP_ADDRESS_ATTRIBUTE, "ip");
 
-        final IspResponse ispResponse = getIspResponse();
+        final IspResponse ispResponse = getIspResponse("1.2.3.4");
 
         
when(databaseReader.isp(InetAddress.getByName("1.2.3.4"))).thenReturn(ispResponse);
 
@@ -120,7 +120,7 @@ public class TestISPEnrichIP {
         testRunner.setProperty(ISPEnrichIP.GEO_DATABASE_FILE, "./");
         testRunner.setProperty(ISPEnrichIP.IP_ADDRESS_ATTRIBUTE, "ip");
 
-        final IspResponse ispResponse = getIspResponseWithoutASNDetail();
+        final IspResponse ispResponse = 
getIspResponseWithoutASNDetail("1.2.3.4");
 
         
when(databaseReader.isp(InetAddress.getByName("1.2.3.4"))).thenReturn(ispResponse);
 
@@ -152,7 +152,7 @@ public class TestISPEnrichIP {
         testRunner.setProperty(ISPEnrichIP.GEO_DATABASE_FILE, "./");
         testRunner.setProperty(ISPEnrichIP.IP_ADDRESS_ATTRIBUTE, 
"${ip.fields:substringBefore(',')}");
 
-        final IspResponse ispResponse = getIspResponse();
+        final IspResponse ispResponse = getIspResponse("1.2.3.4");
         
when(databaseReader.isp(InetAddress.getByName("1.2.3.4"))).thenReturn(ispResponse);
 
         final Map<String, String> attributes = new HashMap<>();
@@ -269,12 +269,13 @@ public class TestISPEnrichIP {
         verifyNoMoreInteractions(databaseReader);
     }
 
-    private IspResponse getIspResponse() throws Exception {
+    private IspResponse getIspResponse(final String ipAddress) throws 
Exception {
         final String maxMindIspResponse = "{\n" +
             "         \"isp\" : \"Apache NiFi - Test ISP\",\n" +
             "         \"organization\" : \"Apache NiFi - Test 
Organization\",\n" +
             "         \"autonomous_system_number\" : 1337,\n" +
-            "         \"autonomous_system_organization\" : \"Apache NiFi - 
Test Chocolate\" \n" +
+            "         \"autonomous_system_organization\" : \"Apache NiFi - 
Test Chocolate\", \n" +
+            "         \"ip_address\" : \"" + ipAddress + "\"\n" +
             "      }\n";
 
         InjectableValues inject = new 
InjectableValues.Std().addValue("locales", Collections.singletonList("en"));
@@ -282,15 +283,16 @@ public class TestISPEnrichIP {
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
 
 
-        return new 
ObjectMapper().reader(IspResponse.class).with(inject).readValue(maxMindIspResponse);
+        return new 
ObjectMapper().readerFor(IspResponse.class).with(inject).readValue(maxMindIspResponse);
 
     }
 
-    private IspResponse getIspResponseWithoutASNDetail() throws Exception {
+    private IspResponse getIspResponseWithoutASNDetail(final String ipAddress) 
throws Exception {
         final String maxMindIspResponse = "{\n" +
             "         \"isp\" : \"Apache NiFi - Test ISP\",\n" +
             "         \"organization\" : \"Apache NiFi - Test 
Organization\",\n" +
-            "         \"autonomous_system_number\" : null " +
+            "         \"autonomous_system_number\" : null,\n" +
+            "         \"ip_address\" : \"" + ipAddress + "\"\n" +
             "      }\n";
 
         InjectableValues inject = new 
InjectableValues.Std().addValue("locales", Collections.singletonList("en"));
@@ -298,7 +300,7 @@ public class TestISPEnrichIP {
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
 
 
-        return new 
ObjectMapper().reader(IspResponse.class).with(inject).readValue(maxMindIspResponse);
+        return new 
ObjectMapper().readerFor(IspResponse.class).with(inject).readValue(maxMindIspResponse);
     }
 
 

Reply via email to