You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestBiffDrawingToXml.java 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hssf.dev;
  16. import java.io.File;
  17. import java.io.FileInputStream;
  18. import java.io.InputStream;
  19. import java.io.PrintStream;
  20. import org.apache.poi.EncryptedDocumentException;
  21. import org.apache.poi.hssf.OldExcelFormatException;
  22. import org.apache.poi.hssf.record.RecordInputStream;
  23. import org.apache.poi.util.RecordFormatException;
  24. import org.junit.BeforeClass;
  25. public class TestBiffDrawingToXml extends BaseXLSIteratingTest {
  26. @BeforeClass
  27. public static void setup() {
  28. EXCLUDED.clear();
  29. EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header
  30. EXCLUDED.put("51832.xls", EncryptedDocumentException.class);
  31. EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class);
  32. EXCLUDED.put("password.xls", EncryptedDocumentException.class);
  33. EXCLUDED.put("46904.xls", OldExcelFormatException.class);
  34. EXCLUDED.put("59074.xls", OldExcelFormatException.class);
  35. EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2
  36. EXCLUDED.put("testEXCEL_3.xls", OldExcelFormatException.class); // Biff 3 / Excel 3, pre-OLE2
  37. EXCLUDED.put("testEXCEL_4.xls", OldExcelFormatException.class); // Biff 4 / Excel 4, pre-OLE2
  38. EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
  39. EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
  40. EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
  41. EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
  42. EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
  43. EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
  44. EXCLUDED.put("61300.xls", RecordFormatException.class);
  45. }
  46. @Override
  47. void runOneFile(File pFile) throws Exception {
  48. PrintStream save = System.out;
  49. try {
  50. //System.setOut(new PrintStream(TestBiffViewer.NULL_OUTPUT_STREAM));
  51. // use a NullOutputStream to not write the bytes anywhere for best runtime
  52. InputStream wb = new FileInputStream(pFile);
  53. try {
  54. BiffDrawingToXml.writeToFile(NULL_OUTPUT_STREAM, wb, false, new String[] {});
  55. } finally {
  56. wb.close();
  57. }
  58. } finally {
  59. System.setOut(save);
  60. }
  61. }
  62. }