Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8806eb

Browse files
committed
Added test for split project.
1 parent 41ba99f commit f8806eb

File tree

4 files changed

+69
-195
lines changed

4 files changed

+69
-195
lines changed

batch/split/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>org.javaee7.batch</groupId>
@@ -8,11 +9,15 @@
89
<relativePath>../pom.xml</relativePath>
910
</parent>
1011

11-
<groupId>org.javaee7.batch</groupId>
1212
<artifactId>split</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1413
<packaging>war</packaging>
1514

1615
<name>${project.artifactId}</name>
1716

17+
<dependencies>
18+
<dependency>
19+
<groupId>org.javaee7</groupId>
20+
<artifactId>util-samples</artifactId>
21+
</dependency>
22+
</dependencies>
1823
</project>

batch/split/src/main/java/org/javaee7/batch/split/TestServlet.java

Lines changed: 0 additions & 137 deletions
This file was deleted.

batch/split/src/main/webapp/index.jsp

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.javaee7.batch.split;
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.assertEquals;
23+
import static org.junit.Assert.assertTrue;
24+
25+
/**
26+
* @author Roberto Cortez
27+
*/
28+
@RunWith(Arquillian.class)
29+
public class BatchSplitTest {
30+
@Deployment
31+
public static WebArchive createDeployment() {
32+
WebArchive war = ShrinkWrap.create(WebArchive.class)
33+
.addClass(BatchTestHelper.class)
34+
.addPackage("org.javaee7.batch.split")
35+
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
36+
.addAsResource("META-INF/batch-jobs/myJob.xml");
37+
System.out.println(war.toString(true));
38+
return war;
39+
}
40+
41+
@Test
42+
public void testBatchSplit() throws Exception {
43+
JobOperator jobOperator = BatchRuntime.getJobOperator();
44+
Long executionId = jobOperator.start("myJob", new Properties());
45+
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
46+
47+
BatchTestHelper.keepTestAlive(jobExecution);
48+
49+
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
50+
List<String> executedSteps = new ArrayList<>();
51+
for (StepExecution stepExecution : stepExecutions) {
52+
executedSteps.add(stepExecution.getStepName());
53+
}
54+
55+
assertEquals(3, stepExecutions.size());
56+
assertTrue(executedSteps.contains("step1"));
57+
assertTrue(executedSteps.contains("step2"));
58+
assertTrue(executedSteps.contains("step3"));
59+
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
60+
}
61+
}

0 commit comments

Comments
 (0)