Search in sources :

Example 16 with BaseFileField

use of org.pentaho.di.trans.steps.file.BaseFileField in project pentaho-kettle by pentaho.

the class TextFileInputContentParsingTest method testEscape.

@Test
public void testEscape() throws Exception {
    meta.content.escapeCharacter = "\\";
    initByFile("escape.csv");
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "first", "1", "1.1" }, { "second", "2", "2.2" }, { "third;third", "3", "3.3" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 17 with BaseFileField

use of org.pentaho.di.trans.steps.file.BaseFileField in project pentaho-kettle by pentaho.

the class TextFileInputContentParsingTest method testGzipCompression.

@Test
public void testGzipCompression() throws Exception {
    meta.content.fileCompression = "GZip";
    initByFile("default.csv.gz");
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "first", "1", "1.1" }, { "second", "2", "2.2" }, { "third", "3", "3.3" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 18 with BaseFileField

use of org.pentaho.di.trans.steps.file.BaseFileField in project pentaho-kettle by pentaho.

the class TextFileInputContentParsingTest method testFixedWidth.

@Test
public void testFixedWidth() throws Exception {
    meta.content.fileType = "Fixed";
    initByFile("fixed.csv");
    setFields(new BaseFileField("f1", 0, 7), new BaseFileField("f2", 8, 7), new BaseFileField("f3", 16, 7));
    process();
    check(new Object[][] { { "first  ", "1      ", "1.1" }, { "second ", "2      ", "2.2" }, { "third  ", "3      ", "3.3" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 19 with BaseFileField

use of org.pentaho.di.trans.steps.file.BaseFileField in project pentaho-kettle by pentaho.

the class TextFileInputContentParsingTest method testVfsBzip2Compression.

@Test
public void testVfsBzip2Compression() throws Exception {
    meta.content.fileCompression = "None";
    String url = "bz2:" + this.getClass().getResource(inPrefix + "default.csv.bz2");
    initByURL(url);
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "first", "1", "1.1" }, { "second", "2", "2.2" }, { "third", "3", "3.3" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 20 with BaseFileField

use of org.pentaho.di.trans.steps.file.BaseFileField in project pentaho-kettle by pentaho.

the class TextFileInputContentParsingTest method testFilterEmptyBacklog5381.

@Test
public void testFilterEmptyBacklog5381() throws Exception {
    meta.content.header = false;
    meta.content.fileType = "Fixed";
    meta.content.noEmptyLines = true;
    meta.content.fileFormat = "mixed";
    initByFile("filterempty-BACKLOG-5381.csv");
    setFields(new BaseFileField("f", 0, 100));
    process();
    check(new Object[][] { { "FirstLine => FirstLine " }, { "ThirdLine => SecondLine" }, { "SixthLine => ThirdLine" }, { "NinthLine => FourthLine" }, { "" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Aggregations

BaseFileField (org.pentaho.di.trans.steps.file.BaseFileField)36 Test (org.junit.Test)19 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12 KettleException (org.pentaho.di.core.exception.KettleException)9 KettleFileException (org.pentaho.di.core.exception.KettleFileException)7 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)5 ArrayList (java.util.ArrayList)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 TableItem (org.eclipse.swt.widgets.TableItem)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 Shell (org.eclipse.swt.widgets.Shell)2 TextFileInputFieldInterface (org.pentaho.di.core.gui.TextFileInputFieldInterface)2 RowMeta (org.pentaho.di.core.row.RowMeta)2 Variables (org.pentaho.di.core.variables.Variables)2 TextFileInputMeta (org.pentaho.di.trans.steps.fileinput.text.TextFileInputMeta)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1