Skip to content

Commit 497225b

Browse files
committed
addendum - add test
1 parent 348b63a commit 497225b

File tree

1 file changed

+28
-8
lines changed
  • hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util

1 file changed

+28
-8
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestClassUtil.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,41 @@
2020

2121
import java.io.File;
2222

23-
import org.junit.Assert;
24-
23+
import org.apache.hadoop.fs.viewfs.ViewFileSystem;
2524
import org.apache.log4j.Logger;
2625
import org.junit.Test;
2726

27+
import static org.assertj.core.api.Assertions.assertThat;
28+
2829
public class TestClassUtil {
2930
@Test(timeout=10000)
3031
public void testFindContainingJar() {
3132
String containingJar = ClassUtil.findContainingJar(Logger.class);
32-
Assert.assertNotNull("Containing jar not found for Logger",
33-
containingJar);
33+
assertThat(containingJar)
34+
.describedAs("Containing jar for %s", Logger.class)
35+
.isNotNull();
3436
File jarFile = new File(containingJar);
35-
Assert.assertTrue("Containing jar does not exist on file system ",
36-
jarFile.exists());
37-
Assert.assertTrue("Incorrect jar file " + containingJar,
38-
jarFile.getName().matches("log4j.*[.]jar"));
37+
assertThat(jarFile)
38+
.describedAs("Containing jar %s", jarFile)
39+
.exists();
40+
assertThat(jarFile.getName())
41+
.describedAs("Containing jar name %s", jarFile.getName())
42+
.matches("log4j.*[.]jar");
3943
}
44+
45+
@Test(timeout = 10000)
46+
public void testFindContainingClass() {
47+
String classFileLocation = ClassUtil.findClassLocation(ViewFileSystem.class);
48+
assertThat(classFileLocation)
49+
.describedAs("Class path for %s", ViewFileSystem.class)
50+
.isNotNull();
51+
File classFile = new File(classFileLocation);
52+
assertThat(classFile)
53+
.describedAs("Containing class file %s", classFile)
54+
.exists();
55+
assertThat(classFile.getName())
56+
.describedAs("Containing class file name %s", classFile.getName())
57+
.matches("ViewFileSystem.class");
58+
}
59+
4060
}

0 commit comments

Comments
 (0)