Update Spring batch test function and project

This commit is contained in:
YuCheng Hu 2019-10-11 14:17:51 -04:00
parent 35d19a3cd3
commit 78fde71a5c
39 changed files with 86 additions and 127 deletions

25
settings.gradle Normal file
View File

@ -0,0 +1,25 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url 'https://maven.ossez.com/repository/internal' }
}
}
buildCache {
local {
enabled = true
}
remote(HttpBuildCache) {
enabled = false
}
}
include "spring-batch"
rootProject.name = "cwiki-us-demo-tutorials"
rootProject.children.each { project ->
project.buildFileName = "${project.name}.gradle"
assert project.projectDir.isDirectory()
assert project.buildFile.exists()
assert project.buildFile.isFile()
}

View File

@ -1,72 +0,0 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>spring-batch</artifactId>
<version>0.1-SNAPSHOT</version>
<name>spring-batch</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<!-- SQLite database driver -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<spring.version>5.0.3.RELEASE</spring.version>
<spring.batch.version>4.0.0.RELEASE</spring.batch.version>
<sqlite.version>3.15.1</sqlite.version>
<opencsv.version>4.1</opencsv.version>
<awaitility.version>3.1.1</awaitility.version>
</properties>
</project>

Binary file not shown.

View File

@ -1,4 +1,4 @@
package org.baeldung.batch;
package com.ossez.spring.batch;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@ -42,4 +42,4 @@ public class App {
System.out.println("Job failed");
}
}
}
}

View File

@ -1,4 +1,4 @@
package us.cwiki.spring.batch.processing;
package com.ossez.spring.batch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,4 +1,4 @@
package org.baeldung.batch;
package com.ossez.spring.batch;
import org.baeldung.batch.model.Transaction;
import org.baeldung.batch.service.CustomItemProcessor;

View File

@ -1,4 +1,4 @@
package org.baeldung.batch;
package com.ossez.spring.batch;
import java.net.MalformedURLException;
@ -75,4 +75,4 @@ public class SpringConfig {
return jobLauncher;
}
}
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.baeldung.batch.partitioner;
package com.ossez.spring.batch.partitioner;
import java.util.HashMap;
import java.util.Map;

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.partitioner;
package com.ossez.spring.batch.partitioner;
import org.baeldung.batch.model.Transaction;
import org.baeldung.batch.service.RecordFieldSetMapper;

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.partitioner;
package com.ossez.spring.batch.partitioner;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@ -25,4 +25,4 @@ public class SpringbatchPartitionerApp {
System.out.println("Job failed");
}
}
}
}

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.service;
package com.ossez.spring.batch.service;
import org.baeldung.batch.model.Transaction;
import org.springframework.batch.item.ItemProcessor;
@ -9,4 +9,4 @@ public class CustomItemProcessor implements ItemProcessor<Transaction, Transacti
System.out.println("Processing..." + item);
return item;
}
}
}

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.service;
package com.ossez.spring.batch.service;
import org.springframework.batch.core.step.skip.SkipLimitExceededException;
import org.springframework.batch.core.step.skip.SkipPolicy;

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.service;
package com.ossez.spring.batch.service;
public class MissingUsernameException extends RuntimeException {
}

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.service;
package com.ossez.spring.batch.service;
public class NegativeAmountException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.service;
package com.ossez.spring.batch.service;
import java.text.ParseException;
import java.text.SimpleDateFormat;

View File

@ -1,4 +1,4 @@
package org.baeldung.batch.service;
package com.ossez.spring.batch.service;
import org.baeldung.batch.model.Transaction;
import org.springframework.batch.item.ItemProcessor;

View File

@ -1,4 +1,4 @@
package org.baeldung.batchscheduler;
package com.ossez.spring.batchscheduler;
import java.util.Date;
import java.util.IdentityHashMap;

View File

@ -1,6 +1,6 @@
package org.baeldung.taskletsvschunks.chunks;
package com.ossez.spring.taskletsvschunks.chunks;
import org.baeldung.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.model.Line;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;

View File

@ -1,7 +1,7 @@
package org.baeldung.taskletsvschunks.chunks;
package com.ossez.spring.taskletsvschunks.chunks;
import org.baeldung.taskletsvschunks.model.Line;
import org.baeldung.taskletsvschunks.utils.FileUtils;
import com.ossez.spring.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;

View File

@ -1,7 +1,8 @@
package org.baeldung.taskletsvschunks.chunks;
package com.ossez.spring.taskletsvschunks.chunks;
import org.baeldung.taskletsvschunks.model.Line;
import org.baeldung.taskletsvschunks.utils.FileUtils;
import com.ossez.spring.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;

View File

@ -1,9 +1,10 @@
package org.baeldung.taskletsvschunks.config;
package com.ossez.spring.taskletsvschunks.config;
import com.ossez.spring.taskletsvschunks.chunks.LineProcessor;
import com.ossez.spring.taskletsvschunks.chunks.LineReader;
import com.ossez.spring.taskletsvschunks.chunks.LinesWriter;
import com.ossez.spring.taskletsvschunks.model.Line;
import org.baeldung.taskletsvschunks.chunks.LineProcessor;
import org.baeldung.taskletsvschunks.chunks.LineReader;
import org.baeldung.taskletsvschunks.chunks.LinesWriter;
import org.baeldung.taskletsvschunks.model.Line;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;

View File

@ -1,8 +1,9 @@
package org.baeldung.taskletsvschunks.config;
package com.ossez.spring.taskletsvschunks.config;
import org.baeldung.taskletsvschunks.tasklets.LinesProcessor;
import org.baeldung.taskletsvschunks.tasklets.LinesReader;
import org.baeldung.taskletsvschunks.tasklets.LinesWriter;
import com.ossez.spring.taskletsvschunks.tasklets.LinesWriter;
import com.ossez.spring.taskletsvschunks.tasklets.LinesProcessor;
import com.ossez.spring.taskletsvschunks.tasklets.LinesReader;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;

View File

@ -1,4 +1,4 @@
package org.baeldung.taskletsvschunks.model;
package com.ossez.spring.taskletsvschunks.model;
import java.io.Serializable;
import java.time.LocalDate;

View File

@ -1,6 +1,6 @@
package org.baeldung.taskletsvschunks.tasklets;
package com.ossez.spring.taskletsvschunks.tasklets;
import org.baeldung.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.model.Line;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;

View File

@ -1,7 +1,7 @@
package org.baeldung.taskletsvschunks.tasklets;
package com.ossez.spring.taskletsvschunks.tasklets;
import org.baeldung.taskletsvschunks.model.Line;
import org.baeldung.taskletsvschunks.utils.FileUtils;
import com.ossez.spring.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;

View File

@ -1,7 +1,8 @@
package org.baeldung.taskletsvschunks.tasklets;
package com.ossez.spring.taskletsvschunks.tasklets;
import org.baeldung.taskletsvschunks.model.Line;
import org.baeldung.taskletsvschunks.utils.FileUtils;
import com.ossez.spring.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ExitStatus;

View File

@ -1,8 +1,8 @@
package org.baeldung.taskletsvschunks.utils;
package com.ossez.spring.taskletsvschunks.utils;
import com.opencsv.CSVReader;
import com.opencsv.CSVWriter;
import org.baeldung.taskletsvschunks.model.Line;
import com.ossez.spring.taskletsvschunks.model.Line;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,12 +1,12 @@
package org.baeldung;
import org.baeldung.batch.App;
import com.ossez.spring.batch.App;
import org.junit.Test;
public class SpringContextIntegrationTest {
@Test
@Test
public final void testMain() throws Exception {
App.main(null);
}
}
}

View File

@ -1,6 +1,8 @@
package org.baeldung;
import org.baeldung.batch.App;
import com.ossez.spring.batch.App;
import org.junit.Test;
public class SpringContextTest {

View File

@ -1,5 +1,6 @@
package org.baeldung.batchscheduler;
import com.ossez.spring.batchscheduler.SpringBatchScheduler;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -1,6 +1,6 @@
package org.baeldung.taskletsvschunks.chunks;
import org.baeldung.taskletsvschunks.config.ChunksConfig;
import com.ossez.spring.taskletsvschunks.config.ChunksConfig;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -22,4 +22,4 @@ public class ChunksIntegrationTest {
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
}
}

View File

@ -1,6 +1,6 @@
package org.baeldung.taskletsvschunks.tasklets;
import org.baeldung.taskletsvschunks.config.TaskletsConfig;
import com.ossez.spring.taskletsvschunks.config.TaskletsConfig;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -22,4 +22,4 @@ public class TaskletsIntegrationTest {
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
}
}

View File

@ -1 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><transactionRecord><transactionRecord><amount>10000.0</amount><transactionDate>2015-10-31T00:00:00+05:30</transactionDate><userId>1234</userId><username>devendra</username></transactionRecord><transactionRecord><amount>12321.0</amount><transactionDate>2015-12-03T00:00:00+05:30</transactionDate><userId>2134</userId><username>john</username></transactionRecord><transactionRecord><amount>23411.0</amount><transactionDate>2015-02-02T00:00:00+05:30</transactionDate><userId>2134</userId><username>robin</username></transactionRecord></transactionRecord>