HHH-18906 Allow unsupported enhancement strategy in hibernate testing

This commit is contained in:
Marco Belladelli 2024-12-03 10:59:09 +01:00
parent cf5b2955db
commit 5b3770e289
3 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import org.hibernate.bytecode.enhance.spi.Enhancer;
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
import org.hibernate.bytecode.enhance.spi.UnloadedField;
import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy;
import org.hibernate.testing.junit4.CustomRunner;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
@ -29,6 +30,7 @@ import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
import static org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy.SKIP;
import static org.hibernate.bytecode.internal.BytecodeProviderInitiator.buildDefaultBytecodeProvider;
/**
@ -113,6 +115,12 @@ public class BytecodeEnhancerRunner extends Suite {
public boolean isLazyLoadable(UnloadedField field) {
return options.lazyLoading() && super.isLazyLoadable( field );
}
@Override
public UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy() {
final UnsupportedEnhancementStrategy strategy = options.unsupportedEnhancementStrategy();
return strategy != SKIP ? strategy : super.getUnsupportedEnhancementStrategy();
}
};
}

View File

@ -4,6 +4,8 @@
*/
package org.hibernate.testing.bytecode.enhancement;
import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
@ -21,4 +23,5 @@ public @interface EnhancementOptions {
boolean inlineDirtyChecking() default false;
boolean lazyLoading() default false;
boolean extendedEnhancement() default false;
UnsupportedEnhancementStrategy unsupportedEnhancementStrategy() default UnsupportedEnhancementStrategy.SKIP;
}

View File

@ -4,6 +4,7 @@
*/
package org.hibernate.testing.bytecode.enhancement.extension.engine;
import static org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy.SKIP;
import static org.hibernate.bytecode.internal.BytecodeProviderInitiator.buildDefaultBytecodeProvider;
import java.io.BufferedInputStream;
@ -27,6 +28,7 @@ import org.hibernate.bytecode.enhance.spi.Enhancer;
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
import org.hibernate.bytecode.enhance.spi.UnloadedField;
import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy;
import org.hibernate.testing.bytecode.enhancement.ClassEnhancementSelector;
import org.hibernate.testing.bytecode.enhancement.ClassEnhancementSelectors;
import org.hibernate.testing.bytecode.enhancement.ClassSelector;
@ -112,6 +114,12 @@ final class BytecodeEnhancedClassUtils {
public boolean isLazyLoadable(UnloadedField field) {
return options.lazyLoading() && super.isLazyLoadable( field );
}
@Override
public UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy() {
final UnsupportedEnhancementStrategy strategy = options.unsupportedEnhancementStrategy();
return strategy != SKIP ? strategy : super.getUnsupportedEnhancementStrategy();
}
};
}