list = new ArrayList<>(Arrays.asList(new String[] { "a", "b", "c" }));
reader = new ListItemReader<>(list);
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ScriptItemProcessorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ScriptItemProcessorTests.java
index 2beaaadae7..db2d1a46da 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ScriptItemProcessorTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ScriptItemProcessorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 the original author or authors.
+ * Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.springframework.batch.item.support;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.scripting.bsh.BshScriptEvaluator;
@@ -28,8 +28,9 @@
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
*
@@ -43,7 +44,7 @@ public class ScriptItemProcessorTests {
private static List availableLanguages = new ArrayList<>();
- @BeforeClass
+ @BeforeAll
public static void populateAvailableEngines() {
List scriptEngineFactories = new ScriptEngineManager().getEngineFactories();
@@ -60,7 +61,7 @@ public void testJavascriptScriptSourceSimple() throws Exception {
scriptItemProcessor.setScriptSource("item.toUpperCase();", "javascript");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -72,7 +73,7 @@ public void testJavascriptScriptSourceFunction() throws Exception {
"javascript");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -83,7 +84,7 @@ public void testJRubyScriptSourceSimple() throws Exception {
scriptItemProcessor.setScriptSource("$item.upcase", "jruby");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -94,7 +95,7 @@ public void testJRubyScriptSourceMethod() throws Exception {
scriptItemProcessor.setScriptSource("def process(item) $item.upcase end \n process($item)", "jruby");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -105,7 +106,7 @@ public void testBeanShellScriptSourceSimple() throws Exception {
scriptItemProcessor.setScriptSource("item.toUpperCase();", "bsh");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -117,7 +118,7 @@ public void testBeanShellScriptSourceFunction() throws Exception {
"bsh");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -128,7 +129,7 @@ public void testGroovyScriptSourceSimple() throws Exception {
scriptItemProcessor.setScriptSource("item.toUpperCase();", "groovy");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -140,7 +141,7 @@ public void testGroovyScriptSourceMethod() throws Exception {
"groovy");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -153,7 +154,7 @@ public void testJavascriptScriptSimple() throws Exception {
scriptItemProcessor.setScript(resource);
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -166,35 +167,34 @@ public void testItemBinding() throws Exception {
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", true, scriptItemProcessor.process("Hello World"));
+ assertEquals(true, scriptItemProcessor.process("Hello World"), "Incorrect transformed value");
}
- @Test(expected = IllegalStateException.class)
- public void testNoScriptSet() throws Exception {
+ @Test
+ public void testNoScriptSet() {
ScriptItemProcessor scriptItemProcessor = new ScriptItemProcessor<>();
- scriptItemProcessor.afterPropertiesSet();
+ assertThrows(IllegalStateException.class, scriptItemProcessor::afterPropertiesSet);
}
- @Test(expected = IllegalStateException.class)
- public void testScriptSourceAndScriptResourceSet() throws Exception {
+ @Test
+ public void testScriptSourceAndScriptResourceSet() {
ScriptItemProcessor scriptItemProcessor = new ScriptItemProcessor<>();
scriptItemProcessor.setScriptSource("blah", "blah");
scriptItemProcessor.setScript(new ClassPathResource("blah"));
- scriptItemProcessor.afterPropertiesSet();
+ assertThrows(IllegalStateException.class, scriptItemProcessor::afterPropertiesSet);
}
- @Test(expected = IllegalStateException.class)
- public void testNoScriptSetWithoutInitBean() throws Exception {
+ @Test
+ public void testNoScriptSetWithoutInitBean() {
ScriptItemProcessor scriptItemProcessor = new ScriptItemProcessor<>();
- scriptItemProcessor.process("blah");
+ assertThrows(IllegalStateException.class, () -> scriptItemProcessor.process("blah"));
}
- @Test(expected = IllegalArgumentException.class)
- public void testScriptSourceWithNoLanguage() throws Exception {
+ @Test
+ public void testScriptSourceWithNoLanguage() {
ScriptItemProcessor scriptItemProcessor = new ScriptItemProcessor<>();
- scriptItemProcessor.setScriptSource("function process(item) { return item.toUpperCase(); } process(item);",
- null);
- scriptItemProcessor.afterPropertiesSet();
+ assertThrows(IllegalArgumentException.class, () -> scriptItemProcessor
+ .setScriptSource("function process(item) { return item.toUpperCase(); } process(item);", null));
}
@Test
@@ -207,7 +207,7 @@ public void testItemBindingNameChange() throws Exception {
"function process(param) { return param.toUpperCase(); } process(someOtherVarName);", "javascript");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -220,7 +220,7 @@ public void testBshScriptEvaluator() throws Exception {
"bsh");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
@Test
@@ -233,7 +233,7 @@ public void testGroovyScriptEvaluator() throws Exception {
"groovy");
scriptItemProcessor.afterPropertiesSet();
- assertEquals("Incorrect transformed value", "SS", scriptItemProcessor.process("ss"));
+ assertEquals("SS", scriptItemProcessor.process("ss"), "Incorrect transformed value");
}
private boolean languageExists(String engineName) {
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java
index 138a00445d..152514d1a0 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2019 the original author or authors.
+ * Copyright 2006-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.springframework.batch.item.support;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.lang.Nullable;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java
index 788d242583..986d9aadbf 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-2019 the original author or authors.
+ * Copyright 2015-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,14 @@
*/
package org.springframework.batch.item.support;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashSet;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamReader;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java
index 2f355ae76c..86bf945643 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 the original author or authors.
+ * Copyright 2020-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.springframework.batch.item.support;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.InitializingBean;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java
index 4a11f7da33..abe95f77f9 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 the original author or authors.
+ * Copyright 2006-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import org.springframework.batch.item.support.ListItemReader;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
import org.springframework.transaction.PlatformTransactionManager;
@@ -30,17 +30,22 @@
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
-public class TransactionAwareListItemReaderTests extends TestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class TransactionAwareListItemReaderTests {
private ListItemReader reader;
- @Override
+ @BeforeEach
protected void setUp() throws Exception {
- super.setUp();
reader = new ListItemReader<>(
TransactionAwareProxyFactory.createTransactionalList(Arrays.asList("a", "b", "c")));
}
+ @Test
public void testNext() throws Exception {
assertEquals("a", reader.read());
assertEquals("b", reader.read());
@@ -48,6 +53,7 @@ public void testNext() throws Exception {
assertEquals(null, reader.read());
}
+ @Test
public void testCommit() throws Exception {
PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
final List