@@ -0,0 +1,2158 @@
+package edu.ucdenver.ccp.common.io;%0A%0Aimport java.io.IOException;%0Aimport java.util.List;%0Aimport java.util.jar.JarFile;%0A%0Aimport org.junit.Test;%0Aimport org.junit.Assert;%0A%0Apublic class ClassPathUtil_Test %7B%0A%09%0A%09@Test%0A%09public  void test_file() throws Exception %7B%0A%09%09List%3CString%3E list = ClassPathUtil.listResourceDirectory(%0A%09%09%09%09this.getClass(), %22test_dir/test_file.txt%22);%0A%09%09Assert.assertTrue(list.get(0).endsWith(%22test_dir/test_file.txt%22));%0A%09%7D%0A%09%0A%09/**%0A%09 * If you name a directory, you get a list of paths of its non-directory%0A%09 * contents...recursive.%0A%09 * @throws Exception%0A%09 */%0A%09@Test%0A%09public void test_dir() throws Exception %7B%0A%09%09List%3CString%3E list = ClassPathUtil.listResourceDirectory(%0A%09%09%09%09this.getClass(), %22test_dir%22);%0A%09%09// incomplete%0A%09%09for (String s : list) %7B%0A%09%09%09System.out.println(%22--%3E%22 + s);%0A%09%09%7D%0A%09%09String%5B%5D classes = %7B %22test_dir/test_file.txt%22,%0A%09%09%22test_dir/other_test_file.txt%22 %7D;%0A%09%0A%09%09for (String c : classes ) %7B%0A%09%09%09Assert.assertTrue(list.contains(c));%0A%09%09%7D%0A%09%7D%0A%09%0A%09/**%0A%09 * If you name the jar, you get it as a file.%0A%09 * @throws Exception%0A%09 */%0A%09@Test%0A%09public void test_jar_as_file() throws Exception %7B%0A%09%09List%3CString%3E list = ClassPathUtil.listResourceDirectory(%0A%09%09%09%09this.getClass(), %22junit-4.8.2.jar%22);%0A%09%09Assert.assertTrue(list.get(0).endsWith(%22junit-4.8.2.jar%22));%0A%09%7D%0A%09%0A%09/**%0A%09 * If you name a directory that happends to be in a jar,%0A%09 * you get a list of its non-directory contents, recursively. YOu get%0A%09 * a list of paths, where each path is within in ther jar.%0A%09 * @throws Exception%0A%09 */%0A%09@Test%0A%09public void test_dir_in_jar() throws Exception %7B%0A%09%09List%3CString%3E list = ClassPathUtil.listResourceDirectory(%0A%09%09%09%09this.getClass(), %22org/junit%22);%0A%09%09%0A%09%09String%5B%5D classes = %7B %22org/junit/After.class%22,%0A%09%09%09%22org/junit/runners/model/TestClass.class%22 %7D;%0A%09%09%0A%09%09for (String c : classes ) %7B%0A%09%09%09Assert.assertTrue(list.contains(c));%0A%09%09%7D%0A%09%09%0A%09%7D%0A%09%0A%09/**%0A%09 *  If you name a file that happens to be in a jar,%0A%09 *  you get it's path within that jar.%0A%09 */%0A%09@Test%0A%09public void test_file_in_jar() throws Exception %7B%0A%09%09List%3CString%3E list = ClassPathUtil.listResourceDirectory(%0A%09%09%09%09this.getClass(), %22org/junit/runner/Runner.class%22);%0A%09%09Assert.assertTrue(list.get(0).endsWith(%22Runner.class%22));%0A%09%7D%0A%0A%7D%0A

test for listResourceDirectory()