commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r493488 [2/2] - in /jakarta/commons/sandbox/csv/trunk: ./ src/java/org/apache/commons/csv/ src/java/org/apache/commons/csv/writer/ src/test/ src/test/org/apache/commons/csv/ src/test/org/apache/commons/csv/writer/
Date Sat, 06 Jan 2007 15:40:41 GMT
Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java?view=diff&rev=493488&r1=493487&r2=493488
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
(original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
Sat Jan  6 07:40:40 2007
@@ -1,91 +1,91 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.  
- */
-package org.apache.commons.csv.writer;
-
-import java.io.ByteArrayInputStream;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for the config guesser.
- *
- * @author Martin van den Bemt
- * @version $Id: $
- */
-public class CSVConfigGuesserTest extends TestCase {
-
-    public void testSetters() throws Exception {
-        CSVConfigGuesser guesser = new CSVConfigGuesser();
-        ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]);
-        guesser.setInputStream(in);
-        assertEquals(in, guesser.getInputStream());
-        guesser = new CSVConfigGuesser(in);
-        assertEquals(in, guesser.getInputStream());
-        assertEquals(false, guesser.hasFieldHeader());
-        guesser.setHasFieldHeader(true);
-        assertEquals(true, guesser.hasFieldHeader());
-    }
-    /**
-     * Test a format like
-     *  1234 ; abcd ; 1234 ;
-     *
-     */
-    public void testConfigGuess1() {
-        CSVConfig expected = new CSVConfig();
-        expected.setDelimiter(';');
-        expected.setValueDelimiter(' ');
-        expected.setFill(CSVConfig.FILLRIGHT);
-        expected.setIgnoreValueDelimiter(false);
-        expected.setFixedWidth(true);
-        CSVField field = new CSVField();
-        field.setSize(4);
-        expected.addField(field);
-        expected.addField(field);
-        StringBuffer sb = new StringBuffer();
-        sb.append("1234;abcd;1234\n");
-        sb.append("abcd;1234;abcd");
-        ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
-        CSVConfigGuesser guesser = new CSVConfigGuesser(in);
-        CSVConfig guessed = guesser.guess();
-        assertEquals(expected.isFixedWidth(), guessed.isFixedWidth());
-        assertEquals(expected.getFields().length, guessed.getFields().length);
-        assertEquals(expected.getFields()[0].getSize(), guessed.getFields()[0].getSize());
-    }
-    /**
-     * Test a format like
-     *  1234,123123,12312312,213123
-     *  1,2,3,4
-     *
-     */
-    public void testConfigGuess2() {
-        CSVConfig expected = new CSVConfig();
-        expected.setDelimiter(';');
-        expected.setValueDelimiter(' ');
-        expected.setFill(CSVConfig.FILLRIGHT);
-        expected.setIgnoreValueDelimiter(false);
-//        expected.setFixedWidth(false);
-        StringBuffer sb = new StringBuffer();
-        sb.append("1,2,3,4\n");
-        sb.append("abcd,1234,abcd,1234");
-        ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
-        CSVConfigGuesser guesser = new CSVConfigGuesser(in);
-        CSVConfig guessed = guesser.guess();
-        assertEquals(expected.isFixedWidth(), guessed.isFixedWidth());
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+package org.apache.commons.csv.writer;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the config guesser.
+ *
+ * @author Martin van den Bemt
+ * @version $Id: $
+ */
+public class CSVConfigGuesserTest extends TestCase {
+
+    public void testSetters() throws Exception {
+        CSVConfigGuesser guesser = new CSVConfigGuesser();
+        ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]);
+        guesser.setInputStream(in);
+        assertEquals(in, guesser.getInputStream());
+        guesser = new CSVConfigGuesser(in);
+        assertEquals(in, guesser.getInputStream());
+        assertEquals(false, guesser.hasFieldHeader());
+        guesser.setHasFieldHeader(true);
+        assertEquals(true, guesser.hasFieldHeader());
+    }
+    /**
+     * Test a format like
+     *  1234 ; abcd ; 1234 ;
+     *
+     */
+    public void testConfigGuess1() {
+        CSVConfig expected = new CSVConfig();
+        expected.setDelimiter(';');
+        expected.setValueDelimiter(' ');
+        expected.setFill(CSVConfig.FILLRIGHT);
+        expected.setIgnoreValueDelimiter(false);
+        expected.setFixedWidth(true);
+        CSVField field = new CSVField();
+        field.setSize(4);
+        expected.addField(field);
+        expected.addField(field);
+        StringBuffer sb = new StringBuffer();
+        sb.append("1234;abcd;1234\n");
+        sb.append("abcd;1234;abcd");
+        ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
+        CSVConfigGuesser guesser = new CSVConfigGuesser(in);
+        CSVConfig guessed = guesser.guess();
+        assertEquals(expected.isFixedWidth(), guessed.isFixedWidth());
+        assertEquals(expected.getFields().length, guessed.getFields().length);
+        assertEquals(expected.getFields()[0].getSize(), guessed.getFields()[0].getSize());
+    }
+    /**
+     * Test a format like
+     *  1234,123123,12312312,213123
+     *  1,2,3,4
+     *
+     */
+    public void testConfigGuess2() {
+        CSVConfig expected = new CSVConfig();
+        expected.setDelimiter(';');
+        expected.setValueDelimiter(' ');
+        expected.setFill(CSVConfig.FILLRIGHT);
+        expected.setIgnoreValueDelimiter(false);
+//        expected.setFixedWidth(false);
+        StringBuffer sb = new StringBuffer();
+        sb.append("1,2,3,4\n");
+        sb.append("abcd,1234,abcd,1234");
+        ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
+        CSVConfigGuesser guesser = new CSVConfigGuesser(in);
+        CSVConfig guessed = guesser.guess();
+        assertEquals(expected.isFixedWidth(), guessed.isFixedWidth());
+    }
+}

Propchange: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java?view=diff&rev=493488&r1=493487&r2=493488
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java
(original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java
Sat Jan  6 07:40:40 2007
@@ -1,103 +1,103 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.csv.writer;
-
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-/**
- * Testcase for the CSVConfig
- *
- * @author Martin van den Bemt
- * @version $Id: $
- */
-public class CSVConfigTest extends TestCase {
-    
-
-    public void testFixedWith() {
-        CSVConfig config = new CSVConfig();
-        assertEquals(false, config.isFixedWidth());
-        config.setFixedWidth(true);
-        assertEquals(true, config.isFixedWidth());
-    }
-    
-    public void testFields() {
-        CSVConfig config = new CSVConfig();
-        assertEquals(0, config.getFields().length);
-        config.setFields((CSVField[])null);
-        assertEquals(0, config.getFields().length);
-        config.setFields((Collection)null);
-        assertEquals(0, config.getFields().length);
-        CSVField field = new CSVField();
-        field.setName("field1");
-        config.addField(field);
-        assertEquals(field, config.getFields()[0]);
-        assertEquals(null, config.getField(null));
-        assertEquals(null, config.getField("field11"));
-        assertEquals(field, config.getField("field1"));
-    }
-    
-    public void testFill() {
-        CSVConfig config = new CSVConfig();
-        assertEquals(CSVConfig.FILLNONE, config.getFill());
-        config.setFill(CSVConfig.FILLLEFT);
-        assertEquals(CSVConfig.FILLLEFT, config.getFill());
-        config.setFill(CSVConfig.FILLRIGHT);
-        assertEquals(CSVConfig.FILLRIGHT, config.getFill());
-        assertEquals(' ', config.getFillChar());
-        config.setFillChar('m');
-        assertEquals('m', config.getFillChar());
-    }
-    
-    public void testDelimiter() {
-        CSVConfig config = new CSVConfig();
-        assertEquals(',', config.getDelimiter());
-        config.setDelimiter(';');
-        assertEquals(';', config.getDelimiter());
-        assertEquals(false, config.isDelimiterIgnored());
-        config.setIgnoreDelimiter(true);
-        assertEquals(true, config.isDelimiterIgnored());
-    }
-    
-    public void testValueDelimiter() {
-        CSVConfig config = new CSVConfig();
-        assertEquals('"', config.getValueDelimiter());
-        config.setValueDelimiter('m');
-        assertEquals('m', config.getValueDelimiter());
-        assertEquals(true, config.isValueDelimiterIgnored());
-        config.setIgnoreValueDelimiter(false);
-        assertEquals(false, config.isValueDelimiterIgnored());
-    }
-    
-    public void testFieldHeader() {
-        CSVConfig config = new CSVConfig();
-        assertEquals(false, config.isFieldHeader());
-        config.setFieldHeader(true);
-        assertEquals(true, config.isFieldHeader());
-    }
-    
-    public void testTrimEnd() {
-        CSVConfig config = new CSVConfig();
-        assertEquals(false, config.isEndTrimmed());
-        config.setEndTrimmed(true);
-        assertEquals(true, config.isEndTrimmed());
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.csv.writer;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+/**
+ * Testcase for the CSVConfig
+ *
+ * @author Martin van den Bemt
+ * @version $Id: $
+ */
+public class CSVConfigTest extends TestCase {
+    
+
+    public void testFixedWith() {
+        CSVConfig config = new CSVConfig();
+        assertEquals(false, config.isFixedWidth());
+        config.setFixedWidth(true);
+        assertEquals(true, config.isFixedWidth());
+    }
+    
+    public void testFields() {
+        CSVConfig config = new CSVConfig();
+        assertEquals(0, config.getFields().length);
+        config.setFields((CSVField[])null);
+        assertEquals(0, config.getFields().length);
+        config.setFields((Collection)null);
+        assertEquals(0, config.getFields().length);
+        CSVField field = new CSVField();
+        field.setName("field1");
+        config.addField(field);
+        assertEquals(field, config.getFields()[0]);
+        assertEquals(null, config.getField(null));
+        assertEquals(null, config.getField("field11"));
+        assertEquals(field, config.getField("field1"));
+    }
+    
+    public void testFill() {
+        CSVConfig config = new CSVConfig();
+        assertEquals(CSVConfig.FILLNONE, config.getFill());
+        config.setFill(CSVConfig.FILLLEFT);
+        assertEquals(CSVConfig.FILLLEFT, config.getFill());
+        config.setFill(CSVConfig.FILLRIGHT);
+        assertEquals(CSVConfig.FILLRIGHT, config.getFill());
+        assertEquals(' ', config.getFillChar());
+        config.setFillChar('m');
+        assertEquals('m', config.getFillChar());
+    }
+    
+    public void testDelimiter() {
+        CSVConfig config = new CSVConfig();
+        assertEquals(',', config.getDelimiter());
+        config.setDelimiter(';');
+        assertEquals(';', config.getDelimiter());
+        assertEquals(false, config.isDelimiterIgnored());
+        config.setIgnoreDelimiter(true);
+        assertEquals(true, config.isDelimiterIgnored());
+    }
+    
+    public void testValueDelimiter() {
+        CSVConfig config = new CSVConfig();
+        assertEquals('"', config.getValueDelimiter());
+        config.setValueDelimiter('m');
+        assertEquals('m', config.getValueDelimiter());
+        assertEquals(true, config.isValueDelimiterIgnored());
+        config.setIgnoreValueDelimiter(false);
+        assertEquals(false, config.isValueDelimiterIgnored());
+    }
+    
+    public void testFieldHeader() {
+        CSVConfig config = new CSVConfig();
+        assertEquals(false, config.isFieldHeader());
+        config.setFieldHeader(true);
+        assertEquals(true, config.isFieldHeader());
+    }
+    
+    public void testTrimEnd() {
+        CSVConfig config = new CSVConfig();
+        assertEquals(false, config.isEndTrimmed());
+        config.setEndTrimmed(true);
+        assertEquals(true, config.isEndTrimmed());
+    }
+
+}

Propchange: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java?view=diff&rev=493488&r1=493487&r2=493488
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java
(original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java
Sat Jan  6 07:40:40 2007
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.csv.writer;
-
-import junit.framework.TestCase;
-
-/**
- * 
- * @author Martin van den Bemt
- * @version $Id: $
- */
-public class CSVFieldTest extends TestCase {
-
-    public void testCSVField() {
-        CSVField field = new CSVField();
-        assertEquals(null, field.getName());
-        field.setName("id");
-        assertEquals("id", field.getName());
-        assertEquals(0, field.getSize());
-        field.setSize(10);
-        assertEquals(10, field.getSize());
-        field = new CSVField("name");
-        assertEquals("name", field.getName());
-        field = new CSVField("name", 10);
-        assertEquals("name", field.getName());
-        assertEquals(10, field.getSize());
-    }
-    
-    public void testFill() {
-        CSVField field = new CSVField();
-        assertEquals(CSVConfig.FILLNONE, field.getFill());
-        assertEquals(false, field.overrideFill());
-        field.setFill(CSVConfig.FILLLEFT);
-        assertEquals(true, field.overrideFill());
-        assertEquals(CSVConfig.FILLLEFT, field.getFill());
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.csv.writer;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ * @author Martin van den Bemt
+ * @version $Id: $
+ */
+public class CSVFieldTest extends TestCase {
+
+    public void testCSVField() {
+        CSVField field = new CSVField();
+        assertEquals(null, field.getName());
+        field.setName("id");
+        assertEquals("id", field.getName());
+        assertEquals(0, field.getSize());
+        field.setSize(10);
+        assertEquals(10, field.getSize());
+        field = new CSVField("name");
+        assertEquals("name", field.getName());
+        field = new CSVField("name", 10);
+        assertEquals("name", field.getName());
+        assertEquals(10, field.getSize());
+    }
+    
+    public void testFill() {
+        CSVField field = new CSVField();
+        assertEquals(CSVConfig.FILLNONE, field.getFill());
+        assertEquals(false, field.overrideFill());
+        field.setFill(CSVConfig.FILLLEFT);
+        assertEquals(true, field.overrideFill());
+        assertEquals(CSVConfig.FILLLEFT, field.getFill());
+    }
+}

Propchange: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java?view=diff&rev=493488&r1=493487&r2=493488
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java
(original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java
Sat Jan  6 07:40:40 2007
@@ -1,59 +1,59 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.csv.writer;
-
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-/**
- * The testcase for the csv writer.
- * 
- * @author Martin van den Bemt
- * @version $Id: $
- */
-public class CSVWriterTest extends TestCase {
-
-    public void testCSVConfig() {
-        CSVWriter writer = new CSVWriter();
-        assertEquals(null, writer.getConfig());
-        CSVConfig config = new CSVConfig();
-        writer.setConfig(config);
-        assertEquals(config, writer.getConfig());
-        writer = new CSVWriter(config);
-        assertEquals(config, writer.getConfig());
-    }
-    
-    public void testWriter() {
-        CSVWriter writer = new CSVWriter();
-        CSVConfig config = new CSVConfig();
-        config.addField(new CSVField("field1", 5));
-        config.addField(new CSVField("field2", 4));
-        writer.setConfig(config);
-        StringWriter sw = new StringWriter();
-        writer.setWriter(sw);
-        Map map = new HashMap();
-        map.put("field1", "12345");
-        map.put("field2", "1234");
-        writer.writeRecord(map);
-        assertEquals("12345,1234\n",sw.toString());
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.csv.writer;
+
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * The testcase for the csv writer.
+ * 
+ * @author Martin van den Bemt
+ * @version $Id: $
+ */
+public class CSVWriterTest extends TestCase {
+
+    public void testCSVConfig() {
+        CSVWriter writer = new CSVWriter();
+        assertEquals(null, writer.getConfig());
+        CSVConfig config = new CSVConfig();
+        writer.setConfig(config);
+        assertEquals(config, writer.getConfig());
+        writer = new CSVWriter(config);
+        assertEquals(config, writer.getConfig());
+    }
+    
+    public void testWriter() {
+        CSVWriter writer = new CSVWriter();
+        CSVConfig config = new CSVConfig();
+        config.addField(new CSVField("field1", 5));
+        config.addField(new CSVField("field2", 4));
+        writer.setConfig(config);
+        StringWriter sw = new StringWriter();
+        writer.setWriter(sw);
+        Map map = new HashMap();
+        map.put("field1", "12345");
+        map.put("field2", "1234");
+        writer.writeRecord(map);
+        assertEquals("12345,1234\n",sw.toString());
+    }
+}

Propchange: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



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


Mime
View raw message