Пример #1
0
 @Before
 public void setUp() {
   if (logConfigs.getLogMethods().size() != 0) {
     logConfigs.getLogMethods().clear();
   }
   logConfigs.addLogMethod(
       "com.sinosoft.one.log.test.ProposalServiceImpl",
       "testParam",
       300,
       5,
       Environment.TEST.name(),
       "此处演示如何进行参数,第一个参数${[0]},第二个参数${[1]}");
   logConfigs.addLogMethod(
       "com.sinosoft.one.log.test.ProposalServiceImpl",
       "testProductTraced",
       300,
       5,
       Environment.PRODUCT.name(),
       "");
   logConfigs.addLogMethod(
       "com.sinosoft.one.log.test.ProposalServiceImpl",
       "testDevelopTraced",
       300,
       5,
       Environment.DEVELOP.name(),
       "");
   logConfigs.addLogMethod(
       "com.sinosoft.one.log.test.ProposalServiceImpl",
       "testTestTraced",
       300,
       5,
       Environment.TEST.name(),
       "");
   logConfigs.addLogMethod(
       "com.sinosoft.one.log.test.ProposalServiceImpl",
       "testInterfaceTraced",
       300,
       5,
       Environment.TEST.name(),
       "测试Trace");
   logStatisticsHandler.init();
 }
Пример #2
0
 @Test
 public void testEnv() {
   LogTraceAspect implTraceAspect = super.applicationContext.getBean(LogTraceAspect.class);
   logConfigs.setEnvironment(Environment.TEST.name());
   int oldLogsCount = this.countRowsInTable(LOG_TABLE_NAME);
   // 生产环境拦截一条
   proposalService.testProductTraced();
   // 开发环境拦截一条
   proposalService.testDevelopTraced();
   // 测试环境拦截一条
   proposalService.testTestTraced();
   // 未拦截测试
   proposalService.notTracedService();
   ThreadUtils.sleep(1000 * 3);
   Assert.assertEquals(oldLogsCount + 2, this.countRowsInTable(LOG_TABLE_NAME));
 }