public boolean matches(Object item) { try { ClassFilter.createDefaultInstance().check(item.toString()); return Boolean.FALSE; } catch (ClassFilter.ClassFilterException ex) { throw new IllegalStateException("Failed to initialize the default class filter", ex); } catch (SecurityException sex) { return Boolean.TRUE; } }
/** * Checks that if given an invalid pattern in the overrides then the defaults are used. */ @Test(expected=Error.class) public void testDefaultsAreUsedIfOverridesAreGarbage() throws Exception { List<String> badClasses = Arrays.asList("Z{100,0}" /* min > max for repetition */); File f = folder.newFile("overrides.txt"); FileOutputStream fos = new FileOutputStream(f); try { for (String s : badClasses) { IOUtils.write(s, fos); IOUtils.write("\n", fos); } } finally { fos.close(); } setOverrideProperty(f.getAbsolutePath()); ClassFilter.createDefaultInstance(); }
/** * Checks that the defaults are loaded when the override property is provided and the file does not exist. */ @Test(expected=Error.class) public void testDefaultsRemainWhenOverrideDoesExists() throws Exception { setOverrideProperty(folder.getRoot().toString() + "/DO_NOT_CREATE_THIS_FILE_OR_ELSE_BAD_THINGS_WILL_HAPPEN_TO_YOU"); ClassFilter.createDefaultInstance(); }