1
2
3
4
5
6
7
8
9
10
11 package psiprobe.tools;
12
13 import java.io.IOException;
14 import java.net.InetAddress;
15
16 import org.junit.jupiter.api.Assertions;
17 import org.junit.jupiter.api.Disabled;
18 import org.junit.jupiter.api.Test;
19
20 import psiprobe.tools.Whois.Response;
21
22
23
24
25 class WhoisTests {
26
27
28
29
30
31
32
33 @Disabled
34 @Test
35 void localhostTest() throws IOException {
36 int a = 127;
37 int b = 0;
38 int c = 0;
39 int d = 1;
40 String dotted = a + "." + b + "." + c + "." + d;
41 byte[] bytes = {(byte) a, (byte) b, (byte) c, (byte) d};
42
43 Response response = Whois.lookup("whois.arin.net", 43, "n " + dotted, 5);
44 Assertions.assertEquals("SPECIAL-IPV4-LOOPBACK-IANA-RESERVED",
45 response.getData().get("NetName"));
46 Assertions.assertEquals("127.0.0.1", InetAddress.getByName(dotted).getHostName());
47 Assertions.assertEquals("127.0.0.1", InetAddress.getByAddress(bytes).getHostName());
48 }
49
50
51
52
53
54
55
56 @Disabled
57 @Test
58 void googleTest() throws IOException {
59 int a = 74;
60 int b = 125;
61 int c = 45;
62 int d = 100;
63 String dotted = a + "." + b + "." + c + "." + d;
64 byte[] bytes = {(byte) a, (byte) b, (byte) c, (byte) d};
65
66 Response response = Whois.lookup("whois.arin.net", 43, "n " + dotted, 5);
67 Assertions.assertEquals("GOOGLE", response.getData().get("NetName"));
68 Assertions.assertEquals("74.125.45.100", InetAddress.getByName(dotted).getHostName());
69 Assertions.assertEquals("74.125.45.100", InetAddress.getByAddress(bytes).getHostName());
70 }
71
72 }