Skip to content

Commit

Permalink
Merge pull request #102 from liweinan/upgrade_jberet_parent_to_3
Browse files Browse the repository at this point in the history
Upgrade JBeret Parent to `3.0.0.Final`
  • Loading branch information
liweinan authored Sep 11, 2024
2 parents d7ee303 + bf8c79d commit 10644cd
Show file tree
Hide file tree
Showing 31 changed files with 214 additions and 174 deletions.
22 changes: 19 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>org.jberet</groupId>
<artifactId>jberet-parent</artifactId>
<version>2.2.1.Final</version>
<version>3.0.0.Final</version>
</parent>

<artifactId>jberet-support</artifactId>
Expand All @@ -37,6 +37,10 @@
<version.org.ow2.asm>9.7</version.org.ow2.asm>
<version.software.amazon.awssdk>2.25.26</version.software.amazon.awssdk>
<version.jandex>3.2.2</version.jandex>
<junit-jupiter.version>5.10.3</junit-jupiter.version>
<version.jakarta.validation.jakarta-validation-api>3.0.2</version.jakarta.validation.jakarta-validation-api>
<version.org.hibernate.validator>8.0.1.Final</version.org.hibernate.validator>
<version.persistence-api>3.1.0</version.persistence-api>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -142,6 +146,7 @@
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>${version.persistence-api}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -236,10 +241,12 @@
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${version.jakarta.validation.jakarta-validation-api}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${version.org.hibernate.validator}</version>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
Expand Down Expand Up @@ -347,9 +354,18 @@
<version>${version.jandex}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/org/jberet/support/io/ArrayItemReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@

package org.jberet.support.io;

import static org.junit.Assert.assertEquals;

import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import org.jberet.runtime.JobExecutionImpl;
import org.junit.Test;

import jakarta.batch.operations.JobOperator;
import jakarta.batch.runtime.BatchRuntime;
import jakarta.batch.runtime.BatchStatus;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* A test class that reads from inlined array data.
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/jberet/support/io/ArtemisReaderWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ArtemisReaderWriterTest {
static final String writerTestJobName = "org.jberet.support.io.ArtemisWriterTest.xml";
Expand All @@ -47,7 +47,7 @@ public class ArtemisReaderWriterTest {
ActiveMQServer server;
ClientSession coreSession;

@Before
@BeforeEach
public void before() throws Exception {
//Create the Configuration, and set the properties accordingly
final Configuration configuration = new ConfigurationImpl();
Expand All @@ -69,7 +69,7 @@ public void before() throws Exception {
coreSession.createQueue(queueAddress, queueAddress);
}

@After
@AfterEach
public void after() throws Exception {
if (coreSession != null) {
coreSession.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import java.util.concurrent.TimeUnit;

import org.jberet.runtime.JobExecutionImpl;
import org.junit.Assert;
import org.junit.Test;

import jakarta.batch.operations.JobOperator;
import jakarta.batch.runtime.BatchRuntime;
import jakarta.batch.runtime.BatchStatus;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public final class BeanIOReaderWriterTest {
static final String jobName = "org.jberet.support.io.BeanIOReaderWriterTest";
Expand Down Expand Up @@ -113,7 +114,7 @@ private void testReadWrite0(final String resource, final String writeResource,
final long jobExecutionId = jobOperator.start(jobName, params);
final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
jobExecution.awaitTermination(CsvItemReaderWriterTest.waitTimeoutMinutes * 100, TimeUnit.MINUTES);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());

CsvItemReaderWriterTest.validate(file, expect, forbid);
}
Expand Down
23 changes: 12 additions & 11 deletions src/test/java/org/jberet/support/io/CassandraReaderWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@

import org.jberet.runtime.JobExecutionImpl;
import org.joda.time.DateTime;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ConsistencyLevel;
Expand All @@ -41,13 +35,20 @@
import jakarta.batch.operations.JobOperator;
import jakarta.batch.runtime.BatchRuntime;
import jakarta.batch.runtime.BatchStatus;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Tests for {@link CassandraItemReader}, {@link CassandraItemWriter} and {@link CassandraBatchlet}.
*
* @since 1.3.0.Final
*/
@Ignore("Need to run Cassandra cluster first")
@Disabled("Need to run Cassandra cluster first")
public class CassandraReaderWriterTest {
static final JobOperator jobOperator = BatchRuntime.getJobOperator();
static final String writerTestJobName = "org.jberet.support.io.CassandraWriterTest";
Expand Down Expand Up @@ -145,19 +146,19 @@ public class CassandraReaderWriterTest {
"update stock_trade_date set close = 3000 where tradedate = '2018-02-22' and tradetime = '09:30'; \n" +
"apply batch;";

@BeforeClass
@BeforeAll
public static void beforeClass() {
initKeyspaceAndTable();
}

@AfterClass
@AfterAll
public static void afterClass() {
if (session != null) {
session.close();
}
}

@Before
@BeforeEach
public void before() {
deleteAllRows();
}
Expand Down Expand Up @@ -473,7 +474,7 @@ private void runTest(final String jobName, final Properties jobParams) throws Ex
final long jobExecutionId = jobOperator.start(jobName, jobParams);
final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
jobExecution.awaitTermination(1, TimeUnit.MINUTES);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}

static void initKeyspaceAndTable() {
Expand Down
25 changes: 13 additions & 12 deletions src/test/java/org/jberet/support/io/CellProcessorConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@

import java.util.Arrays;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.ParseDate;
import org.supercsv.cellprocessor.ParseLong;
import org.supercsv.cellprocessor.constraint.NotNull;
import org.supercsv.cellprocessor.constraint.StrMinMax;
import org.supercsv.cellprocessor.ift.CellProcessor;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CellProcessorConfigTest {

@Test
public void testParseCellProcessors1() throws Exception {
final String val = "StrMinMax(1, 20)";
final CellProcessor[] cellProcessors = CellProcessorConfig.parseCellProcessors(val);
System.out.printf("Resolved cell processors: %s%n", Arrays.toString(cellProcessors));
Assert.assertEquals(1, cellProcessors.length);
Assert.assertEquals(StrMinMax.class, cellProcessors[0].getClass());
assertEquals(1, cellProcessors.length);
assertEquals(StrMinMax.class, cellProcessors[0].getClass());
}

@Test
Expand All @@ -43,13 +44,13 @@ public void testParseCellProcessors7() throws Exception {
+ "Optional, StrMinMax(1, 20), ParseDate('dd/MM/yyyy')";
final CellProcessor[] cellProcessors = CellProcessorConfig.parseCellProcessors(val);
System.out.printf("Resolved cell processors: %s%n", Arrays.toString(cellProcessors));
Assert.assertEquals(7, cellProcessors.length);
Assert.assertEquals(null, cellProcessors[0]);
Assert.assertEquals(Optional.class, cellProcessors[1].getClass());
Assert.assertEquals(ParseLong.class, cellProcessors[2].getClass());
Assert.assertEquals(NotNull.class, cellProcessors[3].getClass());
Assert.assertEquals(ParseDate.class, cellProcessors[4].getClass());
Assert.assertEquals(StrMinMax.class, cellProcessors[5].getClass());
Assert.assertEquals(Optional.class, cellProcessors[6].getClass());
assertEquals(7, cellProcessors.length);
assertEquals(null, cellProcessors[0]);
assertEquals(Optional.class, cellProcessors[1].getClass());
assertEquals(ParseLong.class, cellProcessors[2].getClass());
assertEquals(NotNull.class, cellProcessors[3].getClass());
assertEquals(ParseDate.class, cellProcessors[4].getClass());
assertEquals(StrMinMax.class, cellProcessors[5].getClass());
assertEquals(Optional.class, cellProcessors[6].getClass());
}
}
41 changes: 21 additions & 20 deletions src/test/java/org/jberet/support/io/CsvItemReaderWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import java.util.concurrent.TimeUnit;

import org.jberet.runtime.JobExecutionImpl;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import jakarta.batch.operations.JobOperator;
import jakarta.batch.runtime.BatchRuntime;
import jakarta.batch.runtime.BatchStatus;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CsvItemReaderWriterTest {
static final String jobName = "org.jberet.support.io.CsvReaderTest";
Expand Down Expand Up @@ -151,7 +152,7 @@ private void testReadWrite0(final String resource, final String writeResource,
final long jobExecutionId = jobOperator.start(jobName, params);
final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
validate(writeResourceFile, expect, forbid);
}

Expand All @@ -178,37 +179,37 @@ public void testInvalidWriteResource() throws Exception {
final long jobExecutionId = jobOperator.start(jobName, params);
final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
Assert.assertEquals(BatchStatus.FAILED, jobExecution.getBatchStatus());
assertEquals(BatchStatus.FAILED, jobExecution.getBatchStatus());
}

@Test @Ignore("restore it if needed")
@Test @Disabled("restore it if needed")
public void testStringsToInts() throws Exception {
final String[] ss = {"1", "2", "3", "4"};
int[] ints = CsvItemReader.convertToIntParams(ss, 0, ss.length);
System.out.printf("ints: %s%n", Arrays.toString(ints));
Assert.assertEquals(4, ints.length);
Assert.assertEquals(1, ints[0]);
Assert.assertEquals(2, ints[1]);
Assert.assertEquals(3, ints[2]);
Assert.assertEquals(4, ints[3]);
assertEquals(4, ints.length);
assertEquals(1, ints[0]);
assertEquals(2, ints[1]);
assertEquals(3, ints[2]);
assertEquals(4, ints[3]);

ints = CsvItemReader.convertToIntParams(ss, 1, ss.length - 1);
System.out.printf("ints: %s%n", Arrays.toString(ints));
Assert.assertEquals(3, ints.length);
Assert.assertEquals(2, ints[0]);
Assert.assertEquals(3, ints[1]);
Assert.assertEquals(4, ints[2]);
assertEquals(3, ints.length);
assertEquals(2, ints[0]);
assertEquals(3, ints[1]);
assertEquals(4, ints[2]);

ints = CsvItemReader.convertToIntParams(ss, 2, ss.length - 2);
System.out.printf("ints: %s%n", Arrays.toString(ints));
Assert.assertEquals(2, ints.length);
Assert.assertEquals(3, ints[0]);
Assert.assertEquals(4, ints[1]);
assertEquals(2, ints.length);
assertEquals(3, ints[0]);
assertEquals(4, ints[1]);

ints = CsvItemReader.convertToIntParams(ss, 3, ss.length - 3);
System.out.printf("ints: %s%n", Arrays.toString(ints));
Assert.assertEquals(1, ints.length);
Assert.assertEquals(4, ints[0]);
assertEquals(1, ints.length);
assertEquals(4, ints[0]);
}

static Properties createParams(final String key, final String val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
import java.util.concurrent.TimeUnit;

import org.jberet.runtime.JobExecutionImpl;
import org.junit.Assert;
import org.junit.Test;

import jakarta.batch.api.chunk.AbstractItemWriter;
import jakarta.batch.operations.JobOperator;
import jakarta.batch.runtime.BatchRuntime;
import jakarta.batch.runtime.BatchStatus;
import jakarta.enterprise.context.Dependent;
import jakarta.inject.Named;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public final class CsvReadersPerformanceTest {
private static final String superCsvjobName = "org.jberet.support.io.superCsvTest";
Expand Down Expand Up @@ -106,7 +107,7 @@ private void testReadWrite0(final String jobName, final Properties params) throw
final long jobExecutionId = jobOperator.start(jobName, params);
final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
jobExecution.awaitTermination(CsvItemReaderWriterTest.waitTimeoutMinutes, TimeUnit.MINUTES);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
final long duration = System.currentTimeMillis() - startTime;
System.out.printf("%s\t\t%s seconds%n", jobName, duration / 1000.0);
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/org/jberet/support/io/DynamoDbHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;


class DynamoDbHelper {
static final String ENDPOINT_URI = "http://localhost:8000";
Expand All @@ -46,7 +47,7 @@ public static boolean isDynamoDbLocalAvailable() {
}

public static void assumeDynamoDbLocalAvailable() {
assumeTrue("DynamoDB local should be running and listening at " + ENDPOINT_URI, DynamoDbHelper.isDynamoDbLocalAvailable());
assumeTrue(DynamoDbHelper.isDynamoDbLocalAvailable(), "DynamoDB local should be running and listening at " + ENDPOINT_URI);
}

public void setUp() {
Expand Down
Loading

0 comments on commit 10644cd

Please sign in to comment.