View Javadoc
1   package org.dbunit.dataset.excel;
2   
3   import java.io.File;
4   import java.io.FileOutputStream;
5   import java.io.IOException;
6   import java.net.URI;
7   import java.net.URISyntaxException;
8   import java.net.URL;
9   
10  import org.dbunit.dataset.DataSetException;
11  import org.dbunit.dataset.IDataSet;
12  import org.junit.Test;
13  
14  public class XlsDataSetWriterTest
15  {
16      private static final File OUTPUT_DIR = new File("target", "excel");
17  
18      private static final String INPUT_EXCEL_FILE =
19              "/excel/XlsDataSetWriterCellStyleCaching.xlsx";
20  
21      private static final File OUTPUT_EXCEL_FILE = new File(OUTPUT_DIR,
22              "XlsDataSetWriterCellStyleCachingTestOutput.xls");
23  
24      /**
25       * Test for issue 377. Without 377's changes, test fails with:
26       * java.lang.IllegalStateException: The maximum number of cell styles was
27       * exceeded. You can define up to 4000 styles in a .xls workbook
28       */
29      @Test
30      public void testTimestampTzOffsets()
31              throws URISyntaxException, DataSetException, IOException
32      {
33          OUTPUT_DIR.mkdir();
34  
35          URL excelFileUrl = getClass().getResource(INPUT_EXCEL_FILE);
36          URI excelFileUri = excelFileUrl.toURI();
37          File file = new File(excelFileUri);
38          IDataSet dataSet = new XlsDataSet(file);
39          FileOutputStream outputStream = new FileOutputStream(OUTPUT_EXCEL_FILE);
40          XlsDataSet.write(dataSet, outputStream);
41      }
42  }