Search in sources :

Example 26 with BaseFileField

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

the class TextFileInputContentParsingTest method testFixedWidthCharacters.

@Test
public void testFixedWidthCharacters() throws Exception {
    meta.content.header = false;
    meta.content.fileType = "Fixed";
    meta.content.fileFormat = "DOS";
    meta.content.encoding = "ISO-8859-1";
    meta.content.length = "Characters";
    initByFile("test-fixed-length-characters.txt");
    setFields(new BaseFileField("f1", 0, 3), new BaseFileField("f2", 3, 2), new BaseFileField("f3", 5, 2), new BaseFileField("f4", 7, 4));
    process();
    check(new Object[][] { { "ABC", "DE", "FG", "HIJK" }, { "LmN", "oP", "qR", "sTuV" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 27 with BaseFileField

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

the class TextFileInputContentParsingTest method testBOM_UTF16BE.

@Test
public void testBOM_UTF16BE() throws Exception {
    meta.content.encoding = "UTF-32LE";
    meta.content.header = false;
    initByFile("test-BOM-UTF-16BE.txt");
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "data", "1" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 28 with BaseFileField

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

the class TextFileInputContentParsingTest method testBOM_UTF8.

@Test
public void testBOM_UTF8() throws Exception {
    meta.content.encoding = "UTF-32LE";
    meta.content.header = false;
    initByFile("test-BOM-UTF-8.txt");
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "data", "1" } });
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 29 with BaseFileField

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

the class TextFileInputContentParsingTest method testHeader.

@Test
public void testHeader() throws Exception {
    meta.content.header = false;
    initByFile("default.csv");
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "Field 1", "Field 2", "Field 3" }, { "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 30 with BaseFileField

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

the class TextFileInputContentParsingTest method testVfsGzipCompression.

@Test
public void testVfsGzipCompression() throws Exception {
    meta.content.fileCompression = "None";
    String url = "gz:" + this.getClass().getResource(inPrefix + "default.csv.gz");
    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)

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