diff options
| author | doufenghu <[email protected]> | 2024-01-26 17:16:50 +0800 |
|---|---|---|
| committer | doufenghu <[email protected]> | 2024-01-26 17:16:50 +0800 |
| commit | 42014c322d03cdfdfebed87b59b4a1f1143776b6 (patch) | |
| tree | 1556fdeda4fdc68d810cfedd93e89e66687e7c13 | |
| parent | b601d7cfad0fd3df9994f13edee802bfbb9d7802 (diff) | |
[Fix][IPLookupV2] fix infoLookupToJSON and infoLookup, using correct return type. if return value is empty, will return null.
| -rw-r--r-- | pom.xml | 4 | ||||
| -rw-r--r-- | src/main/java/com/geedgenetworks/model/LocationResponse.java (renamed from src/main/java/com/geedgenetworks/domain/LocationResponse.java) | 8 | ||||
| -rw-r--r-- | src/main/java/com/geedgenetworks/model/Nets.java (renamed from src/main/java/com/geedgenetworks/domain/Nets.java) | 2 | ||||
| -rw-r--r-- | src/main/java/com/geedgenetworks/utils/AsnLookup.java | 6 | ||||
| -rw-r--r-- | src/main/java/com/geedgenetworks/utils/GalaxyDataBaseReader.java | 5 | ||||
| -rw-r--r-- | src/main/java/com/geedgenetworks/utils/IPUtil.java | 4 | ||||
| -rw-r--r-- | src/main/java/com/geedgenetworks/utils/IpLookupV2.java | 245 | ||||
| -rw-r--r-- | src/test/java/com/geedgenetworks/test/IpLookupV2Test.java | 53 |
8 files changed, 175 insertions, 152 deletions
@@ -7,13 +7,13 @@ <artifactId>galaxy</artifactId> <packaging>jar</packaging> <name>galaxy</name> - <version>1.2.2</version> + <version>1.2.3</version> <description>galaxy tools for common</description> <url>http://www.zdjizhi.com/galaxy-tool</url> <licenses> <license> - <name>The geedge networks Software License, Version 21.0</name> + <name>The geedgenetworks Software License, Version 21.0</name> <url>http://www.apache.org/licenses/LICENSE-1.0.txt</url> <distribution>repo</distribution> </license> diff --git a/src/main/java/com/geedgenetworks/domain/LocationResponse.java b/src/main/java/com/geedgenetworks/model/LocationResponse.java index 8d9256a..9b5b2bb 100644 --- a/src/main/java/com/geedgenetworks/domain/LocationResponse.java +++ b/src/main/java/com/geedgenetworks/model/LocationResponse.java @@ -1,4 +1,4 @@ -package com.geedgenetworks.domain;/** +package com.geedgenetworks.model;/** * Created by dell on 2018-10-8. */ @@ -43,15 +43,9 @@ public class LocationResponse implements java.io.Serializable { private String countryCode; private boolean isPrivateIP; - - public LocationResponse() { this("", "", "", "", "", "", "", "", "", "", "", "", "", ""); } - - public LocationResponse(boolean isPrivateIP) { - this.setPrivateIP(isPrivateIP); - } @MaxMindDbConstructor public LocationResponse(@MaxMindDbParameter(name="AREA_CODE") String areaCode, @MaxMindDbParameter(name= "ASN") String asn, @MaxMindDbParameter(name= "ISP") String isp, @MaxMindDbParameter(name= "LATITUDE") String latitude, diff --git a/src/main/java/com/geedgenetworks/domain/Nets.java b/src/main/java/com/geedgenetworks/model/Nets.java index 0f83bed..1a0520c 100644 --- a/src/main/java/com/geedgenetworks/domain/Nets.java +++ b/src/main/java/com/geedgenetworks/model/Nets.java @@ -1,4 +1,4 @@ -package com.geedgenetworks.domain; +package com.geedgenetworks.model; /** * Created by dell on 2018-8-30. diff --git a/src/main/java/com/geedgenetworks/utils/AsnLookup.java b/src/main/java/com/geedgenetworks/utils/AsnLookup.java index 11bf870..fa824af 100644 --- a/src/main/java/com/geedgenetworks/utils/AsnLookup.java +++ b/src/main/java/com/geedgenetworks/utils/AsnLookup.java @@ -3,7 +3,7 @@ package com.geedgenetworks.utils; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.geedgenetworks.domain.LocationResponse; +import com.geedgenetworks.model.LocationResponse; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -307,7 +307,7 @@ public class AsnLookup extends AbstractDatabaseReader { if (ipAddress instanceof Inet4Address) { //Iterate through each 'dbReader' and execute them in the following order: private v4 -> private -> public v4 -> public. for (GalaxyDataBaseReader reader : availableDBReaders.get(AbstractDatabaseReader.IpVersion.IPv4.name())) { - LocationResponse response = reader.locationV2(ipAddress); + LocationResponse response = reader.location(ipAddress); if(StringUtil.isNotEmpty(response)) { return response; } @@ -315,7 +315,7 @@ public class AsnLookup extends AbstractDatabaseReader { } else if (ipAddress instanceof Inet6Address) { //Iterate through each 'dbReader' and execute them in the following order: private v6 -> private -> public v6 -> public. for(GalaxyDataBaseReader reader : availableDBReaders.get(AbstractDatabaseReader.IpVersion.IPv6.name())) { - LocationResponse response = reader.locationV2(ipAddress); + LocationResponse response = reader.location(ipAddress); if(StringUtil.isNotEmpty(response)) { return response; } diff --git a/src/main/java/com/geedgenetworks/utils/GalaxyDataBaseReader.java b/src/main/java/com/geedgenetworks/utils/GalaxyDataBaseReader.java index 47f16fb..809b38c 100644 --- a/src/main/java/com/geedgenetworks/utils/GalaxyDataBaseReader.java +++ b/src/main/java/com/geedgenetworks/utils/GalaxyDataBaseReader.java @@ -1,7 +1,7 @@ package com.geedgenetworks.utils; import com.maxmind.db.*; -import com.geedgenetworks.domain.LocationResponse; +import com.geedgenetworks.model.LocationResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; @@ -114,9 +114,8 @@ public class GalaxyDataBaseReader { } } - public LocationResponse locationV2(InetAddress ipAddress) throws IOException { + public LocationResponse location(InetAddress ipAddress) throws IOException { return reader.get(ipAddress, LocationResponse.class); - } public void close() throws IOException { diff --git a/src/main/java/com/geedgenetworks/utils/IPUtil.java b/src/main/java/com/geedgenetworks/utils/IPUtil.java index e351b46..2d77f3b 100644 --- a/src/main/java/com/geedgenetworks/utils/IPUtil.java +++ b/src/main/java/com/geedgenetworks/utils/IPUtil.java @@ -1,14 +1,12 @@ package com.geedgenetworks.utils; -import com.geedgenetworks.domain.Nets; +import com.geedgenetworks.model.Nets; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; import java.io.StringWriter; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; diff --git a/src/main/java/com/geedgenetworks/utils/IpLookupV2.java b/src/main/java/com/geedgenetworks/utils/IpLookupV2.java index 08b1c71..41a5204 100644 --- a/src/main/java/com/geedgenetworks/utils/IpLookupV2.java +++ b/src/main/java/com/geedgenetworks/utils/IpLookupV2.java @@ -3,10 +3,11 @@ package com.geedgenetworks.utils; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONWriter; +import com.geedgenetworks.model.LocationResponse; +import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.geedgenetworks.domain.LocationResponse; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -22,7 +23,7 @@ import java.util.*; * @Date 2023-08-22 20:00 Geedge Networks * @Version 1.2 **/ -public final class IpLookupV2 extends AbstractDatabaseReader implements IPLocator{ +public final class IpLookupV2 extends AbstractDatabaseReader implements IPLocator { private Map<String, List<GalaxyDataBaseReader>> availableDBReaders = Maps.newHashMap(); private GalaxyDataBaseReader publicDatabaseReader; private GalaxyDataBaseReader publicV4DatabaseReader;; @@ -432,196 +433,173 @@ public final class IpLookupV2 extends AbstractDatabaseReader implements IPLocato } @Override - public String countryLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { - return PRIVATE_IP; - } + public String countryLookup(String ip) { + return getValueWithPrivateIP(getResponse(ip), LocationResponse::getCountry); + } - return StringUtil.setDefaultIfEmpty(response.getCountry(), UNKNOWN).toString() ; + @Override + public String provinceLookup(String ip) { + return getValueWithPrivateIP(getResponse(ip), LocationResponse::getSuperAdministrativeArea); } @Override - public String cityLookupDetail(String ip) { + public String cityLookup(String ip) { + return getValueWithPrivateIP(getResponse(ip), LocationResponse::getAdministrativeArea); + } - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { + @Override + public String cityLookupDetail(String ip) { + Optional<LocationResponse> response = getResponse(ip); + if (response.isPresent() && response.get().isPrivateIP()) { return PRIVATE_IP; } - - return Joiner.on(LOCATION_SEPARATOR).useForNull("").join(response.getCountry(), - response.getSuperAdministrativeArea(), response.getAdministrativeArea()); + return Joiner.on(LOCATION_SEPARATOR).useForNull("").join( + getValue(response, LocationResponse::getCountry), + getValue(response, LocationResponse::getSuperAdministrativeArea), + getValue(response, LocationResponse::getAdministrativeArea)); } @Override public String administrativeAreaLookupDetail(String ip) { - LocationResponse response = getResponse(ip); - - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { + Optional<LocationResponse> response = getResponse(ip); + if (response.isPresent() && response.get().isPrivateIP()) { return PRIVATE_IP; } - - return Joiner.on(LOCATION_SEPARATOR).useForNull("").join(response.getCountry(), - response.getSuperAdministrativeArea(), response.getAdministrativeArea(), - response.getSubAdministrativeArea()); + return Joiner.on(LOCATION_SEPARATOR).useForNull("").join( + getValue(response, LocationResponse::getCountry), + getValue(response, LocationResponse::getSuperAdministrativeArea), + getValue(response, LocationResponse::getAdministrativeArea), + getValue(response, LocationResponse::getSubAdministrativeArea)); } @Override public String locationLookupDetail(String ip) { - LocationResponse response = getResponse(ip); - - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { + Optional<LocationResponse> response = getResponse(ip); + if (response.isPresent() && response.get().isPrivateIP()) { return PRIVATE_IP; } + return Joiner.on(LOCATION_SEPARATOR).useForNull("").join( + getValue(response, LocationResponse::getCountry), + getValue(response, LocationResponse::getSuperAdministrativeArea), + getValue(response, LocationResponse::getAdministrativeArea), + getValue(response, LocationResponse::getSubAdministrativeArea), + getValue(response, LocationResponse::getLocality), + getValue(response, LocationResponse::getDependentLocality), + getValue(response, LocationResponse::getDoubleDependentLocality)); - return Joiner.on(LOCATION_SEPARATOR).useForNull("").join(response.getCountry(), - response.getSuperAdministrativeArea(), response.getAdministrativeArea(), - response.getSubAdministrativeArea(), response.getLocality(), - response.getDependentLocality(), response.getDoubleDependentLocality()); } @Override - public String cityLookup(String ip) { - LocationResponse response = getResponse(ip); - - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { - return PRIVATE_IP; - } - - return StringUtil.setDefaultIfEmpty(response.getAdministrativeArea(), UNKNOWN).toString() ; - + public String countryCodeLookup(String ip) { + return getValue(getResponse(ip), LocationResponse::getCountryCode); } @Override - public String countryCodeLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; + public String regionCodeLookup(String ip) { + return getValue(getResponse(ip), LocationResponse::getAreaCode); + } + + private String getValue(Optional<LocationResponse> response, Function<LocationResponse, String> valueExtractor) { + if (response.isPresent()) { + return StringUtil.setDefaultIfEmpty(valueExtractor.apply(response.get()), UNKNOWN).toString(); } - return StringUtil.setDefaultIfEmpty(response.getCountryCode(), UNKNOWN).toString() ; + return UNKNOWN; } - @Override - public String regionCodeLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; + private String getValueWithPrivateIP(Optional<LocationResponse> response, Function<LocationResponse, String> valueExtractor) { + if (response.isPresent()) { + LocationResponse locationResponse = response.get(); + if (locationResponse.isPrivateIP()) { + return PRIVATE_IP; + } + return StringUtil.setDefaultIfEmpty(valueExtractor.apply(locationResponse), UNKNOWN).toString(); } - return StringUtil.setDefaultIfEmpty(response.getAreaCode(), UNKNOWN).toString() ; + return UNKNOWN; } + @Override public String infoLookupToCSV(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } + Optional<LocationResponse> response = getResponse(ip); StringBuilder ipInfo = new StringBuilder(); ipInfo.append( - Joiner.on(LOCATION_SEPARATOR).useForNull("").join(response.getCountry(), - response.getSuperAdministrativeArea(), response.getAdministrativeArea(), - response.getSubAdministrativeArea(), response.getLocality(), - response.getDependentLocality(), response.getDoubleDependentLocality())) + Joiner.on(LOCATION_SEPARATOR).useForNull("").join( + getValue(response, LocationResponse::getCountry), + getValue(response, LocationResponse::getSuperAdministrativeArea), + getValue(response, LocationResponse::getAdministrativeArea), + getValue(response, LocationResponse::getSubAdministrativeArea), + getValue(response, LocationResponse::getLocality), + getValue(response, LocationResponse::getDependentLocality), + getValue(response, LocationResponse::getDoubleDependentLocality))) .append(OBJECT_SEPARATOR).append( - StringUtil.setDefaultIfEmpty(response.getIsp(), UNKNOWN).toString() + getValue(response, LocationResponse::getIsp) ).append(OBJECT_SEPARATOR).append( - StringUtil.setDefaultIfEmpty(response.getOrganization(), UNKNOWN).toString() + getValue(response, LocationResponse::getOrganization) ).append(OBJECT_SEPARATOR).append( asnLookup.asnLookup(ip) ).append(OBJECT_SEPARATOR).append( - Joiner.on(LAT_LNG_SEPARATOR).skipNulls().join(response.getLatitude(), response.getLongitude()) + Joiner.on(LAT_LNG_SEPARATOR).skipNulls().join( + getValue(response, LocationResponse::getLatitude), + getValue(response, LocationResponse::getLongitude)) ); return ipInfo.toString(); } @Override public String infoLookupToJSONString(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; + Optional<LocationResponse> response = getResponse(ip); + if (response.isPresent()) { + return JSON.toJSONString(response.get(), JSONWriter.Feature.WriteNullStringAsEmpty); } - return JSON.toJSONString(response, JSONWriter.Feature.WriteNullStringAsEmpty); + return UNKNOWN; } @Override - public Object infoLookupToJSON(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; + public JSONObject infoLookupToJSON(String ip) { + Optional<LocationResponse> response = getResponse(ip); + if (response.isPresent()) { + return JSONObject.from(response.get()); } - return JSONObject.from(response); + return null; } @Override - public Object infoLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; + public LocationResponse infoLookup(String ip) { + Optional<LocationResponse> response = getResponse(ip); + if (response.isPresent()) { + return response.get(); } - return response; - } - - @Override - public String provinceLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { - return PRIVATE_IP; - } - return StringUtil.setDefaultIfEmpty(response.getSuperAdministrativeArea(), UNKNOWN).toString() ; + return null; } @Override public String ispLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { - return PRIVATE_IP; - } - return StringUtil.setDefaultIfEmpty(response.getIsp(), UNKNOWN).toString() ; + Optional<LocationResponse> response = getResponse(ip); + response.ifPresent(locationResponse -> { + if (locationResponse.isPrivateIP()) { + locationResponse.setIsp(PRIVATE_IP); + } + }); + return StringUtil.setDefaultIfEmpty(response.orElseGet(()->new LocationResponse()).getIsp(), UNKNOWN).toString(); } @Override public String organizationLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response)) { - return UNKNOWN; - } - if (response.isPrivateIP()) { - return PRIVATE_IP; - } - return StringUtil.setDefaultIfEmpty(response.getOrganization(), UNKNOWN).toString() ; + Optional<LocationResponse> response = getResponse(ip); + response.ifPresent(locationResponse -> { + if (locationResponse.isPrivateIP()) { + locationResponse.setOrganization(PRIVATE_IP); + } + }); + return StringUtil.setDefaultIfEmpty(response.orElseGet(()->new LocationResponse()).getOrganization(), UNKNOWN).toString(); } @Override public String latLngLookup(String ip) { - LocationResponse response = getResponse(ip); - if (StringUtil.isEmpty(response) || response.isPrivateIP()) { - return UNKNOWN; - } - - return Joiner.on(LAT_LNG_SEPARATOR).skipNulls().join(response.getLatitude(), response.getLongitude()); - + Optional<LocationResponse> response = getResponse(ip); + LocationResponse locationResponse = response.orElseGet(()->new LocationResponse()); + return Joiner.on(LAT_LNG_SEPARATOR).skipNulls().join(locationResponse.getLatitude(), locationResponse.getLongitude()); } @Override @@ -648,8 +626,7 @@ public final class IpLookupV2 extends AbstractDatabaseReader implements IPLocato return asnLookup.asnLookupDetail(ip); } - - private LocationResponse getResponse(String ip) { + private Optional<LocationResponse> getResponse(String ip) { try { ip = Optional.ofNullable(ip).orElse("").trim(); InetAddress ipAddress = InetAddress.getByName(ip); @@ -657,30 +634,32 @@ public final class IpLookupV2 extends AbstractDatabaseReader implements IPLocato //Iterate through each 'dbReader' and execute them in the following order: private v4 -> private -> public v4 -> public. for (GalaxyDataBaseReader reader : availableDBReaders.get(IpVersion.IPv4.name())) { - LocationResponse response = reader.locationV2(ipAddress); + LocationResponse response = reader.location(ipAddress); if(StringUtil.isNotEmpty(response)) { - return response; + return Optional.of(response); } } //Is it a private IP if (IPUtil.internalIp(ip)) { - return new LocationResponse(true); + LocationResponse response = new LocationResponse(); + response.setPrivateIP(true); + return Optional.of(response); } } else if (ipAddress instanceof Inet6Address) { //Iterate through each 'dbReader' and execute them in the following order: private v6 -> private -> public v6 -> public. for(GalaxyDataBaseReader reader : availableDBReaders.get(IpVersion.IPv6.name())) { - LocationResponse response = reader.locationV2(ipAddress); + LocationResponse response = reader.location(ipAddress); if(StringUtil.isNotEmpty(response)) { - return response; + return Optional.of(response); } } } else { - throw new IllegalArgumentException("IP address <" + ip +">. "); + throw new IllegalArgumentException(String.format("IP address <%s>. ", ip)); } - return null; + return Optional.empty(); } catch (Exception e) { - throw new IllegalArgumentException("IP address <" + ip +">. " + e); + throw new IllegalArgumentException(String.format("IP address <%s>. ", ip) + e); } } diff --git a/src/test/java/com/geedgenetworks/test/IpLookupV2Test.java b/src/test/java/com/geedgenetworks/test/IpLookupV2Test.java index 6a1481b..846012f 100644 --- a/src/test/java/com/geedgenetworks/test/IpLookupV2Test.java +++ b/src/test/java/com/geedgenetworks/test/IpLookupV2Test.java @@ -1,6 +1,7 @@ package com.geedgenetworks.test; import com.alibaba.fastjson2.JSONObject; +import com.geedgenetworks.model.LocationResponse; import com.geedgenetworks.utils.AbstractDatabaseReader; import com.geedgenetworks.utils.AsnLookup; import com.geedgenetworks.utils.IpLookupV2; @@ -18,6 +19,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class IpLookupV2Test { @@ -164,6 +166,57 @@ public class IpLookupV2Test { } @Test + public void testCountryLookup() { + assertEquals(ipLookupByDatabase.countryLookup("120.221.155.223"), "China"); + assertEquals(ipLookupByDatabase.countryLookup("192.168.12.1"), "Private IP"); + assertEquals(ipLookupByDatabase.countryLookup("2001:db8:3333:4444:5555:6666:7777:8888"), ""); + System.out.println(ipLookupByDatabase.infoLookupToCSV("120.221.155.223")); + } + + @Test + public void testProvinceLookup() { + assertEquals(ipLookupByDatabase.provinceLookup("120.221.155.223"), "Shandong"); + assertEquals(ipLookupByDatabase.provinceLookup("192.168.12.1"), "Private IP"); + assertEquals(ipLookupByDatabase.provinceLookup("2001:db8:3333:4444:5555:6666:7777:8888"), ""); + } + + @Test + public void testCityLookup() { + assertEquals(ipLookupByDatabase.cityLookup("120.221.155.223"), "Other"); + assertEquals(ipLookupByDatabase.cityLookup("192.168.12.1"), "Private IP"); + assertEquals(ipLookupByDatabase.cityLookup("2001:db8:3333:4444:5555:6666:7777:8888"), ""); + } + + @Test + public void testCityLookupDetail() { + assertEquals(ipLookupByStream.cityLookupDetail("120.221.155.223").split("\\" + AbstractDatabaseReader.LOCATION_SEPARATOR).length, 3); + assertEquals(ipLookupByDatabase.cityLookupDetail("192.168.12.1"), "Private IP"); + assertEquals(ipLookupByDatabase.cityLookupDetail("2001:db8:3333:4444:5555:6666:7777:8888"), ".."); + } + + @Test + public void testCountryCodeLookup() { + assertEquals(ipLookupByDatabase.countryCodeLookup("120.221.155.223"), ""); + assertEquals(ipLookupByDatabase.countryCodeLookup("192.168.12.1"), ""); + assertEquals(ipLookupByDatabase.countryCodeLookup("2001:db8:3333:4444:5555:6666:7777:8888"), ""); + } + @Test + public void testRegionCodeLookup() { + assertEquals(ipLookupByDatabase.regionCodeLookup("120.221.155.223"), "-"); + assertEquals(ipLookupByDatabase.regionCodeLookup("192.168.12.1"), ""); + assertEquals(ipLookupByDatabase.regionCodeLookup("2001:db8:3333:4444:5555:6666:7777:8888"), ""); + } + + @Test + public void testInfoLookupJsonString() { + assertTrue(JSONObject.parseObject(ipLookupByDatabase.infoLookupToJSONString("120.221.155.223"), LocationResponse.class) instanceof LocationResponse); + assertEquals(ipLookupByDatabase.infoLookupToJSONString("2001:db8:3333:4444:5555:6666:7777:8888"), ""); + } + + + + + @Test public void testOutputJson() { logger.info(ipLookupByStream.infoLookupToJSON("120.221.155.223")); logger.info(ipLookupByStream.infoLookupToJSON("2001:db8:3333:4444:5555:6666:7777:8888")); |
