use of org.apache.dubbo.common.logger.Logger in project dubbo by alibaba.
the class LogHelperTest method testDebug.
@Test
public void testDebug() throws Exception {
Logger logger = Mockito.mock(Logger.class);
when(logger.isDebugEnabled()).thenReturn(true);
LogHelper.debug(logger, "debug");
verify(logger).debug("debug");
Throwable t = new RuntimeException();
LogHelper.debug(logger, t);
verify(logger).debug(t);
LogHelper.debug(logger, "debug", t);
verify(logger).debug("debug", t);
}
use of org.apache.dubbo.common.logger.Logger in project dubbo by alibaba.
the class LogHelperTest method testTrace.
@Test
public void testTrace() throws Exception {
Logger logger = Mockito.mock(Logger.class);
when(logger.isTraceEnabled()).thenReturn(true);
LogHelper.trace(logger, "trace");
verify(logger).trace("trace");
Throwable t = new RuntimeException();
LogHelper.trace(logger, t);
verify(logger).trace(t);
LogHelper.trace(logger, "trace", t);
verify(logger).trace("trace", t);
}
use of org.apache.dubbo.common.logger.Logger in project dubbo by alibaba.
the class FailsafeLoggerTest method testFailSafeForLoggingMethod.
@Test
public void testFailSafeForLoggingMethod() {
Logger failLogger = mock(Logger.class);
FailsafeLogger failsafeLogger = new FailsafeLogger(failLogger);
doThrow(new RuntimeException()).when(failLogger).error(anyString());
doThrow(new RuntimeException()).when(failLogger).warn(anyString());
doThrow(new RuntimeException()).when(failLogger).info(anyString());
doThrow(new RuntimeException()).when(failLogger).debug(anyString());
doThrow(new RuntimeException()).when(failLogger).trace(anyString());
failsafeLogger.error("error");
failsafeLogger.warn("warn");
failsafeLogger.info("info");
failsafeLogger.debug("debug");
failsafeLogger.trace("info");
doThrow(new RuntimeException()).when(failLogger).error(any(Throwable.class));
doThrow(new RuntimeException()).when(failLogger).warn(any(Throwable.class));
doThrow(new RuntimeException()).when(failLogger).info(any(Throwable.class));
doThrow(new RuntimeException()).when(failLogger).debug(any(Throwable.class));
doThrow(new RuntimeException()).when(failLogger).trace(any(Throwable.class));
failsafeLogger.error(new Exception("error"));
failsafeLogger.warn(new Exception("warn"));
failsafeLogger.info(new Exception("info"));
failsafeLogger.debug(new Exception("debug"));
failsafeLogger.trace(new Exception("trace"));
failsafeLogger.error("error", new Exception("error"));
failsafeLogger.warn("warn", new Exception("warn"));
failsafeLogger.info("info", new Exception("info"));
failsafeLogger.debug("debug", new Exception("debug"));
failsafeLogger.trace("trace", new Exception("trace"));
}
use of org.apache.dubbo.common.logger.Logger in project dubbo by alibaba.
the class FailsafeLoggerTest method testGetLogger.
@Test
public void testGetLogger() {
Assertions.assertThrows(RuntimeException.class, () -> {
Logger failLogger = mock(Logger.class);
FailsafeLogger failsafeLogger = new FailsafeLogger(failLogger);
doThrow(new RuntimeException()).when(failLogger).error(anyString());
failsafeLogger.getLogger().error("should get error");
});
}
Aggregations