From b1072c36b97a39856e72efbf873d4794026b8cf1 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Wed, 19 Nov 2025 15:33:40 +0100 Subject: [PATCH 1/2] Fix tests failing because of location change --- src/test/java/io/ipinfo/IPinfoLiteTest.java | 86 ++++----------------- src/test/java/io/ipinfo/IPinfoTest.java | 14 ++-- 2 files changed, 20 insertions(+), 80 deletions(-) diff --git a/src/test/java/io/ipinfo/IPinfoLiteTest.java b/src/test/java/io/ipinfo/IPinfoLiteTest.java index 7a173c2..058b2a0 100644 --- a/src/test/java/io/ipinfo/IPinfoLiteTest.java +++ b/src/test/java/io/ipinfo/IPinfoLiteTest.java @@ -157,79 +157,19 @@ public void testCloudFlareDNSLite() { response.getAsDomain(), "AS domain mismatch" ), - () -> - assertEquals( - "AU", - response.getCountryCode(), - "country code mismatch" - ), - () -> - assertEquals( - "Australia", - response.getCountry(), - "country mismatch" - ), - () -> - assertEquals( - "Australia", - response.getCountryName(), - "country name mismatch" - ), - () -> - assertEquals( - "OC", - response.getContinentCode(), - "continent code mismatch" - ), - () -> - assertEquals( - "Oceania", - response.getContinent(), - "continent mismatch" - ), - () -> assertFalse(response.isEU(), "isEU mismatch"), - () -> - assertEquals( - "🇦🇺", - response.getCountryFlag().getEmoji(), - "emoji mismatch" - ), - () -> - assertEquals( - "U+1F1E6 U+1F1FA", - response.getCountryFlag().getUnicode(), - "country flag unicode mismatch" - ), - () -> - assertEquals( - "https://cdn.ipinfo.io/static/images/countries-flags/AU.svg", - response.getCountryFlagURL(), - "country flag URL mismatch" - ), - () -> - assertEquals( - "AUD", - response.getCountryCurrency().getCode(), - "country currency code mismatch" - ), - () -> - assertEquals( - "$", - response.getCountryCurrency().getSymbol(), - "country currency symbol mismatch" - ), - () -> - assertEquals( - "OC", - response.getContinentInfo().getCode(), - "continent info code mismatch" - ), - () -> - assertEquals( - "Oceania", - response.getContinentInfo().getName(), - "continent info name mismatch" - ), + () -> assertNotNull(response.getCountryCode(), "country code should be set"), + () -> assertNotNull(response.getCountry(), "country should be set"), + () -> assertNotNull(response.getCountryName(), "country name should be set"), + () -> assertNotNull(response.getContinentCode(), "continent code should be set"), + () -> assertNotNull(response.getContinent(), "continent should be set"), + () -> assertNotNull(response.isEU(), "isEU should be set"), + () -> assertNotNull(response.getCountryFlag().getEmoji(), "emoji should be set"), + () -> assertNotNull(response.getCountryFlag().getUnicode(), "country flag unicode should be set"), + () -> assertNotNull(response.getCountryFlagURL(), "country flag URL should be set"), + () -> assertNotNull(response.getCountryCurrency().getCode(), "country currency code should be set"), + () -> assertNotNull(response.getCountryCurrency().getSymbol(), "country currency symbol should be set"), + () -> assertNotNull(response.getContinentInfo().getCode(), "continent info code should be set"), + () -> assertNotNull(response.getContinentInfo().getName(), "continent info name should be set"), () -> assertFalse(response.getBogon(), "bogon mismatch") ); } catch (RateLimitedException e) { diff --git a/src/test/java/io/ipinfo/IPinfoTest.java b/src/test/java/io/ipinfo/IPinfoTest.java index c44e8d1..d153577 100644 --- a/src/test/java/io/ipinfo/IPinfoTest.java +++ b/src/test/java/io/ipinfo/IPinfoTest.java @@ -165,11 +165,11 @@ public void testGetBatchIps() { () -> assertEquals("1.1.1.1", res1.getIp(), "IP mismatch"), () -> assertEquals("one.one.one.one", res1.getHostname(), "hostname mismatch"), () -> assertTrue(res1.getAnycast(), "anycast mismatch"), - () -> assertEquals("Brisbane", res1.getCity(), "city mismatch"), - () -> assertEquals("Queensland", res1.getRegion(), "region mismatch"), - () -> assertEquals("AU", res1.getCountryCode(), "country code mismatch"), - () -> assertEquals("Australia", res1.getCountryName(), "country name mismatch"), - () -> assertEquals("Australia/Brisbane", res1.getTimezone(), "timezone mismatch"), + () -> assertNotNull(res1.getCity(), "city should be set"), + () -> assertNotNull(res1.getRegion(), "region should be set"), + () -> assertNotNull(res1.getCountryCode(), "country code should be set"), + () -> assertNotNull(res1.getCountryName(), "country name should be set"), + () -> assertNotNull(res1.getTimezone(), "timezone should be set"), () -> assertFalse(res1.getPrivacy().getProxy(), "proxy mismatch"), () -> assertFalse(res1.getPrivacy().getVpn(), "VPN mismatch"), () -> assertFalse(res1.getPrivacy().getTor(), "Tor mismatch"), @@ -254,13 +254,13 @@ public void testGetBatchAsns() { ASNResponse res2 = result.get("AS321"); assertAll("AS321", () -> assertEquals("AS321", res2.getAsn(), "ASN mismatch"), - () -> assertEquals("DoD Network Information Center", res2.getName(), "name mismatch"), + () -> assertNotNull(res2.getName(), "name should be set"), () -> assertEquals("US", res2.getCountryCode(), "country code mismatch"), () -> assertEquals("United States", res2.getCountryName(), "country name mismatch"), () -> assertEquals("1989-06-30", res2.getAllocated(), "allocated mismatch"), () -> assertEquals("arin", res2.getRegistry(), "registry mismatch"), () -> assertEquals("mail.mil", res2.getDomain(), "domain mismatch"), - () -> assertEquals(new Integer(65536), res2.getNumIps(), "num IPs mismatch"), + () -> assertNotNull(res2.getNumIps(), "num IPs should be set"), () -> assertEquals("government", res2.getType(), "type mismatch") ); } catch (RateLimitedException e) { From 5da6268cc90442889da28a83d870babbc3939cf4 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Wed, 19 Nov 2025 15:41:13 +0100 Subject: [PATCH 2/2] Add tests workflow --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d06e926 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + java-version: ["8", "11", "16", "17", "21"] + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java-version }} + distribution: "temurin" + cache: maven + + - name: Run tests + run: mvn test + env: + IPINFO_TOKEN: ${{ secrets.IPINFO_TOKEN }}