Package com.adaptiweb.utils.csvbind.bean

Examples of com.adaptiweb.utils.csvbind.bean.Record2


        Iterator<Record2> it2 = r2.iterator();
        assertNotNull(it2);
        assertTrue(it2.hasNext());
        int c2 = 0;
        while (it2.hasNext()) {
            Record2 rec = it2.next();
            assertNotNull(rec);
            if (c2 == 0) {
                assertEquals("48882467972", rec.getCustomer());
            } else if (c2 == 3) {
                assertEquals("agdvr\"g;;;r", rec.getCustomer());
            }
            c2++;
        }
        assertTrue(c2 >= 4);
        r2.closeResources();

        // CsvTestRecord reader from string
        CsvReader<CsvTestRecord2> r3 = new CsvReader<CsvTestRecord2>(new StringReader("1;2;3;31.12.2008\n3;4\n5;6"), CsvTestRecord2.class);
        assertNotNull(r3);
        Iterator<CsvTestRecord2> it3 = r3.iterator();
        assertNotNull(it3);
        assertTrue(it3.hasNext());
        int c3 = 0;
        while (it3.hasNext()) {
            CsvTestRecord rec = it3.next();
            assertNotNull(rec);
            if (c3 == 0) {
                assertEquals("1", rec.getField1());
                assertEquals(2, rec.getField2());
            } else if (c3 == 1) {
                assertEquals("3", rec.getField1());
                assertEquals(4, rec.getField2());
            } else if (c3 == 2) {
                assertEquals("5", rec.getField1());
                assertEquals(6, rec.getField2());
                assertFalse(it3.hasNext());
            } else {
                fail();
            }
            c3++;
        }
        assertEquals(3, c3);
        r3.closeResources();

        // CsvTestRecord reader with array parsing
        CsvReader<CsvTestRecord3> r4 = new CsvReader<CsvTestRecord3>(
                new StringReader("1;2;3;31.12.2008;" + TestEnum.CCC.name() + ";a1;a2;a3;a4\n3;4;;;" + TestEnum.BBB.name() + ";b1;b2;b3\n5;6"),
                CsvTestRecord3.class);
        assertNotNull(r4);
        Iterator<CsvTestRecord3> it4 = r4.iterator();
        assertNotNull(it4);
        assertTrue(it4.hasNext());
        int c4 = 0;
        while (it4.hasNext()) {
            CsvTestRecord3 rec = it4.next();
            assertNotNull(rec);
            if (c4 == 0) {
                assertEquals("1", rec.getField1());
                assertEquals(2, rec.getField2());
                assertEquals(TestEnum.CCC, rec.getField5());
                assertEquals(4, rec.getField6().size());
                assertTrue(rec.getField6().get(0).equals("a1"));
                assertTrue(rec.getField6().get(1).equals("a2"));
                assertTrue(rec.getField6().get(2).equals("a3"));
                assertTrue(rec.getField6().get(3).equals("a4"));
            } else if (c4 == 1) {
                assertEquals("3", rec.getField1());
                assertEquals(4, rec.getField2());
                assertEquals(TestEnum.BBB, rec.getField5());
                assertEquals(3, rec.getField6().size());
                assertTrue(rec.getField6().get(0).equals("b1"));
                assertTrue(rec.getField6().get(1).equals("b2"));
                assertTrue(rec.getField6().get(2).equals("b3"));
            } else if (c4 == 2) {
                assertEquals("5", rec.getField1());
                assertEquals(6, rec.getField2());
                assertFalse(it4.hasNext());
                assertNull(rec.getField5());
            } else {
                fail();
            }
            c4++;
        }
View Full Code Here


          outFile.delete();
            CsvWriter<Record2> w = new CsvWriter<Record2>(new FileWriter(outFile),
                Record2.class, CsvConstants.EXCEL_SEPARATOR, CsvConstants.EXCEL_QUOTECHAR);
            assertNotNull(w);
           
            Record2 wcRecord = new Record2();
            wcRecord.setCustomer("9876543210");
            wcRecord.setResult("already");
            String out1 = w.writeNext(wcRecord);
            assertEquals("\"9876543210\";\"already\";\"\";\"\"\n", out1);

            w.closeResources();
            Assert.assertTrue("Output file must exist!", outFile.exists());
View Full Code Here

TOP

Related Classes of com.adaptiweb.utils.csvbind.bean.Record2

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.