List of usage examples for org.apache.commons.collections IteratorUtils filteredIterator
public static Iterator filteredIterator(Iterator iterator, Predicate predicate)
From source file:org.mule.tck.junit4.AbstractMuleTestCase.java
/** * Reads the mule-exclusion file for the current test class and * @param test/* w ww . j av a 2s. c o m*/ */ protected boolean isTestIncludedInExclusionFile(AbstractMuleTestCase test) { boolean result = false; final String testName = test.getClass().getName(); try { // We find the physical classpath root URL of the test class and // use that to find the correct resource. Works fine everywhere, // regardless of classloaders. See MULE-2414 URL classUrl = ClassUtils.getClassPathRoot(test.getClass()); URLClassLoader tempClassLoader = new URLClassLoader(new URL[] { classUrl }); URL fileUrl = tempClassLoader.getResource("mule-test-exclusions.txt"); if (fileUrl != null) { InputStream in = null; try { in = fileUrl.openStream(); // this iterates over all lines in the exclusion file Iterator<?> lines = IOUtils.lineIterator(in, "UTF-8"); // ..and this finds non-comments that match the test case name result = IteratorUtils.filteredIterator(lines, new Predicate() { @Override public boolean evaluate(Object object) { return StringUtils.equals(testName, StringUtils.trimToEmpty((String) object)); } }).hasNext(); } finally { IOUtils.closeQuietly(in); } } } catch (IOException ioex) { // ignore } return result; }