From 5bce15288a0bd06a0d69c02ec3eaf1d432baddaa Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Wed, 13 Apr 2022 11:17:47 +0200 Subject: [PATCH] Change Resource to WritableResource in file-based item writers Resolves #756 --- .../ResourceAwareItemWriterItemStream.java | 8 +++---- .../builder/FlatFileItemWriterBuilder.java | 12 +++++----- .../batch/item/json/JsonFileItemWriter.java | 8 +++---- .../builder/JsonFileItemWriterBuilder.java | 12 +++++----- .../item/support/AbstractFileItemWriter.java | 12 +++++----- .../batch/item/xml/StaxEventItemWriter.java | 8 +++---- .../builder/StaxEventItemWriterBuilder.java | 12 +++++----- .../item/file/FlatFileItemWriterTests.java | 6 ++--- .../FlatFileItemWriterBuilderTests.java | 23 ++++++++++--------- .../item/json/JsonFileItemWriterTests.java | 6 ++--- .../JsonFileItemWriterBuilderTests.java | 6 ++--- ...bstractStaxEventWriterItemWriterTests.java | 5 ++-- .../xml/Jaxb2NamespaceMarshallingTests.java | 5 ++-- .../item/xml/StaxEventItemWriterTests.java | 8 +++---- ...TransactionalStaxEventItemWriterTests.java | 6 ++--- .../StaxEventItemWriterBuilderTests.java | 6 ++--- 16 files changed, 73 insertions(+), 70 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourceAwareItemWriterItemStream.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourceAwareItemWriterItemStream.java index da4296a458..e8592ce904 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourceAwareItemWriterItemStream.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourceAwareItemWriterItemStream.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. @@ -19,15 +19,15 @@ import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemStreamWriter; import org.springframework.batch.item.ItemWriter; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; /** * Interface for {@link ItemWriter}s that implement {@link ItemStream} and write - * output to {@link Resource}. + * output to {@link WritableResource}. * * @author Robert Kasanicky */ public interface ResourceAwareItemWriterItemStream extends ItemStreamWriter { - void setResource(Resource resource); + void setResource(WritableResource resource); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilder.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilder.java index db7d562282..6dc0b0cbd6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilder.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-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. @@ -31,7 +31,7 @@ import org.springframework.batch.item.file.transform.FieldExtractor; import org.springframework.batch.item.file.transform.FormatterLineAggregator; import org.springframework.batch.item.file.transform.LineAggregator; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.util.Assert; /** @@ -48,7 +48,7 @@ public class FlatFileItemWriterBuilder { protected Log logger = LogFactory.getLog(getClass()); - private Resource resource; + private WritableResource resource; private boolean forceSync = false; @@ -108,13 +108,13 @@ public FlatFileItemWriterBuilder name(String name) { } /** - * The {@link Resource} to be used as output. + * The {@link WritableResource} to be used as output. * * @param resource the output of the writer. * @return The current instance of the builder. - * @see FlatFileItemWriter#setResource(Resource) + * @see FlatFileItemWriter#setResource(WritableResource) */ - public FlatFileItemWriterBuilder resource(Resource resource) { + public FlatFileItemWriterBuilder resource(WritableResource resource) { this.resource = resource; return this; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonFileItemWriter.java index 7724e23944..c4f8eae1f9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonFileItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-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,13 +20,13 @@ import java.util.List; import org.springframework.batch.item.support.AbstractFileItemWriter; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; /** * Item writer that writes data in json format to an output file. The location - * of the output file is defined by a {@link Resource} and must represent a + * of the output file is defined by a {@link WritableResource} and must represent a * writable file. Items are transformed to json format using a * {@link JsonObjectMarshaller}. Items will be enclosed in a json array as follows: * @@ -61,7 +61,7 @@ public class JsonFileItemWriter extends AbstractFileItemWriter { * @param resource to write json data to * @param jsonObjectMarshaller used to marshal object into json representation */ - public JsonFileItemWriter(Resource resource, JsonObjectMarshaller jsonObjectMarshaller) { + public JsonFileItemWriter(WritableResource resource, JsonObjectMarshaller jsonObjectMarshaller) { Assert.notNull(resource, "resource must not be null"); Assert.notNull(jsonObjectMarshaller, "json object marshaller must not be null"); setResource(resource); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilder.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilder.java index 39dae114ca..c618b84d00 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilder.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-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,7 +20,7 @@ import org.springframework.batch.item.file.FlatFileHeaderCallback; import org.springframework.batch.item.json.JsonFileItemWriter; import org.springframework.batch.item.json.JsonObjectMarshaller; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.util.Assert; /** @@ -32,7 +32,7 @@ */ public class JsonFileItemWriterBuilder { - private Resource resource; + private WritableResource resource; private JsonObjectMarshaller jsonObjectMarshaller; private FlatFileHeaderCallback headerCallback; private FlatFileFooterCallback footerCallback; @@ -119,13 +119,13 @@ public JsonFileItemWriterBuilder jsonObjectMarshaller(JsonObjectMarshaller } /** - * The {@link Resource} to be used as output. + * The {@link WritableResource} to be used as output. * * @param resource the output of the writer. * @return The current instance of the builder. - * @see JsonFileItemWriter#setResource(Resource) + * @see JsonFileItemWriter#setResource(WritableResource) */ - public JsonFileItemWriterBuilder resource(Resource resource) { + public JsonFileItemWriterBuilder resource(WritableResource resource) { this.resource = resource; return this; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractFileItemWriter.java index 9ed8fb50fb..1b2911154f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractFileItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2021 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. @@ -41,13 +41,13 @@ import org.springframework.batch.item.util.FileUtils; import org.springframework.batch.support.transaction.TransactionAwareBufferedWriter; import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.util.Assert; /** * Base class for item writers that write data to a file or stream. * This class provides common features like restart, force sync, append etc. - * The location of the output file is defined by a {@link Resource} which must + * The location of the output file is defined by a {@link WritableResource} which must * represent a writable file.
* * Uses buffered writer to improve performance.
@@ -81,7 +81,7 @@ public abstract class AbstractFileItemWriter extends AbstractItemStreamItemWr private static final String RESTART_DATA_NAME = "current.count"; - private Resource resource; + private WritableResource resource; protected OutputState state = null; @@ -128,12 +128,12 @@ public void setLineSeparator(String lineSeparator) { } /** - * Setter for resource. Represents a file that can be written. + * Setter for a writable resource. Represents a file that can be written. * * @param resource the resource to be written to */ @Override - public void setResource(Resource resource) { + public void setResource(WritableResource resource) { this.resource = resource; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java index 7405c0daf1..c012a204c4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2020 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. @@ -51,7 +51,7 @@ import org.springframework.batch.item.xml.stax.UnopenedElementClosingEventWriter; import org.springframework.batch.support.transaction.TransactionAwareBufferedWriter; import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.oxm.Marshaller; import org.springframework.oxm.XmlMappingException; @@ -103,7 +103,7 @@ public class StaxEventItemWriter extends AbstractItemStreamItemWriter impl private static final String WRITE_STATISTICS_NAME = "record.count"; // file system resource - private Resource resource; + private WritableResource resource; // xml marshaller private Marshaller marshaller; @@ -177,7 +177,7 @@ public StaxEventItemWriter() { * @param resource the output file */ @Override - public void setResource(Resource resource) { + public void setResource(WritableResource resource) { this.resource = resource; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilder.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilder.java index 02050a7b23..15dc154bc5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilder.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 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. @@ -19,7 +19,7 @@ import org.springframework.batch.item.xml.StaxEventItemWriter; import org.springframework.batch.item.xml.StaxWriterCallback; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.oxm.Marshaller; import org.springframework.util.Assert; @@ -34,7 +34,7 @@ */ public class StaxEventItemWriterBuilder { - private Resource resource; + private WritableResource resource; private Marshaller marshaller; @@ -80,13 +80,13 @@ public StaxEventItemWriterBuilder name(String name) { } /** - * The {@link Resource} to be used as output. + * The {@link WritableResource} to be used as output. * * @param resource the output from the writer * @return the current instance of the builder. - * @see StaxEventItemWriter#setResource(Resource) + * @see StaxEventItemWriter#setResource(WritableResource) */ - public StaxEventItemWriterBuilder resource(Resource resource) { + public StaxEventItemWriterBuilder resource(WritableResource resource) { this.resource = resource; return this; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index 4dccfde192..24231672db 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.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. @@ -39,7 +39,7 @@ import org.springframework.batch.item.file.transform.PassThroughLineAggregator; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; @@ -838,7 +838,7 @@ public String aggregate(String item) { * If append=true a new output file should still be created on the first run (not restart). */ public void testAppendToNotYetExistingFile() throws Exception { - Resource toBeCreated = new FileSystemResource("target/FlatFileItemWriterTests.out"); + WritableResource toBeCreated = new FileSystemResource("target/FlatFileItemWriterTests.out"); outputFile = toBeCreated.getFile(); //enable easy content reading and auto-delete the file diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilderTests.java index b6cb2afa57..888ad363d9 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemWriterBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-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. @@ -30,6 +30,7 @@ import org.springframework.batch.item.file.transform.PassThroughLineAggregator; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.test.util.ReflectionTestUtils; import static org.junit.Assert.assertEquals; @@ -55,7 +56,7 @@ public void testMissingLineAggregator() { @Test(expected = IllegalStateException.class) public void testMultipleLineAggregators() throws IOException { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); new FlatFileItemWriterBuilder() .name("itemWriter") @@ -72,7 +73,7 @@ public void testMultipleLineAggregators() throws IOException { @Test public void test() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -98,7 +99,7 @@ public void test() throws Exception { @Test public void testDelimitedOutputWithDefaultDelimiter() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -125,7 +126,7 @@ public void testDelimitedOutputWithDefaultDelimiter() throws Exception { @Test public void testDelimitedOutputWithEmptyDelimiter() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -153,7 +154,7 @@ public void testDelimitedOutputWithEmptyDelimiter() throws Exception { @Test public void testDelimitedOutputWithDefaultFieldExtractor() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -181,7 +182,7 @@ public void testDelimitedOutputWithDefaultFieldExtractor() throws Exception { @Test public void testDelimitedOutputWithCustomFieldExtractor() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -209,7 +210,7 @@ public void testDelimitedOutputWithCustomFieldExtractor() throws Exception { @Test public void testFormattedOutputWithDefaultFieldExtractor() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -237,7 +238,7 @@ public void testFormattedOutputWithDefaultFieldExtractor() throws Exception { @Test public void testFormattedOutputWithCustomFieldExtractor() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") @@ -265,7 +266,7 @@ public void testFormattedOutputWithCustomFieldExtractor() throws Exception { @Test public void testFlags() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); String encoding = Charset.defaultCharset().name(); @@ -287,7 +288,7 @@ public void testFlags() throws Exception { @Test public void testFlagsWithEncoding() throws Exception { - Resource output = new FileSystemResource(File.createTempFile("foo", "txt")); + WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt")); String encoding = "UTF-8"; FlatFileItemWriter writer = new FlatFileItemWriterBuilder() .name("foo") diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonFileItemWriterTests.java index c281d55f2c..b644dfb440 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonFileItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-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. @@ -29,7 +29,7 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; /** * @author Mahmoud Ben Hassine @@ -37,7 +37,7 @@ @RunWith(MockitoJUnitRunner.class) public class JsonFileItemWriterTests { - private Resource resource; + private WritableResource resource; @Mock private JsonObjectMarshaller jsonObjectMarshaller; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilderTests.java index 04472bd35b..977a9f45bf 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2021 the original author or authors. + * Copyright 2018-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. @@ -29,7 +29,7 @@ import org.springframework.batch.item.json.JsonFileItemWriter; import org.springframework.batch.item.json.JsonObjectMarshaller; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.test.util.ReflectionTestUtils; import static org.junit.Assert.assertEquals; @@ -41,7 +41,7 @@ */ public class JsonFileItemWriterBuilderTests { - private Resource resource; + private WritableResource resource; private JsonObjectMarshaller jsonObjectMarshaller; @Before diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java index bdd5d11f43..8d56a73ad7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.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. @@ -36,6 +36,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.oxm.Marshaller; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; @@ -53,7 +54,7 @@ public abstract class AbstractStaxEventWriterItemWriterTests { protected StaxEventItemWriter writer = new StaxEventItemWriter<>(); - private Resource resource; + private WritableResource resource; private File outputFile; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java index d19eacf165..3d14a07249 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.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. @@ -36,6 +36,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.oxm.Marshaller; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.transaction.TransactionStatus; @@ -55,7 +56,7 @@ public class Jaxb2NamespaceMarshallingTests { private StaxEventItemWriter writer = new StaxEventItemWriter<>(); - private Resource resource; + private WritableResource resource; private File outputFile; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java index b833f4f422..8d97fbbdb3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2021 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. @@ -34,7 +34,7 @@ import org.springframework.batch.item.WriterNotOpenException; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.oxm.Marshaller; import org.springframework.oxm.XmlMappingException; import org.springframework.oxm.jaxb.Jaxb2Marshaller; @@ -65,7 +65,7 @@ public class StaxEventItemWriterTests { private StaxEventItemWriter writer; // output file - private Resource resource; + private WritableResource resource; private ExecutionContext executionContext; @@ -479,7 +479,7 @@ public void write(XMLEventWriter writer) throws IOException { @Test public void testNonExistantResource() throws Exception { - Resource doesntExist = mock(Resource.class); + WritableResource doesntExist = mock(WritableResource.class); when(doesntExist.getFile()).thenReturn(File.createTempFile("arbitrary", null)); when(doesntExist.exists()).thenReturn(false); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java index a1422013f9..15781af411 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 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. @@ -35,7 +35,7 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.oxm.Marshaller; import org.springframework.oxm.XmlMappingException; import org.springframework.transaction.PlatformTransactionManager; @@ -56,7 +56,7 @@ public class TransactionalStaxEventItemWriterTests { private PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); // output file - private Resource resource; + private WritableResource resource; private ExecutionContext executionContext; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilderTests.java index 97886b134d..3a280bd023 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/builder/StaxEventItemWriterBuilderTests.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. @@ -35,7 +35,7 @@ import org.springframework.batch.item.xml.StaxEventItemWriter; import org.springframework.batch.support.transaction.TransactionAwareBufferedWriter; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; +import org.springframework.core.io.WritableResource; import org.springframework.oxm.Marshaller; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.test.util.ReflectionTestUtils; @@ -51,7 +51,7 @@ */ public class StaxEventItemWriterBuilderTests { - private Resource resource; + private WritableResource resource; private List items;