CsvExporter allows the separator character in its output to be modified.
ExportRowsCommand has replaced TsvExporter with CsvExporter with a tab character as the separator. TsvExporterTests now tests CsvExporter with a tab character as the separator parameter. All unit tests now work. git-svn-id: http://google-refine.googlecode.com/svn/trunk@858 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
6779707399
commit
2f3980f969
@ -45,7 +45,7 @@ public class ExportRowsCommand extends Command {
|
||||
|
||||
Exporter exporter = s_formatToExporter.get(format.toLowerCase());
|
||||
if (exporter == null){
|
||||
exporter = new TsvExporter();
|
||||
exporter = new CsvExporter('\t');
|
||||
}
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
@ -22,6 +22,15 @@ import au.com.bytecode.opencsv.CSVWriter;
|
||||
public class CsvExporter implements Exporter{
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("CsvExporter");
|
||||
char separator;
|
||||
|
||||
public CsvExporter(){
|
||||
separator = ','; //Comma separated-value is default
|
||||
}
|
||||
|
||||
public CsvExporter(char separator){
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(Project project, Properties options, Engine engine, OutputStream outputStream)
|
||||
@ -91,7 +100,7 @@ public class CsvExporter implements Exporter{
|
||||
}
|
||||
}
|
||||
|
||||
}.init(new CSVWriter(writer), printColumnHeader);
|
||||
}.init(new CSVWriter(writer, separator), printColumnHeader);
|
||||
|
||||
FilteredRows filteredRows = engine.getAllFilteredRows();
|
||||
filteredRows.accept(project, visitor);
|
||||
|
@ -15,6 +15,7 @@ import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.exporters.CsvExporter;
|
||||
import com.metaweb.gridworks.exporters.TsvExporter;
|
||||
import com.metaweb.gridworks.model.Cell;
|
||||
import com.metaweb.gridworks.model.Column;
|
||||
@ -30,11 +31,11 @@ public class TsvExporterTests {
|
||||
Properties options;
|
||||
|
||||
//System Under Test
|
||||
TsvExporter SUT;
|
||||
CsvExporter SUT;
|
||||
|
||||
@BeforeMethod
|
||||
public void SetUp(){
|
||||
SUT = new TsvExporter();
|
||||
SUT = new CsvExporter('\t');//new TsvExporter();
|
||||
writer = new StringWriter();
|
||||
project = new Project();
|
||||
engine = new Engine(project);
|
||||
@ -66,7 +67,7 @@ public class TsvExporterTests {
|
||||
|
||||
}
|
||||
|
||||
@Test(groups={"broken"})
|
||||
@Test
|
||||
public void exportSimpleTsvNoHeader(){
|
||||
CreateGrid(2, 2);
|
||||
when(options.getProperty("printColumnHeader")).thenReturn("false");
|
||||
@ -82,7 +83,7 @@ public class TsvExporterTests {
|
||||
verify(options,times(1)).getProperty("printColumnHeader");
|
||||
}
|
||||
|
||||
@Test(groups={"broken"})
|
||||
@Test
|
||||
public void exportTsvWithLineBreaks(){
|
||||
CreateGrid(3,3);
|
||||
|
||||
@ -99,7 +100,7 @@ public class TsvExporterTests {
|
||||
"row2cell0\trow2cell1\trow2cell2\n");
|
||||
}
|
||||
|
||||
@Test(groups={"broken"})
|
||||
@Test
|
||||
public void exportTsvWithComma(){
|
||||
CreateGrid(3,3);
|
||||
|
||||
@ -116,7 +117,7 @@ public class TsvExporterTests {
|
||||
"row2cell0\trow2cell1\trow2cell2\n");
|
||||
}
|
||||
|
||||
@Test(groups={"broken"})
|
||||
@Test
|
||||
public void exportTsvWithQuote(){
|
||||
CreateGrid(3,3);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user