On Mon, Mar 12, 2012 at 5:48 PM, sebb <seb...@gmail.com> wrote:
> On 12 March 2012 08:45,  <ebo...@apache.org> wrote:
>> Author: ebourg
>> Date: Mon Mar 12 08:45:34 2012
>> New Revision: 1299580
>>
>> URL: http://svn.apache.org/viewvc?rev=1299580&view=rev
>> Log:
>> Serialization test for CSVFormat
>
> Note: this does not test serialisation between versions or JDKs as the
> same JVM is used for writing and reading.

Is it necessary to test/support this? serialization is a standard jdk
feature which has worked like that for ages
(serious question)


>> Modified:
>>    
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
>>
>> Modified: 
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
>> URL: 
>> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java?rev=1299580&r1=1299579&r2=1299580&view=diff
>> ==============================================================================
>> --- 
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
>>  (original)
>> +++ 
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
>>  Mon Mar 12 08:45:34 2012
>> @@ -17,6 +17,11 @@
>>
>>  package org.apache.commons.csv;
>>
>> +import java.io.ByteArrayInputStream;
>> +import java.io.ByteArrayOutputStream;
>> +import java.io.ObjectInputStream;
>> +import java.io.ObjectOutputStream;
>> +
>>  import junit.framework.TestCase;
>>
>>  public class CSVFormatTest extends TestCase {
>> @@ -141,7 +146,28 @@ public class CSVFormatTest extends TestC
>>         } catch (IllegalArgumentException e) {
>>             // expected
>>         }
>> +    }
>> +
>> +    public void testSerialization() throws Exception {
>> +        ByteArrayOutputStream out = new ByteArrayOutputStream();
>>
>> -
>> +        ObjectOutputStream oos = new ObjectOutputStream(out);
>> +        oos.writeObject(CSVFormat.DEFAULT);
>> +        oos.flush();
>> +        oos.close();
>> +
>> +        ObjectInputStream in = new ObjectInputStream(new 
>> ByteArrayInputStream(out.toByteArray()));
>> +        CSVFormat format = (CSVFormat) in.readObject();
>> +
>> +        assertNotNull(format);
>> +        assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), 
>> format.getDelimiter());
>> +        assertEquals("encapsulator", CSVFormat.DEFAULT.getEncapsulator(), 
>> format.getEncapsulator());
>> +        assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), 
>> format.getCommentStart());
>> +        assertEquals("line separator", 
>> CSVFormat.DEFAULT.getLineSeparator(), format.getLineSeparator());
>> +        assertEquals("escape", CSVFormat.DEFAULT.getEscape(), 
>> format.getEscape());
>> +        assertEquals("unicode escape", 
>> CSVFormat.DEFAULT.isUnicodeEscapesInterpreted(), 
>> format.isUnicodeEscapesInterpreted());
>> +        assertEquals("trim left", 
>> CSVFormat.DEFAULT.isLeadingSpacesIgnored(), format.isLeadingSpacesIgnored());
>> +        assertEquals("trim right", 
>> CSVFormat.DEFAULT.isTrailingSpacesIgnored(), 
>> format.isTrailingSpacesIgnored());
>> +        assertEquals("empty lines", 
>> CSVFormat.DEFAULT.isEmptyLinesIgnored(), format.isEmptyLinesIgnored());
>>     }
>>  }
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to