Upgrade to jndn 0.7.1
diff --git a/pom.xml b/pom.xml
index 70dff9a..565a132 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
<dependency>
<groupId>net.named-data</groupId>
<artifactId>jndn</artifactId>
- <version>0.7</version>
+ <version>0.7.1</version>
</dependency>
<!-- Test dependencies -->
<dependency>
diff --git a/src/main/java/com/intel/jndn/mock/MockFace.java b/src/main/java/com/intel/jndn/mock/MockFace.java
index 34b8206..d858d25 100644
--- a/src/main/java/com/intel/jndn/mock/MockFace.java
+++ b/src/main/java/com/intel/jndn/mock/MockFace.java
@@ -61,7 +61,9 @@
private final Node node_;
HashMap<String, Data> responseMap = new HashMap<>();
HashMap<Long, MockOnInterestHandler> handlerMap = new HashMap<>();
- long lastRegisteredId = 0;
+ long lastPendingInterestId = 0;
+ long lastInterestFilterId = 0;
+ long lastRegisteredPrefixId = 0;
/**
* Create a new Face to mock communication over the network; all packets are
@@ -203,7 +205,8 @@
@Override
public long expressInterest(Interest interest, OnData onData, OnTimeout onTimeout,
WireFormat wireFormat) throws IOException {
- long id = node_.expressInterest(interest, onData, onTimeout, wireFormat);
+ long id = lastPendingInterestId++;
+ node_.expressInterest(id, interest, onData, onTimeout, wireFormat, this);
handleIncomingRequests(interest);
return id;
}
@@ -227,8 +230,8 @@
* @param flags The flags for finer control of which interests are forwarded
* to the application.
* @param wireFormat A WireFormat object used to encode the message.
- * @return The lastRegisteredId prefix ID which can be used with
- * removeRegisteredPrefix.
+ * @return The lastRegisteredPrefixId prefix ID which can be used with
+ removeRegisteredPrefix.
* @throws IOException For I/O error in sending the registration request.
* @throws SecurityException If signing a command interest for NFD and cannot
* find the private key for the certificateName.
@@ -238,24 +241,24 @@
ForwardingFlags flags, WireFormat wireFormat) throws IOException, net.named_data.jndn.security.SecurityException {
// since we don't send an Interest, ensure the transport is connected
if (!getTransport().getIsConnected()) {
- getTransport().connect(node_.getConnectionInfo(), node_);
+ getTransport().connect(node_.getConnectionInfo(), node_, null);
}
- lastRegisteredId++;
- handlerMap.put(lastRegisteredId, new MockOnInterestHandler(prefix, onInterest, flags));
- return lastRegisteredId;
+ lastRegisteredPrefixId++;
+ handlerMap.put(lastRegisteredPrefixId, new MockOnInterestHandler(prefix, onInterest, flags));
+ return lastRegisteredPrefixId;
}
@Override
public long registerPrefix(Name prefix, OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed, ForwardingFlags flags, WireFormat wireFormat) throws IOException, SecurityException {
// since we don't send an Interest, ensure the transport is connected
if (!getTransport().getIsConnected()) {
- getTransport().connect(node_.getConnectionInfo(), node_);
+ getTransport().connect(node_.getConnectionInfo(), node_, null);
}
- lastRegisteredId++;
- handlerMap.put(lastRegisteredId, new MockOnInterestHandler(prefix, onInterest, flags));
- return lastRegisteredId;
+ lastRegisteredPrefixId++;
+ handlerMap.put(lastRegisteredPrefixId, new MockOnInterestHandler(prefix, onInterest, flags));
+ return lastRegisteredPrefixId;
}
/**
@@ -283,7 +286,9 @@
@Override
public long setInterestFilter(InterestFilter filter, OnInterestCallback onInterest) {
- return node_.setInterestFilter(filter, onInterest, this);
+ long id = lastInterestFilterId++;
+ node_.setInterestFilter(id, filter, onInterest, this);
+ return id;
}
@Override
diff --git a/src/main/java/com/intel/jndn/mock/MockTransport.java b/src/main/java/com/intel/jndn/mock/MockTransport.java
index 2db422b..02ed7e3 100644
--- a/src/main/java/com/intel/jndn/mock/MockTransport.java
+++ b/src/main/java/com/intel/jndn/mock/MockTransport.java
@@ -130,10 +130,13 @@
*/
@Override
public void connect(Transport.ConnectionInfo connectionInfo,
- ElementListener elementListener) throws IOException {
+ ElementListener elementListener, Runnable onConnected) throws IOException {
logger.fine("Connecting...");
connected = true;
elementReader = new ElementReader(elementListener);
+ if (onConnected != null) {
+ onConnected.run();
+ }
}
/**
@@ -217,31 +220,32 @@
// pass data up to face
ByteBuffer temp = copy(buffer);
temp.flip();
-
+
// reset buffer
buffer = ByteBuffer.allocate(BUFFER_CAPACITY);
-
+
elementReader.onReceivedData(temp);
}
-
+
/**
* Copy one buffer to a new buffer, preserving the source buffer's position
* and limit.
+ *
* @param source the source buffer
* @return a copied buffer
*/
- private ByteBuffer copy(ByteBuffer source){
+ private ByteBuffer copy(ByteBuffer source) {
ByteBuffer dest = ByteBuffer.allocate(source.capacity());
-
+
int saveLimit = source.limit();
int savePosition = source.position();
source.flip();
-
+
dest.put(source);
-
+
source.limit(saveLimit);
source.position(savePosition);
-
+
return dest;
}
@@ -265,4 +269,9 @@
logger.fine("Closing...");
connected = false;
}
+
+ @Override
+ public boolean isAsync() {
+ return false;
+ }
}