Examples of FixedWidthConfiguration


Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

public class FixedWidthDataContextTest extends TestCase {

    public void testEmptyFile() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/empty_file.txt"),
                new FixedWidthConfiguration(10));
        assertEquals(1, dc.getDefaultSchema().getTableCount());

        Table table = dc.getDefaultSchema().getTables()[0];
        assertEquals("empty_file.txt", table.getName());
        assertEquals(0, table.getColumnCount());
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertEquals(0, table.getColumnCount());
    }

    public void testEmptyFileNoHeaderLine() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/empty_file.txt"),
                new FixedWidthConfiguration(FixedWidthConfiguration.NO_COLUMN_NAME_LINE, "UTF8", 10));
        assertEquals(1, dc.getDefaultSchema().getTableCount());

        Table table = dc.getDefaultSchema().getTables()[0];
        assertEquals("empty_file.txt", table.getName());
        assertEquals(0, table.getColumnCount());
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertEquals(0, table.getColumnCount());
    }

    public void testUnexistingHeaderLine() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple1.txt"),
                new FixedWidthConfiguration(20, "UTF8", 10));
        assertEquals(1, dc.getDefaultSchema().getTableCount());

        Table table = dc.getDefaultSchema().getTables()[0];
        assertEquals("example_simple1.txt", table.getName());
        assertEquals(0, table.getColumnCount());
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertEquals("example_simple1.txt", table.getName());
        assertEquals(0, table.getColumnCount());
    }

    public void testExampleSimple1() throws Exception {
        FixedWidthConfiguration conf = new FixedWidthConfiguration(10);
        FixedWidthDataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple1.txt"), conf);

        String[] schemaNames = dc.getSchemaNames();
        assertEquals(2, schemaNames.length);
        assertEquals("[information_schema, resources]", Arrays.toString(schemaNames));
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertEquals("[howdy, partner]", Arrays.toString(ds.getRow().getValues()));
        assertFalse(ds.next());
    }

    public void testFailOnInconsistentWidth() throws Exception {
        FixedWidthConfiguration conf = new FixedWidthConfiguration(FixedWidthConfiguration.NO_COLUMN_NAME_LINE, "UTF8",
                10, true);
        FixedWidthDataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple1.txt"), conf);

        String[] schemaNames = dc.getSchemaNames();
        assertEquals(2, schemaNames.length);
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertFalse(ds.next());
    }

    public void testVaryingValueLengthsCorrect() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple2.txt"),
                new FixedWidthConfiguration(new int[] { 1, 8, 7 }));
        Table table = dc.getDefaultSchema().getTables()[0];
        assertEquals("[i, greeting, greeter]", Arrays.toString(table.getColumnNames()));

        assertEquals(1, table.getColumnByName("i").getColumnSize().intValue());
        assertEquals(8, table.getColumnByName("greeting").getColumnSize().intValue());
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertFalse(ds.next());
    }

    public void testVaryingValueLengthsTooShortLength() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple2.txt"),
                new FixedWidthConfiguration(0, "UTF8", new int[] { 1, 5, 7 }, true));
        try {
            dc.getDefaultSchema().getTables();
            fail("Exception expected");
        } catch (InconsistentValueWidthException e) {
            assertEquals("Inconsistent row format of row no. 1.", e.getMessage());
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        }
    }

    public void testVaryingValueLengthsTooShortLengthErrorTolerant() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple2.txt"),
                new FixedWidthConfiguration(FixedWidthConfiguration.DEFAULT_COLUMN_NAME_LINE, "UTF8", new int[] { 1, 5,
                        7 }, false));

        Table table = dc.getDefaultSchema().getTables()[0];
        assertEquals("[i, greet, inggree]", Arrays.toString(table.getColumnNames()));
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        assertFalse(ds.next());
    }

    public void testVaryingValueLengthsTooLongLength() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple2.txt"),
                new FixedWidthConfiguration(0, "UTF8", new int[] { 1, 8, 9 }, true));

        try {
            dc.getDefaultSchema().getTables();
            fail("Exception expected");
        } catch (InconsistentValueWidthException e) {
View Full Code Here

Examples of org.apache.metamodel.fixedwidth.FixedWidthConfiguration

        }
    }

    public void testVaryingValueLengthsTooLongLengthErrorTolerant() throws Exception {
        DataContext dc = new FixedWidthDataContext(new File("src/test/resources/example_simple2.txt"),
                new FixedWidthConfiguration(FixedWidthConfiguration.DEFAULT_COLUMN_NAME_LINE, "UTF8", new int[] { 1, 8,
                        9 }, false));

        Table table = dc.getDefaultSchema().getTables()[0];
        assertEquals("[i, greeting, greeter]", Arrays.toString(table.getColumnNames()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.