package com.thinkaurelius.titan.hadoop.hdfs;

import com.thinkaurelius.titan.hadoop.BaseTest;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.File;
import java.io.IOException;

/**
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public class HDFSToolsTest extends BaseTest {

    /*public void testGetSuffix() {
        assertEquals(HDFSTools.getSuffix("marko.bz2"), "bz2");
        assertEquals(HDFSTools.getSuffix("hdfs://apath/that/is/long/file.gzip"), "gzip");
    }*/

    public void testFileExists() throws IOException {
        FileSystem local = FileSystem.getLocal(new Configuration());
        File root = computeTestDataRoot();
        local.exists(new Path(root.getAbsolutePath()));
    }

    public void testGlob() throws IOException {
        FileSystem local = FileSystem.getLocal(new Configuration());
        File root = computeTestDataRoot();
        new File(root.getAbsolutePath() + "/test.bz2").createNewFile();
        for (FileStatus status : local.globStatus(new Path(root.getAbsolutePath() + "/*"))) {
            assertEquals(status.getPath().getName(), "test.bz2");
        }
    }
}

@@ -1082,13 +1082,8 @@
     
-for (
 File
@@ -1099,10 +1099,14 @@
 atus
- :
+es%5B%5D =
  loc
@@ -1163,37 +1163,148 @@
 *%22))
-) %7B%0A            assertEquals(
+;%0A        assertTrue(0 %3C statuses.length);%0A        boolean found = false;%0A        for (FileStatus status : statuses) %7B%0A            found %7C= 
 stat
@@ -1325,18 +1325,24 @@
 etName()
-, 
+.equals(
 %22test.bz
@@ -1356,16 +1356,43 @@
       %7D%0A
+        assertTrue(found);%0A
     %7D%0A%7D%0A

Make testGlob tolerate unclean target directory