• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java LogObjectPrinter类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.icthh.xm.commons.logging.util.LogObjectPrinter的典型用法代码示例。如果您正苦于以下问题:Java LogObjectPrinter类的具体用法?Java LogObjectPrinter怎么用?Java LogObjectPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

LogObjectPrinter类属于com.icthh.xm.commons.logging.util包,在下文中一共展示了LogObjectPrinter类的34个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testComposeUrl

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testComposeUrl() {

    String[] arr1 = new String[]{"/first", "/second"};
    String[] arr2 = new String[]{"/third", "/forth"};

    assertEquals("", LogObjectPrinter.composeUrl(null));
    assertEquals("", LogObjectPrinter.composeUrl(null, null));

    assertEquals("/first/second", LogObjectPrinter.composeUrl(arr1));
    assertEquals("/third/forth", LogObjectPrinter.composeUrl(arr2));

    assertEquals("/first/second", LogObjectPrinter.composeUrl(arr1, null));
    assertEquals("/third/forth", LogObjectPrinter.composeUrl(null, arr2));

    Integer[] arrInt = new Integer[]{1, 2, 3};

    assertEquals(
        "printerror:java.lang.IllegalArgumentException: Cannot store java.lang.Integer in an array of java.lang"
        + ".String",
        LogObjectPrinter.composeUrl(arr1, arrInt));

}
 

开发者ID:xm-online,
项目名称:xm-uaa,
代码行数:24,
代码来源:LogObjectPrinterTest.java

示例2: testPrintRestResult

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintRestResult() {
    assertEquals("status=OK, body=null", LogObjectPrinter.printRestResult(null).toString());
    assertEquals("status=OK, body=value1", LogObjectPrinter.printRestResult("value1").toString());
    assertEquals("status=OK, body=[<ArrayList> size = 5]",
                 LogObjectPrinter.printRestResult(Arrays.asList(1, 2, 3, 4, 5)).toString());

    when(responseEntity.getStatusCode()).thenReturn(HttpStatus.OK);

    when(responseEntity.getBody()).thenReturn(null);
    assertEquals("status=200, body=", LogObjectPrinter.printRestResult(responseEntity).toString());

    when(responseEntity.getBody()).thenReturn("value1");
    assertEquals("status=200, body=value1", LogObjectPrinter.printRestResult(responseEntity).toString());

    when(responseEntity.getBody()).thenReturn(Arrays.asList(1, 2, 3, 4, 5));
    assertEquals("status=200, body=[<ArrayList> size = 5]",
                 LogObjectPrinter.printRestResult(responseEntity).toString());

}
 

开发者ID:xm-online,
项目名称:xm-uaa,
代码行数:21,
代码来源:LogObjectPrinterTest.java

示例3: testComposeUrl

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testComposeUrl() {

    String[] arr1 = new String[]{"/first", "/second"};
    String[] arr2 = new String[]{"/third", "/forth"};

    assertEquals("", LogObjectPrinter.joinUrlPaths(null));
    assertEquals("", LogObjectPrinter.joinUrlPaths(null, (Object[]) null));

    assertEquals("/first/second", LogObjectPrinter.joinUrlPaths(arr1));
    assertEquals("/third/forth", LogObjectPrinter.joinUrlPaths(arr2));

    assertEquals("/first/second", LogObjectPrinter.joinUrlPaths(arr1, (Object[]) null));
    assertEquals("/third/forth", LogObjectPrinter.joinUrlPaths(null, arr2));

    Integer[] arrInt = new Integer[]{1, 2, 3};

    assertEquals(
        "printerror:java.lang.IllegalArgumentException: Cannot store java.lang.Integer in an array "
        + "of java.lang.String",
        LogObjectPrinter.joinUrlPaths(arr1, arrInt));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:24,
代码来源:LogObjectPrinterUnitTest.java

示例4: testPrintInputCollectionAware

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputCollectionAware() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodInputCollectionAware", String.class, List.class, Map.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "list", "map"});

    Map<String, Integer> map = new LinkedHashMap<>();
    map.put("one", 1);
    map.put("two", 2);

    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", Arrays.asList(1, 2, 3), map});

    assertEquals("param1=value1,list=[<ArrayList> size = 3],map={one=1, two=2}",
                 LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:21,
代码来源:LogObjectPrinterUnitTest.java

示例5: testPrintResultNoConfig

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintResultNoConfig() throws NoSuchMethodException {

    Class<?> aClass = TestServiceResult.class;
    Method method = aClass.getMethod("methodReturnNoConfig");

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);

    assertEquals("null", LogObjectPrinter.printResult(null, null));
    assertEquals("null", LogObjectPrinter.printResult(joinPoint, null));
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value"));
    assertEquals("[<ArrayList> size = 3]", LogObjectPrinter.printResult(joinPoint, Arrays.asList(1, 2, 3)));
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value", true));
    assertEquals("#hidden#", LogObjectPrinter.printResult(joinPoint, "String value", false));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:18,
代码来源:LogObjectPrinterUnitTest.java

示例6: testPrintResultDefaultConfig

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintResultDefaultConfig() throws NoSuchMethodException {

    Class<?> aClass = TestServiceResult.class;
    Method method = aClass.getMethod("methodReturnDefaultConfig");

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);

    assertEquals("null", LogObjectPrinter.printResult(null, null));
    assertEquals("null", LogObjectPrinter.printResult(joinPoint, null));
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value"));
    assertEquals("[<ArrayList> size = 3]", LogObjectPrinter.printResult(joinPoint, Arrays.asList(1, 2, 3)));
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value", true));
    // printResultDetail input parameter is overridden by @LoggingAspectConfig
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value", false));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:19,
代码来源:LogObjectPrinterUnitTest.java

示例7: testPrintResultDetailsSuppressed

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintResultDetailsSuppressed() throws NoSuchMethodException {

    Class<?> aClass = TestServiceResult.class;
    Method method = aClass.getMethod("methodReturnDetailsSuppressed");

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);

    assertEquals("null", LogObjectPrinter.printResult(null, null));
    assertEquals("#hidden#", LogObjectPrinter.printResult(joinPoint, null));
    assertEquals("#hidden#", LogObjectPrinter.printResult(joinPoint, "String value"));
    assertEquals("#hidden#", LogObjectPrinter.printResult(joinPoint, Arrays.asList(1, 2, 3)));
    assertEquals("#hidden#", LogObjectPrinter.printResult(joinPoint, "String value", true));
    assertEquals("#hidden#", LogObjectPrinter.printResult(joinPoint, "String value", false));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:18,
代码来源:LogObjectPrinterUnitTest.java

示例8: testPrintResultPrintCollection

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintResultPrintCollection() throws NoSuchMethodException {

    Class<?> aClass = TestServiceResult.class;
    Method method = aClass.getMethod("methodReturnPrintWholeCollection");

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);

    assertEquals("null", LogObjectPrinter.printResult(null, null));
    assertEquals("null", LogObjectPrinter.printResult(joinPoint, null));
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value"));
    assertEquals("[1, 2, 3]", LogObjectPrinter.printResult(joinPoint, Arrays.asList(1, 2, 3)));
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value", true));
    // printResultDetail input parameter is overridden by @LoggingAspectConfig
    assertEquals("String value", LogObjectPrinter.printResult(joinPoint, "String value", false));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:19,
代码来源:LogObjectPrinterUnitTest.java

示例9: printRestResult

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
public static RestResp printRestResult(final JoinPoint joinPoint, final Object res, final boolean printBody) {

        if (res == null) {
            return new RestResp("OK", "null", printBody);
        }

        Class<?> respClass = res.getClass();
        String status;
        Object bodyToPrint;

        if (ResponseEntity.class.isAssignableFrom(respClass)) {
            ResponseEntity<?> respEn = ResponseEntity.class.cast(res);

            status = String.valueOf(respEn.getStatusCode());

            Object body = respEn.getBody();
            bodyToPrint = LogObjectPrinter.printResult(joinPoint, body, printBody);

        } else {
            status = "OK";
            bodyToPrint = LogObjectPrinter.printResult(joinPoint, res, printBody);
        }
        return new RestResp(status, bodyToPrint, printBody);

    }
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:26,
代码来源:WebLogObjectPrinter.java

示例10: testComposeUrl

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testComposeUrl() {

    String[] arr1 = new String[]{"/first", "/second"};
    String[] arr2 = new String[]{"/third", "/forth"};

    assertEquals("", LogObjectPrinter.composeUrl(null));
    assertEquals("", LogObjectPrinter.composeUrl(null, (String[]) null));

    assertEquals("/first/second", LogObjectPrinter.composeUrl(arr1));
    assertEquals("/third/forth", LogObjectPrinter.composeUrl(arr2));

    assertEquals("/first/second", LogObjectPrinter.composeUrl(arr1, (String[]) null));
    assertEquals("/third/forth", LogObjectPrinter.composeUrl(null, arr2));

    Integer[] arrInt = new Integer[]{1, 2, 3};

    assertEquals(
        "printerror:java.lang.IllegalArgumentException: Cannot store java.lang.Integer in an array of java.lang"
        + ".String",
        LogObjectPrinter.composeUrl(arr1, arrInt));

}
 

开发者ID:xm-online,
项目名称:xm-gate,
代码行数:24,
代码来源:LogObjectPrinterTest.java

示例11: testComposeUrl

点赞 3

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testComposeUrl() {

    String[] arr1 = new String[] {"/first", "/second"};
    String[] arr2 = new String[] {"/third", "/forth"};

    assertEquals("", LogObjectPrinter.composeUrl(null));
    assertEquals("", LogObjectPrinter.composeUrl(null, null));

    assertEquals("/first/second", LogObjectPrinter.composeUrl(arr1));
    assertEquals("/third/forth", LogObjectPrinter.composeUrl(arr2));

    assertEquals("/first/second", LogObjectPrinter.composeUrl(arr1, null));
    assertEquals("/third/forth", LogObjectPrinter.composeUrl(null, arr2));

    Integer[] arrInt = new Integer[] {1, 2, 3};

    assertEquals(
        "printerror:java.lang.IllegalArgumentException: Cannot store java.lang.Integer in an array " +
                  "of java.lang.String",
                  LogObjectPrinter.composeUrl(arr1, arrInt));

}
 

开发者ID:xm-online,
项目名称:xm-ms-entity,
代码行数:24,
代码来源:LogObjectPrinterUnitTest.java

示例12: testPrintExceptionWithStacktraceInfo

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintExceptionWithStacktraceInfo() {
    assertEquals("null", LogObjectPrinter.printExceptionWithStackInfo(null));
    assertTrue(StringUtils.contains(LogObjectPrinter.printExceptionWithStackInfo(new RuntimeException("Some error")),
               "java.lang.RuntimeException: Some error com.icthh.xm.ms.entity.logging."
               + "LogObjectPrinterTest.testPrintExceptionWithStacktraceInfo"));
}
 

开发者ID:xm-online,
项目名称:xm-uaa,
代码行数:8,
代码来源:LogObjectPrinterTest.java

示例13: testPrintInputParams

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParams() {
    assertEquals("joinPoint is null", LogObjectPrinter.printInputParams(null));
    assertEquals("param1=val1, param2=val2, param3=val3", LogObjectPrinter.printInputParams(joinPoint));

    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "password", "param3"});
    assertEquals("param1=val1, password=*****, param3=val3", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-uaa,
代码行数:10,
代码来源:LogObjectPrinterTest.java

示例14: testPrintInputParamsCustomNames

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParamsCustomNames() {
    assertEquals("param1=val1, param3=val3",
                 LogObjectPrinter.printInputParams(joinPoint, "param1", "param3"));
    assertEquals("param3=val3, param1=val1",
                 LogObjectPrinter.printInputParams(joinPoint, "param3", "param1"));
}
 

开发者ID:xm-online,
项目名称:xm-uaa,
代码行数:8,
代码来源:LogObjectPrinterTest.java

示例15: testPrintExceptionWithStacktraceInfo

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintExceptionWithStacktraceInfo() {
    assertEquals("null", LogObjectPrinter.printExceptionWithStackInfo(null));
    assertTrue(StringUtils.contains(LogObjectPrinter.printExceptionWithStackInfo(new RuntimeException("Some "
                                                                                                      + "error")),
                                    "java.lang.RuntimeException: Some error com.icthh.xm.commons.logging."
                                    + "LogObjectPrinterUnitTest.testPrintExceptionWithStacktraceInfo"));
}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:9,
代码来源:LogObjectPrinterUnitTest.java

示例16: testPrintInputParams

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParams() {

    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"val1", "val2", "val3"});

    assertEquals("joinPoint is null", LogObjectPrinter.printInputParams(null));
    assertEquals("param1=val1,param2=val2,param3=val3", LogObjectPrinter.printInputParams(joinPoint));

    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "password", "param3"});
    assertEquals("param1=val1,password=*****,param3=val3", LogObjectPrinter.printInputParams(joinPoint));
    assertEquals("param3=val3,password=*****", LogObjectPrinter.printInputParams(joinPoint, "param3", "password"));
}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:14,
代码来源:LogObjectPrinterUnitTest.java

示例17: testPrintInputParamsNoDetail

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParamsNoDetail() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodNoDetail", String.class, int.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(getParamNames(method));
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42});

    assertEquals("joinPoint is null", LogObjectPrinter.printInputParams(null));
    assertEquals("#hidden#", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:16,
代码来源:LogObjectPrinterUnitTest.java

示例18: testPrintInputParamsIncludeParams

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParamsIncludeParams() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodIncludeParams", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("param2=42,param3=35.5", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例19: testPrintInputParamsIncludeNonExistentParams

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParamsIncludeNonExistentParams() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodIncludeNonExistentParams", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("param2=42", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例20: testPrintInputParamsExclude

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParamsExclude() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodExcludeParams", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("param1=value1,param3=35.5", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例21: testPrintInputParamsIncludeAndExclude

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParamsIncludeAndExclude() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodIncludeAndExcludeParams", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("param2=42,param3=35.5", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例22: testPrintMethodConfigOverridesClassConfig

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintMethodConfigOverridesClassConfig() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput2.class;
    Method method = aClass.getMethod("methodIncludeParams", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("param2=42,param3=35.5", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例23: testPrintMehodGetConfigFromClassLever

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintMehodGetConfigFromClassLever() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput2.class;
    Method method = aClass.getMethod("methodDefaultDetails", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("#hidden#", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例24: testPrintConfigOverridesParamsToPrint

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintConfigOverridesParamsToPrint() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput2.class;
    Method method = aClass.getMethod("methodIncludeParams", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    assertEquals("param2=42,param3=35.5", LogObjectPrinter.printInputParams(joinPoint, "param1"));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:15,
代码来源:LogObjectPrinterUnitTest.java

示例25: testPrintParamsNoConfigToPrint

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintParamsNoConfigToPrint() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodWithoutLogConfig", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    //test LogObjectPrinter.printInputParams(joinPoint, "param1", "param3")
    assertEquals("param1=value1,param3=35.5", LogObjectPrinter.printInputParams(joinPoint, "param1", "param3"));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:16,
代码来源:LogObjectPrinterUnitTest.java

示例26: testPrintParamsWithConfigToPrint

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintParamsWithConfigToPrint() throws NoSuchMethodException {

    Class<?> aClass = TestServiceInput.class;
    Method method = aClass.getMethod("methodDefaultDetails", String.class, int.class, Double.class);

    when(ms.getDeclaringType()).thenReturn(aClass);
    when(ms.getMethod()).thenReturn(method);
    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "param2", "param3"});
    when(joinPoint.getArgs()).thenReturn(new Object[]{"value1", 42, 35.5});

    //test LogObjectPrinter.printInputParams(joinPoint, "param1", "param3")
    assertEquals("param1=value1,param3=35.5", LogObjectPrinter.printInputParams(joinPoint, "param1", "param3"));

}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:16,
代码来源:LogObjectPrinterUnitTest.java

示例27: logBeforeRest

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Around("restTemplatePointcut()")
public Object logBeforeRest(ProceedingJoinPoint joinPoint) throws Throwable {

    StopWatch stopWatch = StopWatch.createStarted();

    String uri = null;
    String calledApi = null;
    try {

        uri = LogObjectPrinter.printInputParams(joinPoint, "method", "url");
        calledApi = LogObjectPrinter.getCallMethod(joinPoint);

        log.info("rest:start {} --> {}", calledApi, uri);

        Object result = joinPoint.proceed();

        log.info("rest:stop  {} --> {}, {}, time = {} ms",
                 calledApi,
                 uri,
                 WebLogObjectPrinter.printRestResult(joinPoint, result, false),
                 stopWatch.getTime(TimeUnit.MILLISECONDS));

        return result;

    } catch (Exception e) {
        log.error("rest:stop  {} --> request = {}, error = {}, time = {} ms",
                  calledApi,
                  LogObjectPrinter.printInputParams(joinPoint),
                  LogObjectPrinter.printExceptionWithStackInfo(e),
                  stopWatch.getTime(TimeUnit.MILLISECONDS));
        throw e;
    }
}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:34,
代码来源:RestCallLoggingAspect.java

示例28: logStart

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
private void logStart(final JoinPoint joinPoint, HttpMethod method, final String[] controllerPath,
                      final String[] methodPath) {
    log.info("START {} : {} --> {}, input: {}",
             method,
             LogObjectPrinter.joinUrlPaths(controllerPath, methodPath),
             LogObjectPrinter.getCallMethod(joinPoint),
             LogObjectPrinter.printInputParams(joinPoint));
}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:9,
代码来源:RestLoggingAspect.java

示例29: logStop

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
private void logStop(final JoinPoint joinPoint, HttpMethod method, final String[] controllerPath,
                     final String[] methodPath,
                     final Object result) {
    log.info("STOP  {} : {} --> {}, result: {}, time = {} ms",
             method,
             LogObjectPrinter.joinUrlPaths(controllerPath, methodPath),
             LogObjectPrinter.getCallMethod(joinPoint),
             WebLogObjectPrinter.printRestResult(joinPoint, result),
             MdcUtils.getExecTimeMs());
}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:11,
代码来源:RestLoggingAspect.java

示例30: logError

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
private void logError(final JoinPoint joinPoint, HttpMethod method, final String[] controllerPath,
                      final String[] methodPath,
                      final Throwable e) {
    log.error("STOP  {} : {} --> {}, error: {}, time = {} ms",
              method,
              LogObjectPrinter.joinUrlPaths(controllerPath, methodPath),
              LogObjectPrinter.getCallMethod(joinPoint),
              LogObjectPrinter.printExceptionWithStackInfo(e),
              MdcUtils.getExecTimeMs());
}
 

开发者ID:xm-online,
项目名称:xm-commons,
代码行数:11,
代码来源:RestLoggingAspect.java

示例31: testPrintExceptionWithStacktraceInfo

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintExceptionWithStacktraceInfo() {
    assertEquals("null", LogObjectPrinter.printExceptionWithStackInfo(null));
    assertTrue(StringUtils.contains(LogObjectPrinter.printExceptionWithStackInfo(new RuntimeException("Some error")),
                                    "java.lang.RuntimeException: Some error com.icthh.xm.ms.entity.logging."
                                    + "LogObjectPrinterTest.testPrintExceptionWithStacktraceInfo"));
}
 

开发者ID:xm-online,
项目名称:xm-ms-dashboard,
代码行数:8,
代码来源:LogObjectPrinterTest.java

示例32: testPrintInputParams

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintInputParams() {
    assertEquals("joinPoint is null", LogObjectPrinter.printInputParams(null));
    assertEquals("param1=val1,param2=val2,param3=val3", LogObjectPrinter.printInputParams(joinPoint));

    when(ms.getParameterNames()).thenReturn(new String[]{"param1", "password", "param3"});
    assertEquals("param1=val1,password=*****,param3=val3", LogObjectPrinter.printInputParams(joinPoint));

}
 

开发者ID:xm-online,
项目名称:xm-ms-dashboard,
代码行数:10,
代码来源:LogObjectPrinterTest.java

示例33: doFilter

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
throws IOException, ServletException {

    StopWatch stopWatch = StopWatch.createStarted();

    String domain = request.getServerName();
    String remoteAddr = request.getRemoteAddr();
    Long contentLength = request.getContentLengthLong();

    String tenant = tenantMappingService != null ? tenantMappingService.getTenants().get(domain) : null;

    String method = null;
    String userLogin = null;
    String requestUri = null;

    try {

        if (request instanceof HttpServletRequest) {
            HttpServletRequest req = HttpServletRequest.class.cast(request);
            method = req.getMethod();
            userLogin = req.getRemoteUser();
            requestUri = req.getRequestURI();
        }

        MDCUtil.putRid(MDCUtil.generateRid() + ":" + userLogin + ":" + tenant);

        log.info("START {}/{} --> {} {}, contentLength = {} ", remoteAddr, domain, method, requestUri,
                 contentLength);

        chain.doFilter(request, response);

        Integer status = null;

        if (response instanceof HttpServletResponse) {
            HttpServletResponse res = HttpServletResponse.class.cast(response);
            status = res.getStatus();
        }

        log.info("STOP  {}/{} --> {} {}, status = {}, time = {} ms", remoteAddr, domain, method, requestUri,
                 status, stopWatch.getTime());

    } catch (Exception e) {
        log.error("STOP  {}/{} --> {} {}, error = {}, time = {} ms", remoteAddr, domain, method, requestUri,
                  LogObjectPrinter.printException(e), stopWatch.getTime());
        throw e;
    } finally {
        MDCUtil.clear();
    }

}
 

开发者ID:xm-online,
项目名称:xm-gate,
代码行数:52,
代码来源:LoggingFilter.java

示例34: testPrintExceptionWithStacktraceInfo

点赞 2

import com.icthh.xm.commons.logging.util.LogObjectPrinter; //导入依赖的package包/类
@Test
public void testPrintExceptionWithStacktraceInfo() {
    assertEquals("null", LogObjectPrinter.printExceptionWithStackInfo(null));
    assertTrue(StringUtils.contains(LogObjectPrinter.printExceptionWithStackInfo(new RuntimeException("Some error")),
                                    "java.lang.RuntimeException: Some error com.icthh.xm.gate.logging"
                                    + ".LogObjectPrinterTest.testPrintExceptionWithStacktraceInfo"));
}
 

开发者ID:xm-online,
项目名称:xm-gate,
代码行数:8,
代码来源:LogObjectPrinterTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)