コード例 #1
0
  private void messageCheck(Locale locale, String msg, String msgNull, String msgNoSub) {
    ActiveLocale.setProcessLocale(locale);
    setLevel(TEST_CATEGORY, Level.OFF);

    TestMessages.LOGGER.error(TEST_CATEGORY, TEST_THROWABLE);
    TestMessages.LOGGER.error(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    TestMessages.LOGGER.error(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertNoEvents();

    setLevel(TEST_CATEGORY, Level.ERROR);
    TestMessages.LOGGER.error(TEST_CATEGORY, TEST_THROWABLE);
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, SLF4JLoggerProxy.UNKNOWN_MESSAGE, TEST_LOCATION);
    TestMessages.LOGGER.error(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, msg, TEST_LOCATION);
    TestMessages.LOGGER.error(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, msg, TEST_LOCATION);

    TestMessages.LOGGER.error(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, msgNoSub, TEST_LOCATION);
    TestMessages.LOGGER.error(TEST_CATEGORY, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, msgNoSub, TEST_LOCATION);

    TestMessages.LOGGER.error(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, msgNull, TEST_LOCATION);
    TestMessages.LOGGER.error(TEST_CATEGORY, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.ERROR, TEST_CATEGORY, msgNull, TEST_LOCATION);

    TestMessages.LOGGER.warn(TEST_CATEGORY, TEST_THROWABLE);
    TestMessages.LOGGER.warn(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    TestMessages.LOGGER.warn(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertNoEvents();

    setLevel(TEST_CATEGORY, Level.WARN);
    TestMessages.LOGGER.warn(TEST_CATEGORY, TEST_THROWABLE);
    assertSingleEvent(Level.WARN, TEST_CATEGORY, SLF4JLoggerProxy.UNKNOWN_MESSAGE, TEST_LOCATION);
    TestMessages.LOGGER.warn(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.WARN, TEST_CATEGORY, msg, TEST_LOCATION);
    TestMessages.LOGGER.warn(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.WARN, TEST_CATEGORY, msg, TEST_LOCATION);

    TestMessages.LOGGER.warn(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.WARN, TEST_CATEGORY, msgNoSub, TEST_LOCATION);
    TestMessages.LOGGER.warn(TEST_CATEGORY, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.WARN, TEST_CATEGORY, msgNoSub, TEST_LOCATION);

    TestMessages.LOGGER.warn(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.WARN, TEST_CATEGORY, msgNull, TEST_LOCATION);
    TestMessages.LOGGER.warn(TEST_CATEGORY, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.WARN, TEST_CATEGORY, msgNull, TEST_LOCATION);

    TestMessages.LOGGER.info(TEST_CATEGORY, TEST_THROWABLE);
    TestMessages.LOGGER.info(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    TestMessages.LOGGER.info(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertNoEvents();

    setLevel(TEST_CATEGORY, Level.INFO);
    TestMessages.LOGGER.info(TEST_CATEGORY, TEST_THROWABLE);
    assertSingleEvent(Level.INFO, TEST_CATEGORY, SLF4JLoggerProxy.UNKNOWN_MESSAGE, TEST_LOCATION);
    TestMessages.LOGGER.info(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.INFO, TEST_CATEGORY, msg, TEST_LOCATION);
    TestMessages.LOGGER.info(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.INFO, TEST_CATEGORY, msg, TEST_LOCATION);

    TestMessages.LOGGER.info(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.INFO, TEST_CATEGORY, msgNoSub, TEST_LOCATION);
    TestMessages.LOGGER.info(TEST_CATEGORY, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.INFO, TEST_CATEGORY, msgNoSub, TEST_LOCATION);

    TestMessages.LOGGER.info(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.INFO, TEST_CATEGORY, msgNull, TEST_LOCATION);
    TestMessages.LOGGER.info(TEST_CATEGORY, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.INFO, TEST_CATEGORY, msgNull, TEST_LOCATION);

    TestMessages.LOGGER.debug(TEST_CATEGORY, TEST_THROWABLE);
    TestMessages.LOGGER.debug(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    TestMessages.LOGGER.debug(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertNoEvents();

    setLevel(TEST_CATEGORY, Level.DEBUG);
    TestMessages.LOGGER.debug(TEST_CATEGORY, TEST_THROWABLE);
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, SLF4JLoggerProxy.UNKNOWN_MESSAGE, TEST_LOCATION);
    TestMessages.LOGGER.debug(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, msg, TEST_LOCATION);
    TestMessages.LOGGER.debug(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, msg, TEST_LOCATION);

    TestMessages.LOGGER.debug(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, msgNoSub, TEST_LOCATION);
    TestMessages.LOGGER.debug(TEST_CATEGORY, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, msgNoSub, TEST_LOCATION);

    TestMessages.LOGGER.debug(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, msgNull, TEST_LOCATION);
    TestMessages.LOGGER.debug(TEST_CATEGORY, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.DEBUG, TEST_CATEGORY, msgNull, TEST_LOCATION);

    TestMessages.LOGGER.trace(TEST_CATEGORY, TEST_THROWABLE);
    TestMessages.LOGGER.trace(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    TestMessages.LOGGER.trace(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertNoEvents();

    setLevel(TEST_CATEGORY, Level.TRACE);
    TestMessages.LOGGER.trace(TEST_CATEGORY, TEST_THROWABLE);
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, SLF4JLoggerProxy.UNKNOWN_MESSAGE, TEST_LOCATION);
    TestMessages.LOGGER.trace(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, msg, TEST_LOCATION);
    TestMessages.LOGGER.trace(TEST_CATEGORY, TestMessages.LOG_MSG, "a");
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, msg, TEST_LOCATION);

    TestMessages.LOGGER.trace(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, msgNoSub, TEST_LOCATION);
    TestMessages.LOGGER.trace(TEST_CATEGORY, TestMessages.LOG_MSG, (Object[]) null);
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, msgNoSub, TEST_LOCATION);

    TestMessages.LOGGER.trace(TEST_CATEGORY, TEST_THROWABLE, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, msgNull, TEST_LOCATION);
    TestMessages.LOGGER.trace(TEST_CATEGORY, TestMessages.LOG_MSG, (Object) null);
    assertSingleEvent(Level.TRACE, TEST_CATEGORY, msgNull, TEST_LOCATION);
  }
コード例 #2
0
 @Before
 public void setupSessionManagerTest() {
   ActiveLocale.setProcessLocale(Locale.ROOT);
   setLevel(TEST_CATEGORY, Level.INFO);
 }