Add satisfies() and cleanup() to repository servers
diff --git a/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java b/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java
index a840cd0..b6d271b 100644
--- a/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java
+++ b/src/test/java/com/intel/jndn/utils/SegmentedServerTest.java
@@ -16,6 +16,7 @@
 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.util.Blob;
 import static org.junit.Assert.*;
@@ -57,4 +58,40 @@
     assertEquals(in.getName().toUri(), out.getName().toUri());
     assertEquals("1234", out.getContent().toString());
   }
+  
+  @Test(expected = IOException.class)
+  public void testCleanup() throws Exception{
+    Data in = new Data(new Name("/test"));
+    in.getMetaInfo().setFreshnessPeriod(0);
+    instance.serve(in);
+    Thread.sleep(10);
+    
+    Data out = SegmentedClient.getDefault().getSync(face, new Name("/test"));
+    assertNotNull(out);
+    assertEquals(in.getName(), out.getName());
+    
+    instance.cleanup();
+    SegmentedClient.getDefault().getSync(face, new Name("/test"));
+  }
+  
+  @Test
+  public void testServingNoContent() throws IOException{
+    instance.serve(new Data());
+  }
+  
+  @Test
+  public void testWhenDataNameIsLongerThanInterestName() throws Exception{
+    instance.serve(new Data(new Name("/test/prefix/a/b/c/1")));
+    instance.serve(new Data(new Name("/test/prefix/a/b/c/2")));
+    
+    Interest interest = new Interest(new Name("/test/prefix/a/b"))
+            .setChildSelector(Interest.CHILD_SELECTOR_RIGHT).setInterestLifetimeMilliseconds(100);
+    Data out = SegmentedClient.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/repository/RepositoryTest.java b/src/test/java/com/intel/jndn/utils/repository/RepositoryTest.java
index 36fed91..f39e028 100644
--- a/src/test/java/com/intel/jndn/utils/repository/RepositoryTest.java
+++ b/src/test/java/com/intel/jndn/utils/repository/RepositoryTest.java
@@ -54,6 +54,16 @@
     Data data2 = instance.get(interest2);
     assertEquals("/a/b/c/e", data2.getName().toUri());
   }
+  
+  @Test
+  public void testChildSelectorsOnExactMatch() throws DataNotFoundException{
+    instance.put(buildData("/a/b/c"));
+    instance.put(buildData("/a/b/d"));
+    
+    Interest interest = buildInterest("/a/b/c").setChildSelector(Interest.CHILD_SELECTOR_LEFT);
+    assertTrue(instance.satisfies(interest));
+    assertEquals("/a/b/c", instance.get(interest).getName().toUri());
+  }
 
   @Test(expected = DataNotFoundException.class)
   public void testFailure() throws DataNotFoundException {
@@ -80,4 +90,31 @@
     interest.setMustBeFresh(true);
     instance.get(interest);
   }
+
+  @Test
+  public void testSatisfies() throws InterruptedException {
+    instance.put(RepoHelper.buildAlmostStaleData("/stale/data"));
+    instance.put(RepoHelper.buildFreshData("/fresh/data"));
+
+    Thread.sleep(10);
+
+    assertTrue(instance.satisfies(buildInterest("/fresh/data")));
+    assertFalse(instance.satisfies(buildInterest("/stale/data")));
+    assertFalse(instance.satisfies(buildInterest("/not/found/data")));
+  }
+
+  @Test
+  public void testChildSelectors() throws DataNotFoundException {
+    instance.put(RepoHelper.buildFreshData("/a/a"));
+    instance.put(RepoHelper.buildFreshData("/a/b/c/1"));
+    instance.put(RepoHelper.buildFreshData("/a/b/c/2"));
+    instance.put(RepoHelper.buildFreshData("/a/b/c/3"));
+    
+    assertTrue(instance.satisfies(buildInterest("/a")));
+    
+    Data out = instance.get(buildInterest("/a").setChildSelector(Interest.CHILD_SELECTOR_RIGHT));
+    assertEquals("/a/b/c/1", out.getName().toUri());
+    // you may think this should be /a/b/c/3, but the child selectors only
+    // operate on the first component after the interest name; in this case, "b"
+  }
 }