diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java index 6fca83388..89bf1730f 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java @@ -103,7 +103,7 @@ public class JobScopeTestExecutionListener implements TestExecutionListener { @Override public void afterTestMethod(TestContext testContext) throws Exception { if (testContext.hasAttribute(JOB_EXECUTION)) { - JobSynchronizationManager.close(); + JobSynchronizationManager.release(); } } diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestUtils.java index 00e9871fe..989512bb4 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestUtils.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.batch.core.scope.context.JobSynchronizationManager; * * @author Dave Syer * @author Jimmy Praet + * @author Mahmoud Ben Hassine */ public class JobScopeTestUtils { @@ -37,7 +38,7 @@ public class JobScopeTestUtils { return callable.call(); } finally { - JobSynchronizationManager.close(); + JobSynchronizationManager.release(); } } diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/JobScopeTestExecutionListenerIntegrationTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/JobScopeTestExecutionListenerIntegrationTests.java index 707732bba..d295007f0 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/JobScopeTestExecutionListenerIntegrationTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/JobScopeTestExecutionListenerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.batch.test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; import org.springframework.batch.core.JobExecution; @@ -56,6 +57,8 @@ class JobScopeTestExecutionListenerIntegrationTests { void testJob() throws Exception { stream.open(new ExecutionContext()); assertEquals("foo", reader.read()); + assertEquals("bar", reader.read()); + assertNull(reader.read()); } }