@Test
public void testBuildListingForSingleFile() {

  FileSystem fs = null;
  String testRootString = "/singleFileListing";
  Path testRoot = new Path(testRootString);
  SequenceFile.Reader reader = null;
  try {
    fs = FileSystem.get(getConf());
    if (fs.exists(testRoot))
      TestDistCpUtils.delete(fs, testRootString);
    Path sourceFile = new Path(testRoot, "/source/foo/bar/source.txt");
    Path decoyFile  = new Path(testRoot, "/target/moo/source.txt");
    Path targetFile = new Path(testRoot, "/target/moo/target.txt");
    TestDistCpUtils.createFile(fs, sourceFile.toString());
    TestDistCpUtils.createFile(fs, decoyFile.toString());
    TestDistCpUtils.createFile(fs, targetFile.toString());
    List<Path> srcPaths = new ArrayList<Path>();
    srcPaths.add(sourceFile);
    DistCpOptions options = new DistCpOptions(srcPaths, targetFile);
    CopyListing listing = new SimpleCopyListing(getConf(), CREDENTIALS);
    final Path listFile = new Path(testRoot, "/tmp/fileList.seq");
    listing.buildListing(listFile, options);
    reader = new SequenceFile.Reader(fs, listFile, getConf());
    FileStatus fileStatus = new FileStatus();
    Text relativePath = new Text();
    Assert.assertTrue(reader.next(relativePath, fileStatus));
    Assert.assertTrue(relativePath.toString().equals(""));
  }
  catch (Exception e) {
    Assert.fail("Unexpected exception encountered.");
    LOG.error("Unexpected exception: ", e);
  }
  finally {
    TestDistCpUtils.delete(fs, testRootString);
    IOUtils.closeStream(reader);
  }
}