From cf68753006d9a0bf6512df708bb8b145d5f940ca Mon Sep 17 00:00:00 2001 From: dhgarrette Date: Tue, 27 Jan 2009 19:50:47 +0000 Subject: [PATCH] BATCH-1027: Created test class for PassThroughFieldExtractor --- .../PassThroughFieldExtractorTests.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractorTests.java diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractorTests.java new file mode 100644 index 000000000..6ec1e2be7 --- /dev/null +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractorTests.java @@ -0,0 +1,51 @@ +/* + * 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.item.file.transform; + +import static junit.framework.Assert.*; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +/** + * @author Dan Garrette + * @since 2.0 + */ +public class PassThroughFieldExtractorTests { + + @Test + public void testExtract_string() { + PassThroughFieldExtractor extractor = new PassThroughFieldExtractor(); + Object[] result = extractor.extract("abc"); + assertTrue(Arrays.equals(new Object[] { "abc" }, result)); + } + + @Test + public void testExtract_array() { + PassThroughFieldExtractor extractor = new PassThroughFieldExtractor(); + Object[] result = extractor.extract(new String[] { "a", "b", null, "d" }); + assertTrue(Arrays.equals(new Object[] { "a", "b", "", "d" }, result)); + } + + @Test + public void testExtract_collection() { + PassThroughFieldExtractor> extractor = new PassThroughFieldExtractor>(); + Object[] result = extractor.extract(Arrays.asList("a", "b", null, "d")); + assertTrue(Arrays.equals(new Object[] { "a", "b", "", "d" }, result)); + } +}