Package org.apache.wink.common.model.csv

Examples of org.apache.wink.common.model.csv.MultiCsvTable


        }
        assertCsvTable(table);
    }

    public void testMultiTableWrite() {
        MultiCsvTable multi = createMultiCsvTable();
        Iterator<String[]> entities = multi.getEntities();
        int rows = 0;
        int tables = 0;
        while (entities.hasNext()) {
            String[] next = entities.next();
            switch (rows) {
                case 0:
                    ++tables;
                    assertTrue(Arrays.deepEquals(TABLE1_HEADER, next));
                    break;
                case 1:
                    assertTrue(Arrays.deepEquals(TABLE1_ROW1, next));
                    break;
                case 2:
                    assertTrue(Arrays.deepEquals(TABLE1_ROW2, next));
                    break;
                case 3:
                    assertTrue(Arrays.deepEquals(TABLE1_ROW3, next));
                    break;
                case 4:
                    assertTrue(Arrays.deepEquals(EMPTY_ROW, next));
                    break;

                // table 2
                case 5:
                    ++tables;
                    assertTrue(Arrays.deepEquals(TABLE2_HEADER, next));
                    break;
                case 6:
                    assertTrue(Arrays.deepEquals(TABLE2_ROW1, next));
                    break;
                case 7:
                    assertTrue(Arrays.deepEquals(TABLE2_ROW2, next));
                    break;
                case 8:
                    assertTrue(Arrays.deepEquals(EMPTY_ROW, next));
                    break;

                // table 3
                case 9:
                    ++tables;
                    assertTrue(Arrays.deepEquals(TABLE3_ROW1, next));
                    break;
                case 10:
                    assertTrue(Arrays.deepEquals(TABLE3_ROW2, next));
                    break;
                default:
                    fail("too many rows");
            }
            ++rows;
        }
        assertEquals(tables, multi.getTables().size());
        assertEquals(rows, 11);
    }
View Full Code Here


        assertEquals(tables, multi.getTables().size());
        assertEquals(rows, 11);
    }

    public void testMultiTableRead() {
        MultiCsvTable descriptor = new MultiCsvTable();
        MultiCsvTable writableDesc = createMultiCsvTable();
        Iterator<String[]> entities = writableDesc.getEntities();
        while (entities.hasNext()) {
            String[] row = entities.next();
            descriptor.addEntity(row);
        }
        assertMultiCsvTable(descriptor);
View Full Code Here

        assertTrue(Arrays.deepEquals(TABLE1_ROW2, table.getRows().get(2)));
        assertTrue(Arrays.deepEquals(TABLE1_ROW3, table.getRows().get(3)));
    }

    public static MultiCsvTable createMultiCsvTable() {
        MultiCsvTable descriptor = new MultiCsvTable();
        CsvTable table1 = descriptor.createCsvTable(TABLE1_HEADER);
        table1.addRow(TABLE1_ROW1);
        table1.addRow(TABLE1_ROW2);
        table1.addRow(TABLE1_ROW3);
        CsvTable table2 = descriptor.createCsvTable(TABLE2_HEADER);
        table2.addRow(TABLE2_ROW1);
        table2.addRow(TABLE2_ROW2);
        CsvTable table3 = descriptor.createCsvTable();
        table3.addRow(TABLE3_ROW1);
        table3.addRow(TABLE3_ROW2);
        return descriptor;
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.model.csv.MultiCsvTable

Copyright © 2018 www.massapicom. 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.