|
20 | 20 |
|
21 | 21 | import java.io.File; |
22 | 22 |
|
23 | | -import org.junit.Assert; |
24 | | - |
| 23 | +import org.apache.hadoop.fs.viewfs.ViewFileSystem; |
25 | 24 | import org.apache.log4j.Logger; |
26 | 25 | import org.junit.Test; |
27 | 26 |
|
| 27 | +import static org.assertj.core.api.Assertions.assertThat; |
| 28 | + |
28 | 29 | public class TestClassUtil { |
29 | 30 | @Test(timeout=10000) |
30 | 31 | public void testFindContainingJar() { |
31 | 32 | 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(); |
34 | 36 | 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"); |
39 | 43 | } |
| 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 | + |
40 | 60 | } |
0 commit comments