From 7e2b559c8e79339ba9954ebf6f6928b9b22ba1f3 Mon Sep 17 00:00:00 2001 From: Jonathan Charmant Date: Thu, 11 Dec 2025 21:50:46 +0000 Subject: [PATCH] Upgrade abstract flow execution tests from JUnit 4 to JUnit 6 Signed-off-by: Jonathan Charmant --- build.gradle | 1 - spring-webflow/spring-webflow.gradle | 3 +- ...bstractExternalizedFlowExecutionTests.java | 10 ------- .../execution/AbstractFlowExecutionTests.java | 28 +++++++------------ .../AbstractXmlFlowExecutionTests.java | 9 ------ .../test/SearchFlowExecutionTests.java | 3 +- 6 files changed, 13 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index 1d82438f4..bf609e3bc 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,6 @@ allprojects { } dependency "org.slf4j:slf4j-api:2.0.17" - dependency("junit:junit:4.13.2") dependency "org.easymock:easymock:5.6.0" dependency "org.hamcrest:hamcrest:3.0" dependency "org.apache.tomcat:tomcat-jasper-el:10.1.31" diff --git a/spring-webflow/spring-webflow.gradle b/spring-webflow/spring-webflow.gradle index db61765ef..23071b1b9 100644 --- a/spring-webflow/spring-webflow.gradle +++ b/spring-webflow/spring-webflow.gradle @@ -7,14 +7,13 @@ dependencies { compileOnly("jakarta.el:jakarta.el-api") compileOnly("jakarta.servlet:jakarta.servlet-api") - compileOnly("junit:junit") + compileOnly("org.junit.jupiter:junit-jupiter-api") optional("org.hibernate.orm:hibernate-core") optional("org.springframework.security:spring-security-core") optional("org.springframework:spring-orm") optional("org.springframework:spring-tx") - testImplementation("junit:junit") testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.easymock:easymock") testImplementation("org.apache.tomcat:tomcat-jasper-el") diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java index 38eab08a0..d370df2f5 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java @@ -63,21 +63,11 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo /** * Constructs a default externalized flow execution test. - * @see #setName(String) */ public AbstractExternalizedFlowExecutionTests() { init(); } - /** - * Constructs an externalized flow execution test with given name. - * @param name the name of the test - */ - public AbstractExternalizedFlowExecutionTests(String name) { - super(name); - init(); - } - /** * Returns if flow definition caching is turned on. */ diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java index e1ad45c2d..3fa12a47b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java @@ -15,7 +15,7 @@ */ package org.springframework.webflow.test.execution; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import org.springframework.util.Assert; import org.springframework.webflow.context.ExternalContext; @@ -53,7 +53,7 @@ * * @author Keith Donald */ -public abstract class AbstractFlowExecutionTests extends TestCase { +public abstract class AbstractFlowExecutionTests { /** * The factory that will create the flow execution to test. @@ -72,20 +72,11 @@ public abstract class AbstractFlowExecutionTests extends TestCase { /** * Constructs a default flow execution test. - * @see #setName(String) */ public AbstractFlowExecutionTests() { super(); } - /** - * Constructs a flow execution test with given name. - * @param name the name of the test - */ - public AbstractFlowExecutionTests(String name) { - super(name); - } - /** * Gets the factory that will create the flow execution to test. This method will create the factory if it is not * already set. @@ -297,7 +288,7 @@ protected Object getRequiredConversationAttribute(String attributeName, Class * Assert that the entire flow execution is active; that is, it has not ended and has been started. */ protected void assertFlowExecutionActive() { - assertTrue("The flow execution is not active but it should be", getFlowExecution().isActive()); + assertTrue(getFlowExecution().isActive(), "The flow execution is not active but it should be"); } /** @@ -314,7 +305,7 @@ protected void assertActiveFlowEquals(String expectedActiveFlowId) { * Assert that the flow execution has ended; that is, it is no longer active. */ protected void assertFlowExecutionEnded() { - assertTrue("The flow execution is still active but it should have ended", getFlowExecution().hasEnded()); + assertTrue(getFlowExecution().hasEnded(), "The flow execution is still active but it should have ended"); } /** @@ -322,8 +313,8 @@ protected void assertFlowExecutionEnded() { * @param outcome the name of the flow execution outcome */ protected void assertFlowExecutionOutcomeEquals(String outcome) { - assertNotNull("There has been no flow execution outcome", flowExecutionOutcome); - assertEquals("The flow execution outcome is wrong", outcome, flowExecutionOutcome.getId()); + assertNotNull(flowExecutionOutcome, "There has been no flow execution outcome"); + assertEquals(outcome, flowExecutionOutcome.getId(), "The flow execution outcome is wrong"); } /** @@ -331,9 +322,10 @@ protected void assertFlowExecutionOutcomeEquals(String outcome) { * @param expectedCurrentStateId the expected current state */ protected void assertCurrentStateEquals(String expectedCurrentStateId) { - assertEquals("The current state '" + getFlowExecution().getActiveSession().getState().getId() - + "' does not equal the expected state '" + expectedCurrentStateId + "'", expectedCurrentStateId, - getFlowExecution().getActiveSession().getState().getId()); + assertEquals(expectedCurrentStateId, + getFlowExecution().getActiveSession().getState().getId(), + "The current state '" + getFlowExecution().getActiveSession().getState().getId() + + "' does not equal the expected state '" + expectedCurrentStateId + "'"); } /** diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java index 91b1e43cc..fc8cd4807 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java @@ -62,20 +62,11 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized /** * Constructs a default XML flow execution test. - * @see #setName(String) */ public AbstractXmlFlowExecutionTests() { super(); } - /** - * Constructs an XML flow execution test with given name. - * @param name the name of the test - */ - public AbstractXmlFlowExecutionTests(String name) { - super(name); - } - protected final FlowBuilder createFlowBuilder(FlowDefinitionResource resource) { registerDependentFlowModels(); FlowModelBuilder modelBuilder = new XmlFlowModelBuilder(resource.getPath(), flowModelRegistry); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java index 697bdecc0..8244a00b8 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java @@ -19,6 +19,7 @@ import java.util.List; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import org.springframework.webflow.config.FlowDefinitionResource; import org.springframework.webflow.config.FlowDefinitionResourceFactory; @@ -91,7 +92,7 @@ public void testSelectValidResult() { protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) { Flow mockDetailFlow = new Flow("detail-flow"); mockDetailFlow.setInputMapper((source, target) -> { - assertEquals("id of value 1 not provided as input by calling search flow", 1L, ((AttributeMap) source).get("id")); + assertEquals(1L, ((AttributeMap) source).get("id"), "id of value 1 not provided as input by calling search flow"); return null; }); // test responding to finish result