Package org.jtester.annotations

Examples of org.jtester.annotations.DbFit


    @Override
    public void beforeMethodRunning(Object testObject, Method testMethod) {
      Class testedClazz = testObject.getClass();
      JdbcTracerManager.suspendThreadMonitorJdbc();// 不记录dbfit的sql语句

      DbFit dbFit = testMethod.getAnnotation(DbFit.class);
      if (dbFit != null) {
        DBEnvironmentFactory.changeDBEnvironment(dbFit.dataSource());
        DbFitModule.setSymbols(dbFit);
      }
      String[] files = AutoFindDbFit.autoFindMethodWhen(testedClazz, testMethod);
      runDbFiles(testedClazz, files);
View Full Code Here


    @Override
    public void afterMethodRunned(Object testObject, Method testMethod, Throwable testThrowable) {
      Class testedClazz = testObject.getClass();
      JdbcTracerManager.suspendThreadMonitorJdbc();

      DbFit dbFit = testMethod.getAnnotation(DbFit.class);
      if (dbFit != null) {
        DBEnvironmentFactory.changeDBEnvironment(dbFit.dataSource());
        DbFitModule.setSymbols(dbFit);
      }
      String[] files = AutoFindDbFit.autoFindMethodThen(testedClazz, testMethod);
      runDbFiles(testedClazz, files);
      SymbolUtil.cleanSymbols();
View Full Code Here

   *
   * @param testClazz
   * @return
   */
  public static String[] autoFindClassWhen(Class testClazz) {
    DbFit dbFit = AnnotationUtils.getClassLevelAnnotation(DbFit.class, testClazz);
    List<String> whens = getFiles(dbFit == null ? null : dbFit.when());
    if (dbFit != null && dbFit.auto() == AUTO.UN_AUTO) {
      return whens.toArray(new String[0]);
    } else {
      String wiki = String.format(CLAZZ_WHEN_WIKI, testClazz.getSimpleName());
      if (whens.contains(wiki) == false && ResourceHelper.isResourceExists(testClazz, wiki)) {
        whens.add(wiki);
View Full Code Here

   * @return
   */
  public static String[] autoFindMethodWhen(Class testClazz, Method testMethod) {
    boolean isAutoFind = isAutoFind(testClazz, testMethod);

    DbFit dbFit = testMethod.getAnnotation(DbFit.class);
    List<String> whens = getFiles(dbFit == null ? null : dbFit.when());
    if (isAutoFind == false) {
      return whens.toArray(new String[0]);
    } else {
      String wiki = String.format(METHOD_WHEN_WIKI, testClazz.getSimpleName(), testMethod.getName());
      if (whens.contains(wiki) == false && ResourceHelper.isResourceExists(testClazz, wiki)) {
View Full Code Here

   * @return
   */
  public static String[] autoFindMethodThen(Class testClazz, Method testMethod) {
    boolean isAutoFind = isAutoFind(testClazz, testMethod);

    DbFit dbFit = testMethod.getAnnotation(DbFit.class);
    List<String> thens = getFiles(dbFit == null ? null : dbFit.then());

    if (isAutoFind == false) {
      return thens.toArray(new String[0]);
    } else {
      String wiki = String.format(METHOD_THEN_WIKI, testClazz.getSimpleName(), testMethod.getName());
View Full Code Here

   * @param testMethod
   *            测试方法
   * @return
   */
  private static boolean isAutoFind(Class testClazz, Method testMethod) {
    DbFit methodDbFit = testMethod.getAnnotation(DbFit.class);
    if (methodDbFit != null && methodDbFit.auto() != AUTO.DEFAULT) {
      return methodDbFit.auto() == AUTO.AUTO;
    }

    DbFit clazzDbFit = AnnotationUtils.getClassLevelAnnotation(DbFit.class, testClazz);
    if (clazzDbFit == null) {
      return true;
    } else {
      return !(clazzDbFit.auto() == AUTO.UN_AUTO);
    }
  }
View Full Code Here

  }

  protected class DbFitTestListener extends TestListener {
    @Override
    public void setupClass(Class testClazz) {
      DbFit dbFit = AnnotationUtils.getClassLevelAnnotation(DbFit.class, testClazz);
      if (dbFit == null) {
        return;
      }
      JdbcTracerManager.suspendThreadMonitorJdbc();// 不记录dbfit的sql语句

      DBEnvironmentFactory.changeDBEnvironment(dbFit.dataSource());
      DbFitModule.setSymbols(dbFit);
      String[] files = AutoFindDbFit.autoFindClassWhen(testClazz);
      runDbFiles(testClazz, files);
      DBEnvironmentFactory.commitCurrentDBEnvironment();
View Full Code Here

TOP

Related Classes of org.jtester.annotations.DbFit

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.