Search in sources :

Example 1 with Skip

use of org.hibernate.testing.Skip in project hibernate-orm by hibernate.

the class CustomRunner method convertSkipToIgnore.

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
    final List<RequiresDialect> requiresDialects = Helper.collectAnnotations(RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass());
    if (!requiresDialects.isEmpty() && !isDialectMatchingRequired(requiresDialects)) {
        return buildIgnore(requiresDialects);
    }
    // @RequiresDialectFeature
    RequiresDialectFeature requiresDialectFeatureAnn = Helper.locateAnnotation(RequiresDialectFeature.class, frameworkMethod, getTestClass());
    if (requiresDialectFeatureAnn != null) {
        try {
            for (Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value()) {
                if (!checkClass.newInstance().isMatch(dialect)) {
                    return buildIgnore(requiresDialectFeatureAnn);
                }
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException("Unable to instantiate DialectCheck", e);
        }
    }
    return null;
}
Also used : SkipForDialect(org.hibernate.testing.SkipForDialect) RequiresDialectFeature(org.hibernate.testing.RequiresDialectFeature) Skip(org.hibernate.testing.Skip) RequiresDialect(org.hibernate.testing.RequiresDialect) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException)

Example 2 with Skip

use of org.hibernate.testing.Skip in project hibernate-orm by hibernate.

the class QuotedTableNameSchemaUpdateTest method testSchemaUpdateWithQuotedTableName.

@Test
@TestForIssue(jiraKey = "HHH-10820")
@Skip(condition = Skip.OperatingSystem.Windows.class, message = "On Windows, MySQL is case insensitive!")
public void testSchemaUpdateWithQuotedTableName() throws Exception {
    final MetadataSources metadataSources = new MetadataSources(ssr);
    metadataSources.addAnnotatedClass(QuotedTable.class);
    MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
    metadata.validate();
    new SchemaExport().setOutputFile(output.getAbsolutePath()).setFormat(false).create(EnumSet.of(TargetType.DATABASE), metadata);
    new SchemaUpdate().setHaltOnError(true).setOutputFile(output.getAbsolutePath()).setFormat(false).execute(EnumSet.of(TargetType.DATABASE, TargetType.SCRIPT), metadata);
    final List<String> sqlLines = Files.readAllLines(output.toPath(), Charset.defaultCharset());
    assertThat("The update should recognize the existing table", sqlLines.isEmpty(), is(true));
    new SchemaExport().setHaltOnError(true).setOutputFile(output.getAbsolutePath()).setFormat(false).drop(EnumSet.of(TargetType.DATABASE), metadata);
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) SchemaUpdate(org.hibernate.tool.hbm2ddl.SchemaUpdate) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test) Skip(org.hibernate.testing.Skip) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

Skip (org.hibernate.testing.Skip)2 MetadataSources (org.hibernate.boot.MetadataSources)1 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)1 RequiresDialect (org.hibernate.testing.RequiresDialect)1 RequiresDialectFeature (org.hibernate.testing.RequiresDialectFeature)1 SkipForDialect (org.hibernate.testing.SkipForDialect)1 TestForIssue (org.hibernate.testing.TestForIssue)1 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)1 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)1 Test (org.junit.Test)1 NoTestsRemainException (org.junit.runner.manipulation.NoTestsRemainException)1