@Test
public void testRun() throws Exception {

    String outputFile = "exportkeys_test.keys";
    try {
        byte[] splitPoint = "splitpoint".getBytes();
        splitTable(splitPoint);
        String[] argsParam = {"zookeeper", tableName, outputFile};
        Args args = new ManagerArgs(argsParam);
        assertEquals("zookeeper", args.getZookeeperQuorum());
        ExportKeys command = new ExportKeys(admin, args);
        waitForSplitting(2);
        command.run();
        int i = 0;
        List<Triple<String, String, String>> results = new ArrayList<>();
        for (String keys : Files.readAllLines(Paths.get(outputFile), Constant.CHARSET)) {
            i++;
            String[] split = keys.split(ExportKeys.DELIMITER);
            results.add(new ImmutableTriple<>(split[0], split[1], split[2]));
        }
        assertEquals(2, i);
        assertEquals(tableName, results.get(0).getLeft().trim());
        assertArrayEquals("".getBytes(), Bytes.toBytesBinary(results.get(0).getMiddle().trim()));
        assertArrayEquals(splitPoint, Bytes.toBytesBinary(results.get(0).getRight().trim()));
        assertEquals(tableName, results.get(1).getLeft().trim());
        assertArrayEquals(splitPoint, Bytes.toBytesBinary(results.get(1).getMiddle().trim()));
        assertArrayEquals("".getBytes(), Bytes.toBytesBinary(results.get(1).getRight().trim()));
        // split once more
        byte[] splitPoint2 = Bytes.toBytes(100L);
        splitTable(splitPoint2);
        command.run();
        i = 0;
        results.clear();
        for (String keys : Files.readAllLines(Paths.get(outputFile), Constant.CHARSET)) {
            i++;
            String[] split = keys.split(ExportKeys.DELIMITER);
            results.add(new ImmutableTriple<>(split[0], split[1], split[2]));
        }
        assertEquals(3, i);
        assertEquals(tableName, results.get(0).getLeft().trim());
        assertArrayEquals("".getBytes(), Bytes.toBytesBinary(results.get(0).getMiddle().trim()));
        assertArrayEquals(splitPoint2, Bytes.toBytesBinary(results.get(0).getRight().trim()));
        assertEquals(tableName, results.get(1).getLeft().trim());
        assertArrayEquals(splitPoint2, Bytes.toBytesBinary(results.get(1).getMiddle().trim()));
        assertArrayEquals(splitPoint, Bytes.toBytesBinary(results.get(1).getRight().trim()));
        assertEquals(tableName, results.get(2).getLeft().trim());
        assertArrayEquals(splitPoint, Bytes.toBytesBinary(results.get(2).getMiddle().trim()));
        assertArrayEquals("".getBytes(), Bytes.toBytesBinary(results.get(2).getRight().trim()));
    } finally {
        Files.delete(Paths.get(outputFile));
    }
}