Skip to content

Commit 3869b8a

Browse files
committed
Added test for decision project.
1 parent ad0fe61 commit 3869b8a

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

batch/decision/pom.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

11-
<groupId>org.javaee7.batch</groupId>
1211
<artifactId>decision</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1412
<packaging>war</packaging>
1513

1614
<name>${project.artifactId}</name>
1715

16+
<dependencies>
17+
<dependency>
18+
<groupId>org.javaee7</groupId>
19+
<artifactId>util-samples</artifactId>
20+
</dependency>
21+
</dependencies>
1822
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.javaee7.batch.decision;
2+
3+
import org.javaee7.util.BatchTestHelper;
4+
import org.jboss.arquillian.container.test.api.Deployment;
5+
import org.jboss.arquillian.junit.Arquillian;
6+
import org.jboss.shrinkwrap.api.ArchivePaths;
7+
import org.jboss.shrinkwrap.api.ShrinkWrap;
8+
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
9+
import org.jboss.shrinkwrap.api.spec.WebArchive;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
13+
import javax.batch.operations.JobOperator;
14+
import javax.batch.runtime.BatchRuntime;
15+
import javax.batch.runtime.BatchStatus;
16+
import javax.batch.runtime.JobExecution;
17+
import javax.batch.runtime.StepExecution;
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
import java.util.Properties;
21+
22+
import static org.junit.Assert.*;
23+
24+
/**
25+
* @author Roberto Cortez
26+
*/
27+
@RunWith(Arquillian.class)
28+
public class BatchDecisionTest {
29+
@Deployment
30+
public static WebArchive createDeployment() {
31+
WebArchive war = ShrinkWrap.create(WebArchive.class)
32+
.addClass(BatchTestHelper.class)
33+
.addPackage("org.javaee7.batch.decision")
34+
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
35+
.addAsResource("META-INF/batch-jobs/myJob.xml");
36+
System.out.println(war.toString(true));
37+
return war;
38+
}
39+
40+
@Test
41+
public void testBatchDecision() throws Exception {
42+
JobOperator jobOperator = BatchRuntime.getJobOperator();
43+
Long executionId = jobOperator.start("myJob", new Properties());
44+
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
45+
46+
BatchTestHelper.keepTestAlive(jobExecution);
47+
48+
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
49+
List<String> executedSteps = new ArrayList<>();
50+
for (StepExecution stepExecution : stepExecutions) {
51+
executedSteps.add(stepExecution.getStepName());
52+
}
53+
54+
assertEquals(2, stepExecutions.size());
55+
assertArrayEquals(new String[] {"step1", "step3"}, executedSteps.toArray());
56+
assertFalse(executedSteps.contains("step2"));
57+
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
58+
}
59+
}

0 commit comments

Comments
 (0)