Merge pull request #11195 from anuragkumawat/master
JAVA-5947 - Removed the large Geo Location File - GeoLite2-City.mmdb from code an…
This commit is contained in:
commit
ea08759607
|
@ -10,13 +10,18 @@ import com.maxmind.geoip2.DatabaseReader;
|
||||||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||||
import com.maxmind.geoip2.model.CityResponse;
|
import com.maxmind.geoip2.model.CityResponse;
|
||||||
|
|
||||||
public class GeoIpIntegrationTest {
|
public class GeoIpManualTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception {
|
public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception {
|
||||||
|
|
||||||
ClassLoader classLoader = getClass().getClassLoader();
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
File database = new File(classLoader.getResource("GeoLite2-City.mmdb").getFile());
|
/**
|
||||||
|
* 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();
|
DatabaseReader dbReader = new DatabaseReader.Builder(database).build();
|
||||||
|
|
||||||
InetAddress ipAddress = InetAddress.getByName("google.com");
|
InetAddress ipAddress = InetAddress.getByName("google.com");
|
Loading…
Reference in New Issue