/** Tests the write() method with a String array. */ @Test public void testWriteStringArray() throws IOException { listWriter.writeHeader(HEADER); for (CustomerStringBean customer : STRING_CUSTOMERS) { final String[] customerArray = new String[] { customer.getCustomerNo(), customer.getFirstName(), customer.getLastName(), customer.getBirthDate(), customer.getMailingAddress(), customer.getMarried(), customer.getNumberOfKids(), customer.getFavouriteQuote(), customer.getEmail(), customer.getLoyaltyPoints() }; listWriter.write(customerArray); } listWriter.flush(); assertEquals(CSV_FILE, writer.toString()); }
/** Tests the write() method with a List and array of CellProcessors. */ @Test public void testWriteListAndProcessors() throws IOException { listWriter.writeHeader(HEADER); for (CustomerBean customer : CUSTOMERS) { final List<Object> customerList = Arrays.asList( new Object[] { customer.getCustomerNo(), customer.getFirstName(), customer.getLastName(), customer.getBirthDate(), customer.getMailingAddress(), customer.getMarried(), customer.getNumberOfKids(), customer.getFavouriteQuote(), customer.getEmail(), customer.getLoyaltyPoints() }); listWriter.write(customerList, WRITE_PROCESSORS); } listWriter.flush(); assertEquals(CSV_FILE, writer.toString()); }
/** Tests the write() method with a List and null array of CellProcessors. */ @Test(expected = NullPointerException.class) public void testWriteListAndProcessorsWithNullProcessors() throws IOException { listWriter.write(Arrays.asList(""), null); }
/** Tests the write() method with a null List and array of CellProcessors. */ @Test(expected = NullPointerException.class) public void testWriteListAndProcessorsWithNullList() throws IOException { listWriter.write(null, WRITE_PROCESSORS); }
/** Closes the list writer after the test. */ @After public void tearDown() throws IOException { listWriter.close(); }
/** Tests the write() method with a null String array. */ @Test(expected = NullPointerException.class) public void testWriteStringArrayWithNullArray() throws IOException { listWriter.write((String[]) null); }
/** Tests the write() method with a null List. */ @Test(expected = NullPointerException.class) public void testWriteListWithNullList() throws IOException { listWriter.write((List<?>) null); }