@@ -0,0 +1,2323 @@
+package charts.builder.csv;%0A%0Aimport static java.lang.String.format;%0A%0Aimport java.io.IOException;%0Aimport java.io.StringWriter;%0Aimport java.util.List;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.supercsv.io.CsvListWriter;%0Aimport org.supercsv.prefs.CsvPreference;%0A%0Aimport charts.ChartType;%0Aimport charts.Region;%0A%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.collect.Lists;%0A%0Apublic class CsvTest %7B%0A%0A  //@Test%0A  public void testCsvMultiThreaded() throws InterruptedException %7B%0A    final List%3CThrowable%3E errors = Lists.newArrayList();%0A    final List%3CThread%3E tlist = Lists.newArrayList();%0A    for(final ChartType type : ChartType.values()) %7B%0A      for(final Region r : Region.values()) %7B%0A        Thread t = new Thread(new Runnable() %7B%0A          @Override%0A          public void run() %7B%0A            testCsv(r, type);%0A          %7D%7D);%0A        t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()  %7B%0A          @Override%0A          public void uncaughtException(Thread t, Throwable e) %7B%0A            errors.add(e);%0A          %7D%0A        %7D);%0A        t.start();%0A        tlist.add(t);%0A      %7D%0A    %7D%0A    for(Thread t : tlist) %7B%0A      t.join();%0A    %7D%0A    Assert.assertTrue(errors.toString(), errors.isEmpty());%0A  %7D%0A%0A  @Test%0A  public void testCsv() %7B%0A    for(final ChartType type : ChartType.values()) %7B%0A      for(final Region r : Region.values()) %7B%0A        testCsv(r, type);%0A      %7D%0A    %7D%0A  %7D%0A%0A  private void testCsv(Region region, ChartType type) %7B%0A    Assert.assertEquals(String.format(%22%25s %25s,1,2,3,4%5Cr%5Cn%22,%0A        region.getProperName(), type.getLabel()), getCsv(region, type));%0A  %7D%0A%0A  private String getCsv(Region region, ChartType type) %7B%0A    final StringWriter sw = new StringWriter();%0A    try %7B%0A      final CsvListWriter csv = new CsvListWriter(sw,%0A          CsvPreference.STANDARD_PREFERENCE);%0A      List%3CString%3E columnKeys = Lists.newArrayList(%221%22, %222%22, %223%22, %224%22);%0A      final List%3CString%3E heading = ImmutableList.%3CString%3Ebuilder()%0A          .add(format(%22%25s %25s%22, region.getProperName(), type.getLabel()))%0A          .addAll(columnKeys)%0A          .build();%0A      csv.write(heading);%0A      csv.close();%0A    %7D catch (IOException e) %7B%0A      // How on earth would you get an IOException with a StringWriter?%0A      throw new RuntimeException(e);%0A    %7D%0A    return sw.toString();%0A  %7D%0A%0A%7D%0A

test case for issue #157