From f007dc7c90d47873db0be8f8f692da56f7ec1da6 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 31 Jan 2017 17:57:18 +0000 Subject: [PATCH] HHH-11428 - When multiple @RequiresDialect annotation is applied the test is ignored --- .../testing/junit4/CustomRunner.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java index 84efbd1256..1765659e60 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java @@ -261,25 +261,13 @@ public class CustomRunner extends BlockJUnit4ClassRunner { } } - boolean foundMatch = false; + // @RequiresDialects & @RequiresDialect final List requiresDialects = Helper.collectAnnotations( RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass() ); - for ( RequiresDialect requiresDialectAnn : requiresDialects ) { - for ( Class dialectClass : requiresDialectAnn.value() ) { - foundMatch = requiresDialectAnn.strictMatching() - ? dialectClass.equals( dialect.getClass() ) - : dialectClass.isInstance( dialect ); - if ( foundMatch ) { - break; - } - } - if ( foundMatch ) { - break; - } - } - if ( !foundMatch ) { + + if ( !requiresDialects.isEmpty() && !isDialectMatchingRequired( requiresDialects ) ) { return buildIgnore( requiresDialects ); } @@ -308,6 +296,24 @@ public class CustomRunner extends BlockJUnit4ClassRunner { return null; } + private boolean isDialectMatchingRequired(List requiresDialects) { + boolean foundMatch = false; + for ( RequiresDialect requiresDialectAnn : requiresDialects ) { + for ( Class dialectClass : requiresDialectAnn.value() ) { + foundMatch = requiresDialectAnn.strictMatching() + ? dialectClass.equals( dialect.getClass() ) + : dialectClass.isInstance( dialect ); + if ( foundMatch ) { + break; + } + } + if ( foundMatch ) { + break; + } + } + return foundMatch; + } + private Ignore buildIgnore(Skip skip) { return new IgnoreImpl( "@Skip : " + skip.message() ); }