Merge pull request #83 from mdeinum/main
Polish testing and dependencies
This commit is contained in:
@@ -44,14 +44,14 @@
|
||||
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
<spring.batch.version>4.3.3</spring.batch.version>
|
||||
<spring.batch.version>4.3.4</spring.batch.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
|
||||
<!-- Test Dependencies -->
|
||||
<assertj.version>3.18.1</assertj.version>
|
||||
<junit.jupiter.version>5.7.1</junit.jupiter.version>
|
||||
<junit.jupiter.version>5.8.2</junit.jupiter.version>
|
||||
<log4j.version>2.13.3</log4j.version>
|
||||
<mockito.version>3.6.0</mockito.version>
|
||||
<mockito.version>3.11.0</mockito.version>
|
||||
</properties>
|
||||
|
||||
<developers>
|
||||
@@ -183,6 +183,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public interface Sheet extends Iterable<String[]>, AutoCloseable {
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the row as a {@code String[]}. Returns {@code null} if the row doesn't exist.
|
||||
* Get the row as a {@code String[]}. Returns {@code null} if the row doesn't exist. Can throw an
|
||||
* {@code UnsupportedOperationException} when the underlying implementation doesn't support indexed access to rows.
|
||||
* @param rowNumber the row number to read.
|
||||
* @return a {@code String[]} or {@code null}
|
||||
*/
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.batch.extensions.excel.streaming;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -42,7 +40,13 @@ import org.springframework.batch.extensions.excel.Sheet;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
|
||||
class StreamingSheet implements Sheet, Iterable<String[]>, Closeable {
|
||||
/**
|
||||
* {@code Sheet} implementation for Apache POI using the streaming event mode to read the rows.
|
||||
*
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class StreamingSheet implements Sheet {
|
||||
|
||||
private final Log logger = LogFactory.getLog(StreamingSheet.class);
|
||||
|
||||
@@ -143,7 +147,7 @@ class StreamingSheet implements Sheet, Iterable<String[]>, Closeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() throws Exception {
|
||||
try {
|
||||
this.reader.close();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.extensions.excel.poi;
|
||||
|
||||
import org.springframework.batch.extensions.excel.AbstractExcelItemReader;
|
||||
import org.springframework.batch.extensions.excel.AbstractExcelItemReaderTests;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class PoiItemReaderXlsxWithBlankLinesTests extends AbstractExcelItemReaderTests {
|
||||
|
||||
@Override
|
||||
protected void configureItemReader(AbstractExcelItemReader<String[]> itemReader) {
|
||||
itemReader.setResource(new ClassPathResource("player_with_blank_lines.xlsx"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractExcelItemReader<String[]> createExcelItemReader() {
|
||||
return new PoiItemReader<>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.extensions.excel.streaming;
|
||||
|
||||
import org.springframework.batch.extensions.excel.AbstractExcelItemReader;
|
||||
import org.springframework.batch.extensions.excel.AbstractExcelItemReaderTests;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class StreamingXlsxItemReaderWithBlankLinesTest extends AbstractExcelItemReaderTests {
|
||||
|
||||
@Override
|
||||
protected void configureItemReader(AbstractExcelItemReader<String[]> itemReader) {
|
||||
itemReader.setResource(new ClassPathResource("player_with_blank_lines.xlsx"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractExcelItemReader<String[]> createExcelItemReader() {
|
||||
return new StreamingXlsxItemReader<>();
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user