You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/17 12:37:10 UTC
[50/70] [abbrv] incubator-taverna-common-activities git commit:
taverna-spreadsheet-import-activity/
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetRowProcessor.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetRowProcessor.java
deleted file mode 100644
index 98bc466..0000000
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetRowProcessor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import java.util.SortedMap;
-
-/**
- * Interface for processing a row of data from a {@link ExcelSpreadsheetReader}.
- *
- * @author David Withers
- */
-public interface SpreadsheetRowProcessor {
-
- /**
- * Called by a {@link SpreadsheetReader} when all the cells of a row have been read.
- *
- * @param rowIndex
- * the index of the spreadsheet row
- * @param rowData
- * the map of column index -> cell data for the spreadsheet row
- */
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetUtils.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetUtils.java
deleted file mode 100644
index 970b3b9..0000000
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetUtils.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Utility functions for handling spreadsheet column labels and indexes.
- *
- * @author David Withers
- */
-public class SpreadsheetUtils {
-
- /**
- * Converts a column label to a (0 based) column index.
- * <p>
- * Label must match the format [A-Z]+ for result to be valid.
- *
- * @param column
- * the column label
- * @return the (0 based) column index
- */
- public static int getColumnIndex(String column) {
- int result = -1;
- char a = 'A' - 1;
- char[] chars = column.toCharArray();
- for (int i = 0; i < chars.length; i++) {
- int pos = (chars[i] - a);
- result += pos * Math.pow(26, chars.length - i - 1);
- }
- return result;
- }
-
- /**
- * Converts a (0 based) column index to a column label.
- *
- * @param column
- * the (0 based) column index
- * @return the column label
- */
- public static String getColumnLabel(int column) {
- StringBuilder result = new StringBuilder();
- while (column >= 0) {
- result.insert(0, (char) ((char) (column % 26) + 'A'));
- column = (column / 26) - 1;
- }
- return result.toString();
- }
-
- /**
- * Returns the port name for the column label.
- *
- * @param columnLabel
- * the column label
- * @param columnNameMapping
- * @return the port name for the column label
- */
- public static String getPortName(String columnLabel, JsonNode jsonNode) {
- String portName = columnLabel;
- if (jsonNode != null && jsonNode.has("columnNames")) {
- for (JsonNode mappingNode : jsonNode.get("columnNames")) {
- if (columnLabel.equals(mappingNode.get("column").textValue())) {
- portName = mappingNode.get("port").textValue();
- break;
- }
- }
- }
- return portName;
- }
-
- /**
- * Returns the port name for the column index.
- *
- * @param columnIndex
- * the column index
- * @param columnNameMapping
- * @return the port name for the column index
- */
- public static String getPortName(int columnIndex, JsonNode jsonNode) {
- return getPortName(getColumnLabel(columnIndex), jsonNode);
- }
-
- /**
- * @param jsonNode
- * @return
- */
- public static Range getRange(JsonNode jsonNode) {
- Range range = new Range();
- if (jsonNode != null) {
- if (jsonNode.has("start")) {
- range.setStart(jsonNode.get("start").intValue());
- }
- if (jsonNode.has("end")) {
- range.setEnd(jsonNode.get("end").intValue());
- }
- if (jsonNode.has("excludes")) {
- List<Range> excludes = new ArrayList<>();
- for (JsonNode rangeNode : jsonNode.get("excludes")) {
- excludes.add(getRange(rangeNode));
- }
- range.setExcludes(excludes);
- }
- }
- return range;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/java/net/sf/taverna/t2/activities/spreadsheet/package.html
----------------------------------------------------------------------
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/package.html b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/package.html
deleted file mode 100644
index 356b9b2..0000000
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Contains the activity classes required to include spreadsheet files within a DataFlow.
-</body>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
deleted file mode 100644
index e8dfa9a..0000000
--- a/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
+++ /dev/null
@@ -1 +0,0 @@
-net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthChecker
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/resources/META-INF/spring/spreadsheetimport-activity-context-osgi.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/spring/spreadsheetimport-activity-context-osgi.xml b/src/main/resources/META-INF/spring/spreadsheetimport-activity-context-osgi.xml
deleted file mode 100644
index 577b30b..0000000
--- a/src/main/resources/META-INF/spring/spreadsheetimport-activity-context-osgi.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:beans="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/osgi
- http://www.springframework.org/schema/osgi/spring-osgi.xsd">
-
- <service ref="spreadsheetImportActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
-
- <service ref="spreadsheetImportActivityFactory" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" />
-
- <reference id="edits" interface="net.sf.taverna.t2.workflowmodel.Edits" />
-
-</beans:beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/resources/META-INF/spring/spreadsheetimport-activity-context.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/spring/spreadsheetimport-activity-context.xml b/src/main/resources/META-INF/spring/spreadsheetimport-activity-context.xml
deleted file mode 100644
index 031ab52..0000000
--- a/src/main/resources/META-INF/spring/spreadsheetimport-activity-context.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="spreadsheetImportActivityHealthChecker" class="net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthChecker" />
-
- <bean id="spreadsheetImportActivityFactory" class="net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivityFactory">
- <property name="edits" ref="edits" />
- </bean>
-
-</beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/main/resources/schema.json
----------------------------------------------------------------------
diff --git a/src/main/resources/schema.json b/src/main/resources/schema.json
deleted file mode 100644
index b351137..0000000
--- a/src/main/resources/schema.json
+++ /dev/null
@@ -1,126 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-03/schema#",
- "id": "http://ns.taverna.org.uk/2010/activity/spreadsheet-import.schema.json",
- "title": "Spreadsheet import activity configuration",
- "type": "object",
- "properties": {
- "@context": {
- "description": "JSON-LD context for interpreting the configuration as RDF",
- "required": true,
- "enum": ["http://ns.taverna.org.uk/2010/activity/spreadsheet-import.context.json"]
- },
- "columnRange": {
- "title": "Column Range",
- "description": "The range of columns to be imported (e.g. columns 2 to 7)",
- "type": "object",
- "$ref": "#/definitions/range",
- "default": {"start": 0, "end": 1},
- "required": true
- },
- "rowRange": {
- "title": "Row Range",
- "description": "The range of rows to be imported (e.g. rows 1 to 15)",
- "type": "object",
- "$ref": "#/definitions/range",
- "default": {"start": 0, "end": -1},
- "required": true
- },
- "emptyCellValue": {
- "title": "Empty Cell Value",
- "description": "The value to use for empty cells. The default is \"\"",
- "type": "string",
- "default": "",
- "required": true
- },
- "columnNames": {
- "title": "Column Name Mapping",
- "description": "Mapping from column to port names",
- "type": "array",
- "elements": {
- "type": "object",
- "properties": {
- "column": {
- "title": "Column",
- "description": "The name of the column",
- "type": "string",
- "required": true
- },
- "port": {
- "title": "Port",
- "description": "The name of the port",
- "type": "string",
- "required": true
- }
- }
- },
- "required": false
- },
- "allRows": {
- "title": "Import All Rows",
- "description": "Imports all the rows containing data",
- "type": "boolean",
- "default": true,
- "required": true
- },
- "excludeFirstRow": {
- "title": "Exclude First Row",
- "description": "Excludes the first row from the import",
- "type": "boolean",
- "default": false,
- "required": true
- },
- "ignoreBlankRows": {
- "title": "Ignore Blank Rows",
- "description": "Excludes blank rows from the import",
- "type": "boolean",
- "default": false,
- "required": true
- },
- "emptyCellPolicy": {
- "title": "Empty Cell Policy",
- "description": "Policy for handling empty cells",
- "enum": ["EMPTY_STRING", "USER_DEFINED", "GENERATE_ERROR"],
- "default": "EMPTY_STRING",
- "required": true
- },
- "outputFormat": {
- "title": "Output Format",
- "description": "How the activity outputs are to be formatted",
- "enum": ["PORT_PER_COLUMN", "SINGLE_PORT"],
- "default": "PORT_PER_COLUMN",
- "required": true
- },
- "csvDelimiter": {
- "title": "CSV Delimiter",
- "description": "The delimiter to use for CSV input files. The default is ','",
- "type": "string",
- "default": ",",
- "required": true
- }
- },
- "definitions": {
- "range": {
- "properties": {
- "start": {
- "title": "Start",
- "description": "The start of the range",
- "type": "integer",
- "required": true
- },
- "end": {
- "title": "End",
- "description": "The end of the range",
- "type": "integer",
- "required": true
- },
- "excludes": {
- "title": "Excludes Ranges",
- "description": "The ranges to exclude from this range",
- "type": "array",
- "items": { "type": "object", "$ref": "#/definitions/range" },
- "required": false
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/CSVSpreadsheetReaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/CSVSpreadsheetReaderTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/CSVSpreadsheetReaderTest.java
deleted file mode 100644
index fc04468..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/CSVSpreadsheetReaderTest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.Map.Entry;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class CSVSpreadsheetReaderTest {
-
- private SpreadsheetReader spreadsheetReader;
-
- @Before
- public void setUp() throws Exception {
- spreadsheetReader = new CSVSpreadsheetReader();
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.OdfSpreadsheetReader#read(java.io.InputStream, net.sf.taverna.t2.activities.spreadsheet.Range, net.sf.taverna.t2.activities.spreadsheet.Range, net.sf.taverna.t2.activities.spreadsheet.SpreadsheetRowProcessor)}.
- */
- @Test
- public void testRead() throws Exception {
- String[] testFiles2 = new String[] { "/test-spreadsheet.csv" };
- for (int i = 0; i < testFiles2.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, 5), new Range(0, 4), false,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("TRUE", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("15/06/09", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else {
- assertNull(cell.getValue());
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
-
- }
-
- }
-
- @Test(expected=SpreadsheetReadException.class)
- public void testReadException() throws Exception {
- spreadsheetReader.read(new InputStream() {
- public int read() throws IOException {
- throw new IOException();
- }
- }, new Range(0,1), new Range(0,1), false, new SpreadsheetRowProcessor() {
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData) {
- }
- });
- }
-
- @Test
- public void testReadAllRows() throws Exception {
- String[] testFiles2 = new String[] { "/test-spreadsheet.csv" };
- for (int i = 0; i < testFiles2.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, -1), new Range(0, 4), false,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("TRUE", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("15/06/09", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 5 || rowIndex == 6 || rowIndex == 7
- || rowIndex == 8) {
- assertNull(cell.getValue());
- } else if (rowIndex == 9 || rowIndex == 10 || rowIndex == 11
- || rowIndex == 12 || rowIndex == 13 || rowIndex == 14) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("y", cell.getValue());
- }
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
- @Test
- public void testIgnoreBlankRows() throws Exception {
- String[] testFiles2 = new String[] { "/test-spreadsheet.csv" };
- for (int i = 0; i < testFiles2.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, -1), new Range(0, 4), true,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("TRUE", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("15/06/09", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 9 || rowIndex == 10 || rowIndex == 11
- || rowIndex == 12 || rowIndex == 13 || rowIndex == 14) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("y", cell.getValue());
- }
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ExcelSpreadsheetReaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ExcelSpreadsheetReaderTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ExcelSpreadsheetReaderTest.java
deleted file mode 100644
index 90960b6..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ExcelSpreadsheetReaderTest.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.Map.Entry;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit tests for {@link net.sf.taverna.t2.activities.spreadsheet.ExcelSpreadsheetReader}.
- *
- * @author David Withers
- */
-public class ExcelSpreadsheetReaderTest {
-
- private SpreadsheetReader spreadsheetReader;
- private String[] testFiles = new String[] {"/test-spreadsheet.xlsx" , "/test-spreadsheet.xls"};
-
- @Before
- public void setUp() throws Exception {
- spreadsheetReader = new ExcelSpreadsheetReader();
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.activities.spreadsheet.ExcelSpreadsheetReader#read(java.io.InputStream, net.sf.taverna.t2.activities.spreadsheet.SpreadsheetRowProcessor)}
- *
- * @throws Exception
- */
- @Test
- public void testRead() throws Exception {
- for (int i = 0; i < testFiles.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles[i]), new Range(0, 5),
- new Range(0, 4), false, new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("true", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertTrue("Unexpected date format: " + cell.getValue(), cell.getValue().matches("Mon Jun 15 00:00:00 ....? 2009"));
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 5) {
- assertNull(cell.getValue());
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
- @Test(expected=SpreadsheetReadException.class)
- public void testReadIOException() throws Exception {
- spreadsheetReader.read(new InputStream() {
- public int read() throws IOException {
- throw new IOException();
- }
- }, new Range(0,1), new Range(0,1), false, new SpreadsheetRowProcessor() {
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData) {
- }
- });
- }
-
- @Test(expected=SpreadsheetReadException.class)
- public void testReadInvalidFormatException() throws Exception {
- spreadsheetReader.read(getClass().getResourceAsStream("/test-spreadsheet.ods"), new Range(0,1), new Range(0,1), false, new SpreadsheetRowProcessor() {
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData) {
- }
- });
- }
-
- @Test(expected=SpreadsheetReadException.class)
- public void testReadIllegalArgumentException() throws Exception {
- spreadsheetReader.read(getClass().getResourceAsStream("/test-spreadsheet.csv"), new Range(0,1), new Range(0,1), false, new SpreadsheetRowProcessor() {
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData) {
- }
- });
- }
-
- @Test
- public void testReadAllRows() throws Exception {
- for (int i = 0; i < testFiles.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles[i]), new Range(0, -1), new Range(0, 4), false,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("true", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertTrue("Unexpected date format: " + cell.getValue(), cell.getValue().matches("Mon Jun 15 00:00:00 ....? 2009"));
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 5 || rowIndex == 6 || rowIndex == 7
- || rowIndex == 8) {
- assertNull(cell.getValue());
- } else if (rowIndex == 9 || rowIndex == 10 || rowIndex == 11
- || rowIndex == 12 || rowIndex == 13 || rowIndex == 14) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("y", cell.getValue());
- }
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
- @Test
- public void testIgnoreBlankRows() throws Exception {
- for (int i = 0; i < testFiles.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles[i]), new Range(0, -1), new Range(0, 4), true,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("true", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertTrue("Unexpected date format: " + cell.getValue(), cell.getValue().matches("Mon Jun 15 00:00:00 ....? 2009"));
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 9 || rowIndex == 10 || rowIndex == 11
- || rowIndex == 12 || rowIndex == 13 || rowIndex == 14) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("y", cell.getValue());
- }
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ODFSpreadsheetReaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ODFSpreadsheetReaderTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ODFSpreadsheetReaderTest.java
deleted file mode 100644
index 055ef09..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/ODFSpreadsheetReaderTest.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.Map.Entry;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit tests for {@link net.sf.taverna.t2.activities.spreadsheet.ODFSpreadsheetReader}.
- *
- * @author David Withers
- */
-public class ODFSpreadsheetReaderTest {
-
- private SpreadsheetReader spreadsheetReader;
-
- @Before
- public void setUp() throws Exception {
- spreadsheetReader = new ODFSpreadsheetReader();
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.OdfSpreadsheetReader#read(java.io.InputStream, net.sf.taverna.t2.activities.spreadsheet.Range, net.sf.taverna.t2.activities.spreadsheet.Range, net.sf.taverna.t2.activities.spreadsheet.SpreadsheetRowProcessor)}.
- */
- @Test
- public void testRead() throws Exception {
- String[] testFiles2 = new String[] { "/test-spreadsheet.ods" };
- for (int i = 0; i < testFiles2.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, 5), new Range(0, 4), false,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("true", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("2009-06-15", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else {
- assertNull(cell.getValue());
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
-
- }
-
- }
-
- @Test(expected=SpreadsheetReadException.class)
- public void testReadException() throws Exception {
- spreadsheetReader.read(getClass().getResourceAsStream("/test-spreadsheet.csv"), new Range(0,1), new Range(0,1), false, new SpreadsheetRowProcessor() {
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData) {
- }
-
- });
- }
-
- @Test(expected=RuntimeException.class)
- public void testReadRuntimeException() throws Exception {
- spreadsheetReader.read(new InputStream() {
- public int read() throws IOException {
- throw new RuntimeException();
- }
- }, new Range(0,1), new Range(0,1), false, new SpreadsheetRowProcessor() {
- public void processRow(int rowIndex, SortedMap<Integer, String> rowData) {
- }
- });
- }
-
- @Test
- public void testReadAllRows() throws Exception {
- String[] testFiles2 = new String[] { "/test-spreadsheet.ods" };
- for (int i = 0; i < testFiles2.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, -1), new Range(0, 4), false,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("true", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("2009-06-15", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 5 || rowIndex == 6 || rowIndex == 7
- || rowIndex == 8) {
- assertNull(cell.getValue());
- } else if (rowIndex == 9 || rowIndex == 10 || rowIndex == 11
- || rowIndex == 12 || rowIndex == 13 || rowIndex == 14) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("y", cell.getValue());
- }
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
- @Test
- public void testIgnoreBlankRows() throws Exception {
- String[] testFiles2 = new String[] { "/test-spreadsheet.ods" };
- for (int i = 0; i < testFiles2.length; i++) {
- final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14));
- spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, -1), new Range(0, 4), true,
- new SpreadsheetRowProcessor() {
-
- public void processRow(int rowIndex, SortedMap<Integer, String> row) {
- assertTrue(rows.remove((Integer) rowIndex));
- List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
- 3, 4));
- for (Entry<Integer, String> cell : row.entrySet()) {
- assertTrue(columns.remove(cell.getKey()));
- if (rowIndex == 0) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 1) {
- if (cell.getKey().equals(0)) {
- assertEquals("A", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("5.0", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertEquals("C", cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("1.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 2) {
- if (cell.getKey().equals(0)) {
- assertEquals("true", cell.getValue());
- } else if (cell.getKey().equals(1)) {
- assertEquals("2009-06-15", cell.getValue());
- } else if (cell.getKey().equals(2)) {
- assertNull(cell.getValue());
- } else if (cell.getKey().equals(3)) {
- assertEquals("2.0", cell.getValue());
- } else {
- assertNull(cell.getValue());
- }
- } else if (rowIndex == 3 || rowIndex == 4) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("X", cell.getValue());
- }
- } else if (rowIndex == 9 || rowIndex == 10 || rowIndex == 11
- || rowIndex == 12 || rowIndex == 13 || rowIndex == 14) {
- if (cell.getKey().equals(4)) {
- assertNull(cell.getValue());
- } else {
- assertEquals("y", cell.getValue());
- }
- }
- }
- assertTrue(columns.isEmpty());
- }
- });
- assertTrue(rows.isEmpty());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/RangeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/RangeTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/RangeTest.java
deleted file mode 100644
index ffe9032..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/RangeTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit tests for {@link net.sf.taverna.t2.activities.spreadsheet.Range}.
- *
- * @author David Withers
- */
-public class RangeTest {
-
- private Range range;
-
- @Before
- public void setUp() throws Exception {
- range = new Range(1, 5);
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#Range(int, int)}.
- */
- @Test
- public void testRangeIntInt() {
- Range range = new Range(3, 9);
- assertEquals(3, range.getStart());
- assertEquals(9, range.getEnd());
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.activities.spreadsheet.Range#Range(int, int, net.sf.taverna.t2.activities.spreadsheet.Range)}
- * .
- */
- @Test
- public void testRangeIntIntRange() {
- Range range = new Range(0, 12, new Range(3, 9));
- assertEquals(0, range.getStart());
- assertEquals(12, range.getEnd());
- assertTrue(range.contains(0));
- assertTrue(range.contains(2));
- assertFalse(range.contains(5));
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.activities.spreadsheet.Range#Range(int, int, java.util.List)}.
- */
- @Test
- public void testRangeIntIntListOfRange() {
- Range range = new Range(-2, 12, Arrays.asList(new Range(3, 5), new Range(10, 11)));
- assertEquals(-2, range.getStart());
- assertEquals(12, range.getEnd());
- assertTrue(range.contains(-2));
- assertTrue(range.contains(-0));
- assertTrue(range.contains(6));
- assertTrue(range.contains(12));
- assertFalse(range.contains(4));
- assertFalse(range.contains(11));
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.activities.spreadsheet.Range#Range(net.sf.taverna.t2.activities.spreadsheet.Range)}
- * .
- */
- @Test
- public void testRangeRange() {
- Range rangeCopy = new Range(range);
- assertEquals(rangeCopy, range);
- assertEquals(range.getStart(), rangeCopy.getStart());
- assertEquals(range.getEnd(), rangeCopy.getEnd());
- range = new Range(0, 7, range);
- rangeCopy = new Range(range);
- assertFalse(rangeCopy.equals(new Range(2,3)));
- assertEquals(rangeCopy, range);
- assertEquals(range.getStart(), rangeCopy.getStart());
- assertEquals(range.getEnd(), rangeCopy.getEnd());
- assertArrayEquals(range.getRangeValues(), rangeCopy.getRangeValues());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#contains(int)}.
- */
- @Test
- public void testContains() {
- assertTrue(range.contains(2));
- assertFalse(range.contains(7));
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#getRangeValues()}.
- */
- @Test
- public void testGetRangeValues() {
- assertArrayEquals(new int[] { 1, 2, 3, 4, 5 }, range.getRangeValues());
- Range range2 = new Range(0, 7, range);
- assertArrayEquals(new int[] { 0, 6, 7 }, range2.getRangeValues());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#getStart()}.
- */
- @Test
- public void testGetStart() {
- assertEquals(1, range.getStart());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#setStart(int)}.
- */
- @Test
- public void testSetStart() {
- range.setStart(2);
- assertEquals(2, range.getStart());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#getEnd()}.
- */
- @Test
- public void testGetEnd() {
- assertEquals(5, range.getEnd());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#setEnd(int)}.
- */
- @Test
- public void testSetEnd() {
- range.setEnd(7);
- assertEquals(7, range.getEnd());
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.activities.spreadsheet.Range#addExclude(net.sf.taverna.t2.activities.spreadsheet.Range)}
- * .
- */
- @Test
- public void testAddExclude() {
- range.addExclude(new Range(4, 4));
- assertTrue(range.contains(2));
- assertTrue(range.contains(5));
- assertFalse(range.contains(4));
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.activities.spreadsheet.Range#removeExclude(net.sf.taverna.t2.activities.spreadsheet.Range)}
- * .
- */
- @Test
- public void testRemoveExclude() {
- range.addExclude(new Range(4, 4));
- range.removeExclude(new Range(4, 4));
- assertTrue(range.contains(4));
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.Range#toString()}.
- */
- @Test
- public void testToString() {
- assertEquals("[1..5]", range.toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityFactoryTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityFactoryTest.java
deleted file mode 100644
index f97eb0b..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityFactoryTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- *
- * @author David Withers
- */
-public class SpreadsheetImportActivityFactoryTest {
-
- private SpreadsheetImportActivityFactory factory;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- factory = new SpreadsheetImportActivityFactory();
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity#createActivity()}.
- */
- @Test
- public void testCreateActivity() {
- SpreadsheetImportActivity createActivity = factory.createActivity();
- assertNotNull(createActivity);
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity#getActivityType()}.
- */
- @Test
- public void testGetActivityURI() {
- assertEquals(URI.create(SpreadsheetImportActivity.URI), factory.getActivityType());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.rshell.RshellActivityFactory#getActivityConfigurationSchema()}.
- */
- @Test
- public void testGetActivityConfigurationSchema() {
- assertTrue(factory.getActivityConfigurationSchema() instanceof JsonNode);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityTest.java
deleted file mode 100644
index 2cd2a2a..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportActivityTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.taverna.t2.activities.testutils.ActivityInvoker;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.Port;
-import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Unit tests for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivityTest}.
- *
- * @author David Withers
- */
-public class SpreadsheetImportActivityTest {
-
- private SpreadsheetImportActivity activity;
- private SpreadsheetImportActivityFactory activityFactory;
- private Edits edits;
- private ObjectNode configuration;
-
- @Before
- public void setUp() throws Exception {
- activity = new SpreadsheetImportActivity();
- activityFactory = new SpreadsheetImportActivityFactory();
- edits = new EditsImpl();
- activityFactory.setEdits(edits);
- configuration = JsonNodeFactory.instance.objectNode();
- configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 1));
- configuration.put("rowRange", configuration.objectNode().put("start", 0).put("end", -1));
- configuration.put("emptyCellValue", "");
- configuration.put("allRows", true);
- configuration.put("excludeFirstRow", false);
- configuration.put("ignoreBlankRows", false);
- configuration.put("emptyCellPolicy", "EMPTY_STRING");
- configuration.put("outputFormat", "PORT_PER_COLUMN");
- configuration.put("csvDelimiter", ",");
- }
-
- @Test
- public void testSpreadsheetImportActivity() {
- assertNotNull(activity);
- assertNull(activity.getConfiguration());
- }
-
- @Test
- public void testConfigureSpreadsheetImportConfiguration() throws Exception {
- assertEquals(0, activity.getInputPorts().size());
- assertEquals(0, activity.getOutputPorts().size());
- configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 10));
- ArrayNode columnNames = configuration.arrayNode();
- columnNames.addObject().put("column", "C").put("port", "test");
- configuration.put("columnNames", columnNames);
- activity.configure(configuration);
- for (ActivityInputPort activityInputPort : activityFactory.getInputPorts(configuration)) {
- edits.getAddActivityInputPortEdit(activity, activityInputPort).doEdit();
- }
- for (ActivityOutputPort activityOutputPort : activityFactory.getOutputPorts(configuration)) {
- edits.getAddActivityOutputPortEdit(activity, activityOutputPort).doEdit();
- }
- assertEquals(configuration, activity.getConfiguration());
- assertEquals(1, activity.getInputPorts().size());
- Set<ActivityOutputPort> outputPorts = activity.getOutputPorts();
- int[] rangeValues = SpreadsheetUtils.getRange(configuration.get("columnRange")).getRangeValues();
- assertEquals(rangeValues.length, outputPorts.size());
- for (int i = 0; i < rangeValues.length; i++) {
- String portName = SpreadsheetUtils.getPortName(rangeValues[i], configuration);
- Port port = null;
- for (Port outputPort : outputPorts) {
- if (outputPort.getName().equals(portName)) {
- port = outputPort;
- break;
- }
- }
- assertNotNull(port);
- outputPorts.remove(port);
- }
- assertEquals(0, outputPorts.size());
-
- configuration.put("outputFormat", SpreadsheetOutputFormat.SINGLE_PORT.name());
- activity.configure(configuration);
- assertEquals(1, activityFactory.getOutputPorts(configuration).size());
- }
-
- @Test
- public void testGetConfiguration() throws ActivityConfigurationException {
- assertNull(activity.getConfiguration());
- activity.configure(configuration);
- assertNotNull(activity.getConfiguration());
- assertEquals(configuration, activity.getConfiguration());
- }
-
- @Test
- public void testExecuteAsynchMapOfStringT2ReferenceAsynchronousActivityCallback() throws Exception {
- configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 3));
- activity.configure(configuration);
- for (ActivityInputPort activityInputPort : activityFactory.getInputPorts(configuration)) {
- edits.getAddActivityInputPortEdit(activity, activityInputPort).doEdit();
- }
- for (ActivityOutputPort activityOutputPort : activityFactory.getOutputPorts(configuration)) {
- edits.getAddActivityOutputPortEdit(activity, activityOutputPort).doEdit();
- }
- Map<String, Class<?>> outputs = new HashMap<String, Class<?>>();
- outputs.put("A", String.class);
- outputs.put("B", String.class);
- outputs.put("C", String.class);
- outputs.put("D", String.class);
- Map<String, Object> results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
- (Object) "src/test/resources/test-spreadsheet.xls"), outputs);
- assertEquals(4, results.size());
- assertTrue(results.get("A") instanceof List<?>);
- assertEquals(15, ((List<?>) results.get("A")).size());
- results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
- (Object) "src/test/resources/test-spreadsheet.ods"), outputs);
- assertEquals(4, results.size());
- assertTrue(results.get("A") instanceof List<?>);
- assertEquals(15, ((List<?>) results.get("A")).size());
- results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
- (Object) "src/test/resources/test-spreadsheet.csv"), outputs);
- assertEquals(4, results.size());
- assertTrue(results.get("A") instanceof List<?>);
- assertEquals(15, ((List<?>) results.get("A")).size());
-
- // CSV output
- configuration.put("outputFormat", SpreadsheetOutputFormat.SINGLE_PORT.name());
- activity.configure(configuration);
- outputs = new HashMap<String, Class<?>>();
- outputs.put("output", String.class);
- results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
- (Object) "src/test/resources/test-spreadsheet.xls"), outputs);
- assertEquals(1, results.size());
- assertTrue(results.get("output") instanceof String);
- assertEquals(15, ((String) results.get("output")).split(System.getProperty("line.separator")).length);
-
- // TSV output
- configuration.put("csvDelimiter", "\t");
- activity.configure(configuration);
- results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
- (Object) "src/test/resources/test-spreadsheet.csv"), outputs);
- assertEquals(1, results.size());
- assertTrue(results.get("output") instanceof String);
- assertEquals(15, ((String) results.get("output")).split(System.getProperty("line.separator")).length);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportConfigurationTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportConfigurationTest.java
deleted file mode 100644
index 918f6f7..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportConfigurationTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit tests for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration}.
- *
- * @author David Withers
- */
-public class SpreadsheetImportConfigurationTest {
-
- private SpreadsheetImportConfiguration configuration;
-
- @Before
- public void setUp() throws Exception {
- configuration = new SpreadsheetImportConfiguration();
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#SpreadsheetImportConfiguration()}.
- */
- @Test
- public void testSpreadsheetImportConfiguration() {
- assertNotNull(configuration);
- assertEquals(new Range(0, 1), configuration.getColumnRange());
- assertEquals(new Range(0, -1), configuration.getRowRange());
- assertEquals("", configuration.getEmptyCellValue());
- assertEquals(SpreadsheetEmptyCellPolicy.EMPTY_STRING, configuration.getEmptyCellPolicy());
- assertEquals(SpreadsheetOutputFormat.PORT_PER_COLUMN, configuration.getOutputFormat());
- assertEquals(Collections.EMPTY_MAP, configuration.getColumnNames());
- assertEquals(true, configuration.isAllRows());
- assertEquals(false, configuration.isExcludeFirstRow());
- assertEquals(false, configuration.isIgnoreBlankRows());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#SpreadsheetImportConfiguration(net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration)}.
- */
- @Test
- public void testSpreadsheetImportConfigurationSpreadsheetImportConfiguration() {
- configuration.setColumnRange(new Range(3, 22));
- configuration.setColumnRange(new Range(2, 53));
- configuration.setAllRows(false);
- configuration.setExcludeFirstRow(true);
- configuration.setIgnoreBlankRows(true);
- configuration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.GENERATE_ERROR);
- configuration.setEmptyCellValue("NO VALUE");
- configuration.setColumnNames(Collections.singletonMap("D", "delta"));
- configuration.setOutputFormat(SpreadsheetOutputFormat.SINGLE_PORT);
- configuration.setCsvDelimiter(" ");
- SpreadsheetImportConfiguration newConfiguration = new SpreadsheetImportConfiguration(configuration);
- assertEquals(configuration, newConfiguration);
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#getEmptyCellValue()}.
- */
- @Test
- public void testGetEmptyCellValue() {
- assertEquals("", configuration.getEmptyCellValue());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setEmptyCellValue(java.lang.String)}.
- */
- @Test
- public void testSetEmptyCellValue() {
- configuration.setEmptyCellValue("XXXX");
- assertEquals("XXXX", configuration.getEmptyCellValue());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#getColumnRange()}.
- */
- @Test
- public void testGetColumnRange() {
- assertEquals(new Range(0, 1), configuration.getColumnRange());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setColumnRange(net.sf.taverna.t2.activities.spreadsheet.Range)}.
- */
- @Test
- public void testSetColumnRange() {
- configuration.setColumnRange(new Range(5, 89));
- assertEquals(new Range(5, 89), configuration.getColumnRange());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#getRowRange()}.
- */
- @Test
- public void testGetRowRange() {
- assertEquals(new Range(0, -1), configuration.getRowRange());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setRowRange(net.sf.taverna.t2.activities.spreadsheet.Range)}.
- */
- @Test
- public void testSetRowRange() {
- configuration.setRowRange(new Range(41, 67));
- assertEquals(new Range(41, 67), configuration.getRowRange());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#getColumnNames()}.
- */
- @Test
- public void testGetColumnNames() {
- assertEquals(Collections.EMPTY_MAP, configuration.getColumnNames());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setColumnNames(java.util.Map)}.
- */
- @Test
- public void testSetColumnNames() {
- configuration.setColumnNames(Collections.singletonMap("A", "alpha"));
- assertEquals(Collections.singletonMap("A", "alpha"), configuration.getColumnNames());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#isAllRows()}.
- */
- @Test
- public void testIsAllRows() {
- assertEquals(true, configuration.isAllRows());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setAllRows(boolean)}.
- */
- @Test
- public void testSetAllRows() {
- configuration.setAllRows(false);
- assertEquals(false, configuration.isAllRows());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#isExcludeFirstRow()}.
- */
- @Test
- public void testIsExcludeFirstRow() {
- assertEquals(false, configuration.isExcludeFirstRow());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setExcludeFirstRow(boolean)}.
- */
- @Test
- public void testSetExcludeFirstRow() {
- configuration.setExcludeFirstRow(true);
- assertEquals(true, configuration.isExcludeFirstRow());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#isIgnoreBlankRows()}.
- */
- @Test
- public void testIsIgnoreBlankRows() {
- assertEquals(false, configuration.isIgnoreBlankRows());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setIgnoreBlankRows(boolean)}.
- */
- @Test
- public void testSetIgnoreBlankRows() {
- configuration.setIgnoreBlankRows(true);
- assertEquals(true, configuration.isIgnoreBlankRows());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#getEmptyCellPolicy()}.
- */
- @Test
- public void testGetEmptyCellPolicy() {
- assertEquals(SpreadsheetEmptyCellPolicy.EMPTY_STRING, configuration.getEmptyCellPolicy());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#setEmptyCellPolicy(net.sf.taverna.t2.activities.spreadsheet.SpreadsheetEmptyCellPolicy)}.
- */
- @Test
- public void testSetEmptyCellPolicy() {
- configuration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.GENERATE_ERROR);
- assertEquals(SpreadsheetEmptyCellPolicy.GENERATE_ERROR, configuration.getEmptyCellPolicy());
- configuration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.USER_DEFINED);
- assertEquals(SpreadsheetEmptyCellPolicy.USER_DEFINED, configuration.getEmptyCellPolicy());
- configuration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.EMPTY_STRING);
- assertEquals(SpreadsheetEmptyCellPolicy.EMPTY_STRING, configuration.getEmptyCellPolicy());
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#equals(java.lang.Object)}.
- */
- @Test
- public void testEqualsObject() {
- assertTrue(configuration.equals(configuration));
- assertTrue(configuration.equals(new SpreadsheetImportConfiguration()));
- assertFalse(configuration.equals(null));
- configuration.setEmptyCellValue("NIL");
- assertFalse(configuration.equals(new SpreadsheetImportConfiguration()));
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration#hashCode()}.
- */
- @Test
- public void testHashCode() {
- assertEquals(configuration.hashCode(), configuration.hashCode());
- assertEquals(configuration.hashCode(), new SpreadsheetImportConfiguration().hashCode());
- }
-
- @Test
- public void testGetOutputFormat() {
- assertEquals(SpreadsheetOutputFormat.PORT_PER_COLUMN, configuration.getOutputFormat());
- }
-
- @Test
- public void testSetOutputFormat() {
- configuration.setOutputFormat(SpreadsheetOutputFormat.PORT_PER_COLUMN);
- assertEquals(SpreadsheetOutputFormat.PORT_PER_COLUMN, configuration.getOutputFormat());
- configuration.setOutputFormat(SpreadsheetOutputFormat.SINGLE_PORT);
- assertEquals(SpreadsheetOutputFormat.SINGLE_PORT, configuration.getOutputFormat());
- }
-
- @Test
- public void testGetCsvDelimiter() {
- assertEquals(",", configuration.getCsvDelimiter());
- }
-
- @Test
- public void testSetCsvDelimiter() {
- configuration.setCsvDelimiter("'");
- assertEquals("'", configuration.getCsvDelimiter());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportHealthCheckerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportHealthCheckerTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportHealthCheckerTest.java
deleted file mode 100644
index dbf6711..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetImportHealthCheckerTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-
-import net.sf.taverna.t2.visit.VisitReport.Status;
-import net.sf.taverna.t2.workflowmodel.impl.EditsImpl;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Unit tests for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthChecker}.
- *
- * @author David Withers
- */
-public class SpreadsheetImportHealthCheckerTest {
-
- private SpreadsheetImportHealthChecker healthChecker;
-
- private SpreadsheetImportActivity activity;
- private ArrayList ancestors;
-
- @Before
- public void setUp() throws Exception {
- EditsImpl ei = new EditsImpl();
- healthChecker = new SpreadsheetImportHealthChecker();
- activity = new SpreadsheetImportActivity();
- activity.setEdits(new EditsImpl());
- ancestors = new ArrayList();
- ancestors.add(ei.createProcessor("fred"));
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthChecker#canHandle(java.lang.Object)}.
- */
- @Test
- public void testCanHandle() {
- assertTrue(healthChecker.canVisit(activity));
- assertFalse(healthChecker.canVisit(null));
- assertFalse(healthChecker.canVisit(""));
- }
-
- /**
- * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthChecker#checkHealth(net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity)}.
- * @throws Exception
- */
- @Test
- public void testCheckHealth() throws Exception {
- assertEquals(Status.SEVERE, healthChecker.visit(activity, ancestors).getStatus());
- ObjectNode configuration = JsonNodeFactory.instance.objectNode();
- configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 1));
- configuration.put("rowRange", configuration.objectNode().put("start", 0).put("end", -1));
- configuration.put("emptyCellValue", "");
- configuration.put("allRows", true);
- configuration.put("excludeFirstRow", false);
- configuration.put("ignoreBlankRows", false);
- configuration.put("emptyCellPolicy", "EMPTY_STRING");
- configuration.put("outputFormat", "PORT_PER_COLUMN");
- configuration.put("csvDelimiter", ",");
- activity.configure(configuration);
- assertEquals(Status.OK, healthChecker.visit(activity, ancestors).getStatus());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/b7e29f54/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetReadExceptionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetReadExceptionTest.java b/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetReadExceptionTest.java
deleted file mode 100644
index ef3445f..0000000
--- a/src/test/java/net/sf/taverna/t2/activities/spreadsheet/SpreadsheetReadExceptionTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package net.sf.taverna.t2.activities.spreadsheet;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class SpreadsheetReadExceptionTest {
-
- @Test
- public void testSpreadsheetReadException() {
- SpreadsheetReadException spreadsheetReadException = new SpreadsheetReadException();
- assertNull(spreadsheetReadException.getMessage());
- assertNull(spreadsheetReadException.getCause());
- }
-
- @Test
- public void testSpreadsheetReadExceptionString() {
- SpreadsheetReadException spreadsheetReadException = new SpreadsheetReadException("test exception");
- assertEquals("test exception", spreadsheetReadException.getMessage());
- assertNull(spreadsheetReadException.getCause());
- }
-
- @Test
- public void testSpreadsheetReadExceptionThrowable() {
- Exception exception = new Exception();
- SpreadsheetReadException spreadsheetReadException = new SpreadsheetReadException(exception);
- assertEquals(exception, spreadsheetReadException.getCause());
- }
-
- @Test
- public void testSpreadsheetReadExceptionStringThrowable() {
- Exception exception = new Exception();
- SpreadsheetReadException spreadsheetReadException = new SpreadsheetReadException("test exception", exception);
- assertEquals("test exception", spreadsheetReadException.getMessage());
- assertEquals(exception, spreadsheetReadException.getCause());
- }
-
-}