<commit_before>package org.openmrs.util;

import java.io.File;
import java.io.FilenameFilter;
import junit.framework.Assert;
import org.junit.Test;
import org.openmrs.test.BaseContextSensitiveTest;

public class OpenmrsClassLoaderTest extends BaseContextSensitiveTest {
	
	/**
	 * @see OpenmrsClassLoader#deleteOldLibCaches(java.io.File)
	 * @verifies return current cache folders
	 */
	@Test
	public void deleteOldLibCaches_shouldReturnOnlyCurrentCacheFolders() throws Exception {
		FilenameFilter cacheDirFilter = new FilenameFilter() {
			
			@Override
			public boolean accept(File dir, String name) {
				return name.endsWith(".openmrs-lib-cache");
			}
		};
		File oldCache = new File(System.getProperty("java.io.tmpdir"), "oldCache.openmrs-lib-cache");
		//create old cache folder
		oldCache.mkdirs();
		File currentCache = new File(System.getProperty("java.io.tmpdir"), "currentCache.openmrs-lib-cache");
		//create current cache folder
		currentCache.mkdirs();
		File tempDir = currentCache.getParentFile();
		// two caches should exist
		Assert.assertEquals(tempDir.listFiles(cacheDirFilter).length, 2);
		OpenmrsClassLoader.deleteOldLibCaches(currentCache);
		//verify after deleting only one cache should exist
		Assert.assertEquals(tempDir.listFiles(cacheDirFilter).length, 1);
		//verify that it is current cache
		Assert.assertEquals(tempDir.listFiles(cacheDirFilter)[0], currentCache);
	}
}<commit_msg>Fix failing test by starting with a fresh temp folder<commit_after>package org.openmrs.util;

import java.io.File;
import java.io.FilenameFilter;
import junit.framework.Assert;
import org.junit.Test;
import org.openmrs.test.BaseContextSensitiveTest;

public class OpenmrsClassLoaderTest extends BaseContextSensitiveTest {
	
	/**
	 * @see OpenmrsClassLoader#deleteOldLibCaches(java.io.File)
	 * @verifies return current cache folders
	 */
	@Test
	public void deleteOldLibCaches_shouldReturnOnlyCurrentCacheFolders() throws Exception {
		FilenameFilter cacheDirFilter = new FilenameFilter() {
			
			@Override
			public boolean accept(File dir, String name) {
				return name.endsWith(".openmrs-lib-cache");
			}
		};
		File oldCache = new File(System.getProperty("java.io.tmpdir"), "oldCache.openmrs-lib-cache");
        OpenmrsClassLoader.deleteOldLibCaches(oldCache);
		//create old cache folder
		oldCache.mkdirs();
		File currentCache = new File(System.getProperty("java.io.tmpdir"), "currentCache.openmrs-lib-cache");
		//create current cache folder
		currentCache.mkdirs();
		File tempDir = currentCache.getParentFile();
		// two caches should exist
		Assert.assertEquals(2, tempDir.listFiles(cacheDirFilter).length);
		OpenmrsClassLoader.deleteOldLibCaches(currentCache);
		//verify after deleting only one cache should exist
		Assert.assertEquals(1, tempDir.listFiles(cacheDirFilter).length);
		//verify that it is current cache
		Assert.assertEquals(tempDir.listFiles(cacheDirFilter)[0], currentCache);
	}
}
{'fraction_non_alphanumeric': 0.10569382884418684, 'fraction_numerical': 0.002045687009887487, 'mean_word_length': 5.242553191489361, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4042949', 'n_tokens_mistral': 941, 'n_tokens_neox': 867, 'n_words': 192}