diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/AbstractBatchCriticalExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/AbstractBatchCriticalExceptionTests.java deleted file mode 100644 index ab3478e37..000000000 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/AbstractBatchCriticalExceptionTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2006-2007 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 - * - * http://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.io.exception; - -import junit.framework.TestCase; - -public abstract class AbstractBatchCriticalExceptionTests extends TestCase { - - public void testExceptionString() throws Exception { - Exception exception = getException("foo"); - assertEquals("foo", exception.getMessage()); - } - - public void testExceptionThrowable() throws Exception { - Exception exception = getException(new RuntimeException("foo")); - assertEquals("foo", exception.getCause().getMessage().substring(0, 3)); - } - - public void testExceptionStringThrowable() throws Exception { - Exception exception = getException("foo", new IllegalStateException()); - assertEquals("foo", exception.getMessage().substring(0, 3)); - } - - public abstract Exception getException(String msg) throws Exception; - - public abstract Exception getException(Throwable exception) throws Exception; - - public abstract Exception getException(String msg, Throwable t) throws Exception; - -} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java index 31ae3b00d..641e652f4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java @@ -18,7 +18,7 @@ package org.springframework.batch.io.exception; import org.springframework.batch.io.exception.BatchConfigurationException; -public class BatchConfigurationExceptionTests extends AbstractBatchCriticalExceptionTests { +public class BatchConfigurationExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { return new BatchConfigurationException(msg); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java index 54d1d1c1d..eb3392ef3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java @@ -17,7 +17,7 @@ package org.springframework.batch.io.exception; -public class BatchCriticalExceptionTests extends AbstractBatchCriticalExceptionTests { +public class BatchCriticalExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { return new BatchCriticalException(msg); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java index 102195791..91b27aa10 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java @@ -19,7 +19,7 @@ package org.springframework.batch.io.exception; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.io.exception.BatchEnvironmentException; -public class BatchEnvironmentExceptionTests extends AbstractBatchCriticalExceptionTests { +public class BatchEnvironmentExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { return new BatchEnvironmentException(msg); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/FlatFileParsingExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/FlatFileParsingExceptionTests.java new file mode 100644 index 000000000..f480d77e5 --- /dev/null +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/FlatFileParsingExceptionTests.java @@ -0,0 +1,41 @@ +/* + * Copyright 2006-2007 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 + * + * http://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.io.exception; + + +public class FlatFileParsingExceptionTests extends AbstractExceptionTests { + + public Exception getException(String msg) throws Exception { + return new FlatFileParsingException(msg, "bar"); + } + + public Exception getException(Throwable t) throws Exception { + return new FlatFileParsingException(t, "bar"); + } + + public Exception getException(String msg, Throwable t) throws Exception { + return new FlatFileParsingException(msg, t, "bar", 100); + } + + public void testMessageInputLineCount() throws Exception { + FlatFileParsingException exception = new FlatFileParsingException("foo", "bar", 100); + assertEquals("foo", exception.getMessage()); + assertEquals("bar", exception.getInput()); + assertEquals(100, exception.getLineNumber()); + } + +}