() {
@Override
@@ -29,6 +30,7 @@ public class ItemRecoveryHandlerTests extends TestCase {
}
};
+ @Test
public void testRecover() throws Exception {
try {
recoverer.recover(new Object[] { "foo" }, null);
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java
index 1ad3fbf2d..734d6ea4c 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java
@@ -18,15 +18,16 @@ package org.springframework.batch.item.adapter;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.InvocationTargetThrowableWrapper;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests for {@link AbstractMethodInvokingDelegator}
@@ -43,7 +44,7 @@ public class AbstractDelegatorTests {
private Foo foo = new Foo("foo", 1);
- @Before
+ @BeforeEach
public void setUp() throws Exception {
delegator.setTargetObject(foo);
delegator.setArguments(null);
@@ -97,6 +98,7 @@ public class AbstractDelegatorTests {
* Regular use - calling methods directly and via delegator leads to same results
*/
@Test
+ @Disabled // FIXME
public void testDelegationWithMultipleArguments() throws Exception {
FooService fooService = new FooService();
delegator.setTargetObject(fooService);
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java
index cbe13b7bb..75262ff23 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2021 the original author or authors.
+ * Copyright 2010-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,13 +15,13 @@
*/
package org.springframework.batch.item.adapter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class HippyMethodInvokerTests {
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemProcessorAdapterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemProcessorAdapterTests.java
index aa79a63c2..b9594be5f 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemProcessorAdapterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemProcessorAdapterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 the original author or authors.
+ * Copyright 2009-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,22 +15,19 @@
*/
package org.springframework.batch.item.adapter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.sample.Foo;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* Tests for {@link ItemProcessorAdapter}.
*
* @author Dave Syer
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "delegating-item-processor.xml")
+@SpringJUnitConfig(locations = "delegating-item-processor.xml")
public class ItemProcessorAdapterTests {
@Autowired
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemReaderAdapterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemReaderAdapterTests.java
index 2d51e8c56..bedf65d21 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemReaderAdapterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemReaderAdapterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 the original author or authors.
+ * Copyright 2008-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,26 +15,23 @@
*/
package org.springframework.batch.item.adapter;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.item.sample.Foo;
import org.springframework.batch.item.sample.FooService;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.beans.factory.annotation.Autowired;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
/**
* Tests for {@link ItemReaderAdapter}.
*
* @author Robert Kasanicky
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "delegating-item-provider.xml")
+@SpringJUnitConfig(locations = "delegating-item-provider.xml")
public class ItemReaderAdapterTests {
@Autowired
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemWriterAdapterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemWriterAdapterTests.java
index 375990cff..1a5842142 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemWriterAdapterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/ItemWriterAdapterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 the original author or authors.
+ * Copyright 2008-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,29 +15,26 @@
*/
package org.springframework.batch.item.adapter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.sample.Foo;
import org.springframework.batch.item.sample.FooService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* Tests for {@link ItemWriterAdapter}.
*
* @author Robert Kasanicky
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "delegating-item-writer.xml")
+@SpringJUnitConfig(locations = "delegating-item-writer.xml")
public class ItemWriterAdapterTests {
@Autowired
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemProcessorIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemProcessorIntegrationTests.java
index 398a80358..55e8c4238 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemProcessorIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemProcessorIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2018 the original author or authors.
+ * Copyright 2008-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,17 +15,15 @@
*/
package org.springframework.batch.item.adapter;
-import static org.junit.Assert.*;
-import org.junit.runner.RunWith;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import org.springframework.batch.item.sample.Foo;
import org.springframework.batch.item.sample.FooService;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -34,8 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author Robert Kasanicky
* @author Mahmoud Ben Hassine
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "pe-delegating-item-writer.xml")
+@SpringJUnitConfig(locations = "pe-delegating-item-writer.xml")
public class PropertyExtractingDelegatingItemProcessorIntegrationTests {
@Autowired
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemReaderTests.java
index 83f49f02c..1e698c79f 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemReaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 the original author or authors.
+ * Copyright 2012-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.
@@ -19,13 +19,14 @@ package org.springframework.batch.item.amqp;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -37,9 +38,9 @@ import static org.junit.Assert.fail;
*/
public class AmqpItemReaderTests {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullAmqpTemplate() {
- new AmqpItemReader(null);
+ assertThrows(IllegalArgumentException.class, () -> new AmqpItemReader(null));
}
@Test
@@ -96,12 +97,12 @@ public class AmqpItemReaderTests {
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullItemType() {
final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
final AmqpItemReader amqpItemReader = new AmqpItemReader<>(amqpTemplate);
- amqpItemReader.setItemType(null);
+ assertThrows(IllegalArgumentException.class, () -> amqpItemReader.setItemType(null));
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemWriterTests.java
index 980148064..f237f888e 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemWriterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/AmqpItemWriterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 the original author or authors.
+ * Copyright 2012-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.
@@ -16,9 +16,10 @@
package org.springframework.batch.item.amqp;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.amqp.core.AmqpTemplate;
import java.util.Arrays;
@@ -33,9 +34,9 @@ import java.util.Arrays;
*/
public class AmqpItemWriterTests {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullAmqpTemplate() {
- new AmqpItemWriter(null);
+ assertThrows(IllegalArgumentException.class, () -> new AmqpItemWriter(null));
}
@Test
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemReaderBuilderTests.java
index 8acb1b1c4..ff2b523b4 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemReaderBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-2021 the original author or authors.
+ * Copyright 2017-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.
@@ -16,28 +16,25 @@
package org.springframework.batch.item.amqp.builder;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.batch.item.amqp.AmqpItemReader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* @author Glenn Renfro
*/
+@ExtendWith(MockitoExtension.class)
public class AmqpItemReaderBuilderTests {
- @Rule
- public MockitoRule rule = MockitoJUnit.rule().silent();
-
@Mock
AmqpTemplate amqpTemplate;
@@ -79,8 +76,8 @@ public class AmqpItemReaderBuilderTests {
fail("IllegalArgumentException should have been thrown");
}
catch (IllegalArgumentException iae) {
- assertEquals("IllegalArgumentException message did not match the expected result.",
- "amqpTemplate is required.", iae.getMessage());
+ assertEquals("amqpTemplate is required.", iae.getMessage(),
+ "IllegalArgumentException message did not match the expected result.");
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemWriterBuilderTests.java
index 5f4007dce..bf700d09a 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemWriterBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/amqp/builder/AmqpItemWriterBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 the original author or authors.
+ * Copyright 2017-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.
@@ -18,14 +18,14 @@ package org.springframework.batch.item.amqp.builder;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.batch.item.amqp.AmqpItemWriter;
import static org.aspectj.bridge.MessageUtil.fail;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -41,8 +41,8 @@ public class AmqpItemWriterBuilderTests {
fail("IllegalArgumentException should have been thrown");
}
catch (IllegalArgumentException iae) {
- assertEquals("IllegalArgumentException message did not match the expected result.",
- "amqpTemplate is required.", iae.getMessage());
+ assertEquals("amqpTemplate is required.", iae.getMessage(),
+ "IllegalArgumentException message did not match the expected result.");
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemReaderTests.java
index c8c24676e..8909ee97b 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemReaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2019-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.
@@ -17,12 +17,14 @@
package org.springframework.batch.item.avro;
import org.apache.avro.generic.GenericRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.avro.example.User;
import org.springframework.batch.item.avro.support.AvroItemReaderTestSupport;
import org.springframework.core.io.ClassPathResource;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* @author David Turanski
*/
@@ -68,14 +70,16 @@ public class AvroItemReaderTests extends AvroItemReaderTestSupport {
verify(itemReader, plainOldUsers());
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void dataResourceDoesNotExist() {
- new AvroItemReader(new ClassPathResource("doesnotexist"), schemaResource);
+ assertThrows(IllegalStateException.class,
+ () -> new AvroItemReader(new ClassPathResource("doesnotexist"), schemaResource));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void schemaResourceDoesNotExist() {
- new AvroItemReader(dataResource, new ClassPathResource("doesnotexist"));
+ assertThrows(IllegalStateException.class,
+ () -> new AvroItemReader(dataResource, new ClassPathResource("doesnotexist")));
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemWriterTests.java
index 7c2cce235..4c3168372 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemWriterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/AvroItemWriterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2019-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.
@@ -19,13 +19,15 @@ package org.springframework.batch.item.avro;
import java.io.ByteArrayOutputStream;
import org.apache.avro.generic.GenericRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.avro.example.User;
import org.springframework.batch.item.avro.support.AvroItemWriterTestSupport;
import org.springframework.core.io.WritableResource;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* @author David Turanski
* @author Mahmoud Ben Hassine
@@ -87,15 +89,16 @@ public class AvroItemWriterTests extends AvroItemWriterTestSupport {
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void shouldFailWitNoOutput() {
- new AvroItemWriter<>(null, this.schemaResource, User.class).open(new ExecutionContext());
-
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemWriter<>(null, this.schemaResource, User.class).open(new ExecutionContext()));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void shouldFailWitNoType() {
- new AvroItemWriter<>(this.output, this.schemaResource, null).open(new ExecutionContext());
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemWriter<>(this.output, this.schemaResource, null).open(new ExecutionContext()));
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemReaderBuilderTests.java
index 034baa975..336bab70b 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemReaderBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2019-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.
@@ -17,12 +17,14 @@
package org.springframework.batch.item.avro.builder;
import org.apache.avro.generic.GenericRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.avro.AvroItemReader;
import org.springframework.batch.item.avro.example.User;
import org.springframework.batch.item.avro.support.AvroItemReaderTestSupport;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* @author David Turanski
*/
@@ -66,20 +68,22 @@ public class AvroItemReaderBuilderTests extends AvroItemReaderTestSupport {
verify(avroItemReader, avroGeneratedUsers());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void itemReaderWithNoSchemaStringShouldFail() {
- new AvroItemReaderBuilder().schema("").resource(dataResource).build();
-
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemReaderBuilder().schema("").resource(dataResource).build());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void itemReaderWithPartialConfigurationShouldFail() {
- new AvroItemReaderBuilder().resource(dataResource).build();
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemReaderBuilder().resource(dataResource).build());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void itemReaderWithNoInputsShouldFail() {
- new AvroItemReaderBuilder().schema(schemaResource).build();
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemReaderBuilder().schema(schemaResource).build());
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java
index 9c7425b12..e3d194846 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2019-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.
@@ -19,7 +19,7 @@ package org.springframework.batch.item.avro.builder;
import java.io.ByteArrayOutputStream;
import org.apache.avro.generic.GenericRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.avro.AvroItemWriter;
@@ -27,6 +27,8 @@ import org.springframework.batch.item.avro.example.User;
import org.springframework.batch.item.avro.support.AvroItemWriterTestSupport;
import org.springframework.core.io.WritableResource;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* @author David Turanski
*/
@@ -90,18 +92,16 @@ public class AvroItemWriterBuilderTests extends AvroItemWriterTestSupport {
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void shouldFailWitNoOutput() {
-
- new AvroItemWriterBuilder().type(GenericRecord.class).build();
-
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemWriterBuilder().type(GenericRecord.class).build());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void shouldFailWitNoType() {
-
- new AvroItemWriterBuilder<>().resource(output).schema(schemaResource).build();
-
+ assertThrows(IllegalArgumentException.class,
+ () -> new AvroItemWriterBuilder<>().resource(output).schema(schemaResource).build());
}
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/GemfireItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/GemfireItemWriterTests.java
index fad7cb850..3c4b0930e 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/GemfireItemWriterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/GemfireItemWriterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2021 the original author or authors.
+ * Copyright 2013-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,35 +15,31 @@
*/
package org.springframework.batch.item.data;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.batch.item.SpELItemKeyMapper;
import org.springframework.data.gemfire.GemfireTemplate;
import org.springframework.core.convert.converter.Converter;
-@SuppressWarnings("serial")
+@ExtendWith(MockitoExtension.class)
public class GemfireItemWriterTests {
- @Rule
- public MockitoRule rule = MockitoJUnit.rule().silent();
-
private GemfireItemWriter writer;
@Mock
private GemfireTemplate template;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
writer = new GemfireItemWriter<>();
writer.setTemplate(template);
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemReaderTests.java
index 936150ca8..d73ec32db 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemReaderTests.java
@@ -20,13 +20,12 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
@@ -34,10 +33,10 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Query;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+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;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@@ -45,11 +44,9 @@ import static org.mockito.Mockito.when;
* @author Michael Minella
* @author Parikshit Dutta
*/
+@ExtendWith(MockitoExtension.class)
public class MongoItemReaderTests {
- @Rule
- public MockitoRule rule = MockitoJUnit.rule().silent();
-
private MongoItemReader reader;
@Mock
@@ -57,7 +54,7 @@ public class MongoItemReaderTests {
private Map sortOptions;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
reader = new MongoItemReader<>();
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java
index 0fe701ab6..451d20ab9 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2021 the original author or authors.
+ * Copyright 2013-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.
@@ -21,10 +21,12 @@ import java.util.Collections;
import java.util.List;
import org.bson.Document;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
+
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verifyNoInteractions;
@@ -33,8 +35,8 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.never;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mongodb.core.BulkOperations;
@@ -50,8 +52,8 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -61,11 +63,9 @@ import static org.mockito.ArgumentMatchers.eq;
* @author Parikshit Dutta
* @author Mahmoud Ben Hassine
*/
+@ExtendWith(MockitoExtension.class)
public class MongoItemWriterTests {
- @Rule
- public MockitoRule rule = MockitoJUnit.rule().silent();
-
private MongoItemWriter