Revert "Upgrade jndn to version 0.9 and jndn-mock to 1.0.1-SNAPSHOT"

This reverts commit c898bca4a2e38831e33379adab7c92456ef15675.

Change-Id: I9e123beb1eb9ebf80fecbc6a99fe73fce699b18e
diff --git a/src/test/java/com/intel/jndn/utils/TestHelper.java b/src/test/java/com/intel/jndn/utils/TestHelper.java
index 7b79bf4..fbf931e 100644
--- a/src/test/java/com/intel/jndn/utils/TestHelper.java
+++ b/src/test/java/com/intel/jndn/utils/TestHelper.java
@@ -13,6 +13,7 @@
  */
 package com.intel.jndn.utils;
 
+import com.intel.jndn.mock.MockKeyChain;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -23,12 +24,8 @@
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
-import com.intel.jndn.mock.MockFace;
-import com.intel.jndn.mock.MockKeyChain;
 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.security.KeyChain;
@@ -43,42 +40,6 @@
  */
 public class TestHelper {
 
-  public interface Tester {
-    boolean test();
-  }
-
-  public static void run(Face face, int limit, Tester t) throws IOException, EncodingException, InterruptedException {
-    while (t.test() && limit > 0) {
-      face.processEvents();
-      Thread.sleep(500);
-      limit--;
-    }
-  }
-
-  public static void run(Face face, int limit) throws IOException, EncodingException, InterruptedException {
-    run(face, limit, new Tester() {
-      @Override
-      public boolean test() {
-        return true;
-      }
-    });
-  }
-
-  public static void addDataPublisher(final MockFace face, final int finalBlockId) {
-    face.onSendInterest.add(new MockFace.SignalOnSendInterest() {
-      @Override
-      public void emit(Interest interest) throws EncodingException, SecurityException {
-        if (finalBlockId < 0) {
-          face.receive(TestHelper.buildData(interest.getName(), "..."));
-        }
-        else {
-          face.receive(TestHelper.buildData(interest.getName(), "...", finalBlockId));
-        }
-      }
-    });
-  }
-
-
   public static Data retrieve(CompletableFuture<Data> future) {
     try {
       return future.get(4000, TimeUnit.MILLISECONDS);
@@ -165,4 +126,8 @@
       }
     }
   }
+  
+  public static class TestCounter{
+    public int count = 0;
+  }
 }
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 6f8a910..67058d6 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
@@ -13,19 +13,21 @@
  */
 package com.intel.jndn.utils.client.impl;
 
-import java.sql.Time;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
-
 import com.intel.jndn.mock.MockFace;
 import com.intel.jndn.utils.TestHelper;
-import net.named_data.jndn.*;
-import net.named_data.jndn.encoding.EncodingException;
-import net.named_data.jndn.security.SecurityException;
+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 net.named_data.jndn.Data;
+import net.named_data.jndn.Face;
+import net.named_data.jndn.Interest;
+import net.named_data.jndn.InterestFilter;
+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;
 
 /**
@@ -34,157 +36,130 @@
  */
 public class AdvancedClientTest {
 
-  private static final Logger logger = Logger.getLogger(AdvancedClientTest.class.getName());
-
-  MockFace face;
-  AdvancedClient instance;
-  DefaultRetryClient retryClient;
-
-  @Before
-  public void init() throws SecurityException {
-    face = new MockFace();
-    retryClient = new DefaultRetryClient(5);
-    assertEquals(0, retryClient.totalRetries());
-    instance = new AdvancedClient(500, 2000, new DefaultSegmentedClient(), retryClient, new DefaultStreamingClient());
-  }
+  MockFace face = new MockFace();
+  AdvancedClient instance = new AdvancedClient();
 
   @Test
-  public void GetAsyncBasic() throws Exception {
+  public void testRetries() throws Exception {
     Name name = new Name("/test/advanced/client");
-    Interest interest = new Interest(name, 2000);
+    Interest interest = new Interest(name, 1);
 
-    TestHelper.addDataPublisher(face, -1);
+    CompletableFuture<Data> future = instance.getAsync(face, interest);
 
-    final CompletableFuture<Data> future = instance.getAsync(face, interest);
-
-    TestHelper.run(face, 20, new TestHelper.Tester() {
-      @Override
-      public boolean test() {
-        return !future.isDone();
-      }
-    });
-
-    assertFalse(future.isCompletedExceptionally());
-    assertEquals(0, retryClient.totalRetries());
-    assertEquals(1, face.sentInterests.size());
-    assertEquals("...", future.get().getContent().toString());
-  }
-
-  @Test
-  public void GetAsyncSegmented() throws Exception {
-    Name name = new Name("/test/advanced/client").appendSegment(0);
-    Interest interest = new Interest(name, 2000);
-
-    TestHelper.addDataPublisher(face, 9);
-
-    final CompletableFuture<Data> future = instance.getAsync(face, interest);
-
-    TestHelper.run(face, 20, new TestHelper.Tester() {
-      @Override
-      public boolean test() {
-        return !future.isDone();
-      }
-    });
-
-    assertFalse(future.isCompletedExceptionally());
-    assertEquals(0, retryClient.totalRetries());
-    assertEquals(10, face.sentInterests.size());
-    assertEquals("..............................", future.get().getContent().toString());
-  }
-
-  @Test
-  public void GetAsyncBasicNoData() throws Exception {
-    Name name = new Name("/test/advanced/client");
-    Interest interest = new Interest(name, 100);
-
-    final CompletableFuture<Data> future = instance.getAsync(face, interest);
-
-    TestHelper.run(face, 20, new TestHelper.Tester() {
-      @Override
-      public boolean test() {
-        return !future.isDone();
-      }
-    });
+    while (!future.isDone()) {
+      face.processEvents();
+    }
 
     assertTrue(future.isCompletedExceptionally());
-    assertEquals(5, retryClient.totalRetries());
-    assertNotEquals(face.sentInterests.get(0).getNonce(), face.sentInterests.get(1).getNonce());
-    assertEquals(6, face.sentInterests.size()); // original interest and 5 retries
   }
 
   @Test
-  public void GetSyncBasic() throws Exception {
-    final Name name = new Name("/segmented/data");
+  public void testGetSync() throws Exception {
+    Name name = new Name("/segmented/data");
 
-    TestHelper.addDataPublisher(face, -1);
+    face.registerPrefix(name, new OnInterestCallback() {
+      private int count = 0;
+      private int max = 9;
 
-    Data data = instance.getSync(face, name);
-    assertEquals("...", data.getContent().toString());
-    assertEquals(1, face.sentInterests.size());
+      @Override
+      public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) {
+        Data data = new Data(interest.getName());
+        if (!SegmentationHelper.isSegmented(data.getName(), SegmentationType.SEGMENT.value())) {
+          data.getName().appendSegment(0);
+        }
+        data.getMetaInfo().setFinalBlockId(Name.Component.fromNumberWithMarker(max, 0x00));
+        data.setContent(new Blob("."));
+        try {
+          face.putData(data);
+        } catch (IOException e) {
+          fail(e.getMessage());
+        }
+      }
+    }, null);
+
+    Data data = instance.getSync(face, new Name(name).appendSegment(0));
+    assertEquals(10, data.getContent().size());
   }
-
+  
+    /**
+   * Verify that Data returned with a different Name than the Interest is still
+   * segmented correctly.
+   *
+   * @throws Exception
+   */
   @Test
-  public void GetSyncSegmented() throws Exception {
-    final Name name = new Name("/segmented/data").appendSegment(0);
+  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);
+    }
 
-    TestHelper.addDataPublisher(face, 9);
+    Name name = new Name("/a/b");
+    face.addResponse(name, segments.get(0));
 
     Data data = instance.getSync(face, name);
-    assertEquals(10, face.sentInterests.size());
-    assertEquals("..............................", data.getContent().toString());
+    assertNotNull(data);
+    assertEquals("/a/b/c/d", data.getName().toUri());
   }
 
   /**
-   * Verify that Data returned with a different Name than the Interest is still
-   * segmented correctly.
+   * Verify that Data packets with no content do not cause errors; identifies
+   * bug.
+   *
+   * @throws Exception
    */
   @Test
-  public void DataNameIsLongerThanInterestName() throws Exception {
-    for (int i = 0; i < 10; i++) {
-      face.receive(TestHelper.buildData(new Name("/a/b/c/d").appendSegment(i), "...", 9));
-    }
+  public void testNoContent() throws Exception {
+    Name name = new Name("/test/no-content").appendSegment(0);
+    Data data = TestHelper.buildData(name, "", 0);
+    face.addResponse(name, data);
 
-    Data data = instance.getSync(face, new Name("/a/b"));
-    assertNotNull(data);
-    assertEquals("/a/b/c/d", data.getName().toUri());
-    assertEquals(10, face.sentInterests.size());
-    assertEquals("..............................", data.getContent().toString());
+    Future<Data> result = instance.getAsync(face, name);
+    face.processEvents();
+    assertEquals("/test/no-content", result.get().getName().toUri());
+    assertEquals("", result.get().getContent().toString());
   }
 
-  // @TODO This needs to be fixed in AdvancedClient
-   @Test(expected = AssertionError.class)
-   public void UnorderedSegments() throws Exception {
-     for (int i = 9; i >= 0; i--) {
-       face.receive(TestHelper.buildData(new Name("/a/b/c/d").appendSegment(i), "...", 9));
-     }
+  /**
+   * Verify that segmented content is the correct length when retrieved by the
+   * client.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testContentLength() throws Exception {
+    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);
 
-     final CompletableFuture<Data> future = instance.getAsync(face, new Name("/a/b"));
+    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);
 
-     TestHelper.run(face, 20, new TestHelper.Tester() {
-       @Override
-       public boolean test() {
-         return !future.isDone();
-       }
-     });
+    Future<Data> result = instance.getAsync(face, new Name("/test/content-length").appendSegment(0));
+    face.processEvents();
+    face.processEvents();
+    assertEquals(20, result.get().getContent().size());
+  }
 
-     assertTrue(future.isCompletedExceptionally());
-     assertNotNull(future.get());
-     assertEquals("/a/b/c/d", future.get().getName().toUri());
-     assertEquals(10, face.sentInterests.size());
-     assertEquals("..............................", future.get().getContent().toString());
-   }
+  /**
+   * If a Data packet does not have a FinalBlockId, the AdvancedClient should
+ just return the packet.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testNoFinalBlockId() throws Exception {
+    Name name = new Name("/test/no-final-block-id");
+    Data data = new Data(name);
+    data.setContent(new Blob("1"));
+    face.addResponse(name, data);
 
-   /**
-    * Verify that Data packets with no content do not cause errors
-    */
-   @Test
-   public void GetSyncDataNoContent() throws Exception {
-     Name name = new Name("/test/no-content").appendSegment(0);
-     face.receive(TestHelper.buildData(name, "", 0));
-
-     Data data = instance.getSync(face, name);
-
-     assertEquals("/test/no-content", data.getName().toUri());
-     assertEquals("", data.getContent().toString());
-   }
+    Future<Data> result = instance.getAsync(face, name);
+    face.processEvents();
+    assertEquals("/test/no-final-block-id", result.get().getName().toUri());
+    assertEquals("1", result.get().getContent().toString());
+  }
 }
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 46db570..aa0549a 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
@@ -14,8 +14,8 @@
 package com.intel.jndn.utils.client.impl;
 
 import com.intel.jndn.mock.MockFace;
-
-import com.intel.jndn.utils.TestHelper;
+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;
@@ -23,9 +23,6 @@
 import net.named_data.jndn.OnTimeout;
 import net.named_data.jndn.encoding.EncodingException;
 import static org.junit.Assert.*;
-
-import net.named_data.jndn.security.SecurityException;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -34,66 +31,44 @@
  * @author Andrew Brown <andrew.brown@intel.com>
  */
 public class DefaultRetryClientTest {
-  DefaultRetryClient client;
-  MockFace face;
-  int nData;
-  int nTimeouts;
 
-  @Before
-  public void setUp() throws Exception {
-    face = new MockFace();
-    client = new DefaultRetryClient(3);
-    nData = 0;
-    nTimeouts = 0;
+  DefaultRetryClient client = new DefaultRetryClient(3);
+  MockFace face = new MockFace();
+  Name name = new Name("/test/retry/client");
+  Interest interest = new Interest(name, 0.0);
+  TestCounter counter = new TestCounter();
 
-    client.retry(face, new Interest(new Name("/test/retry/client"), 10), new OnData() {
+  @Test
+  public void testRetry() throws Exception {
+
+    client.retry(face, interest, new OnData() {
       @Override
       public void onData(Interest interest, Data data) {
-        nData++;
+        counter.count++;
       }
     }, new OnTimeout() {
       @Override
       public void onTimeout(Interest interest) {
-        nTimeouts++;
+        fail("Should not timeout.");
       }
     });
-  }
-
-  @Test
-  public void MaxRetries() throws Exception {
-    TestHelper.run(face, 10);
-    assertEquals(3, client.totalRetries());
-    assertEquals(3, face.sentInterests.size());
-    assertEquals(0, nData);
-    assertEquals(1, nTimeouts);
-  }
-
-  @Test
-  public void RetryAndSuccess() throws Exception {
-    TestHelper.run(face, 1);
     assertEquals(1, client.totalRetries());
-    assertEquals(1, face.sentInterests.size());
-    assertEquals(0, nData);
-    assertEquals(0, nTimeouts);
 
-    TestHelper.run(face, 1);
-    assertEquals(2, client.totalRetries());
-    assertEquals(2, face.sentInterests.size());
-    assertEquals(0, nData);
-    assertEquals(0, nTimeouts);
+    timeoutAndVerifyRetry(2);
+    timeoutAndVerifyRetry(3);
+    respondToRetryAttempt();
+  }
 
-    face.onSendInterest.add(new MockFace.SignalOnSendInterest() {
-      @Override
-      public void emit(Interest interest) throws EncodingException, SecurityException {
-        face.receive(new Data(new Name("/test/retry/client")));
-        face.onSendInterest.clear();
-      }
-    });
+  private void timeoutAndVerifyRetry(int retryCount) throws Exception {
+    Thread.sleep(1);
+    face.processEvents();
+    assertEquals(retryCount, client.totalRetries());
+    assertEquals(0, counter.count);
+  }
 
-    TestHelper.run(face, 5);
-    assertEquals(3, face.sentInterests.size());
-    assertEquals(2, client.totalRetries());
-    assertEquals(1, nData);
-    assertEquals(0, nTimeouts);
+  protected void respondToRetryAttempt() throws IOException, EncodingException {
+    face.getTransport().respondWith(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 e18846e..7ed72d4 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
@@ -15,15 +15,16 @@
 
 import com.intel.jndn.mock.MockFace;
 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 net.named_data.jndn.OnData;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
-import static junit.framework.TestCase.assertEquals;
+import net.named_data.jndn.OnData;
+import org.junit.Test;
 
 /**
  * Test DefaultSegmentedClient
@@ -32,27 +33,20 @@
  */
 public class DefaultSegmentedClientTest {
 
-  DefaultSegmentedClient instance;
-  MockFace face;
-  int counter;
-
-  @Before
-  public void setUp() throws Exception {
-    instance = new DefaultSegmentedClient();
-    face = new MockFace();
-    counter = 0;
-  }
+  DefaultSegmentedClient instance = new DefaultSegmentedClient();
 
   @Test
   public void testGetSegmentsAsync() throws Exception {
+    MockFace face = new MockFace();
     Name name = new Name("/test/segmented/client");
     Interest interest = new Interest(name);
     DataStream stream = instance.getSegmentsAsync(face, interest);
 
+    final TestCounter counter = new TestCounter();
     stream.observe(new OnData() {
       @Override
       public void onData(Interest interest, Data data) {
-        counter++;
+        counter.count++;
       }
     });
 
@@ -60,7 +54,7 @@
       stream.onData(interest, segment);
     }
 
-    assertEquals(5, counter);
+    assertEquals(5, counter.count);
     assertEquals("01234", stream.assemble().getContent().toString());
   }
 
@@ -83,25 +77,26 @@
 
   @Test
   public void verifyThatSegmentsAreRetrievedOnlyOnce() throws Exception {
+    MockFace face = new MockFace();
     Name name = new Name("/test/segmented/client");
     Interest interest = new Interest(name);
     DataStream stream = instance.getSegmentsAsync(face, interest);
 
+    final TestCounter counter = new TestCounter();
     stream.observe(new OnData() {
       @Override
       public void onData(Interest interest, Data data) {
-        counter++;
+        counter.count++;
       }
     });
 
     for (Data segment : TestHelper.buildSegments(name, 0, 5)) {
-      face.receive(segment);
+      face.putData(segment);
+      face.processEvents();
     }
 
-    TestHelper.run(face, 10);
-
-    assertEquals(5, counter);
-    assertEquals(5, face.sentInterests.size());
+    assertEquals(5, counter.count);
+    assertEquals(5, face.getTransport().getSentInterestPackets().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 f583fbc..41e461c 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,12 +13,11 @@
  */
 package com.intel.jndn.utils.client.impl;
 
+import com.intel.jndn.utils.client.impl.SimpleClient;
 import com.intel.jndn.mock.MockFace;
-import com.intel.jndn.utils.TestHelper;
-import net.named_data.jndn.security.SecurityException;
-import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.*;
+import com.intel.jndn.mock.MockTransport;
 import java.io.IOException;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
@@ -42,79 +41,90 @@
 public class SimpleClientTest {
 
   private static final Logger logger = Logger.getLogger(SimpleClient.class.getName());
+  public ExpectedException thrown = ExpectedException.none();
 
-  MockFace face;
-  SimpleClient instance;
+  @Test
+  public void testGetSync() throws IOException {
+    // setup face
+    MockTransport transport = new MockTransport();
+    Face face = new Face(transport, null);
 
-  @Before
-  public void init() throws SecurityException {
-    face = new MockFace();
-    instance = new SimpleClient();
+    // setup return data
+    Data response = new Data(new Name("/test/sync"));
+    response.setContent(new Blob("..."));
+    transport.respondWith(response);
+
+    // retrieve data
+    logger.info("Client expressing interest synchronously: /test/sync");
+    SimpleClient client = new SimpleClient();
+    Data data = client.getSync(face, new Name("/test/sync"));
+    assertEquals(new Blob("...").buf(), data.getContent().buf());
   }
 
   @Test
-  public void GetAsync() throws Exception {
-    Name name = new Name("/test/simple/client/async");
-    Interest interest = new Interest(name, 2000);
+  public void testGetAsync() throws InterruptedException, ExecutionException, IOException, EncodingException {
+    // setup face
+    MockTransport transport = new MockTransport();
+    Face face = new Face(transport, null);
 
-    TestHelper.addDataPublisher(face, -1);
+    // setup return data
+    Data response = new Data(new Name("/test/async"));
+    response.setContent(new Blob("..."));
+    transport.respondWith(response);
 
-    final CompletableFuture<Data> future = instance.getAsync(face, interest);
+    // retrieve data
+    logger.info("Client expressing interest asynchronously: /test/async");
+    SimpleClient client = new SimpleClient();
+    Future<Data> futureData = client.getAsync(face, new Name("/test/async"));
+    assertTrue(!futureData.isDone());
 
-    TestHelper.run(face, 20, new TestHelper.Tester() {
-      @Override
-      public boolean test() {
-        return !future.isDone();
-      }
-    });
-
-    assertFalse(future.isCompletedExceptionally());
-    assertEquals(1, face.sentInterests.size());
-    assertEquals("...", future.get().getContent().toString());
+    // process events to retrieve data
+    face.processEvents();
+    assertTrue(futureData.isDone());
+    assertEquals(new Blob("...").toString(), futureData.get().getContent().toString());
   }
 
   @Test
-  public void GetAsyncNoData() throws Exception {
-    Name name = new Name("/test/simple/client/async/timeout");
-    Interest interest = new Interest(name, 100);
+  public void testTimeout() throws Exception {
+    // setup face
+    MockTransport transport = new MockTransport();
+    Face face = new Face(transport, null);
 
-    final CompletableFuture<Data> future = instance.getAsync(face, interest);
+    // retrieve non-existent data, should timeout
+    logger.info("Client expressing interest asynchronously: /test/timeout");
+    Interest interest = new Interest(new Name("/test/timeout"), 1);
+    CompletableFuture<Data> futureData = SimpleClient.getDefault().getAsync(face, interest);
 
-    TestHelper.run(face, 20, new TestHelper.Tester() {
-      @Override
-      public boolean test() {
-        return !future.isDone();
-      }
-    });
+    // wait for NDN timeout
+    Thread.sleep(2);
+    face.processEvents();
 
-    assertTrue(future.isCompletedExceptionally());
+    // verify that the client is completing the future with a TimeoutException
+    assertTrue(futureData.isDone());
+    assertTrue(futureData.isCompletedExceptionally());
+    try {
+      futureData.get();
+    } catch (ExecutionException e) {
+      assertTrue(e.getCause() instanceof TimeoutException);
+    }
   }
 
-  @Test
-  public void GetSync() throws Exception {
-    final Name name = new Name("/test/simple/client/sync");
+  @Test(expected = Exception.class)
+  public void testAsyncFailureToRetrieve() throws Exception {
+    Face face = new MockFace();
 
-    TestHelper.addDataPublisher(face, -1);
+    logger.info("Client expressing interest asynchronously: /test/no-data");
+    Interest interest = new Interest(new Name("/test/no-data"), 10);
+    Future future = SimpleClient.getDefault().getAsync(face, interest);
 
-    Data data = instance.getSync(face, name);
-    assertEquals("...", data.getContent().toString());
-    assertEquals(1, face.sentInterests.size());
+    face.processEvents();
+    future.get(15, TimeUnit.MILLISECONDS);
   }
 
-//  @Test(expected = Exception.class)
-//  public void testAsyncFailureToRetrieve() throws Exception {
-//    logger.info("Client expressing interest asynchronously: /test/no-data");
-//    Interest interest = new Interest(new Name("/test/no-data"), 10);
-//    Future future = SimpleClient.getDefault().getAsync(face, interest);
-//
-//    face.processEvents();
-//    future.get(15, TimeUnit.MILLISECONDS);
-//  }
-//
-//  @Test(expected = IOException.class)
-//  public void testSyncFailureToRetrieve() throws IOException {
-//    logger.info("Client expressing interest synchronously: /test/no-data");
-//    Interest interest = new Interest(new Name("/test/no-data"), 10);
-//    SimpleClient.getDefault().getSync(new Face(), interest);
-//  }
+  @Test(expected = IOException.class)
+  public void testSyncFailureToRetrieve() throws IOException {
+    logger.info("Client expressing interest synchronously: /test/no-data");
+    Interest interest = new Interest(new Name("/test/no-data"), 10);
+    SimpleClient.getDefault().getSync(new Face(), interest);
+  }
 }
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 bcfb28e..71f505e 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
@@ -13,18 +13,14 @@
  */
 package com.intel.jndn.utils.server.impl;
 
-import com.intel.jndn.mock.MockFace;
-import com.intel.jndn.utils.TestHelper;
 import com.intel.jndn.utils.client.impl.AdvancedClient;
+import com.intel.jndn.mock.MockFace;
 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.encoding.EncodingException;
 import net.named_data.jndn.util.Blob;
 import static org.junit.Assert.*;
-
-import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -33,14 +29,8 @@
  */
 public class SegmentedServerTest {
 
-  MockFace face;
-  SegmentedServer instance;
-
-  @Before
-  public void setUp() throws Exception {
-    face = new MockFace();
-    instance = new SegmentedServer(face, new Name("/test/prefix"));
-  }
+  MockFace face = new MockFace();
+  SegmentedServer instance = new SegmentedServer(face, new Name("/test/prefix"));
 
   @Test
   public void testGetPrefix() {
@@ -60,18 +50,14 @@
   }
 
   @Test
-  public void testServe() throws IOException, EncodingException, InterruptedException {
+  public void testServe() throws IOException {
     Data in = new Data(new Name("/test/prefix/serve"));
     in.setContent(new Blob("1234"));
     instance.serve(in);
-
-    face.receive(new Interest(new Name("/test/prefix/serve")));
-
-    TestHelper.run(face, 5);
-
-    assertEquals(1, face.sentData.size());
-    assertEquals("1234", face.sentData.get(0).getContent().toString());
-    assertEquals(in.getName().toUri(), face.sentData.get(0).getName().toUri());
+    Data out = AdvancedClient.getDefault().getSync(face, new Name("/test/prefix/serve"));
+    assertEquals(in.getContent(), out.getContent());
+    assertEquals(in.getName().toUri(), out.getName().toUri());
+    assertEquals("1234", out.getContent().toString());
   }
   
   @Test(expected = IOException.class)
@@ -101,12 +87,10 @@
     
     Interest interest = new Interest(new Name("/test/prefix/a/b"))
             .setChildSelector(Interest.CHILD_SELECTOR_RIGHT).setInterestLifetimeMilliseconds(100);
-    face.receive(interest);
-
-    TestHelper.run(face, 2);
-
-    assertEquals(1, face.sentData.size());
-    assertEquals("/test/prefix/a/b/c/1", face.sentData.get(0).getName().toUri());
+    Data out = AdvancedClient.getDefault().getSync(face, interest);
+    
+    assertNotNull(out);
+    assertEquals("/test/prefix/a/b/c/1", out.getName().toUri());
     // note that this won't be .../c/2 since .../c/1 satisfies both the Interest
     // name and "c" is the rightmost component (child selectors operate on the
     // next component after the Interest name only)
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 f3f5eb9..767a021 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
@@ -13,8 +13,8 @@
  */
 package com.intel.jndn.utils.server.impl;
 
-import com.intel.jndn.mock.MockFace;
 import com.intel.jndn.utils.ProcessingStage;
+import com.intel.jndn.mock.MockFace;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import net.named_data.jndn.Data;
@@ -22,7 +22,6 @@
 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.*;
 
@@ -33,8 +32,8 @@
  */
 public class ServerBaseImplTest {
 
-  Face face;
-  ServerBaseImpl instance;
+  Face face = new MockFace();
+  ServerBaseImpl instance = new ServerBaseImplImpl(face, new Name("/test/base"));
 
   public class ServerBaseImplImpl extends ServerBaseImpl {
 
@@ -48,12 +47,6 @@
     }
   }
 
-  @Before
-  public void setUp() throws Exception {
-    face = new MockFace();
-    instance = new ServerBaseImplImpl(face, new Name("/test/base"));
-  }
-
   /**
    * Test of getPrefix method, of class 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 1fba769..e3766b2 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,8 +24,6 @@
 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;
 
 /**
@@ -35,14 +33,8 @@
  */
 public class SimpleServerTest {
 
-  MockFace face;
-  SimpleServer instance;
-
-  @Before
-  public void setUp() throws Exception {
-    face = new MockFace();
-    instance = new SimpleServer(face, new Name("/test/prefix"));
-  }
+  MockFace face = new MockFace();
+  SimpleServer instance = new SimpleServer(face, new Name("/test/prefix"));
 
   @Test
   public void testGetPrefix() {
@@ -89,11 +81,16 @@
 
   private void sendAndCheckOneInterest(Name interestName) throws EncodingException, IOException {
     Interest interest = new Interest(interestName);
-    face.receive(interest);
+    face.getTransport().clear();
+    face.expressInterest(interest, new OnData() {
+      @Override
+      public void onData(Interest interest, Data data) {
+        assertEquals("/test/prefix/response", data.getName().toUri());
+      }
+    });
 
     face.processEvents();
-
-    assertEquals(1, face.sentData.size());
-    assertEquals("...", face.sentData.get(0).getContent().toString());
+    assertEquals(1, face.getTransport().getSentDataPackets().size());
+    assertEquals("...", face.getTransport().getSentDataPackets().get(0).getContent().toString());
   }
 }