Skip to content

Commit 1c8eaa0

Browse files
committed
Upgrade abstract flow execution tests from JUnit 4 to JUnit 6
1 parent d29cc65 commit 1c8eaa0

6 files changed

Lines changed: 13 additions & 41 deletions

File tree

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ allprojects {
5050
}
5151
dependency "org.slf4j:slf4j-api:2.0.17"
5252

53-
dependency("junit:junit:4.13.2")
5453
dependency "org.easymock:easymock:5.6.0"
5554
dependency "org.hamcrest:hamcrest:3.0"
5655
dependency "org.apache.tomcat:tomcat-jasper-el:10.1.31"

spring-webflow/spring-webflow.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ dependencies {
77

88
compileOnly("jakarta.el:jakarta.el-api")
99
compileOnly("jakarta.servlet:jakarta.servlet-api")
10-
compileOnly("junit:junit")
10+
compileOnly("org.junit.jupiter:junit-jupiter-api")
1111

1212
optional("org.hibernate.orm:hibernate-core")
1313
optional("org.springframework.security:spring-security-core")
1414
optional("org.springframework:spring-orm")
1515
optional("org.springframework:spring-tx")
1616

17-
testImplementation("junit:junit")
1817
testImplementation("org.junit.jupiter:junit-jupiter")
1918
testImplementation("org.easymock:easymock")
2019
testImplementation("org.apache.tomcat:tomcat-jasper-el")

spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,11 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
6363

6464
/**
6565
* Constructs a default externalized flow execution test.
66-
* @see #setName(String)
6766
*/
6867
public AbstractExternalizedFlowExecutionTests() {
6968
init();
7069
}
7170

72-
/**
73-
* Constructs an externalized flow execution test with given name.
74-
* @param name the name of the test
75-
*/
76-
public AbstractExternalizedFlowExecutionTests(String name) {
77-
super(name);
78-
init();
79-
}
80-
8171
/**
8272
* Returns if flow definition caching is turned on.
8373
*/

spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.webflow.test.execution;
1717

18-
import junit.framework.TestCase;
18+
import static org.junit.jupiter.api.Assertions.*;
1919

2020
import org.springframework.util.Assert;
2121
import org.springframework.webflow.context.ExternalContext;
@@ -53,7 +53,7 @@
5353
*
5454
* @author Keith Donald
5555
*/
56-
public abstract class AbstractFlowExecutionTests extends TestCase {
56+
public abstract class AbstractFlowExecutionTests {
5757

5858
/**
5959
* The factory that will create the flow execution to test.
@@ -72,20 +72,11 @@ public abstract class AbstractFlowExecutionTests extends TestCase {
7272

7373
/**
7474
* Constructs a default flow execution test.
75-
* @see #setName(String)
7675
*/
7776
public AbstractFlowExecutionTests() {
7877
super();
7978
}
8079

81-
/**
82-
* Constructs a flow execution test with given name.
83-
* @param name the name of the test
84-
*/
85-
public AbstractFlowExecutionTests(String name) {
86-
super(name);
87-
}
88-
8980
/**
9081
* Gets the factory that will create the flow execution to test. This method will create the factory if it is not
9182
* already set.
@@ -297,7 +288,7 @@ protected Object getRequiredConversationAttribute(String attributeName, Class<?>
297288
* Assert that the entire flow execution is active; that is, it has not ended and has been started.
298289
*/
299290
protected void assertFlowExecutionActive() {
300-
assertTrue("The flow execution is not active but it should be", getFlowExecution().isActive());
291+
assertTrue(getFlowExecution().isActive(), "The flow execution is not active but it should be");
301292
}
302293

303294
/**
@@ -314,26 +305,27 @@ protected void assertActiveFlowEquals(String expectedActiveFlowId) {
314305
* Assert that the flow execution has ended; that is, it is no longer active.
315306
*/
316307
protected void assertFlowExecutionEnded() {
317-
assertTrue("The flow execution is still active but it should have ended", getFlowExecution().hasEnded());
308+
assertTrue(getFlowExecution().hasEnded(), "The flow execution is still active but it should have ended");
318309
}
319310

320311
/**
321312
* Assert that the flow execution has ended with the outcome specified.
322313
* @param outcome the name of the flow execution outcome
323314
*/
324315
protected void assertFlowExecutionOutcomeEquals(String outcome) {
325-
assertNotNull("There has been no flow execution outcome", flowExecutionOutcome);
326-
assertEquals("The flow execution outcome is wrong", outcome, flowExecutionOutcome.getId());
316+
assertNotNull(flowExecutionOutcome, "There has been no flow execution outcome");
317+
assertEquals(outcome, flowExecutionOutcome.getId(), "The flow execution outcome is wrong");
327318
}
328319

329320
/**
330321
* Assert that the current state of the flow execution equals the provided state id.
331322
* @param expectedCurrentStateId the expected current state
332323
*/
333324
protected void assertCurrentStateEquals(String expectedCurrentStateId) {
334-
assertEquals("The current state '" + getFlowExecution().getActiveSession().getState().getId()
335-
+ "' does not equal the expected state '" + expectedCurrentStateId + "'", expectedCurrentStateId,
336-
getFlowExecution().getActiveSession().getState().getId());
325+
assertEquals(expectedCurrentStateId,
326+
getFlowExecution().getActiveSession().getState().getId(),
327+
"The current state '" + getFlowExecution().getActiveSession().getState().getId()
328+
+ "' does not equal the expected state '" + expectedCurrentStateId + "'");
337329
}
338330

339331
/**

spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,11 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized
6262

6363
/**
6464
* Constructs a default XML flow execution test.
65-
* @see #setName(String)
6665
*/
6766
public AbstractXmlFlowExecutionTests() {
6867
super();
6968
}
7069

71-
/**
72-
* Constructs an XML flow execution test with given name.
73-
* @param name the name of the test
74-
*/
75-
public AbstractXmlFlowExecutionTests(String name) {
76-
super(name);
77-
}
78-
7970
protected final FlowBuilder createFlowBuilder(FlowDefinitionResource resource) {
8071
registerDependentFlowModels();
8172
FlowModelBuilder modelBuilder = new XmlFlowModelBuilder(resource.getPath(), flowModelRegistry);

spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020

2121
import org.junit.jupiter.api.Test;
22+
import static org.junit.jupiter.api.Assertions.*;
2223

2324
import org.springframework.webflow.config.FlowDefinitionResource;
2425
import org.springframework.webflow.config.FlowDefinitionResourceFactory;
@@ -91,7 +92,7 @@ public void testSelectValidResult() {
9192
protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
9293
Flow mockDetailFlow = new Flow("detail-flow");
9394
mockDetailFlow.setInputMapper((source, target) -> {
94-
assertEquals("id of value 1 not provided as input by calling search flow", 1L, ((AttributeMap<?>) source).get("id"));
95+
assertEquals(1L, ((AttributeMap<?>) source).get("id"), "id of value 1 not provided as input by calling search flow");
9596
return null;
9697
});
9798
// test responding to finish result

0 commit comments

Comments
 (0)