commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaco...@apache.org
Subject svn commit: r1065950 [3/3] - in /commons/sandbox/csv/trunk/src: java/org/apache/commons/csv/ java/org/apache/commons/csv/writer/ test/org/apache/commons/csv/ test/org/apache/commons/csv/writer/
Date Tue, 01 Feb 2011 08:46:01 GMT
Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java Tue Feb
 1 08:46:00 2011
@@ -24,68 +24,68 @@ import junit.framework.TestCase;
  * CSVStrategyTest
  *
  * The test are organized in three different sections:
- * The 'setter/getter' section, the lexer section and finally the strategy 
- * section. In case a test fails, you should follow a top-down approach for 
+ * The 'setter/getter' section, the lexer section and finally the strategy
+ * section. In case a test fails, you should follow a top-down approach for
  * fixing a potential bug (its likely that the strategy itself fails if the lexer
  * has problems...).
  */
 public class CSVStrategyTest extends TestCase {
 
-  // ======================================================
-  //   getters / setters
-  // ======================================================
-  public void testGetSetCommentStart() {
-    CSVStrategy strategy = (CSVStrategy)CSVStrategy.DEFAULT_STRATEGY.clone();
-    strategy.setCommentStart('#');
-    assertEquals(strategy.getCommentStart(), '#');
-    strategy.setCommentStart('!');
-    assertEquals(strategy.getCommentStart(), '!');
-  }
-
-  public void testGetSetEncapsulator() {
-    CSVStrategy strategy = (CSVStrategy)CSVStrategy.DEFAULT_STRATEGY.clone();
-    strategy.setEncapsulator('"');
-    assertEquals(strategy.getEncapsulator(), '"');
-    strategy.setEncapsulator('\'');
-    assertEquals(strategy.getEncapsulator(), '\'');
-  }
-
-  public void testGetSetDelimiter() {
-    CSVStrategy strategy = (CSVStrategy)CSVStrategy.DEFAULT_STRATEGY.clone();
-    strategy.setDelimiter(';');
-    assertEquals(strategy.getDelimiter(), ';');
-    strategy.setDelimiter(',');
-    assertEquals(strategy.getDelimiter(), ',');
-    strategy.setDelimiter('\t');
-    assertEquals(strategy.getDelimiter(), '\t');
-  }
-
-  public void testSetCSVStrategy() {
-    CSVStrategy strategy = CSVStrategy.DEFAULT_STRATEGY;
-    // default settings
-    assertEquals(strategy.getDelimiter(), ',');
-    assertEquals(strategy.getEncapsulator(), '"');
-    assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
-    assertEquals(true,  strategy.getIgnoreLeadingWhitespaces());
-    assertEquals(false, strategy.getUnicodeEscapeInterpretation());
-    assertEquals(true,  strategy.getIgnoreEmptyLines());
-    // explicit csv settings
-    assertEquals(strategy.getDelimiter(), ',');
-    assertEquals(strategy.getEncapsulator(), '"');
-    assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
-    assertEquals(true,  strategy.getIgnoreLeadingWhitespaces());
-    assertEquals(false, strategy.getUnicodeEscapeInterpretation());
-    assertEquals(true,  strategy.getIgnoreEmptyLines());
-  }
-  
-  public void testSetExcelStrategy() {
-    CSVStrategy strategy = CSVStrategy.EXCEL_STRATEGY;
-    assertEquals(strategy.getDelimiter(), ',');
-    assertEquals(strategy.getEncapsulator(), '"');
-    assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
-    assertEquals(false,  strategy.getIgnoreLeadingWhitespaces());
-    assertEquals(false, strategy.getUnicodeEscapeInterpretation());
-    assertEquals(false, strategy.getIgnoreEmptyLines());
-  }
-  
+    // ======================================================
+    //   getters / setters
+    // ======================================================
+    public void testGetSetCommentStart() {
+        CSVStrategy strategy = (CSVStrategy) CSVStrategy.DEFAULT_STRATEGY.clone();
+        strategy.setCommentStart('#');
+        assertEquals(strategy.getCommentStart(), '#');
+        strategy.setCommentStart('!');
+        assertEquals(strategy.getCommentStart(), '!');
+    }
+
+    public void testGetSetEncapsulator() {
+        CSVStrategy strategy = (CSVStrategy) CSVStrategy.DEFAULT_STRATEGY.clone();
+        strategy.setEncapsulator('"');
+        assertEquals(strategy.getEncapsulator(), '"');
+        strategy.setEncapsulator('\'');
+        assertEquals(strategy.getEncapsulator(), '\'');
+    }
+
+    public void testGetSetDelimiter() {
+        CSVStrategy strategy = (CSVStrategy) CSVStrategy.DEFAULT_STRATEGY.clone();
+        strategy.setDelimiter(';');
+        assertEquals(strategy.getDelimiter(), ';');
+        strategy.setDelimiter(',');
+        assertEquals(strategy.getDelimiter(), ',');
+        strategy.setDelimiter('\t');
+        assertEquals(strategy.getDelimiter(), '\t');
+    }
+
+    public void testSetCSVStrategy() {
+        CSVStrategy strategy = CSVStrategy.DEFAULT_STRATEGY;
+        // default settings
+        assertEquals(strategy.getDelimiter(), ',');
+        assertEquals(strategy.getEncapsulator(), '"');
+        assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
+        assertEquals(true, strategy.getIgnoreLeadingWhitespaces());
+        assertEquals(false, strategy.getUnicodeEscapeInterpretation());
+        assertEquals(true, strategy.getIgnoreEmptyLines());
+        // explicit csv settings
+        assertEquals(strategy.getDelimiter(), ',');
+        assertEquals(strategy.getEncapsulator(), '"');
+        assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
+        assertEquals(true, strategy.getIgnoreLeadingWhitespaces());
+        assertEquals(false, strategy.getUnicodeEscapeInterpretation());
+        assertEquals(true, strategy.getIgnoreEmptyLines());
+    }
+
+    public void testSetExcelStrategy() {
+        CSVStrategy strategy = CSVStrategy.EXCEL_STRATEGY;
+        assertEquals(strategy.getDelimiter(), ',');
+        assertEquals(strategy.getEncapsulator(), '"');
+        assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
+        assertEquals(false, strategy.getIgnoreLeadingWhitespaces());
+        assertEquals(false, strategy.getUnicodeEscapeInterpretation());
+        assertEquals(false, strategy.getIgnoreEmptyLines());
+    }
+
 } 

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVUtilsTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVUtilsTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVUtilsTest.java Tue Feb  1
08:46:00 2011
@@ -24,127 +24,127 @@ import junit.framework.TestCase;
  * CSVUtilsTest
  */
 public class CSVUtilsTest extends TestCase {
-  
-  // ======================================================
-  //   static parser tests
-  // ======================================================
-  public void testParse1() throws IOException {
-      String[][] data = CSVUtils.parse("abc\ndef");
-      assertEquals(2, data.length);
-      assertEquals(1, data[0].length);
-      assertEquals(1, data[1].length);
-      assertEquals("abc", data[0][0]);
-      assertEquals("def", data[1][0]);
+
+    // ======================================================
+    //   static parser tests
+    // ======================================================
+    public void testParse1() throws IOException {
+        String[][] data = CSVUtils.parse("abc\ndef");
+        assertEquals(2, data.length);
+        assertEquals(1, data[0].length);
+        assertEquals(1, data[1].length);
+        assertEquals("abc", data[0][0]);
+        assertEquals("def", data[1][0]);
     }
 
     public void testParse2() throws IOException {
-      String[][] data = CSVUtils.parse("abc,def,\"ghi,jkl\"\ndef");
-      assertEquals(2, data.length);
-      assertEquals(3, data[0].length);
-      assertEquals(1, data[1].length);
-      assertEquals("abc", data[0][0]);
-      assertEquals("def", data[0][1]);
-      assertEquals("ghi,jkl", data[0][2]);
-      assertEquals("def", data[1][0]);
+        String[][] data = CSVUtils.parse("abc,def,\"ghi,jkl\"\ndef");
+        assertEquals(2, data.length);
+        assertEquals(3, data[0].length);
+        assertEquals(1, data[1].length);
+        assertEquals("abc", data[0][0]);
+        assertEquals("def", data[0][1]);
+        assertEquals("ghi,jkl", data[0][2]);
+        assertEquals("def", data[1][0]);
     }
 
     public void testParse3() throws IOException {
-      String[][] data = CSVUtils.parse("abc,\"def\nghi\"\njkl");
-      assertEquals(2, data.length);
-      assertEquals(2, data[0].length);
-      assertEquals(1, data[1].length);
-      assertEquals("abc", data[0][0]);
-      assertEquals("def\nghi", data[0][1]);
-      assertEquals("jkl", data[1][0]);
+        String[][] data = CSVUtils.parse("abc,\"def\nghi\"\njkl");
+        assertEquals(2, data.length);
+        assertEquals(2, data[0].length);
+        assertEquals(1, data[1].length);
+        assertEquals("abc", data[0][0]);
+        assertEquals("def\nghi", data[0][1]);
+        assertEquals("jkl", data[1][0]);
     }
 
     public void testParse4() throws IOException {
-      String[][] data = CSVUtils.parse("abc,\"def\\\\nghi\"\njkl");
-      assertEquals(2, data.length);
-      assertEquals(2, data[0].length);
-      assertEquals(1, data[1].length);
-      assertEquals("abc", data[0][0]);
-      // an escape char in quotes only escapes a delimiter, not itself
-      assertEquals("def\\\\nghi", data[0][1]);
-      assertEquals("jkl", data[1][0]);
+        String[][] data = CSVUtils.parse("abc,\"def\\\\nghi\"\njkl");
+        assertEquals(2, data.length);
+        assertEquals(2, data[0].length);
+        assertEquals(1, data[1].length);
+        assertEquals("abc", data[0][0]);
+        // an escape char in quotes only escapes a delimiter, not itself
+        assertEquals("def\\\\nghi", data[0][1]);
+        assertEquals("jkl", data[1][0]);
     }
 
     public void testParse5() throws IOException {
-      String[][] data = CSVUtils.parse("abc,def\\nghi\njkl");
-      assertEquals(2, data.length);
-      assertEquals(2, data[0].length);
-      assertEquals(1, data[1].length);
-      assertEquals("abc", data[0][0]);
-      assertEquals("def\\nghi", data[0][1]);
-      assertEquals("jkl", data[1][0]);
+        String[][] data = CSVUtils.parse("abc,def\\nghi\njkl");
+        assertEquals(2, data.length);
+        assertEquals(2, data[0].length);
+        assertEquals(1, data[1].length);
+        assertEquals("abc", data[0][0]);
+        assertEquals("def\\nghi", data[0][1]);
+        assertEquals("jkl", data[1][0]);
     }
-    
+
     public void testParse6() throws IOException {
-      String[][] data = CSVUtils.parse("");
-      // default strategy is CSV, which ignores empty lines
-      assertEquals(0, data.length);
+        String[][] data = CSVUtils.parse("");
+        // default strategy is CSV, which ignores empty lines
+        assertEquals(0, data.length);
     }
-    
+
     public void testParse7() throws IOException {
-      boolean io = false;
-      try {
-        CSVUtils.parse(null);
-      } catch (IllegalArgumentException e) {
-        io = true;
-      }
-      assertTrue(io);
+        boolean io = false;
+        try {
+            CSVUtils.parse(null);
+        } catch (IllegalArgumentException e) {
+            io = true;
+        }
+        assertTrue(io);
     }
-    
+
     public void testParseLine1() throws IOException {
-      String[] data = CSVUtils.parseLine("abc,def,ghi");
-      assertEquals(3, data.length);
-      assertEquals("abc", data[0]);
-      assertEquals("def", data[1]);
-      assertEquals("ghi", data[2]);
+        String[] data = CSVUtils.parseLine("abc,def,ghi");
+        assertEquals(3, data.length);
+        assertEquals("abc", data[0]);
+        assertEquals("def", data[1]);
+        assertEquals("ghi", data[2]);
     }
 
     public void testParseLine2() throws IOException {
-      String[] data = CSVUtils.parseLine("abc,def,ghi\n");
-      assertEquals(3, data.length);
-      assertEquals("abc", data[0]);
-      assertEquals("def", data[1]);
-      assertEquals("ghi", data[2]);
+        String[] data = CSVUtils.parseLine("abc,def,ghi\n");
+        assertEquals(3, data.length);
+        assertEquals("abc", data[0]);
+        assertEquals("def", data[1]);
+        assertEquals("ghi", data[2]);
     }
 
     public void testParseLine3() throws IOException {
-      String[] data = CSVUtils.parseLine("abc,\"def,ghi\"");
-      assertEquals(2, data.length);
-      assertEquals("abc", data[0]);
-      assertEquals("def,ghi", data[1]);
+        String[] data = CSVUtils.parseLine("abc,\"def,ghi\"");
+        assertEquals(2, data.length);
+        assertEquals("abc", data[0]);
+        assertEquals("def,ghi", data[1]);
     }
 
     public void testParseLine4() throws IOException {
-      String[] data = CSVUtils.parseLine("abc,\"def\nghi\"");
-      assertEquals(2, data.length);
-      assertEquals("abc", data[0]);
-      assertEquals("def\nghi", data[1]);
+        String[] data = CSVUtils.parseLine("abc,\"def\nghi\"");
+        assertEquals(2, data.length);
+        assertEquals("abc", data[0]);
+        assertEquals("def\nghi", data[1]);
     }
-    
+
     public void testParseLine5() throws IOException {
-      String[] data = CSVUtils.parseLine("");
-      assertEquals(0, data.length);
-      // assertEquals("", data[0]);
+        String[] data = CSVUtils.parseLine("");
+        assertEquals(0, data.length);
+        // assertEquals("", data[0]);
     }
-    
+
     public void testParseLine6() throws IOException {
-      boolean io = false;
-      try {
-        CSVUtils.parseLine(null);
-      } catch (IllegalArgumentException e) {
-        io = true;
-      }
-      assertTrue(io);
+        boolean io = false;
+        try {
+            CSVUtils.parseLine(null);
+        } catch (IllegalArgumentException e) {
+            io = true;
+        }
+        assertTrue(io);
     }
-    
+
     public void testParseLine7() throws IOException {
-      String[] res = CSVUtils.parseLine("");
-      assertNotNull(res);
-      assertEquals(0, res.length);  
+        String[] res = CSVUtils.parseLine("");
+        assertNotNull(res);
+        assertEquals(0, res.length);
     }
-      
+
 }

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CharBufferTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CharBufferTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CharBufferTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CharBufferTest.java Tue Feb
 1 08:46:00 2011
@@ -21,7 +21,6 @@ package org.apache.commons.csv;
 import junit.framework.TestCase;
 
 /**
- * 
  * @author Ortwin Gl├╝ck
  */
 public class CharBufferTest extends TestCase {
@@ -31,14 +30,14 @@ public class CharBufferTest extends Test
         try {
             cb = new CharBuffer(0);
             fail("Should not be possible");
-        } catch(IllegalArgumentException e) {
+        } catch (IllegalArgumentException e) {
             // expected
         }
-        
+
         cb = new CharBuffer(128);
         assertEquals(0, cb.length());
     }
-    
+
     public void testAppendChar() {
         CharBuffer cb = new CharBuffer(1);
         String expected = "";
@@ -49,59 +48,59 @@ public class CharBufferTest extends Test
             assertEquals(expected.length(), cb.length());
         }
     }
-    
+
     public void testAppendCharArray() {
         CharBuffer cb = new CharBuffer(1);
         char[] abcd = "abcd".toCharArray();
         String expected = "";
-        for (int i=0; i<10; i++) {
+        for (int i = 0; i < 10; i++) {
             cb.append(abcd);
             expected += "abcd";
             assertEquals(expected, cb.toString());
-            assertEquals(4*(i+1), cb.length());
+            assertEquals(4 * (i + 1), cb.length());
         }
     }
-    
+
     public void testAppendString() {
         CharBuffer cb = new CharBuffer(1);
         String abcd = "abcd";
         String expected = "";
-        for (int i=0; i<10; i++) {
+        for (int i = 0; i < 10; i++) {
             cb.append(abcd);
             expected += abcd;
             assertEquals(expected, cb.toString());
-            assertEquals(4*(i+1), cb.length());
+            assertEquals(4 * (i + 1), cb.length());
         }
     }
-    
+
     public void testAppendStringBuffer() {
         CharBuffer cb = new CharBuffer(1);
         StringBuffer abcd = new StringBuffer("abcd");
         String expected = "";
-        for (int i=0; i<10; i++) {
+        for (int i = 0; i < 10; i++) {
             cb.append(abcd);
             expected += "abcd";
             assertEquals(expected, cb.toString());
-            assertEquals(4*(i+1), cb.length());
+            assertEquals(4 * (i + 1), cb.length());
         }
     }
-    
+
     public void testAppendCharBuffer() {
         CharBuffer cb = new CharBuffer(1);
         CharBuffer abcd = new CharBuffer(17);
         abcd.append("abcd");
         String expected = "";
-        for (int i=0; i<10; i++) {
+        for (int i = 0; i < 10; i++) {
             cb.append(abcd);
             expected += "abcd";
             assertEquals(expected, cb.toString());
-            assertEquals(4*(i+1), cb.length());
+            assertEquals(4 * (i + 1), cb.length());
         }
     }
-    
+
     public void testShrink() {
         String data = "123456789012345678901234567890";
-        
+
         CharBuffer cb = new CharBuffer(data.length() + 100);
         assertEquals(data.length() + 100, cb.capacity());
         cb.append(data);
@@ -112,24 +111,24 @@ public class CharBufferTest extends Test
         assertEquals(data.length(), cb.length());
         assertEquals(data, cb.toString());
     }
-    
+
     //-- the following test cases have been adapted from the HttpComponents project
     //-- written by Oleg Kalnichevski
-    
+
     public void testSimpleAppend() throws Exception {
         CharBuffer buffer = new CharBuffer(16);
-        assertEquals(16, buffer.capacity()); 
+        assertEquals(16, buffer.capacity());
         assertEquals(0, buffer.length());
         char[] b1 = buffer.getCharacters();
         assertNotNull(b1);
         assertEquals(0, b1.length);
         assertEquals(0, buffer.length());
-        
-        char[] tmp = new char[] { '1', '2', '3', '4'};
+
+        char[] tmp = new char[]{'1', '2', '3', '4'};
         buffer.append(tmp);
-        assertEquals(16, buffer.capacity()); 
+        assertEquals(16, buffer.capacity());
         assertEquals(4, buffer.length());
-        
+
         char[] b2 = buffer.getCharacters();
         assertNotNull(b2);
         assertEquals(4, b2.length);
@@ -137,35 +136,35 @@ public class CharBufferTest extends Test
             assertEquals(tmp[i], b2[i]);
         }
         assertEquals("1234", buffer.toString());
-        
+
         buffer.clear();
-        assertEquals(16, buffer.capacity()); 
+        assertEquals(16, buffer.capacity());
         assertEquals(0, buffer.length());
     }
-    
+
     public void testAppendString2() throws Exception {
         CharBuffer buffer = new CharBuffer(8);
         buffer.append("stuff");
         buffer.append(" and more stuff");
         assertEquals("stuff and more stuff", buffer.toString());
     }
-    
+
     public void testAppendNull() throws Exception {
         CharBuffer buffer = new CharBuffer(8);
-        
-        buffer.append((StringBuffer)null);
+
+        buffer.append((StringBuffer) null);
         assertEquals("", buffer.toString());
-        
-        buffer.append((String)null);
+
+        buffer.append((String) null);
         assertEquals("", buffer.toString());
 
-        buffer.append((CharBuffer)null);
+        buffer.append((CharBuffer) null);
         assertEquals("", buffer.toString());
 
-        buffer.append((char[])null);
+        buffer.append((char[]) null);
         assertEquals("", buffer.toString());
     }
-    
+
     public void testAppendCharArrayBuffer() throws Exception {
         CharBuffer buffer1 = new CharBuffer(8);
         buffer1.append(" and more stuff");
@@ -174,7 +173,7 @@ public class CharBufferTest extends Test
         buffer2.append(buffer1);
         assertEquals("stuff and more stuff", buffer2.toString());
     }
-    
+
     public void testAppendSingleChar() throws Exception {
         CharBuffer buffer = new CharBuffer(4);
         buffer.append('1');
@@ -185,7 +184,7 @@ public class CharBufferTest extends Test
         buffer.append('6');
         assertEquals("123456", buffer.toString());
     }
-    
+
     public void testProvideCapacity() throws Exception {
         CharBuffer buffer = new CharBuffer(4);
         buffer.provideCapacity(2);

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/ExtendedBufferedReaderTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/ExtendedBufferedReaderTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/ExtendedBufferedReaderTest.java
(original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/ExtendedBufferedReaderTest.java
Tue Feb  1 08:46:00 2011
@@ -25,139 +25,138 @@ import junit.framework.TestSuite;
 
 /**
  * ExtendedBufferedReaderTest
- *
  */
 public class ExtendedBufferedReaderTest extends TestCase {
 
-  // ======================================================
-  //   the test cases
-  // ======================================================
- 
-  public void testConstructors() {
-    ExtendedBufferedReader br = new ExtendedBufferedReader(new StringReader(""));
-    br = new ExtendedBufferedReader(new StringReader(""), 10); 
-  }
-  
-  public void testReadLookahead1() throws Exception {
-   
-    assertEquals(ExtendedBufferedReader.END_OF_STREAM, getEBR("").read());
-    ExtendedBufferedReader br = getEBR("1\n2\r3\n");
-    assertEquals('1', br.lookAhead());
-    assertEquals(ExtendedBufferedReader.UNDEFINED, br.readAgain());
-    assertEquals('1', br.read());
-    assertEquals('1', br.readAgain());
-
-    assertEquals(0, br.getLineNumber());
-    assertEquals('\n', br.lookAhead());
-    assertEquals(0, br.getLineNumber());
-    assertEquals('1', br.readAgain());    
-    assertEquals('\n', br.read());
-    assertEquals(1, br.getLineNumber());
-    assertEquals('\n', br.readAgain());
-    assertEquals(1, br.getLineNumber());
-    
-    assertEquals('2', br.lookAhead());
-    assertEquals(1, br.getLineNumber());
-    assertEquals('\n', br.readAgain());
-    assertEquals(1, br.getLineNumber());
-    assertEquals('2', br.read());
-    assertEquals('2', br.readAgain());
-    
-    assertEquals('\r', br.lookAhead());
-    assertEquals('2', br.readAgain());
-    assertEquals('\r', br.read());
-    assertEquals('\r', br.readAgain());
-    
-    assertEquals('3', br.lookAhead());
-    assertEquals('\r', br.readAgain());
-    assertEquals('3', br.read());
-    assertEquals('3', br.readAgain());
-    
-    assertEquals('\n', br.lookAhead());
-    assertEquals(1, br.getLineNumber());
-    assertEquals('3', br.readAgain());
-    assertEquals('\n', br.read());
-    assertEquals(2, br.getLineNumber());
-    assertEquals('\n', br.readAgain());
-    assertEquals(2, br.getLineNumber());
-    
-    assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead());
-    assertEquals('\n', br.readAgain());
-    assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.read());
-    assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.readAgain());
-    assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.read());
-    assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead());
- 
-  }
-  
-
-  public void testReadLookahead2() throws Exception {
-    char[] ref = new char[5];
-    char[] res = new char[5];  
-    
-    ExtendedBufferedReader br = getEBR("");
-    assertEquals(0, br.read(res, 0, 0));
-    assertTrue(Arrays.equals(res, ref)); 
-    
-    br = getEBR("abcdefg");
-    ref[0] = 'a';
-    ref[1] = 'b';
-    ref[2] = 'c';
-    assertEquals(3, br.read(res, 0, 3));
-    assertTrue(Arrays.equals(res, ref));
-    assertEquals('c', br.readAgain());
-    
-    assertEquals('d', br.lookAhead());
-    ref[4] = 'd';
-    assertEquals(1, br.read(res, 4, 1));
-    assertTrue(Arrays.equals(res, ref));
-    assertEquals('d', br.readAgain());
- 
-  }
-  
-  public void testReadLine() throws Exception {
-    ExtendedBufferedReader br = getEBR("");
-    assertTrue(br.readLine() == null);
-    
-    br = getEBR("\n");
-    assertTrue(br.readLine().equals(""));
-    assertTrue(br.readLine() == null);
-    
-    br = getEBR("foo\n\nhello");
-    assertEquals(0, br.getLineNumber());
-    assertTrue(br.readLine().equals("foo"));
-    assertEquals(1, br.getLineNumber());
-    assertTrue(br.readLine().equals(""));
-    assertEquals(2, br.getLineNumber());
-    assertTrue(br.readLine().equals("hello"));
-    assertEquals(3, br.getLineNumber());
-    assertTrue(br.readLine() == null);
-    assertEquals(3, br.getLineNumber());
-    
-    br = getEBR("foo\n\nhello");
-    assertEquals('f', br.read());
-    assertEquals('o', br.lookAhead());
-    assertTrue(br.readLine().equals("oo"));
-    assertEquals(1, br.getLineNumber());
-    assertEquals('\n', br.lookAhead());
-    assertTrue(br.readLine().equals(""));
-    assertEquals(2, br.getLineNumber());
-    assertEquals('h', br.lookAhead());
-    assertTrue(br.readLine().equals("hello"));
-    assertTrue(br.readLine() == null);
-    assertEquals(3, br.getLineNumber());
-    
- 
-    br = getEBR("foo\rbaar\r\nfoo");
-    assertTrue(br.readLine().equals("foo"));
-    assertEquals('b', br.lookAhead());
-    assertTrue(br.readLine().equals("baar"));
-    assertEquals('f', br.lookAhead());
-    assertTrue(br.readLine().equals("foo"));
-    assertTrue(br.readLine() == null);
-  }
-  
-  private ExtendedBufferedReader getEBR(String s) {
-    return new ExtendedBufferedReader(new StringReader(s));
-  }
+    // ======================================================
+    //   the test cases
+    // ======================================================
+
+    public void testConstructors() {
+        ExtendedBufferedReader br = new ExtendedBufferedReader(new StringReader(""));
+        br = new ExtendedBufferedReader(new StringReader(""), 10);
+    }
+
+    public void testReadLookahead1() throws Exception {
+
+        assertEquals(ExtendedBufferedReader.END_OF_STREAM, getEBR("").read());
+        ExtendedBufferedReader br = getEBR("1\n2\r3\n");
+        assertEquals('1', br.lookAhead());
+        assertEquals(ExtendedBufferedReader.UNDEFINED, br.readAgain());
+        assertEquals('1', br.read());
+        assertEquals('1', br.readAgain());
+
+        assertEquals(0, br.getLineNumber());
+        assertEquals('\n', br.lookAhead());
+        assertEquals(0, br.getLineNumber());
+        assertEquals('1', br.readAgain());
+        assertEquals('\n', br.read());
+        assertEquals(1, br.getLineNumber());
+        assertEquals('\n', br.readAgain());
+        assertEquals(1, br.getLineNumber());
+
+        assertEquals('2', br.lookAhead());
+        assertEquals(1, br.getLineNumber());
+        assertEquals('\n', br.readAgain());
+        assertEquals(1, br.getLineNumber());
+        assertEquals('2', br.read());
+        assertEquals('2', br.readAgain());
+
+        assertEquals('\r', br.lookAhead());
+        assertEquals('2', br.readAgain());
+        assertEquals('\r', br.read());
+        assertEquals('\r', br.readAgain());
+
+        assertEquals('3', br.lookAhead());
+        assertEquals('\r', br.readAgain());
+        assertEquals('3', br.read());
+        assertEquals('3', br.readAgain());
+
+        assertEquals('\n', br.lookAhead());
+        assertEquals(1, br.getLineNumber());
+        assertEquals('3', br.readAgain());
+        assertEquals('\n', br.read());
+        assertEquals(2, br.getLineNumber());
+        assertEquals('\n', br.readAgain());
+        assertEquals(2, br.getLineNumber());
+
+        assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead());
+        assertEquals('\n', br.readAgain());
+        assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.read());
+        assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.readAgain());
+        assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.read());
+        assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead());
+
+    }
+
+
+    public void testReadLookahead2() throws Exception {
+        char[] ref = new char[5];
+        char[] res = new char[5];
+
+        ExtendedBufferedReader br = getEBR("");
+        assertEquals(0, br.read(res, 0, 0));
+        assertTrue(Arrays.equals(res, ref));
+
+        br = getEBR("abcdefg");
+        ref[0] = 'a';
+        ref[1] = 'b';
+        ref[2] = 'c';
+        assertEquals(3, br.read(res, 0, 3));
+        assertTrue(Arrays.equals(res, ref));
+        assertEquals('c', br.readAgain());
+
+        assertEquals('d', br.lookAhead());
+        ref[4] = 'd';
+        assertEquals(1, br.read(res, 4, 1));
+        assertTrue(Arrays.equals(res, ref));
+        assertEquals('d', br.readAgain());
+
+    }
+
+    public void testReadLine() throws Exception {
+        ExtendedBufferedReader br = getEBR("");
+        assertTrue(br.readLine() == null);
+
+        br = getEBR("\n");
+        assertTrue(br.readLine().equals(""));
+        assertTrue(br.readLine() == null);
+
+        br = getEBR("foo\n\nhello");
+        assertEquals(0, br.getLineNumber());
+        assertTrue(br.readLine().equals("foo"));
+        assertEquals(1, br.getLineNumber());
+        assertTrue(br.readLine().equals(""));
+        assertEquals(2, br.getLineNumber());
+        assertTrue(br.readLine().equals("hello"));
+        assertEquals(3, br.getLineNumber());
+        assertTrue(br.readLine() == null);
+        assertEquals(3, br.getLineNumber());
+
+        br = getEBR("foo\n\nhello");
+        assertEquals('f', br.read());
+        assertEquals('o', br.lookAhead());
+        assertTrue(br.readLine().equals("oo"));
+        assertEquals(1, br.getLineNumber());
+        assertEquals('\n', br.lookAhead());
+        assertTrue(br.readLine().equals(""));
+        assertEquals(2, br.getLineNumber());
+        assertEquals('h', br.lookAhead());
+        assertTrue(br.readLine().equals("hello"));
+        assertTrue(br.readLine() == null);
+        assertEquals(3, br.getLineNumber());
+
+
+        br = getEBR("foo\rbaar\r\nfoo");
+        assertTrue(br.readLine().equals("foo"));
+        assertEquals('b', br.lookAhead());
+        assertTrue(br.readLine().equals("baar"));
+        assertEquals('f', br.lookAhead());
+        assertTrue(br.readLine().equals("foo"));
+        assertTrue(br.readLine() == null);
+    }
+
+    private ExtendedBufferedReader getEBR(String s) {
+        return new ExtendedBufferedReader(new StringReader(s));
+    }
 }

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
(original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigGuesserTest.java
Tue Feb  1 08:46:00 2011
@@ -41,10 +41,10 @@ public class CSVConfigGuesserTest extend
         guesser.setHasFieldHeader(true);
         assertEquals(true, guesser.hasFieldHeader());
     }
+
     /**
      * Test a format like
-     *  1234 ; abcd ; 1234 ;
-     *
+     * 1234 ; abcd ; 1234 ;
      */
     public void testConfigGuess1() {
         CSVConfig expected = new CSVConfig();
@@ -67,11 +67,11 @@ public class CSVConfigGuesserTest extend
         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
-     *
+     * 1234,123123,12312312,213123
+     * 1,2,3,4
      */
     public void testConfigGuess2() {
         CSVConfig expected = new CSVConfig();

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVConfigTest.java Tue
Feb  1 08:46:00 2011
@@ -29,7 +29,7 @@ import junit.framework.TestCase;
  * @version $Id: $
  */
 public class CSVConfigTest extends TestCase {
-    
+
 
     public void testFixedWith() {
         CSVConfig config = new CSVConfig();
@@ -37,13 +37,13 @@ public class CSVConfigTest extends TestC
         config.setFixedWidth(true);
         assertEquals(true, config.isFixedWidth());
     }
-    
+
     public void testFields() {
         CSVConfig config = new CSVConfig();
         assertEquals(0, config.getFields().length);
-        config.setFields((CSVField[])null);
+        config.setFields((CSVField[]) null);
         assertEquals(0, config.getFields().length);
-        config.setFields((Collection)null);
+        config.setFields((Collection) null);
         assertEquals(0, config.getFields().length);
         CSVField field = new CSVField();
         field.setName("field1");
@@ -53,7 +53,7 @@ public class CSVConfigTest extends TestC
         assertEquals(null, config.getField("field11"));
         assertEquals(field, config.getField("field1"));
     }
-    
+
     public void testFill() {
         CSVConfig config = new CSVConfig();
         assertEquals(CSVConfig.FILLNONE, config.getFill());
@@ -65,7 +65,7 @@ public class CSVConfigTest extends TestC
         config.setFillChar('m');
         assertEquals('m', config.getFillChar());
     }
-    
+
     public void testDelimiter() {
         CSVConfig config = new CSVConfig();
         assertEquals(',', config.getDelimiter());
@@ -75,7 +75,7 @@ public class CSVConfigTest extends TestC
         config.setIgnoreDelimiter(true);
         assertEquals(true, config.isDelimiterIgnored());
     }
-    
+
     public void testValueDelimiter() {
         CSVConfig config = new CSVConfig();
         assertEquals('"', config.getValueDelimiter());
@@ -85,14 +85,14 @@ public class CSVConfigTest extends TestC
         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());

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVFieldTest.java Tue
Feb  1 08:46:00 2011
@@ -21,7 +21,6 @@ package org.apache.commons.csv.writer;
 import junit.framework.TestCase;
 
 /**
- * 
  * @author Martin van den Bemt
  * @version $Id: $
  */
@@ -41,7 +40,7 @@ public class CSVFieldTest extends TestCa
         assertEquals("name", field.getName());
         assertEquals(10, field.getSize());
     }
-    
+
     public void testFill() {
         CSVField field = new CSVField();
         assertEquals(CSVConfig.FILLNONE, field.getFill());

Modified: commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java?rev=1065950&r1=1065949&r2=1065950&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/writer/CSVWriterTest.java Tue
Feb  1 08:46:00 2011
@@ -26,17 +26,17 @@ import junit.framework.TestCase;
 
 /**
  * The testcase for the csv writer.
- * 
+ *
  * @author Martin van den Bemt
  * @version $Id: $
  */
 public class CSVWriterTest extends TestCase {
 
     private Map map;
-    
+
     protected void setUp() throws Exception {
         super.setUp();
-        
+
         map = new HashMap();
         map.put("field1", "12345");
         map.put("field2", "1234");



Mime
View raw message