From 263f5c99fed6e3eb1b5cc0289ab1e51de36e97d3 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Wed, 4 Jun 2025 09:28:08 +0200 Subject: [PATCH 1/3] HHH-19516 Upgrade to JUnit 5.13.0 --- .../extension/engine/BytecodeEnhancedTestEngine.java | 9 ++++++++- settings.gradle | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java b/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java index 86914a9d2999..4ae99dfbb63c 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java @@ -39,6 +39,7 @@ import org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor; import org.junit.jupiter.engine.descriptor.ClassTestDescriptor; import org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor; +import org.junit.jupiter.engine.descriptor.LauncherStoreFacade; import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor; import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor; import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext; @@ -215,7 +216,8 @@ private Method findMethodReplacement(ClassTestDescriptor updated, Method testMet protected JupiterEngineExecutionContext createExecutionContext(ExecutionRequest request) { return new JupiterEngineExecutionContext( request.getEngineExecutionListener(), - this.getJupiterConfiguration( request ) + this.getJupiterConfiguration( request ), + new LauncherStoreFacade( request.getStore() ) ); } @@ -272,6 +274,11 @@ public boolean isParallelExecutionEnabled() { return configuration.isParallelExecutionEnabled(); } + @Override + public boolean isClosingStoredAutoCloseablesEnabled() { + return configuration.isClosingStoredAutoCloseablesEnabled(); + } + @Override public boolean isExtensionAutoDetectionEnabled() { return configuration.isExtensionAutoDetectionEnabled(); diff --git a/settings.gradle b/settings.gradle index 0c7993dca334..c9ec73615a1f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -161,7 +161,7 @@ dependencyResolutionManagement { library( "xjc", "org.glassfish.jaxb", "jaxb-xjc" ).versionRef( xjcVersion ) } testLibs { - def junit5Version = version "junit5", "5.12.0" + def junit5Version = version "junit5", "5.13.0" def junit4Version = version "junit4", "4.13.2" def junit5LauncherVersion = version "junit5Launcher", "1.12.0" From e9ada68a6853a5bbccd72ef71da8fa3e9d5a5a47 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Fri, 18 Jul 2025 08:42:12 +0200 Subject: [PATCH 2/3] Ensure compatibility with JUnit < 5.13 --- .../extension/engine/BytecodeEnhancedTestEngine.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java b/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java index 4ae99dfbb63c..ca634910482f 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java @@ -9,6 +9,8 @@ import static org.hibernate.testing.bytecode.enhancement.extension.engine.BytecodeEnhancedClassUtils.enhanceTestClass; import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashSet; @@ -44,6 +46,7 @@ import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor; import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext; import org.junit.platform.engine.EngineDiscoveryRequest; +import org.junit.platform.engine.EngineExecutionListener; import org.junit.platform.engine.ExecutionRequest; import org.junit.platform.engine.TestDescriptor; import org.junit.platform.engine.UniqueId; @@ -214,6 +217,15 @@ private Method findMethodReplacement(ClassTestDescriptor updated, Method testMet @Override protected JupiterEngineExecutionContext createExecutionContext(ExecutionRequest request) { + try { + // Try constructing the JupiterEngineExecutionContext the way it was done in 5.12 and before + final Constructor constructorV5_12 = JupiterEngineExecutionContext.class + .getConstructor( EngineExecutionListener.class, JupiterConfiguration.class ); + return constructorV5_12.newInstance( request.getEngineExecutionListener(), this.getJupiterConfiguration( request ) ); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e ) { + // Ignore errors as they are probably due to version mismatches and try the 5.13 way + } + return new JupiterEngineExecutionContext( request.getEngineExecutionListener(), this.getJupiterConfiguration( request ), From eb26999bc824ee69fa8bce11db435d4b0e178bec Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Fri, 18 Jul 2025 09:04:06 +0200 Subject: [PATCH 3/3] Fix missing newline --- .../extension/engine/BytecodeEnhancedTestEngine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java b/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java index ca634910482f..3bccc2927867 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java @@ -222,7 +222,8 @@ protected JupiterEngineExecutionContext createExecutionContext(ExecutionRequest final Constructor constructorV5_12 = JupiterEngineExecutionContext.class .getConstructor( EngineExecutionListener.class, JupiterConfiguration.class ); return constructorV5_12.newInstance( request.getEngineExecutionListener(), this.getJupiterConfiguration( request ) ); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e ) { + } + catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { // Ignore errors as they are probably due to version mismatches and try the 5.13 way }