private void checkDirectoryListing(Path path, String[] expected_children,
                                       boolean[] expected_kinds) {
        // List the given directory.
        String[]    listing = null;

        try {
            listing = serviceStub.list(path);
        } catch(Throwable t) {
            t.printStackTrace();
            Assert.fail("unable to list directory " + path);
        }

        if(listing == null) {
            Assert.fail("listing directory " + path + " resulted in " +
                                 "null");
        }

        // Compare the result of the list method and the set of expected
        // children.
        if(!TestUtil.sameElements(listing, expected_children)) {
            Assert.fail("directory listing incorrect for " + path);
        }

        // Go through all the expected children. For each child, ensure that the
        // isDirectory method returns the correct result.
        for(int child_index = 0; child_index < expected_children.length;
            ++child_index) {
            Path    child_path = new Path(path, expected_children[child_index]);
            boolean isDirectory = false;

            try {
                isDirectory = serviceStub.isDirectory(child_path);
            } catch(Throwable t) {
                t.printStackTrace();
                Assert.fail("unable to determine if " + child_path +
                                     " is a directory");
            }

            if(isDirectory && !expected_kinds[child_index]) {
                Assert.fail(child_path + " is reported as a " +
                                     "directory but is in fact a file");
            }
            
            if(!isDirectory && expected_kinds[child_index]) {
                Assert.fail(child_path + " is reported as a file " +
                                     "but is in fact a directory");
            }
        }
    }