Skip to content

Commit 784631e

Browse files
committed
Added documentation to split project.
1 parent c2d4ae2 commit 784631e

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

batch/split/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
<artifactId>split</artifactId>
1313
<packaging>war</packaging>
14-
15-
<name>${project.artifactId}</name>
14+
<name>Batch Split</name>
15+
<description>Batch JSL - Splitting Steps</description>
1616

1717
<dependencies>
1818
<dependency>

batch/split/src/test/java/org/javaee7/batch/split/BatchSplitTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,29 @@
2323
import static org.junit.Assert.assertTrue;
2424

2525
/**
26+
* The Batch specification allows you to implement process workflows using a Job Specification Language (JSL). In this
27+
* sample, by using the +split+ element, it's possible to configure a job that runs parallel flows. A +split+ can only
28+
* contain +flow+ elements. These +flow+ elements can be used to implement separate executions to be processed by the
29+
* job.
30+
*
31+
* Three simple Batchlet's are configured in the file +myjob.xml+. +MyBatchlet1+ and +MyBatchlet2+ are setted up to
32+
* execute in parallel by using the +split+ and +flow+ elements. +MyBatchlet3+ is only going to execute after
33+
* +MyBatchlet1+ and +MyBatchlet2+ are both done with their job.
34+
*
2635
* @author Roberto Cortez
2736
*/
2837
@RunWith(Arquillian.class)
2938
public class BatchSplitTest {
39+
/**
40+
* We're just going to deploy the application as a +web archive+. Note the inclusion of the following files:
41+
*
42+
* [source,file]
43+
* ----
44+
* /META-INF/batch-jobs/myjob.xml
45+
* ----
46+
*
47+
* The +myjob.xml+ file is needed for running the batch definition.
48+
*/
3049
@Deployment
3150
public static WebArchive createDeployment() {
3251
WebArchive war = ShrinkWrap.create(WebArchive.class)
@@ -38,6 +57,12 @@ public static WebArchive createDeployment() {
3857
return war;
3958
}
4059

60+
/**
61+
* In the test, we're just going to invoke the batch execution and wait for completion. To validate the test
62+
* expected behaviour we need to query +JobOperator#getStepExecutions+.
63+
*
64+
* @throws Exception an exception if the batch could not complete successfully.
65+
*/
4166
@Test
4267
public void testBatchSplit() throws Exception {
4368
JobOperator jobOperator = BatchRuntime.getJobOperator();
@@ -52,13 +77,19 @@ public void testBatchSplit() throws Exception {
5277
executedSteps.add(stepExecution.getStepName());
5378
}
5479

80+
// <1> Make sure all the steps were executed.
5581
assertEquals(3, stepExecutions.size());
5682
assertTrue(executedSteps.contains("step1"));
5783
assertTrue(executedSteps.contains("step2"));
5884
assertTrue(executedSteps.contains("step3"));
85+
86+
// <2> Steps 'step1' and 'step2' can appear in any order, since they were executed in parallel.
5987
assertTrue(executedSteps.get(0).equals("step1") || executedSteps.get(0).equals("step2"));
6088
assertTrue(executedSteps.get(1).equals("step1") || executedSteps.get(1).equals("step2"));
89+
// <3> Step 'step3' is always the last to be executed.
6190
assertTrue(executedSteps.get(2).equals("step3"));
91+
92+
// <4> Job should be completed.
6293
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
6394
}
6495
}

0 commit comments

Comments
 (0)