diff --git a/network/pom.xml b/network/pom.xml
index ea508fd..92d538b 100644
--- a/network/pom.xml
+++ b/network/pom.xml
@@ -22,13 +22,6 @@
${project.artifactId}
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
@@ -47,6 +40,11 @@
org.slf4j
slf4j-api
+
+ org.slf4j
+ slf4j-log4j12
+ test
+
de.muehlencord.shared
shared-util
diff --git a/network/src/main/java/de/muehlencord/shared/network/whois/DefaultWhoisParser.java b/network/src/main/java/de/muehlencord/shared/network/whois/DefaultWhoisParser.java
index 1193ee4..975f926 100644
--- a/network/src/main/java/de/muehlencord/shared/network/whois/DefaultWhoisParser.java
+++ b/network/src/main/java/de/muehlencord/shared/network/whois/DefaultWhoisParser.java
@@ -1,6 +1,7 @@
package de.muehlencord.shared.network.whois;
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
+import java.util.ArrayList;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,9 +70,9 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
// FIXME add CDIR notation support
String startIpAddress = ipAddresses[0];
String endIPAddress = ipAddresses[2];
- whoisInformation.getNetwork().addAll(rangeToCidrList(startIpAddress, endIPAddress));
+ whoisInformation.addNetwork(rangeToCidrList(startIpAddress, endIPAddress));
} else {
- whoisInformation.getNetwork().add(inetnum);
+ whoisInformation.addNetwork(inetnum);
}
LOGGER.info("Network:" + whoisInformation.getNetwork().toString());
@@ -88,7 +89,7 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
throw new WhoisException ("Error while reading route information: "+ex.getMessage(), ex);
}
*/
- whoisInformation.getRootNetwork().add(route);
+ whoisInformation.addRootNetwork(route);
LOGGER.info("Root network " + whoisInformation.getRootNetwork().toString());
break;
@@ -109,6 +110,7 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
break;
default:
LOGGER.info("Unknown block found");
+ LOGGER.error(block);
}
}
}
diff --git a/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java b/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java
index 006a230..3e97bac 100644
--- a/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java
+++ b/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java
@@ -10,11 +10,17 @@ import java.util.List;
*/
public class WhoisInformation {
- /** network list in CIDR form the host belongs to */
+ /**
+ * network list in CIDR form the host belongs to
+ */
private List network;
- /** network list in CIDDR form network belongs to */
+ /**
+ * network list in CIDDR form network belongs to
+ */
private List rootNetwork;
- /** network information of host */
+ /**
+ * network information of host
+ */
private NetworkInformation networkInformation;
public WhoisInformation() {
@@ -28,7 +34,11 @@ public class WhoisInformation {
* @return the network
*/
public List getNetwork() {
- return new ArrayList<>(network);
+ return new ArrayList<>(network);
+ }
+
+ public void addNetwork(List network) {
+ this.network.addAll(new ArrayList<>(network));
}
/**
@@ -38,11 +48,20 @@ public class WhoisInformation {
this.network = new ArrayList<>(network);
}
+ /**
+ * add a new network to the list of existing networks
+ *
+ * @param network the new network to add
+ */
+ public void addNetwork(String network) {
+ this.network.add(network);
+ }
+
/**
* @return the rootNetwork
*/
public List getRootNetwork() {
- return new ArrayList<>(rootNetwork);
+ return new ArrayList<>(rootNetwork);
}
/**
@@ -51,6 +70,10 @@ public class WhoisInformation {
public void setRootNetwork(List rootNetwork) {
this.rootNetwork = new ArrayList<>(rootNetwork);
}
+
+ public void addRootNetwork (String rootNetwork) {
+ this.rootNetwork.add (rootNetwork);
+ }
/**
* @return the networkInformation
diff --git a/network/src/test/java/de/muehlencord/shared/network/whois/WhoisTest.java b/network/src/test/java/de/muehlencord/shared/network/whois/WhoisTest.java
index 9ddc887..dc07101 100644
--- a/network/src/test/java/de/muehlencord/shared/network/whois/WhoisTest.java
+++ b/network/src/test/java/de/muehlencord/shared/network/whois/WhoisTest.java
@@ -2,6 +2,7 @@ package de.muehlencord.shared.network.whois;
import de.muehlencord.shared.network.BaseTest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
@@ -74,6 +75,19 @@ public class WhoisTest extends BaseTest {
whoIsClient.execute("whois.arin.net", "32.64.68.229");
}
+ @Test
+ public void testGeneric() throws WhoisException {
+ Whois whoIsClient = new Whois();
+ WhoisInformation info = whoIsClient.execute("whois.ripe.net", "185.125.4.210");
+ assertNotNull (info);
+ assertNotNull (info.getNetwork());
+ assertFalse (info.getNetwork().isEmpty());
+ System.out.println (info.getNetwork().toString());
+ System.out.println (info.getRootNetwork().toString());
+ System.out.println (info.getNetworkInformation().getDescription());
+
+ }
+
@Test
@Ignore
diff --git a/network/src/test/resources/log4j.xml b/network/src/test/resources/log4j.xml
new file mode 100644
index 0000000..2f69c97
--- /dev/null
+++ b/network/src/test/resources/log4j.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+