<commit_before>package edu.ucdenver.ccp.common.io;

import java.io.IOException;
import java.util.List;
import java.util.jar.JarFile;

import org.junit.Test;
import org.junit.Assert;

public class ClassPathUtil_Test {
	
	@Test
	public  void test_file() throws Exception {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "test_dir/test_file.txt");
		Assert.assertTrue(list.get(0).endsWith("test_dir/test_file.txt"));
	}
	
	/**
	 * If you name a directory, you get a list of paths of its non-directory
	 * contents...recursive.
	 * @throws Exception
	 */
	@Test
	public void test_dir() throws Exception {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "test_dir");
		// incomplete
		for (String s : list) {
			System.out.println("-->" + s);
		}
		String[] classes = { "test_dir/test_file.txt",
		"test_dir/other_test_file.txt" };
	
		for (String c : classes ) {
			Assert.assertTrue(list.contains(c));
		}
	}
	
	/**
	 * If you name the jar, you get it as a file.
	 * @throws Exception
	 */
	@Test
	public void test_jar_as_file() throws Exception {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "junit-4.8.2.jar");
		Assert.assertTrue(list.get(0).endsWith("junit-4.8.2.jar"));
	}
	
	/**
	 * If you name a directory that happends to be in a jar,
	 * you get a list of its non-directory contents, recursively. YOu get
	 * a list of paths, where each path is within in ther jar.
	 * @throws Exception
	 */
	@Test
	public void test_dir_in_jar() throws Exception {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "org/junit");
		
		String[] classes = { "org/junit/After.class",
			"org/junit/runners/model/TestClass.class" };
		
		for (String c : classes ) {
			Assert.assertTrue(list.contains(c));
		}
		
	}
	
	/**
	 *  If you name a file that happens to be in a jar,
	 *  you get it's path within that jar.
	 */
	@Test
	public void test_file_in_jar() throws Exception {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "org/junit/runner/Runner.class");
		Assert.assertTrue(list.get(0).endsWith("Runner.class"));
	}

}<commit_msg>attempt to avoid running tests that don't work in an OSGI environment when they are running in an OSGI environment.<commit_after>package edu.ucdenver.ccp.common.io;

import java.util.List;

import org.junit.Assert;
import org.junit.Test;


public class ClassPathUtil_Test {
	
	static String OSGI_CLASSLOADER_PREFIX="org.osgi";
	
	@Test
	public  void testFile() throws Exception {

			if (!this.getClass().getClassLoader().getClass().getName().startsWith("OSGI_CLASSLOADER_PREFIX")) {
			//org.osgi.framework.BundleReference

			List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "test_dir/test_file.txt");
			Assert.assertTrue(list.get(0).endsWith("test_dir/test_file.txt"));
			}
	}
	
	/**
	 * If you name a directory, you get a list of paths of its non-directory
	 * contents...recursive.
	 * @throws Exception
	 */
	@Test
	public void testDir() throws Exception {
		if (!this.getClass().getClassLoader().getClass().getName().startsWith("OSGI_CLASSLOADER_PREFIX")) {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "test_dir");
		String[] classes = { "test_dir/test_file.txt",
		"test_dir/other_test_file.txt" };
	
		for (String c : classes ) {
			Assert.assertTrue(list.contains(c));
		}
		}
	}
	
	/**
	 * If you name the jar, you get it as a file.
	 * @throws Exception
	 */
	@Test
	public void testJarAsFile() throws Exception {
		if (!this.getClass().getClassLoader().getClass().getName().startsWith("OSGI_CLASSLOADER_PREFIX")) {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "junit-4.8.2.jar");
		Assert.assertTrue(list.get(0).endsWith("junit-4.8.2.jar"));
		}
	}
	
	/**
	 * If you name a directory that happends to be in a jar,
	 * you get a list of its non-directory contents, recursively. YOu get
	 * a list of paths, where each path is within in ther jar.
	 * @throws Exception
	 */
	@Test
	public void testDirInJar() throws Exception {
		if (!this.getClass().getClassLoader().getClass().getName().startsWith("OSGI_CLASSLOADER_PREFIX")) {
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "org/junit");
		
		String[] classes = { "org/junit/After.class",
			"org/junit/runners/model/TestClass.class" };
		
		for (String c : classes ) {
			Assert.assertTrue(list.contains(c));
		}
		}
	}
	
	/**
	 *  If you name a file that happens to be in a jar,
	 *  you get it's path within that jar.
	 */
	@Test
	public void testFileInJar() throws Exception {
		if (!this.getClass().getClassLoader().getClass().getName().startsWith("OSGI_CLASSLOADER_PREFIX")) {
	
		List<String> list = ClassPathUtil.listResourceDirectory(
				this.getClass(), "org/junit/runner/Runner.class");
		Assert.assertTrue(list.get(0).endsWith("Runner.class"));
		}
	}

}
{'fraction_non_alphanumeric': 0.1395959595959596, 'fraction_numerical': 0.0036363636363636364, 'mean_word_length': 3.844422700587084, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1115294', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1634, 'n_words': 390}