On 24 March 2013 18:59, Benedikt Ritter <brit...@apache.org> wrote:
> 2013/3/24 <s...@apache.org>
>
>> Author: sebb
>> Date: Sun Mar 24 15:28:11 2013
>> New Revision: 1460400
>>
>> URL: http://svn.apache.org/r1460400
>> Log:
>> Close printer (at least for non-Exception cases - these are unit tests)
>>
>
> Would be nice if we could move this to @After
>

This would require using a class variable. Not all the tests use a
printer, and not all the tests create the same printer.

I don't know if Eclipse would stop complaining if this change was
made; seems like quite a bit of work for little gain.

>>
>> Modified:
>>
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
>>
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
>>
>> Modified:
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
>> URL:
>> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1460400&r1=1460399&r2=1460400&view=diff
>>
>> ==============================================================================
>> ---
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
>> (original)
>> +++
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
>> Sun Mar 24 15:28:11 2013
>> @@ -446,6 +446,7 @@ public class CSVParserTest {
>>              printer.printRecord(record);
>>          }
>>          assertEquals(input, out.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>>
>> Modified:
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
>> URL:
>> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1460400&r1=1460399&r2=1460400&view=diff
>>
>> ==============================================================================
>> ---
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
>> (original)
>> +++
>> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
>> Sun Mar 24 15:28:11 2013
>> @@ -148,6 +148,7 @@ public class CSVPrinterTest {
>>          printer.printComment("This is a comment");
>>
>>          assertEquals("", sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -156,6 +157,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
>>          printer.printRecords(new String[][] { { "r1c1", "r1c2" }, {
>> "r2c1", "r2c2" } });
>>          assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" +
>> recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -164,6 +166,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
>>          printer.printRecords(new List[] { Arrays.asList(new String[] {
>> "r1c1", "r1c2" }), Arrays.asList(new String[] { "r2c1", "r2c2" }) });
>>          assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" +
>> recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -172,6 +175,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
>>          printer.printRecords(Arrays.asList(new String[][] { { "r1c1",
>> "r1c2" }, { "r2c1", "r2c2" } }));
>>          assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" +
>> recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -181,6 +185,7 @@ public class CSVPrinterTest {
>>          printer.printRecords(Arrays.asList(new List[] { Arrays.asList(new
>> String[] { "r1c1", "r1c2" }),
>>                  Arrays.asList(new String[] { "r2c1", "r2c2" }) }));
>>          assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" +
>> recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -189,6 +194,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
>>          printer.printRecord("a", "b");
>>          assertEquals("a,b" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -197,6 +203,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
>>          printer.printRecord("a,b", "b");
>>          assertEquals("\"a,b\",b" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -212,6 +219,7 @@ public class CSVPrinterTest {
>>              final CSVPrinter printer = new CSVPrinter(sw,
>> CSVFormat.DEFAULT);
>>              printer.printRecords(stmt.executeQuery("select ID, NAME from
>> TEST"));
>>              assertEquals("1,r1" + recordSeparator + "2,r2" +
>> recordSeparator, sw.toString());
>> +            printer.close();
>>          } finally {
>>              connection.close();
>>          }
>> @@ -224,6 +232,7 @@ public class CSVPrinterTest {
>>          printer.printComment("This is a comment\non multiple lines");
>>
>>          assertEquals("# This is a comment" + recordSeparator + "# on
>> multiple lines" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -232,6 +241,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a", "b");
>>          assertEquals("a,b" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -240,6 +250,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a,b", "b");
>>          assertEquals("\"a,b\",b" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -248,6 +259,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a, b", "b ");
>>          assertEquals("\"a, b\",\"b \"" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -256,6 +268,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a", "b\"c");
>>          assertEquals("a,\"b\"\"c\"" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -264,6 +277,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a", "b\nc");
>>          assertEquals("a,\"b\nc\"" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -272,6 +286,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a", "b\r\nc");
>>          assertEquals("a,\"b\r\nc\"" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -280,6 +295,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a", "b\\c");
>>          assertEquals("a,b\\c" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -288,6 +304,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
>>          printer.printRecord("a", null, "b");
>>          assertEquals("a,,b" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -296,6 +313,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw,
>> CSVFormat.newBuilder().withQuotePolicy(Quote.ALL).build());
>>          printer.printRecord("a", "b\nc", "d");
>>          assertEquals("\"a\",\"b\nc\",\"d\"" + recordSeparator,
>> sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -304,6 +322,7 @@ public class CSVPrinterTest {
>>          final CSVPrinter printer = new CSVPrinter(sw,
>> CSVFormat.newBuilder().withQuotePolicy(Quote.NON_NUMERIC).build());
>>          printer.printRecord("a", "b\nc", Integer.valueOf(1));
>>          assertEquals("\"a\",\"b\nc\",1" + recordSeparator, sw.toString());
>> +        printer.close();
>>      }
>>
>>      @Test
>> @@ -321,6 +340,7 @@ public class CSVPrinterTest {
>>          printer.printComment("This is a comment");
>>
>>          assertEquals("# This is a comment" + recordSeparator,
>> sw.toString());
>> +        printer.close();
>>      }
>>
>>  }
>>
>>
>>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter

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

Reply via email to