From d4d3ac77f8e47bb44fbf6917ac4a4a16514f9f17 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Fri, 3 Sep 2021 02:23:16 +0530 Subject: [PATCH 1/3] Removed the large Geo Location File - GeoLite2-City.mmdb from code and it's references. --- .../src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java index 0aa23842b1..206e9b6e52 100644 --- a/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java +++ b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java @@ -16,7 +16,7 @@ public class GeoIpIntegrationTest { public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception { ClassLoader classLoader = getClass().getClassLoader(); - File database = new File(classLoader.getResource("GeoLite2-City.mmdb").getFile()); + File database = new File("your-path-to-db-file"); DatabaseReader dbReader = new DatabaseReader.Builder(database).build(); InetAddress ipAddress = InetAddress.getByName("google.com"); From 8f737fc3c277f2321687cadc5e1eb3a321e76f57 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Mon, 6 Sep 2021 19:58:33 +0530 Subject: [PATCH 2/3] JAVA-5947 - Changed the Integration Test to Manual Test and also added the comment to download the location file and run the test manually in code --- .../{GeoIpIntegrationTest.java => GeoIpManualTest.java} | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) rename spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/{GeoIpIntegrationTest.java => GeoIpManualTest.java} (68%) diff --git a/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java similarity index 68% rename from spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java rename to spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java index 206e9b6e52..5bfb78017c 100644 --- a/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java +++ b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.geoip; +package test.java.com.baeldung.geoip; import java.io.File; import java.io.IOException; @@ -10,12 +10,17 @@ import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.exception.GeoIp2Exception; import com.maxmind.geoip2.model.CityResponse; -public class GeoIpIntegrationTest { +public class GeoIpManualTest { @Test public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception { ClassLoader classLoader = getClass().getClassLoader(); + /** + * Download the db file as shown in the article https://www.baeldung.com/geolocation-by-ip-with-maxmind, + * then replace the "your-path-to-db-file" string in the test with the file path before running the test + * HINT : Copy the downloaded file at spring-web-modules/spring-mvc-xml/src/test/resources/GeoLite2-City.mmdb + * **/ File database = new File("your-path-to-db-file"); DatabaseReader dbReader = new DatabaseReader.Builder(database).build(); From 3ead19dc38d324eb82320f1902176cd25ddb99de Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Mon, 6 Sep 2021 20:03:03 +0530 Subject: [PATCH 3/3] JAVA-5947 - Corrected the package name in code --- .../src/test/java/com/baeldung/geoip/GeoIpManualTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java index 5bfb78017c..99a76099b2 100644 --- a/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java +++ b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpManualTest.java @@ -1,4 +1,4 @@ -package test.java.com.baeldung.geoip; +package com.baeldung.geoip; import java.io.File; import java.io.IOException;