HADOOP-8695. TestPathData fails intermittently with JDK7 (Trevor Robinson via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1374447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Graves 2012-08-17 21:43:31 +00:00
parent 7fc6ad661d
commit 31cb5a7fa5
2 changed files with 41 additions and 40 deletions

View File

@ -925,6 +925,9 @@ Release 0.23.3 - UNRELEASED
HADOOP-8697. TestWritableName fails intermittently with JDK7 (Trevor HADOOP-8697. TestWritableName fails intermittently with JDK7 (Trevor
Robinson via tgraves) Robinson via tgraves)
HADOOP-8695. TestPathData fails intermittently with JDK7 (Trevor
Robinson via tgraves)
Release 0.23.2 - UNRELEASED Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -26,23 +26,17 @@ import java.util.Arrays;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.junit.BeforeClass; import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class TestPathData { public class TestPathData {
protected static Configuration conf; protected Configuration conf;
protected static FileSystem fs; protected FileSystem fs;
protected static String dirString; protected Path testDir;
protected static Path testDir;
protected static PathData item; @Before
public void initialize() throws Exception {
protected static String[] d1Paths =
new String[] { "d1/f1", "d1/f1.1", "d1/f2" };
protected static String[] d2Paths =
new String[] { "d2/f3" };
@BeforeClass
public static void initialize() throws Exception {
conf = new Configuration(); conf = new Configuration();
fs = FileSystem.getLocal(conf); fs = FileSystem.getLocal(conf);
testDir = new Path( testDir = new Path(
@ -60,23 +54,28 @@ public class TestPathData {
fs.create(new Path("d2","f3")); fs.create(new Path("d2","f3"));
} }
@After
public void cleanup() throws Exception {
fs.close();
}
@Test @Test
public void testWithDirStringAndConf() throws Exception { public void testWithDirStringAndConf() throws Exception {
dirString = "d1"; String dirString = "d1";
item = new PathData(dirString, conf); PathData item = new PathData(dirString, conf);
checkPathData(); checkPathData(dirString, item);
// properly implementing symlink support in various commands will require // properly implementing symlink support in various commands will require
// trailing slashes to be retained // trailing slashes to be retained
dirString = "d1/"; dirString = "d1/";
item = new PathData(dirString, conf); item = new PathData(dirString, conf);
checkPathData(); checkPathData(dirString, item);
} }
@Test @Test
public void testUnqualifiedUriContents() throws Exception { public void testUnqualifiedUriContents() throws Exception {
dirString = "d1"; String dirString = "d1";
item = new PathData(dirString, conf); PathData item = new PathData(dirString, conf);
PathData[] items = item.getDirectoryContents(); PathData[] items = item.getDirectoryContents();
assertEquals( assertEquals(
sortedString("d1/f1", "d1/f1.1", "d1/f2"), sortedString("d1/f1", "d1/f1.1", "d1/f2"),
@ -86,8 +85,8 @@ public class TestPathData {
@Test @Test
public void testQualifiedUriContents() throws Exception { public void testQualifiedUriContents() throws Exception {
dirString = fs.makeQualified(new Path("d1")).toString(); String dirString = fs.makeQualified(new Path("d1")).toString();
item = new PathData(dirString, conf); PathData item = new PathData(dirString, conf);
PathData[] items = item.getDirectoryContents(); PathData[] items = item.getDirectoryContents();
assertEquals( assertEquals(
sortedString(dirString+"/f1", dirString+"/f1.1", dirString+"/f2"), sortedString(dirString+"/f1", dirString+"/f1.1", dirString+"/f2"),
@ -97,8 +96,8 @@ public class TestPathData {
@Test @Test
public void testCwdContents() throws Exception { public void testCwdContents() throws Exception {
dirString = Path.CUR_DIR; String dirString = Path.CUR_DIR;
item = new PathData(dirString, conf); PathData item = new PathData(dirString, conf);
PathData[] items = item.getDirectoryContents(); PathData[] items = item.getDirectoryContents();
assertEquals( assertEquals(
sortedString("d1", "d2"), sortedString("d1", "d2"),
@ -106,17 +105,16 @@ public class TestPathData {
); );
} }
@Test
@Test public void testToFile() throws Exception {
public void testToFile() throws Exception { PathData item = new PathData(".", conf);
item = new PathData(".", conf);
assertEquals(new File(testDir.toString()), item.toFile()); assertEquals(new File(testDir.toString()), item.toFile());
item = new PathData("d1/f1", conf); item = new PathData("d1/f1", conf);
assertEquals(new File(testDir+"/d1/f1"), item.toFile()); assertEquals(new File(testDir + "/d1/f1"), item.toFile());
item = new PathData(testDir+"/d1/f1", conf); item = new PathData(testDir + "/d1/f1", conf);
assertEquals(new File(testDir+"/d1/f1"), item.toFile()); assertEquals(new File(testDir + "/d1/f1"), item.toFile());
} }
@Test @Test
public void testAbsoluteGlob() throws Exception { public void testAbsoluteGlob() throws Exception {
PathData[] items = PathData.expandAsGlob(testDir+"/d1/f1*", conf); PathData[] items = PathData.expandAsGlob(testDir+"/d1/f1*", conf);
@ -147,18 +145,18 @@ public class TestPathData {
@Test @Test
public void testWithStringAndConfForBuggyPath() throws Exception { public void testWithStringAndConfForBuggyPath() throws Exception {
dirString = "file:///tmp"; String dirString = "file:///tmp";
testDir = new Path(dirString); Path tmpDir = new Path(dirString);
item = new PathData(dirString, conf); PathData item = new PathData(dirString, conf);
// this may fail some day if Path is fixed to not crunch the uri // this may fail some day if Path is fixed to not crunch the uri
// if the authority is null, however we need to test that the PathData // if the authority is null, however we need to test that the PathData
// toString() returns the given string, while Path toString() does // toString() returns the given string, while Path toString() does
// the crunching // the crunching
assertEquals("file:/tmp", testDir.toString()); assertEquals("file:/tmp", tmpDir.toString());
checkPathData(); checkPathData(dirString, item);
} }
public void checkPathData() throws Exception { public void checkPathData(String dirString, PathData item) throws Exception {
assertEquals("checking fs", fs, item.fs); assertEquals("checking fs", fs, item.fs);
assertEquals("checking string", dirString, item.toString()); assertEquals("checking string", dirString, item.toString());
assertEquals("checking path", assertEquals("checking path",