commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1299580 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
Date Mon, 12 Mar 2012 16:48:04 GMT
On 12 March 2012 08:45,  <ebourg@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.

> 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-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message