Convert API to throw exceptions instead of return values
diff --git a/src/test/java/com/intel/jndn/management/FaceStatusTest.java b/src/test/java/com/intel/jndn/management/FaceStatusTest.java
index 2bf7ce6..5a587a6 100644
--- a/src/test/java/com/intel/jndn/management/FaceStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/FaceStatusTest.java
@@ -15,7 +15,8 @@
import com.intel.jndn.management.types.StatusDataset;
import com.intel.jndn.management.types.FaceStatus;
-import com.intel.jndn.utils.Client;
+import com.intel.jndn.utils.SimpleClient;
+import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;
import junit.framework.Assert;
@@ -113,7 +114,7 @@
* @param usePreComputedData to avoid errors when local NFD is not present
* @return
*/
- private static Data getFaceData(boolean usePreComputedData) {
+ private static Data getFaceData(boolean usePreComputedData) throws IOException {
// use pre-computed data to avoid errors when local NFD is not present
if (usePreComputedData) {
Data data = new Data();
@@ -130,7 +131,7 @@
interest.setInterestLifetimeMilliseconds(2000.0);
// send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ Data data = SimpleClient.getDefault().getSync(forwarder, interest);
String hex = data.getContent().toHex();
logger.info("Hex dump of face list: " + hex);
return data;
diff --git a/src/test/java/com/intel/jndn/management/FibEntryTest.java b/src/test/java/com/intel/jndn/management/FibEntryTest.java
index 026178f..1cd5897 100644
--- a/src/test/java/com/intel/jndn/management/FibEntryTest.java
+++ b/src/test/java/com/intel/jndn/management/FibEntryTest.java
@@ -16,7 +16,7 @@
import com.intel.jndn.management.types.StatusDataset;
import com.intel.jndn.management.types.NextHopRecord;
import com.intel.jndn.management.types.FibEntry;
-import com.intel.jndn.utils.Client;
+import com.intel.jndn.utils.SimpleClient;
import java.util.List;
import junit.framework.Assert;
import net.named_data.jndn.Data;
@@ -79,7 +79,7 @@
interest.setInterestLifetimeMilliseconds(2000.0);
// send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ Data data = SimpleClient.getDefault().getSync(forwarder, interest);
// decode results
List<FibEntry> results = StatusDataset.wireDecode(data.getContent(), FibEntry.class);
diff --git a/src/test/java/com/intel/jndn/management/IntegrationSuite.java b/src/test/java/com/intel/jndn/management/IntegrationSuite.java
index f0167b5..e94b328 100644
--- a/src/test/java/com/intel/jndn/management/IntegrationSuite.java
+++ b/src/test/java/com/intel/jndn/management/IntegrationSuite.java
@@ -13,6 +13,7 @@
*/
package com.intel.jndn.management;
+import com.intel.jndn.management.types.RibEntry;
import java.util.logging.Logger;
import junit.framework.Assert;
import net.named_data.jndn.Face;
@@ -48,10 +49,19 @@
Assert.assertFalse(NFD.getRouteList(face).isEmpty());
// create a new route
- Assert.assertTrue(NFD.register(face, "udp4://127.0.0.1:56363", new Name("/my/test/route"), 999));
+ NFD.register(face, "udp4://127.0.0.1:56363", new Name("/my/test/route"), 999);
+
+ // check that route is created
+ boolean found = false;
+ for(RibEntry route : NFD.getRouteList(face)){
+ if(route.getName().equals(new Name("/my/test/route"))){
+ found = true;
+ }
+ }
+ Assert.assertTrue(found);
// remove the route
- Assert.assertTrue(NFD.unregister(face, new Name("/my/test/route"), "udp4://127.0.0.1:56363"));
+ NFD.unregister(face, new Name("/my/test/route"), "udp4://127.0.0.1:56363");
}
/**
diff --git a/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java b/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java
index 2034d13..7686616 100644
--- a/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java
+++ b/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java
@@ -14,8 +14,9 @@
package com.intel.jndn.management;
import com.intel.jndn.management.types.LocalControlHeader;
-import com.intel.jndn.utils.Client;
+import com.intel.jndn.utils.SimpleClient;
import java.util.logging.Logger;
+import junit.framework.Assert;
import net.named_data.jndn.Data;
import net.named_data.jndn.Face;
import net.named_data.jndn.Name;
@@ -45,12 +46,12 @@
forwarder.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
// enable incoming face ID header
- boolean success = NFD.enableLocalControlHeader(forwarder, LocalControlHeader.INCOMING_FACE_ID);
- assertTrue(success);
+ NFD.enableLocalControlHeader(forwarder, LocalControlHeader.INCOMING_FACE_ID);
// use and verify
- Data data = Client.getDefault().getSync(forwarder, new Name("/localhost/nfd"));
+ Data data = SimpleClient.getDefault().getSync(forwarder, new Name("/localhost/nfd"));
long faceId = data.getIncomingFaceId();
+ Assert.assertTrue(faceId != -1); // this verifies that the headers are working correctly
logger.info("Face ID for this client on the forwarder: " + faceId);
}
}
diff --git a/src/test/java/com/intel/jndn/management/RibEntryTest.java b/src/test/java/com/intel/jndn/management/RibEntryTest.java
index ea54fbd..8a63abb 100644
--- a/src/test/java/com/intel/jndn/management/RibEntryTest.java
+++ b/src/test/java/com/intel/jndn/management/RibEntryTest.java
@@ -16,7 +16,7 @@
import com.intel.jndn.management.types.StatusDataset;
import com.intel.jndn.management.types.RibEntry;
import com.intel.jndn.management.types.Route;
-import com.intel.jndn.utils.Client;
+import com.intel.jndn.utils.SimpleClient;
import java.util.List;
import junit.framework.Assert;
import net.named_data.jndn.Data;
@@ -81,7 +81,7 @@
interest.setInterestLifetimeMilliseconds(2000.0);
// send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ Data data = SimpleClient.getDefault().getSync(forwarder, interest);
// decode results
List<RibEntry> results = StatusDataset.wireDecode(data.getContent(), RibEntry.class);