Exemplo n.º 1
0
  @Test
  public void exportDb() throws Exception {
    Class dialectClass = dialect.getClass();

    if (logger.isDebugEnabled()) {
      logger.debug("Using dialect class " + dialectClass.getName());
    }

    if (PostgreSQLDialect.class.isAssignableFrom(dialectClass)) {
      exportTester = new PostgreSQLDialectExportTester(exporter, tx, jdbcTemplate);
    } else if (MySQLDialect.class.isAssignableFrom(dialectClass)) {
      exportTester = new MySQLDialectExportTester(exporter, tx, jdbcTemplate);
    }

    if (exportTester != null) {
      // Run the DBMS specific tests.
      exportTester.runExportTest();
    } else {
      if (logger.isInfoEnabled()) {
        logger.info("Unsupported dialect for this test " + dialectClass.getName());
      }
    }
  }
Exemplo n.º 2
0
  protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {
    // @Skip
    Skip skip = Helper.locateAnnotation(Skip.class, frameworkMethod, getTestClass());
    if (skip != null) {
      if (isMatch(skip.condition())) {
        return buildIgnore(skip);
      }
    }

    // @SkipForDialects & @SkipForDialect
    for (SkipForDialect skipForDialectAnn :
        Helper.collectAnnotations(
            SkipForDialect.class, SkipForDialects.class, frameworkMethod, getTestClass())) {
      for (Class<? extends Dialect> dialectClass : skipForDialectAnn.value()) {
        if (skipForDialectAnn.strictMatching()) {
          if (dialectClass.equals(dialect.getClass())) {
            return buildIgnore(skipForDialectAnn);
          }
        } else {
          if (dialectClass.isInstance(dialect)) {
            return buildIgnore(skipForDialectAnn);
          }
        }
      }
    }

    // @RequiresDialects & @RequiresDialect
    for (RequiresDialect requiresDialectAnn :
        Helper.collectAnnotations(
            RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass())) {
      boolean foundMatch = false;
      for (Class<? extends Dialect> dialectClass : requiresDialectAnn.value()) {
        foundMatch =
            requiresDialectAnn.strictMatching()
                ? dialectClass.equals(dialect.getClass())
                : dialectClass.isInstance(dialect);
        if (foundMatch) {
          break;
        }
      }
      if (!foundMatch) {
        return buildIgnore(requiresDialectAnn);
      }
    }

    // @RequiresDialectFeature
    RequiresDialectFeature requiresDialectFeatureAnn =
        Helper.locateAnnotation(RequiresDialectFeature.class, frameworkMethod, getTestClass());
    if (requiresDialectFeatureAnn != null) {
      try {
        boolean foundMatch = false;
        for (Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value()) {
          foundMatch = checkClass.newInstance().isMatch(dialect);
          if (!foundMatch) {
            return buildIgnore(requiresDialectFeatureAnn);
          }
        }
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new RuntimeException("Unable to instantiate DialectCheck", e);
      }
    }

    return null;
  }
 @Override
 public boolean isMatch(Dialect dialect) {
   return getCorrespondingDialect().getClass().equals(dialect.getClass());
 }