Add new Server implementation
diff --git a/src/test/java/com/intel/jndn/utils/SegmentedClientTest.java b/src/test/java/com/intel/jndn/utils/SegmentedClientTest.java
index a08f3af..56231db 100644
--- a/src/test/java/com/intel/jndn/utils/SegmentedClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/SegmentedClientTest.java
@@ -97,6 +97,14 @@
   }
 
   /**
+   * Test that a sync failed request fails with an exception.
+   */
+  @Test(expected = IOException.class)
+  public void testSyncFailureToRetrieve() throws IOException {
+    SegmentedClient.getDefault().getSync(new MockFace(), new Name("/test/no-data"));
+  }
+
+  /**
    * Ensure Name of the returned Data is the same as was requested; identifies
    * bug where the last Name.Component was always cut off.
    *
@@ -115,4 +123,5 @@
     assertEquals(name.toUri(), future.getName().toUri());
     assertEquals(name.toUri(), future.get().getName().toUri());
   }
+
 }
diff --git a/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java b/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java
new file mode 100644
index 0000000..a840cd0
--- /dev/null
+++ b/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java
@@ -0,0 +1,60 @@
+/*
+ * jndn-utils
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.utils;
+
+import com.intel.jndn.mock.MockFace;
+import java.io.IOException;
+import net.named_data.jndn.Data;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.util.Blob;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class SegmentedServerTest {
+
+  MockFace face = new MockFace();
+  SegmentedServer instance = new SegmentedServer(face, new Name("/test/prefix"));
+
+  @Test
+  public void testGetPrefix() {
+    assertNotNull(instance.getPrefix());
+  }
+
+  @Test
+  public void testAddPipelineStage() {
+    instance.addPipelineStage(null);
+  }
+
+  @Test
+  public void testProcessPipeline() throws Exception {
+    Data in = new Data(new Name("/test"));
+    Data out = instance.processPipeline(in);
+    assertEquals(out, in);
+  }
+
+  @Test
+  public void testServe() throws IOException {
+    Data in = new Data(new Name("/test/prefix/serve"));
+    in.setContent(new Blob("1234"));
+    instance.serve(in);
+    Data out = SegmentedClient.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());
+  }
+}
diff --git a/src/test/java/com/intel/jndn/utils/SimpleClientTest.java b/src/test/java/com/intel/jndn/utils/SimpleClientTest.java
index 0386db1..9a94066 100644
--- a/src/test/java/com/intel/jndn/utils/SimpleClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/SimpleClientTest.java
@@ -16,6 +16,7 @@
 import org.junit.Test;
 import static org.junit.Assert.*;
 import com.intel.jndn.mock.MockTransport;
+import com.intel.jndn.utils.client.FutureData;
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -106,4 +107,22 @@
     // expect an exception
     futureData.get(50, TimeUnit.MILLISECONDS);
   }
+
+  /**
+   * Test that a sync failed request fails with an exception.
+   */
+  @Test(expected = ExecutionException.class)
+  public void testAsyncFailureToRetrieve() throws InterruptedException, ExecutionException {
+    Future future = SimpleClient.getDefault().getAsync(new Face(), new Name("/test/no-data"));
+    assertTrue(future.isDone());
+    future.get();
+  }
+
+  /**
+   * Test that a sync failed request fails with an exception.
+   */
+  @Test(expected = IOException.class)
+  public void testSyncFailureToRetrieve() throws IOException {
+    SimpleClient.getDefault().getSync(new Face(), new Name("/test/no-data"));
+  }
 }
diff --git a/src/test/java/com/intel/jndn/utils/SimpleServerTest.java b/src/test/java/com/intel/jndn/utils/SimpleServerTest.java
new file mode 100644
index 0000000..6910059
--- /dev/null
+++ b/src/test/java/com/intel/jndn/utils/SimpleServerTest.java
@@ -0,0 +1,96 @@
+/*
+ * jndn-utils
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.utils;
+
+import com.intel.jndn.utils.server.RespondWithData;
+import com.intel.jndn.mock.MockFace;
+import com.intel.jndn.utils.server.RespondWithBlob;
+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.encoding.EncodingException;
+import net.named_data.jndn.util.Blob;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ * Test {@link SimpleServer}
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class SimpleServerTest {
+
+  MockFace face = new MockFace();
+  SimpleServer instance = new SimpleServer(face, new Name("/test/prefix"));
+
+  @Test
+  public void testGetPrefix() {
+    assertNotNull(instance.getPrefix());
+  }
+
+  @Test
+  public void testAddPipelineStage() {
+    instance.addPipelineStage(null);
+  }
+
+  @Test
+  public void testProcessPipeline() throws Exception {
+    Data in = new Data(new Name("/test"));
+    Data out = instance.processPipeline(in);
+    assertEquals(out, in);
+  }
+
+  @Test
+  public void testRespond() throws IOException, EncodingException {
+    instance.respondUsing(new RespondWithData() {
+      @Override
+      public Data onInterest(Name prefix, Interest interest) throws Exception {
+        Data data = new Data(interest.getName());
+        data.setContent(new Blob("..."));
+        return data;
+      }
+    });
+
+    sendAndCheckOneInterest(new Name("/test/prefix/response"));
+  }
+
+  @Test
+  public void testRespondFromBlob() throws IOException, EncodingException {
+    instance.respondUsing(new RespondWithBlob() {
+      @Override
+      public Blob onInterest(Name prefix, Interest interest) throws Exception {
+        return new Blob("...");
+      }
+    });
+
+    sendAndCheckOneInterest(new Name("/test/prefix/response"));
+  }
+
+  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) {
+        assertEquals("/test/prefix/response", data.getName().toUri());
+      }
+    });
+
+    face.processEvents();
+    assertEquals(1, face.getTransport().getSentDataPackets().size());
+    assertEquals("...", face.getTransport().getSentDataPackets().get(0).getContent().toString());
+  }
+}
diff --git a/src/test/java/com/intel/jndn/utils/client/FutureDataTest.java b/src/test/java/com/intel/jndn/utils/client/FutureDataTest.java
new file mode 100644
index 0000000..e632cae
--- /dev/null
+++ b/src/test/java/com/intel/jndn/utils/client/FutureDataTest.java
@@ -0,0 +1,98 @@
+/*
+ * jndn-utils
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.utils.client;
+
+import com.intel.jndn.mock.MockFace;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import net.named_data.jndn.Data;
+import net.named_data.jndn.Name;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test {@link FutureData}
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class FutureDataTest {
+  
+  FutureData instance;
+  
+  public FutureDataTest(){
+    instance = new FutureData(new MockFace(), new Name("/test/future"));
+  }
+
+  /**
+   * Test of getName method, of class FutureData.
+   */
+  @Test
+  public void testGetName() {
+    assertNotNull(instance.getName());
+  }
+
+  /**
+   * Test of cancel method, of class FutureData.
+   */
+  @Test(expected = InterruptedException.class)
+  public void testCancellation() throws InterruptedException, ExecutionException {
+    instance.cancel(true);
+    assertTrue(instance.isCancelled());
+    instance.get();
+  }
+
+  /**
+   * Test of isDone method, of class FutureData.
+   */
+  @Test
+  public void testIsDone() {
+    assertFalse(instance.isDone());
+  }
+
+  /**
+   * Test of resolve method, of class FutureData.
+   */
+  @Test
+  public void testResolve() {
+    instance.resolve(new Data());
+    assertTrue(instance.isDone());
+  }
+
+  /**
+   * Test of reject method, of class FutureData.
+   */
+  @Test
+  public void testReject() {
+    instance.reject(new Error());
+    assertTrue(instance.isDone());
+  }
+
+  /**
+   * Test of get method, of class FutureData.
+   */
+  @Test
+  public void testGet_0args() throws Exception {
+    instance.resolve(new Data(new Name("/test/packet")));
+    Data result = instance.get();
+    assertEquals("/test/packet", result.getName().toUri());
+  }
+
+  /**
+   * Test of get method, of class FutureData.
+   */
+  @Test(expected = TimeoutException.class)
+  public void testGet_long_TimeUnit() throws Exception {
+    instance.get(10, TimeUnit.MILLISECONDS);
+  }
+}
diff --git a/src/test/java/com/intel/jndn/utils/client/SegmentedFutureDataTest.java b/src/test/java/com/intel/jndn/utils/client/SegmentedFutureDataTest.java
new file mode 100644
index 0000000..5bc3149
--- /dev/null
+++ b/src/test/java/com/intel/jndn/utils/client/SegmentedFutureDataTest.java
@@ -0,0 +1,76 @@
+/*
+ * jndn-utils
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.utils.client;
+
+import com.intel.jndn.mock.MockFace;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import net.named_data.jndn.Data;
+import net.named_data.jndn.Face;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.util.Blob;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class SegmentedFutureDataTest {
+
+  SegmentedFutureData instance;
+
+  public SegmentedFutureDataTest() {
+    Face face = new MockFace();
+    List<Future<Data>> segments = new ArrayList<>();
+    for (int i = 0; i < 10; i++) {
+      Data data = new Data(new Name("/test/packet").appendSegment(i));
+      data.setContent(new Blob("."));
+      FutureData future = new FutureData(face, data.getName());
+      future.resolve(data);
+      segments.add(future);
+    }
+    instance = new SegmentedFutureData(new Name("/test/packet"), segments);
+  }
+
+  @Test
+  public void testIsDone() {
+    assertTrue(instance.isDone());
+  }
+  
+  @Test
+  public void testIsDoneWhenCancelled() {
+    instance.cancel(false);
+    assertTrue(instance.isDone());
+  }
+
+  /**
+   * Test of get method, of class SegmentedFutureData.
+   */
+  @Test
+  public void testGet_0args() throws Exception {
+    assertEquals(10, instance.get().getContent().size());
+  }
+
+  /**
+   * Test of get method, of class FutureData.
+   */
+  @Test
+  public void testGet_long_TimeUnit() throws Exception {
+    instance.get(10, TimeUnit.MILLISECONDS);
+  }
+}
diff --git a/src/test/java/com/intel/jndn/utils/server/ServerBaseImplTest.java b/src/test/java/com/intel/jndn/utils/server/ServerBaseImplTest.java
new file mode 100644
index 0000000..41cdf3c
--- /dev/null
+++ b/src/test/java/com/intel/jndn/utils/server/ServerBaseImplTest.java
@@ -0,0 +1,94 @@
+/*
+ * jndn-utils
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.utils.server;
+
+import com.intel.jndn.mock.MockFace;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+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.transport.Transport;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test base server implementation.
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class ServerBaseImplTest {
+
+  Face face = new MockFace();
+  ServerBaseImpl instance = new ServerBaseImplImpl(face, new Name("/test/base"));
+
+  public class ServerBaseImplImpl extends ServerBaseImpl {
+
+    public ServerBaseImplImpl(Face face, Name prefix) {
+      super(face, prefix);
+    }
+
+    @Override
+    public void onInterest(Name prefix, Interest interest, Transport transport, long registeredPrefixId) {
+      throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+  }
+
+  /**
+   * Test of getPrefix method, of class ServerBaseImpl.
+   */
+  @Test
+  public void testGetPrefix() {
+    assertNotNull(instance.getPrefix());
+  }
+
+  /**
+   * Test of register method, of class ServerBaseImpl.
+   */
+  @Test
+  public void testRegister() throws Exception {
+    assertFalse(instance.isRegistered());
+    instance.register();
+    assertTrue(instance.isRegistered());
+  }
+
+  /**
+   * Test of addPipelineStage method, of class ServerBaseImpl.
+   */
+  @Test(expected = Exception.class)
+  public void testPipeline() throws Exception {
+    PipelineStage<Data, Data> pipelineStage = new PipelineStage<Data, Data>() {
+      @Override
+      public Data process(Data context) throws Exception {
+        throw new Exception("Test exceptions with this");
+      }
+    };
+    instance.addPipelineStage(pipelineStage);
+    instance.processPipeline(new Data());
+  }
+
+  /**
+   * Test of run method, of class ServerBaseImpl.
+   */
+  @Test
+  public void testRun() throws InterruptedException {
+    assertFalse(instance.isRegistered());
+    ExecutorService executor = Executors.newSingleThreadExecutor();
+    executor.submit(instance);
+    Thread.sleep(100);
+    assertTrue(instance.isRegistered());
+    executor.shutdownNow();
+  }
+}