-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing of the
stop
element in step XML
Previously, users were forced to set the attribute `exit-code` of the element to `""` as a work-around to prevent failing restarts. Resolves #1287
- Loading branch information
1 parent
09df30f
commit bd00cde
Showing
13 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...ramework/batch/core/configuration/xml/StopAndRestartWithCustomExitCodeJobParserTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.batch.core.configuration.xml; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.batch.core.BatchStatus; | ||
import org.springframework.batch.core.ExitStatus; | ||
import org.springframework.batch.core.JobExecution; | ||
import org.springframework.batch.core.StepExecution; | ||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Henning Pöttker | ||
*/ | ||
@SpringJUnitConfig | ||
class StopAndRestartWithCustomExitCodeJobParserTests extends AbstractJobParserTests { | ||
|
||
@Test | ||
void testStopIncomplete() throws Exception { | ||
|
||
// | ||
// First Launch | ||
// | ||
JobExecution jobExecution = createJobExecution(); | ||
job.execute(jobExecution); | ||
assertEquals(1, stepNamesList.size()); | ||
assertEquals("[s1]", stepNamesList.toString()); | ||
|
||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus()); | ||
assertEquals("CUSTOM", jobExecution.getExitStatus().getExitCode()); | ||
|
||
StepExecution stepExecution1 = getStepExecution(jobExecution, "s1"); | ||
assertEquals(BatchStatus.COMPLETED, stepExecution1.getStatus()); | ||
assertEquals(ExitStatus.COMPLETED.getExitCode(), stepExecution1.getExitStatus().getExitCode()); | ||
|
||
// | ||
// Second Launch | ||
// | ||
stepNamesList.clear(); | ||
jobExecution = createJobExecution(); | ||
job.execute(jobExecution); | ||
assertEquals(1, stepNamesList.size()); // step1 is not executed | ||
assertEquals("[s2]", stepNamesList.toString()); | ||
|
||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); | ||
assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); | ||
|
||
StepExecution stepExecution2 = getStepExecution(jobExecution, "s2"); | ||
assertEquals(BatchStatus.COMPLETED, stepExecution2.getStatus()); | ||
assertEquals(ExitStatus.COMPLETED, stepExecution2.getExitStatus()); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...org/springframework/batch/core/configuration/xml/StopAndRestartJobParserTests-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...k/batch/core/configuration/xml/StopAndRestartWithCustomExitCodeJobParserTests-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans:beans xmlns="http://www.springframework.org/schema/batch" xmlns:beans="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd | ||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
|
||
<beans:import resource="common-context.xml" /> | ||
|
||
<job id="job"> | ||
<step id="s1" parent="step1"> | ||
<stop on="*" restart="s2" exit-code="CUSTOM"/> | ||
</step> | ||
<step id="s2" parent="step2"/> | ||
</job> | ||
|
||
</beans:beans> |
2 changes: 1 addition & 1 deletion
2
...g/springframework/batch/core/configuration/xml/StopCustomStatusJobParserTests-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...org/springframework/batch/core/configuration/xml/StopIncompleteJobParserTests-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...resources/org/springframework/batch/core/configuration/xml/StopJobParserTests-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters