Java Code Examples for com.alibaba.dubbo.common.logger.Logger#error()

The following examples show how to use com.alibaba.dubbo.common.logger.Logger#error() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExceptionFilterTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testRpcException() {
    Logger logger = EasyMock.createMock(Logger.class);
    RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234);
    RpcException exception = new RpcException("TestRpcException");
    logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception));
    ExceptionFilter exceptionFilter = new ExceptionFilter(logger);
    RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"});
    Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class);
    EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception);
    
    EasyMock.replay(logger, invoker);
    
    try {
        exceptionFilter.invoke(invoker, invocation);
    } catch (RpcException e) {
        assertEquals("TestRpcException", e.getMessage());
    }
    EasyMock.verify(logger, invoker);
    RpcContext.removeContext();
}
 
Example 2
Source File: ExceptionFilterTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testRpcException() {
    Logger logger = EasyMock.createMock(Logger.class);
    RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234);
    RpcException exception = new RpcException("TestRpcException");
    logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception));
    ExceptionFilter exceptionFilter = new ExceptionFilter(logger);
    RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"});
    Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class);
    EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception);
    
    EasyMock.replay(logger, invoker);
    
    try {
        exceptionFilter.invoke(invoker, invocation);
    } catch (RpcException e) {
        assertEquals("TestRpcException", e.getMessage());
    }
    EasyMock.verify(logger, invoker);
    RpcContext.removeContext();
}
 
Example 3
Source File: ExceptionFilterTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testRpcException() {
    Logger logger = EasyMock.createMock(Logger.class);
    RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234);
    RpcException exception = new RpcException("TestRpcException");
    logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception));
    ExceptionFilter exceptionFilter = new ExceptionFilter(logger);
    RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"});
    Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class);
    EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception);
    
    EasyMock.replay(logger, invoker);
    
    try {
        exceptionFilter.invoke(invoker, invocation);
    } catch (RpcException e) {
        assertEquals("TestRpcException", e.getMessage());
    }
    EasyMock.verify(logger, invoker);
    RpcContext.removeContext();
}
 
Example 4
Source File: ExceptionFilterTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testRpcException() {
    Logger logger = EasyMock.createMock(Logger.class);
    RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234);
    RpcException exception = new RpcException("TestRpcException");
    logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception));
    ExceptionFilter exceptionFilter = new ExceptionFilter(logger);
    RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"});
    Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class);
    EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception);
    
    EasyMock.replay(logger, invoker);
    
    try {
        exceptionFilter.invoke(invoker, invocation);
    } catch (RpcException e) {
        assertEquals("TestRpcException", e.getMessage());
    }
    EasyMock.verify(logger, invoker);
    RpcContext.removeContext();
}
 
Example 5
Source File: ExceptionFilterTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testRpcException() {
    Logger logger = EasyMock.createMock(Logger.class);
    RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234);
    RpcException exception = new RpcException("TestRpcException");
    logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception));
    ExceptionFilter exceptionFilter = new ExceptionFilter(logger);
    RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"});
    Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class);
    EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception);
    
    EasyMock.replay(logger, invoker);
    
    try {
        exceptionFilter.invoke(invoker, invocation);
    } catch (RpcException e) {
        assertEquals("TestRpcException", e.getMessage());
    }
    EasyMock.verify(logger, invoker);
    RpcContext.removeContext();
}
 
Example 6
Source File: LogHelper.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg, e);
    }
}
 
Example 7
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg, e);
    }
}
 
Example 8
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg);
    }
}
 
Example 9
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(e);
    }
}
 
Example 10
Source File: LogHelper.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg, e);
    }
}
 
Example 11
Source File: LogHelper.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg);
    }
}
 
Example 12
Source File: LogHelper.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(e);
    }
}
 
Example 13
Source File: LogHelper.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(e);
    }
}
 
Example 14
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(e);
    }
}
 
Example 15
Source File: LogHelper.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(e);
    }
}
 
Example 16
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg, e);
    }
}
 
Example 17
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg);
    }
}
 
Example 18
Source File: LogHelper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(e);
    }
}
 
Example 19
Source File: LogHelper.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg, Throwable e) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg, e);
    }
}
 
Example 20
Source File: LogHelper.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public static void error(Logger logger, String msg) {
    if (logger == null) {
        return;
    }

    if (logger.isErrorEnabled()) {
        logger.error(msg);
    }
}