HHH-13206 - Fix custom runner properly determine dialect feature checks.
This commit is contained in:
parent
aa288ba345
commit
27ddc8e834
|
@ -272,24 +272,27 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
|
|||
}
|
||||
|
||||
// @RequiresDialectFeature
|
||||
RequiresDialectFeature requiresDialectFeatureAnn = Helper.locateAnnotation(
|
||||
final List<RequiresDialectFeature> requiresDialectFeatures = Helper.locateAllAnnotations(
|
||||
RequiresDialectFeature.class,
|
||||
frameworkMethod,
|
||||
getTestClass()
|
||||
);
|
||||
if ( requiresDialectFeatureAnn != null ) {
|
||||
try {
|
||||
for ( Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value() ) {
|
||||
if ( !checkClass.newInstance().isMatch( dialect ) ) {
|
||||
return buildIgnore( requiresDialectFeatureAnn );
|
||||
|
||||
if ( !requiresDialectFeatures.isEmpty() ) {
|
||||
for ( RequiresDialectFeature requiresDialectFeature : requiresDialectFeatures ) {
|
||||
try {
|
||||
for ( Class<? extends DialectCheck> checkClass : requiresDialectFeature.value() ) {
|
||||
if ( !checkClass.newInstance().isMatch( dialect ) ) {
|
||||
return buildIgnore( requiresDialectFeature );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to instantiate DialectCheck", e );
|
||||
catch (RuntimeException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to instantiate DialectCheck", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,38 @@ public final class Helper {
|
|||
return annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates the specified annotation both at the method site and class site.
|
||||
*
|
||||
* This is useful for situations where you may apply the same annotation at both the method
|
||||
* and class level and rather than both sites being mutually exclusive, this permits both
|
||||
* to be returned instead.
|
||||
*
|
||||
* @param annotationClass Annotation class
|
||||
* @param frameworkMethod Test method.
|
||||
* @param testClass Test class.
|
||||
* @param <T> Annotation type.
|
||||
*
|
||||
* @return Collection of all annotations detected at both method or class level.
|
||||
*/
|
||||
public static <T extends Annotation> List<T> locateAllAnnotations(
|
||||
Class<T> annotationClass,
|
||||
FrameworkMethod frameworkMethod,
|
||||
TestClass testClass) {
|
||||
final List<T> annotations = new LinkedList<>();
|
||||
|
||||
T annotation = frameworkMethod.getAnnotation( annotationClass );
|
||||
if ( annotation != null ) {
|
||||
annotations.add( annotation );
|
||||
}
|
||||
|
||||
annotation = testClass.getJavaClass().getAnnotation( annotationClass );
|
||||
if ( annotation != null ) {
|
||||
annotations.add( annotation );
|
||||
}
|
||||
return annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param singularAnnotationClass Singular annotation class (e.g. {@link org.hibernate.testing.SkipForDialect}).
|
||||
* @param pluralAnnotationClass Plural annotation class (e.g. {@link org.hibernate.testing.SkipForDialects}),
|
||||
|
|
Loading…
Reference in New Issue