Update to jndn v0.11
This commit also breaks some tests by moving to the new jndn-mock APIs; TODO fix these tests
diff --git a/.gitignore b/.gitignore
index 619d7e5..7ef0804 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,4 +31,8 @@
.settings
# Netbeans specific project files
-nbactions.xml
\ No newline at end of file
+nbactions.xml
+
+# IntelliJ specific project files
+.idea
+*.iml
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5e4b3b1..2e9135f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.intel.jndn.utils</groupId>
<artifactId>jndn-utils</artifactId>
- <version>1.0.0</version>
+ <version>1.0.2</version>
<name>jndn-utils</name>
<description>Collection of tools to simplify synchronous and asynchronous data transfer over the NDN network</description>
<url>https://github.com/01org/jndn-utils</url>
@@ -35,7 +35,7 @@
<dependency>
<groupId>net.named-data</groupId>
<artifactId>jndn</artifactId>
- <version>0.7</version>
+ <version>0.11</version>
</dependency>
<!-- Test dependencies -->
<dependency>
@@ -47,7 +47,7 @@
<dependency>
<groupId>com.intel.jndn.mock</groupId>
<artifactId>jndn-mock</artifactId>
- <version>RELEASE</version>
+ <version>1.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientTest.java b/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientTest.java
index 67058d6..26942d0 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientTest.java
@@ -16,10 +16,7 @@
import com.intel.jndn.mock.MockFace;
import com.intel.jndn.utils.TestHelper;
import com.intel.jndn.utils.client.SegmentationType;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
+import com.intel.jndn.utils.server.impl.SimpleServer;
import net.named_data.jndn.Data;
import net.named_data.jndn.Face;
import net.named_data.jndn.Interest;
@@ -27,17 +24,33 @@
import net.named_data.jndn.Name;
import net.named_data.jndn.OnInterestCallback;
import net.named_data.jndn.util.Blob;
-import static org.junit.Assert.*;
+import org.junit.Before;
import org.junit.Test;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
public class AdvancedClientTest {
- MockFace face = new MockFace();
- AdvancedClient instance = new AdvancedClient();
+ MockFace face;
+ AdvancedClient instance;
+
+ @Before
+ public void before() throws Exception {
+ face = new MockFace();
+ instance = new AdvancedClient();
+ }
@Test
public void testRetries() throws Exception {
@@ -91,11 +104,11 @@
public void testWhenDataNameIsLongerThanInterestName() throws Exception {
final List<Data> segments = TestHelper.buildSegments(new Name("/a/b/c/d"), 0, 10);
for (Data segment : segments) {
- face.addResponse(segment.getName(), segment);
+ face.receive(segment);
}
Name name = new Name("/a/b");
- face.addResponse(name, segments.get(0));
+ face.receive(segments.get(0));
Data data = instance.getSync(face, name);
assertNotNull(data);
@@ -112,7 +125,7 @@
public void testNoContent() throws Exception {
Name name = new Name("/test/no-content").appendSegment(0);
Data data = TestHelper.buildData(name, "", 0);
- face.addResponse(name, data);
+ face.receive(data);
Future<Data> result = instance.getAsync(face, name);
face.processEvents();
@@ -131,12 +144,12 @@
Data data1 = new Data(new Name("/test/content-length").appendSegment(0));
data1.setContent(new Blob("0123456789"));
data1.getMetaInfo().setFinalBlockId(Name.Component.fromNumberWithMarker(1, 0x00));
- face.addResponse(data1.getName(), data1);
+ face.receive(data1);
Data data2 = new Data(new Name("/test/content-length").appendSegment(1));
data2.setContent(new Blob("0123456789"));
data1.getMetaInfo().setFinalBlockId(Name.Component.fromNumberWithMarker(1, 0x00));
- face.addResponse(data2.getName(), data2);
+ face.receive(data2);
Future<Data> result = instance.getAsync(face, new Name("/test/content-length").appendSegment(0));
face.processEvents();
@@ -155,7 +168,7 @@
Name name = new Name("/test/no-final-block-id");
Data data = new Data(name);
data.setContent(new Blob("1"));
- face.addResponse(name, data);
+ face.receive(data);
Future<Data> result = instance.getAsync(face, name);
face.processEvents();
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/DefaultRetryClientTest.java b/src/test/java/com/intel/jndn/utils/client/impl/DefaultRetryClientTest.java
index aa0549a..6cf256b 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/DefaultRetryClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/client/impl/DefaultRetryClientTest.java
@@ -15,16 +15,20 @@
import com.intel.jndn.mock.MockFace;
import com.intel.jndn.utils.TestHelper.TestCounter;
-import java.io.IOException;
import net.named_data.jndn.Data;
import net.named_data.jndn.Interest;
import net.named_data.jndn.Name;
import net.named_data.jndn.OnData;
import net.named_data.jndn.OnTimeout;
import net.named_data.jndn.encoding.EncodingException;
-import static org.junit.Assert.*;
+import org.junit.Before;
import org.junit.Test;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
/**
* Test DefaultRetryClient
*
@@ -32,12 +36,18 @@
*/
public class DefaultRetryClientTest {
- DefaultRetryClient client = new DefaultRetryClient(3);
- MockFace face = new MockFace();
+ DefaultRetryClient client;
+ MockFace face;
Name name = new Name("/test/retry/client");
Interest interest = new Interest(name, 0.0);
TestCounter counter = new TestCounter();
+ @Before
+ public void before() throws Exception {
+ face = new MockFace();
+ client = new DefaultRetryClient(3);
+ }
+
@Test
public void testRetry() throws Exception {
@@ -67,7 +77,7 @@
}
protected void respondToRetryAttempt() throws IOException, EncodingException {
- face.getTransport().respondWith(new Data(name));
+ face.receive(new Data(name));
face.processEvents();
assertEquals(1, counter.count);
}
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java b/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java
index 2d65724..060350b 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java
@@ -17,13 +17,13 @@
import com.intel.jndn.utils.TestHelper;
import com.intel.jndn.utils.TestHelper.TestCounter;
import com.intel.jndn.utils.client.DataStream;
-import java.util.Random;
import net.named_data.jndn.Data;
import net.named_data.jndn.Interest;
import net.named_data.jndn.Name;
-import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
/**
* Test DefaultSegmentedClient
*
@@ -88,7 +88,7 @@
}
assertEquals(5, counter.count);
- assertEquals(5, face.getTransport().getSentInterestPackets().size());
+ assertEquals(5, face.sentInterests.size());
assertEquals("01234", stream.assemble().getContent().toString());
}
}
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTest.java b/src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTest.java
index 41e461c..4e529be 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTest.java
@@ -13,11 +13,15 @@
*/
package com.intel.jndn.utils.client.impl;
-import com.intel.jndn.utils.client.impl.SimpleClient;
import com.intel.jndn.mock.MockFace;
+import net.named_data.jndn.Data;
+import net.named_data.jndn.Face;
+import net.named_data.jndn.Interest;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.util.Blob;
import org.junit.Test;
-import static org.junit.Assert.*;
-import com.intel.jndn.mock.MockTransport;
+import org.junit.rules.ExpectedException;
+
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -25,13 +29,9 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import net.named_data.jndn.Data;
-import net.named_data.jndn.Face;
-import net.named_data.jndn.Interest;
-import net.named_data.jndn.Name;
-import net.named_data.jndn.encoding.EncodingException;
-import net.named_data.jndn.util.Blob;
-import org.junit.rules.ExpectedException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Test SimpleClient.java
@@ -44,15 +44,14 @@
public ExpectedException thrown = ExpectedException.none();
@Test
- public void testGetSync() throws IOException {
+ public void testGetSync() throws Exception {
// setup face
- MockTransport transport = new MockTransport();
- Face face = new Face(transport, null);
+ MockFace face = new MockFace();
// setup return data
Data response = new Data(new Name("/test/sync"));
response.setContent(new Blob("..."));
- transport.respondWith(response);
+ face.receive(response);
// retrieve data
logger.info("Client expressing interest synchronously: /test/sync");
@@ -62,15 +61,14 @@
}
@Test
- public void testGetAsync() throws InterruptedException, ExecutionException, IOException, EncodingException {
+ public void testGetAsync() throws Exception {
// setup face
- MockTransport transport = new MockTransport();
- Face face = new Face(transport, null);
+ MockFace face = new MockFace();
// setup return data
Data response = new Data(new Name("/test/async"));
response.setContent(new Blob("..."));
- transport.respondWith(response);
+ face.receive(response);
// retrieve data
logger.info("Client expressing interest asynchronously: /test/async");
@@ -87,8 +85,7 @@
@Test
public void testTimeout() throws Exception {
// setup face
- MockTransport transport = new MockTransport();
- Face face = new Face(transport, null);
+ MockFace face = new MockFace();
// retrieve non-existent data, should timeout
logger.info("Client expressing interest asynchronously: /test/timeout");
diff --git a/src/test/java/com/intel/jndn/utils/server/impl/SegmentedServerTest.java b/src/test/java/com/intel/jndn/utils/server/impl/SegmentedServerTest.java
index 71f505e..409edbe 100644
--- a/src/test/java/com/intel/jndn/utils/server/impl/SegmentedServerTest.java
+++ b/src/test/java/com/intel/jndn/utils/server/impl/SegmentedServerTest.java
@@ -21,6 +21,8 @@
import net.named_data.jndn.Name;
import net.named_data.jndn.util.Blob;
import static org.junit.Assert.*;
+
+import org.junit.Before;
import org.junit.Test;
/**
@@ -29,8 +31,14 @@
*/
public class SegmentedServerTest {
- MockFace face = new MockFace();
- SegmentedServer instance = new SegmentedServer(face, new Name("/test/prefix"));
+ MockFace face;
+ SegmentedServer instance;
+
+ @Before
+ public void before() throws Exception {
+ face = new MockFace();
+ instance = new SegmentedServer(face, new Name("/test/prefix"));
+ }
@Test
public void testGetPrefix() {
diff --git a/src/test/java/com/intel/jndn/utils/server/impl/ServerBaseImplTest.java b/src/test/java/com/intel/jndn/utils/server/impl/ServerBaseImplTest.java
index 767a021..bd054cc 100644
--- a/src/test/java/com/intel/jndn/utils/server/impl/ServerBaseImplTest.java
+++ b/src/test/java/com/intel/jndn/utils/server/impl/ServerBaseImplTest.java
@@ -22,6 +22,7 @@
import net.named_data.jndn.Interest;
import net.named_data.jndn.InterestFilter;
import net.named_data.jndn.Name;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -32,8 +33,14 @@
*/
public class ServerBaseImplTest {
- Face face = new MockFace();
- ServerBaseImpl instance = new ServerBaseImplImpl(face, new Name("/test/base"));
+ Face face;
+ ServerBaseImpl instance;
+
+ @Before
+ public void before() throws Exception {
+ face = new MockFace();
+ instance = new ServerBaseImplImpl(face, new Name("/test/base"));
+ }
public class ServerBaseImplImpl extends ServerBaseImpl {
diff --git a/src/test/java/com/intel/jndn/utils/server/impl/SimpleServerTest.java b/src/test/java/com/intel/jndn/utils/server/impl/SimpleServerTest.java
index e3766b2..01df6f2 100644
--- a/src/test/java/com/intel/jndn/utils/server/impl/SimpleServerTest.java
+++ b/src/test/java/com/intel/jndn/utils/server/impl/SimpleServerTest.java
@@ -24,6 +24,8 @@
import net.named_data.jndn.encoding.EncodingException;
import net.named_data.jndn.util.Blob;
import static org.junit.Assert.*;
+
+import org.junit.Before;
import org.junit.Test;
/**
@@ -33,8 +35,14 @@
*/
public class SimpleServerTest {
- MockFace face = new MockFace();
- SimpleServer instance = new SimpleServer(face, new Name("/test/prefix"));
+ MockFace face;
+ SimpleServer instance;
+
+ @Before
+ public void before() throws Exception {
+ face = new MockFace();
+ instance = new SimpleServer(face, new Name("/test/prefix"));
+ }
@Test
public void testGetPrefix() {
@@ -81,7 +89,7 @@
private void sendAndCheckOneInterest(Name interestName) throws EncodingException, IOException {
Interest interest = new Interest(interestName);
- face.getTransport().clear();
+
face.expressInterest(interest, new OnData() {
@Override
public void onData(Interest interest, Data data) {
@@ -90,7 +98,7 @@
});
face.processEvents();
- assertEquals(1, face.getTransport().getSentDataPackets().size());
- assertEquals("...", face.getTransport().getSentDataPackets().get(0).getContent().toString());
+ assertEquals(1, face.sentData.size());
+ assertEquals("...", face.sentData.get(0).getContent().toString());
}
}