@Test
public void testAddReader() throws Exception {

  String resource = "resource1";
  TestReader reader1 = new TestReader();
  resourcePartitionMap.addReader(resource, "part1", reader1);
  assertEquals(reader1, resourcePartitionMap.getReader(resource, "part1"));
  // Check that we do not overwrite already existing reader objects.
  TestReader reader2 = new TestReader();
  resourcePartitionMap.addReader(resource, "part1", reader2);
  assertEquals(reader1, resourcePartitionMap.getReader(resource, "part1"));
  // Check that we throw the correct exception for missing partitions.
  testGetExceptionErrorCode(resource, "part2", TerrapinGetErrorCode.NOT_SERVING_PARTITION);
  // Check that we throw the correct exception for resources missing in entirety.
  testGetExceptionErrorCode("resource2", "part1", TerrapinGetErrorCode.NOT_SERVING_RESOURCE);
}