Skip to content

Commit ad0fe61

Browse files
committed
Added test for chunk-simple-nobeans project.
1 parent 6b1ada2 commit ad0fe61

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

batch/chunk-simple-nobeans/pom.xml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
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>
67
<artifactId>batch-samples</artifactId>
78
<version>1.0-SNAPSHOT</version>
89
</parent>
910

10-
<groupId>org.javaee7.batch</groupId>
1111
<artifactId>chunk-simple-nobeans</artifactId>
12-
<version>1.0-SNAPSHOT</version>
1312
<packaging>war</packaging>
1413

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

16+
<dependencies>
17+
<dependency>
18+
<groupId>org.javaee7</groupId>
19+
<artifactId>util-samples</artifactId>
20+
</dependency>
21+
</dependencies>
1722
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.javaee7.batch.samples.chunk.simple.nobeans;
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.ShrinkWrap;
7+
import org.jboss.shrinkwrap.api.spec.WebArchive;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import javax.batch.operations.JobOperator;
12+
import javax.batch.runtime.*;
13+
import java.util.List;
14+
import java.util.Map;
15+
import java.util.Properties;
16+
17+
import static org.junit.Assert.assertEquals;
18+
19+
/**
20+
* @author Roberto Cortez
21+
*/
22+
@RunWith(Arquillian.class)
23+
public class BatchChunkSimpleNoBeansTest {
24+
@Deployment
25+
public static WebArchive createDeployment() {
26+
WebArchive war = ShrinkWrap.create(WebArchive.class)
27+
.addClass(BatchTestHelper.class)
28+
.addPackage("org.javaee7.batch.samples.chunk.simple.nobeans")
29+
.addAsResource("META-INF/batch-jobs/myJob.xml");
30+
System.out.println(war.toString(true));
31+
return war;
32+
}
33+
34+
@Test
35+
public void testBatchChunkSimpleNoBeans() throws Exception {
36+
JobOperator jobOperator = BatchRuntime.getJobOperator();
37+
Long executionId = jobOperator.start("myJob", new Properties());
38+
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
39+
40+
BatchTestHelper.keepTestAlive(jobExecution);
41+
42+
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
43+
for (StepExecution stepExecution : stepExecutions) {
44+
if (stepExecution.getStepName().equals("myStep")) {
45+
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
46+
47+
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
48+
assertEquals(10L / 2L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
49+
assertEquals(10L / 3 + 10 % 3, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
50+
}
51+
}
52+
53+
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
54+
}
55+
}

0 commit comments

Comments
 (0)