@SuppressWarnings("boxing") // no need to worry about boxing here @Test public void testSerialization() throws Exception { final ByteArrayOutputStream out = new ByteArrayOutputStream(); try (final ObjectOutputStream oos = new ObjectOutputStream(out)) { oos.writeObject(CSVFormat.DEFAULT); oos.flush(); } final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray())); final CSVFormat format = (CSVFormat) in.readObject(); assertNotNull(format); assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter()); assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteCharacter(), format.getQuoteCharacter()); assertEquals("comment start", CSVFormat.DEFAULT.getCommentMarker(), format.getCommentMarker()); assertEquals( "record separator", CSVFormat.DEFAULT.getRecordSeparator(), format.getRecordSeparator()); assertEquals("escape", CSVFormat.DEFAULT.getEscapeCharacter(), format.getEscapeCharacter()); assertEquals( "trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces()); assertEquals( "empty lines", CSVFormat.DEFAULT.getIgnoreEmptyLines(), format.getIgnoreEmptyLines()); }