Beispiel #1
0
 /**
  * 存放跟踪信息的文件根路径
  *
  * @return
  */
 public static String tracerFileDir() {
   String dir = ConfigHelper.getString(TRACER_FILE_DIR);
   if (StringHelper.isBlankOrNull(dir)) {
     dir = System.getProperty("user.dir") + "/target/tracer";
   }
   return dir;
 }
 /** assign to fields by SpringBeanByName */
 public static void injectSpringBeanByName(
     final ApplicationContext ctx, final Class testedClazz, final Object testedObject) {
   Set<Field> springBeanByNamefields = getFieldsAnnotatedWith(testedClazz, SpringBeanByName.class);
   for (Field field : springBeanByNamefields) {
     try {
       SpringBeanByName byName = field.getAnnotation(SpringBeanByName.class);
       String beanName = field.getName();
       if (StringHelper.isBlankOrNull(byName.value()) == false) {
         beanName = byName.value();
       }
       FieldHelper.setFieldValue(testedObject, field, ctx.getBean(beanName));
     } catch (Throwable e) {
       throw new Test4JException(
           "Unable to assign the Spring bean value to field annotated with @SpringBeanByName", e);
     }
   }
 }