File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 6565 <version >3.9.0</version >
6666 <scope >compile</scope >
6767 </dependency >
68+ <dependency >
69+ <groupId >org.junit.jupiter</groupId >
70+ <artifactId >junit-jupiter-api</artifactId >
71+ <version >5.2.0</version >
72+ <scope >test</scope >
73+ </dependency >
6874 </dependencies >
6975
7076 <build >
7177 <defaultGoal >clean package</defaultGoal >
7278 <directory >target</directory >
7379 <outputDirectory >target/classes</outputDirectory >
74- <sourceDirectory >${basedir} /src/main/java</sourceDirectory >
7580
7681 <finalName >${project.name} -${project.version} </finalName >
7782 <resources >
Original file line number Diff line number Diff line change 1+ package io .ipinfo ;
2+
3+ import io .ipinfo .errors .ErrorResponseException ;
4+ import io .ipinfo .errors .RateLimitedException ;
5+ import io .ipinfo .model .IPResponse ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ import static org .junit .jupiter .api .Assertions .*;
10+
11+ public class IPInfoTests {
12+ private IPInfo ipInfo ;
13+
14+ @ BeforeEach
15+ void initAll () {
16+ ipInfo = IPInfo .builder ().build ();
17+ }
18+
19+ @ Test
20+ void testGoogleDNS () {
21+ try {
22+ IPResponse response = ipInfo .lookupIP ("8.8.8.8" );
23+
24+ assertAll ("Country Code" ,
25+ () -> assertEquals (response .getCountryCode (), "US" ),
26+ () -> assertEquals (response .getCountryName (), "United States" ),
27+ () -> assertEquals (response .getHostname (), "google-public-dns-a.google.com" ),
28+ () -> assertEquals (response .getIp (), "8.8.8.8" )
29+ );
30+
31+ } catch (RateLimitedException e ) {
32+ fail (e );
33+ }
34+ }
35+
36+ @ Test
37+ void testASNWithoutAuth () {
38+ assertThrows (ErrorResponseException .class , () -> {
39+ ipInfo .lookupASN ("AS7922" );
40+ });
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments