@Test
public void testConditionalEntropy() throws Exception {

  Configuration configuration = new Configuration();
  Path input = getTestTempFilePath("input");
  Path output = getTestTempFilePath("output");
  FileSystem fileSystem = FileSystem.get(input.toUri(), configuration);
  // create input
  String[] keys = { "Math", "History", "CS", "Math", "Math", "CS", "History", "Math" };
  String[] values = { "Yes", "No", "Yes", "No", "No", "Yes", "No", "Yes" };
  SequenceFile.Writer writer = new SequenceFile.Writer(fileSystem, configuration, input, Text.class, Text.class);
  try {
    for (int i = 0; i < keys.length; i++) {
      writer.append(new Text(keys[i]), new Text(values[i]));
    }
  } finally {
    Closeables.closeQuietly(writer);
  }
  // run the job
  Tool job = new ConditionalEntropy();
  String[] args = { "-i", input.toString(), "-o", output.toString(),
      "--tempDir", getTestTempDirPath("tmp").toString() };
  ToolRunner.run(job, args);
  // check the output
  Iterator<DoubleWritable> iteratorNodes =
      new SequenceFileDirValueIterator<DoubleWritable>(output,
                                                       PathType.LIST,
                                                       PathFilters.logsCRCFilter(),
                                                       null,
                                                       false,
                                                       new Configuration());
  while (iteratorNodes.hasNext()) {
    assertEquals(0.5, iteratorNodes.next().get(), EPSILON);
  }
}