Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions batch/chunk-csv-database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.javaee7.batch</groupId>
<artifactId>chunk-csv-database</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>org.javaee7</groupId>
<artifactId>util-samples</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
*/
@Named
public class MyItemProcessor implements ItemProcessor {
SimpleDateFormat format = new SimpleDateFormat("M/dd/yy");
private static int id = 1;
private SimpleDateFormat format = new SimpleDateFormat("M/dd/yy");

@Override
public Person processItem(Object t) {
Expand All @@ -69,6 +70,6 @@ public Person processItem(Object t) {
return null;
}

return new Person(name, date);
return new Person(id++, name, date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,11 @@
*/
package org.javaee7.batch.chunk.csv.database;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

/**
* @author Arun Gupta
Expand All @@ -66,7 +58,6 @@
public class Person implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -94,6 +85,12 @@ public Person(String name, String hiredate) {
this.hiredate = hiredate;
}

public Person(int id, String name, String hiredate) {
this.id = id;
this.name = name;
this.hiredate = hiredate;
}

public int getId() {
return id;
}
Expand Down Expand Up @@ -132,15 +129,12 @@ public boolean equals(Object object) {
return false;
}
Person other = (Person) object;
if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) {
return false;
}
return true;
return !((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name)));
}

@Override
public String toString() {
return name;
return name + id;
}

}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE TABLE CHUNK_CSV_DATABASE ("ID" INTEGER not null primary key, "NAME" VARCHAR(50) not null primary key, "HIREDATE" VARCHAR(50) not null)
CREATE TABLE CHUNK_CSV_DATABASE ("ID" INTEGER not null primary key, "NAME" VARCHAR(50) not null, "HIREDATE" VARCHAR(50) not null)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Penny, 12/1/12
Leonard Hofstadter, 14/6/08
Leonard Hofstadter, 12/6/08
Howard Wolowitz, 8/27/7
Bernadette Rostenkowski-Wolowitz, 8/14/13
Sheldon Cooper, 3/18/9
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.javaee7.batch.chunk.csv.database;

import org.javaee7.util.BatchTestHelper;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.batch.operations.JobOperator;
import javax.batch.runtime.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import static org.junit.Assert.assertEquals;

/**
* @author Roberto Cortez
*/
@RunWith(Arquillian.class)
public class BatchCSVDatabaseTest {
@PersistenceContext
private EntityManager entityManager;

@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addClass(BatchTestHelper.class)
.addPackage("org.javaee7.batch.chunk.csv.database")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml")
.addAsResource("META-INF/persistence.xml")
.addAsResource("META-INF/create.sql")
.addAsResource("META-INF/drop.sql")
.addAsResource("META-INF/mydata.csv");
System.out.println(war.toString(true));
return war;
}

@Test
public void testBatchCSVDatabase() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);

BatchTestHelper.keepTestAlive(jobExecution);

List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());

assertEquals(7L, (long) metricsMap.get(Metric.MetricType.READ_COUNT));
assertEquals(7L, (long) metricsMap.get(Metric.MetricType.WRITE_COUNT));
assertEquals(3L, (long) metricsMap.get(Metric.MetricType.COMMIT_COUNT));
}
}

Query query = entityManager.createNamedQuery("Person.findAll");
@SuppressWarnings("unchecked")
List<Person> persons = query.getResultList();

assertEquals(7L, persons.size());
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
}
2 changes: 1 addition & 1 deletion cdi/alternatives/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion cdi/bean-discovery-all/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion cdi/bean-discovery-none/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion cdi/beansxml-noversion/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion cdi/nobeans-xml/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion el/standalone/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion jaxrs/jaxrs-endpoint/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion jpa/datasourcedefinition/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion json/object-builder/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion jta/transactional/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion jta/tx-exception/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion jta/user-transaction/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<container qualifier="test" default="true">
<configuration>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.CR1}</property>
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
</configuration>
</container>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<maven.min.version>3.0.0</maven.min.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.jboss.arquillian.version>1.1.1.Final</org.jboss.arquillian.version>
<org.wildfly>8.0.0.Beta1</org.wildfly>
<org.wildfly>8.0.0.CR1</org.wildfly>
<!-- Plugin versions -->
<plugin.enforcer.version>1.3.1</plugin.enforcer.version>
<maven.test.skip>false</maven.test.skip>
Expand Down