public boolean contains(String substring) { return toString().contains(substring); }
public boolean contains(String substring) { return toString().contains(substring); }
public boolean matches(Pattern sub) { return sub.matcher(toString()).matches(); }
public boolean matches(Pattern sub) { return sub.matcher(toString()).matches(); }
private void assertContains(StringPrintStream str, String expected) throws Error { if (!str.contains(expected)) { throw new AssertionError("expected '" + expected + "' but got '" + str.toString() + "'"); } }
private void assertNotContains(StringPrintStream str, String expected) throws Error { if (str.contains(expected)) { throw new AssertionError("expected absence of '" + expected + "' but got '" + str.toString() + "'"); } } }
public void testPrintSuppressionsAffectsPrintStreamAndNotLogging() { StringPrintStream ps = StringPrintStream.newStream(); TestLoggerFactory f = Settings.instance() .redirectPrintStream(LogLevel.ErrorLevel, ps) .suppressPrinting(".*suppressPrinting-me.*") .buildLogging(); TestLogger log = f.getLogger("john"); String ShouldBeLogged = "printme"; String ShouldBePrintSuppressed = "suppressPrinting-me <<" + System.lineSeparator() + " dont print"; log.error(ShouldBeLogged); log.error(ShouldBePrintSuppressed); assert (ps.toString().contains(ShouldBeLogged)); assert (log.contains(ShouldBeLogged)); assert (!ps.toString().contains(ShouldBePrintSuppressed)); assert (log.contains(ShouldBePrintSuppressed)); }