Package org.jtester.exception

Examples of org.jtester.exception.JTesterException


   * @return True if the module exists and is enabled
   */
  public static boolean isModuleEnabled(Class<? extends Module> moduleClass) {
    List<? extends Module> modulesOfType = getModulesOfType(moduleClass);
    if (modulesOfType.size() > 1) {
      throw new JTesterException("More than one module found of type " + moduleClass.getName());
    }
    return modulesOfType.size() == 1;
  }
View Full Code Here


  public static Object getAdvisedObject(Object target) {
    if (target instanceof org.springframework.aop.framework.Advised) {
      try {
        return ((org.springframework.aop.framework.Advised) target).getTargetSource().getTarget();
      } catch (Exception e) {
        throw new JTesterException(e);
      }
    } else {
      return target;
    }
  }
View Full Code Here

      try {
        FieldHelper.setFieldValue(testedObject, field, null);
      } catch (Throwable e) {
        String error = String.format("clean @%s field[%s] in class[%s] error.", annotation.getName(),
            field.getName(), testedClazz.getName());
        throw new JTesterException(error, e);
      }
    }
  }
View Full Code Here

        if (StringHelper.isBlankOrNull(byName.value()) == false) {
          beanName = byName.value();
        }
        FieldHelper.setFieldValue(testedObject, field, ctx.getBean(beanName));
      } catch (Throwable e) {
        throw new JTesterException(
            "Unable to assign the Spring bean value to field annotated with @SpringBeanByName", e);
      }
    }
  }
View Full Code Here

    Set<Field> springBeanByTypeFields = getFieldsAnnotatedWith(testedClazz, SpringBeanByType.class);
    for (Field field : springBeanByTypeFields) {
      try {
        FieldHelper.setFieldValue(testedObject, field, getSpringBeanByType(ctx, field.getType()));
      } catch (Throwable e) {
        throw new JTesterException(
            "Unable to assign the Spring bean value to field annotated with @SpringBeanByType", e);
      }
    }
  }
View Full Code Here

  }

  private static <T> T getSpringBeanByType(final ApplicationContext ctx, final Class<T> type) {
    Map<String, T> beans = ctx.getBeansOfType(type);
    if (beans == null || beans.size() == 0) {
      throw new JTesterException("Unable to get Spring bean by type. No Spring bean found for type "
          + type.getSimpleName());
    }
    if (beans.size() > 1) {
      throw new JTesterException(
          "Unable to get Spring bean by type. More than one possible Spring bean for type "
              + type.getSimpleName() + ". Possible beans; " + beans);
    }
    return beans.values().iterator().next();
  }
View Full Code Here

      try {
        Object bean = ctx.getBean(beanID);
        FieldHelper.setFieldValue(testedObject, field, bean);
      } catch (Throwable e) {
        throw new JTesterException(
            "Unable to assign the Spring http invoker bean to field annotated with @HttpInvoker", e);
      }
    }
  }
View Full Code Here

    Locale locale = Locale.getDefault();
    target.setDateFormatSymbols(new DateFormatSymbols(locale));
    try {
      MethodHelper.invoke(target, "initialize", locale);
    } catch (Exception e) {
      throw new JTesterException("Unable to invoke method[initialize].", e);
    }
  }
View Full Code Here

      }
    }

    // check whether a suitable comparator was found
    if (!compared) {
      throw new JTesterException(
          "Could not determine differences. No comparator found that is able to compare the values. Left: "
              + expectedValue + ", right " + actualValue);
    }

    // register outcome in cache
View Full Code Here

  protected static Object invokeLazyInitializerMethod(String methodName, Object proxy) {
    try {
      Object lazyInitializer = hibernateProxyClass.getMethod("getHibernateLazyInitializer").invoke(proxy);
      return lazyInitializer.getClass().getMethod(methodName).invoke(lazyInitializer);
    } catch (Throwable e) {
      throw new JTesterException("Unable to invoke method on lazy initializer of Hibernate proxy. Method: "
          + methodName + ", proxy: " + proxy, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.jtester.exception.JTesterException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.