Author: pkluegl Date: Fri Jan 4 14:43:23 2019 New Revision: 1850370 URL: http://svn.apache.org/viewvc?rev=1850370&view=rev Log: no jira - rat
Modified: uima/ruta/trunk/ruta-core/pom.xml uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/resource/CSVTableTest.java Modified: uima/ruta/trunk/ruta-core/pom.xml URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/pom.xml?rev=1850370&r1=1850369&r2=1850370&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/pom.xml (original) +++ uima/ruta/trunk/ruta-core/pom.xml Fri Jan 4 14:43:23 2019 @@ -144,10 +144,13 @@ <exclude>src/test/resources/org/apache/uima/ruta/**/*.ruta</exclude> <!-- test data --> <exclude>src/test/resources/org/apache/uima/ruta/action/*.*</exclude> <!-- test data --> <exclude>src/test/resources/org/apache/uima/ruta/table2.csv</exclude> <!-- test data --> + <exclude>src/test/resources/org/apache/uima/ruta/resource/test_csvfile.csv</exclude> <!-- test data --> <exclude>src/test/resources/org/apache/uima/ruta/engine/*.html</exclude> <!-- test data --> <exclude>src/test/resources/META-INF/org.apache.uima.fit/types.txt</exclude> <!-- test data --> <exclude>src/main/resources/META-INF/org.apache.uima.fit/*.txt</exclude> <exclude>issuesFixed/**</exclude> <!-- generated --> + <exclude>input/**</exclude> <!-- temp test data --> + <exclude>TypeSystem.xml</exclude> <!-- temp test data --> <exclude>marker-file-identifying-*</exclude> </excludes> </configuration> Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/resource/CSVTableTest.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/resource/CSVTableTest.java?rev=1850370&r1=1850369&r2=1850370&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/resource/CSVTableTest.java (original) +++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/resource/CSVTableTest.java Fri Jan 4 14:43:23 2019 @@ -1,54 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.uima.ruta.resource; -import org.junit.Test; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; import java.io.IOException; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import org.junit.Test; public class CSVTableTest { - private static final String CUSTOM_SEPARATOR = "#|#"; + private static final String CUSTOM_SEPARATOR = "#|#"; - @Test - public void testDefaultLookup() throws IOException { - CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), CSVTable.DEFAULT_CSV_SEPARATOR); - checkValue(csvTable,0, 0, "this is the first line first column"); - checkValue(csvTable,0, 1, "ONE"); - checkValue(csvTable,1, 0, "this is the second line first column"); - checkValue(csvTable,1, 1, "TWO"); - checkValue(csvTable,2, 0, "this is the a line with custom"); - checkValue(csvTable,2, 1, " non default separator used#|#THREE"); - } - - @Test - public void testDefaultLookupWithEmptyColumn() throws IOException { - CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), CSVTable.DEFAULT_CSV_SEPARATOR); - checkValue(csvTable,3, 0, "line with empty column"); - checkValue(csvTable,3, 1, " "); // spacer added by table implementation - checkValue(csvTable,3, 2, "AFTER_EMPTY_COLUMN"); - } - - @Test - public void testLookupWithCustomSeparator() throws IOException { - CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), CUSTOM_SEPARATOR); - checkValue(csvTable,0, 0, "this is the first line first column;ONE"); - checkValue(csvTable,1, 0, "this is the second line first column;TWO"); - checkValue(csvTable,2, 0, "this is the a line with custom; non default separator used"); - checkValue(csvTable,2, 1, "THREE"); - } - - @Test - public void testLookupWithCustomSeparatorAndEmptyColumn() throws IOException { - CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), CUSTOM_SEPARATOR); - checkValue(csvTable,4, 0, "line with empty column custom separator"); - checkValue(csvTable,4, 1, " "); // spacer added by table implementation - checkValue(csvTable,4, 2, "AFTER_EMPTY_COLUMN2"); - } - - private void checkValue(CSVTable table, int row, int column, String expectedValue) { - String actualValue = table.getEntry(row, column); - assertThat(actualValue, is(expectedValue)); - } + @Test + public void testDefaultLookup() throws IOException { + CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), + CSVTable.DEFAULT_CSV_SEPARATOR); + checkValue(csvTable, 0, 0, "this is the first line first column"); + checkValue(csvTable, 0, 1, "ONE"); + checkValue(csvTable, 1, 0, "this is the second line first column"); + checkValue(csvTable, 1, 1, "TWO"); + checkValue(csvTable, 2, 0, "this is the a line with custom"); + checkValue(csvTable, 2, 1, " non default separator used#|#THREE"); + } + + @Test + public void testDefaultLookupWithEmptyColumn() throws IOException { + CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), + CSVTable.DEFAULT_CSV_SEPARATOR); + checkValue(csvTable, 3, 0, "line with empty column"); + checkValue(csvTable, 3, 1, " "); // spacer added by table implementation + checkValue(csvTable, 3, 2, "AFTER_EMPTY_COLUMN"); + } + + @Test + public void testLookupWithCustomSeparator() throws IOException { + CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), + CUSTOM_SEPARATOR); + checkValue(csvTable, 0, 0, "this is the first line first column;ONE"); + checkValue(csvTable, 1, 0, "this is the second line first column;TWO"); + checkValue(csvTable, 2, 0, "this is the a line with custom; non default separator used"); + checkValue(csvTable, 2, 1, "THREE"); + } + + @Test + public void testLookupWithCustomSeparatorAndEmptyColumn() throws IOException { + CSVTable csvTable = new CSVTable(CSVTable.class.getResourceAsStream("test_csvfile.csv"), + CUSTOM_SEPARATOR); + checkValue(csvTable, 4, 0, "line with empty column custom separator"); + checkValue(csvTable, 4, 1, " "); // spacer added by table implementation + checkValue(csvTable, 4, 2, "AFTER_EMPTY_COLUMN2"); + } + + private void checkValue(CSVTable table, int row, int column, String expectedValue) { + String actualValue = table.getEntry(row, column); + assertThat(actualValue, is(expectedValue)); + } } \ No newline at end of file