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:
Loredana Crusoveanu 2021-09-07 08:27:50 +03:00 committed by GitHub
commit ea08759607
1 changed files with 7 additions and 2 deletions

View File

@ -10,13 +10,18 @@ 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();
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();
InetAddress ipAddress = InetAddress.getByName("google.com");