CompactFormatter extends java.util.logging.Formatter { protected boolean ignore(StackTraceElement s) { return isUnknown(s) || defaultIgnore(s); } CompactFormatter();  CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); String formatMessage(final Throwable t); String formatLevel(final LogRecord record); String formatSource(final LogRecord record); String formatLoggerName(final LogRecord record); String formatThrown(final LogRecord record); String formatBackTrace(LogRecord record);  }
@Test(expected = NullPointerException.class) public void testIgnoreNull() { CompactFormatter cf = new CompactFormatter(); cf.ignore((StackTraceElement) null); fail(cf.toString()); }
@Test public void testIgnoreKnownClass() { CompactFormatter cf = new CompactFormatter(); String n = cf.getClass().getName(); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "format", f, 20); assertFalse(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreUnknownClass() { CompactFormatter cf = new CompactFormatter(); String n = UNKNOWN_CLASS_NAME; String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "format", f, 20); assertFalse(s.toString(), cf.ignore(s)); }
@Test public void testIgnorePrivateInnerClass() { CompactFormatter cf = new CompactFormatter(); String n = Arrays.asList("foo", "bar", "baz").getClass().getName(); assertTrue(n, n.contains("$")); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "size", f, 20); assertFalse(s.toString(), cf.ignore(s)); }
@Test public void testIgnorePrivateStaticInnerClass() { CompactFormatter cf = new CompactFormatter(); String n = Collections.emptySet().getClass().getName(); assertTrue(n, n.contains("$")); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "size", f, 20); assertFalse(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreStaticUtilityClass() { CompactFormatter cf = new CompactFormatter(); String n = MimeUtility.class.getName(); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "encodeText", f, 400); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreStaticUtilityClassUtilError() { CompactFormatter cf = new CompactFormatter(); String n = getClass().getName().concat("MimeUtility"); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "encodeText", f, 400); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreStaticUtilityClassWithSError() { CompactFormatter cf = new CompactFormatter(); String n = getClass().getName().concat("Collections"); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "nCopies", f, 400); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreStaticUtilityClassWithSeError() { CompactFormatter cf = new CompactFormatter(); String n = getClass().getName().concat("Properties"); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "get", f, 400); assertFalse(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreSyntheticMethod() { CompactFormatter cf = new CompactFormatter(); String n = UNKNOWN_CLASS_NAME; String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "access$100", f, 10); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreNativeMethod() { CompactFormatter cf = new CompactFormatter(); String n = UNKNOWN_CLASS_NAME; String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "foo", f, -2); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreReflectMethod() { CompactFormatter cf = new CompactFormatter(); String n = java.lang.reflect.Method.class.getName(); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "invoke", f, 10); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreReflectMethodApiError() { CompactFormatter cf = new CompactFormatter(); String n = "java.lang.reflect.".concat(getClass().getName()); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "invoke", f, 10); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreReflectMethodSunError() { CompactFormatter cf = new CompactFormatter(); String n = "sun.reflect.".concat(getClass().getName()); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "invoke", f, 10); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreReflectConstructor() { CompactFormatter cf = new CompactFormatter(); String n = java.lang.reflect.Constructor.class.getName(); String f = n.concat(".java"); StackTraceElement s = new StackTraceElement(n, "newInstance", f, 10); assertTrue(s.toString(), cf.ignore(s)); }
@Test public void testIgnoreUnknownLine() { CompactFormatter cf = new CompactFormatter(); String n = UNKNOWN_CLASS_NAME; StackTraceElement s = new StackTraceElement(n, "foo", null, -1); assertTrue(s.toString(), cf.ignore(s)); }