Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TestFormulaViewer.java 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 static org.junit.Assume.assumeTrue;
  17. import java.io.File;
  18. import java.io.PrintStream;
  19. import org.apache.poi.EncryptedDocumentException;
  20. import org.apache.poi.hssf.OldExcelFormatException;
  21. import org.apache.poi.hssf.record.RecordInputStream;
  22. import org.apache.poi.util.LocaleUtil;
  23. import org.apache.poi.util.RecordFormatException;
  24. import org.junit.BeforeClass;
  25. public class TestFormulaViewer 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 fileIn) throws Exception {
  48. PrintStream save = System.out;
  49. try {
  50. // redirect standard out during the test to avoid spamming the console with output
  51. System.setOut(new PrintStream(NULL_OUTPUT_STREAM,true,LocaleUtil.CHARSET_1252.name()));
  52. FormulaViewer viewer = new FormulaViewer();
  53. viewer.setFile(fileIn.getAbsolutePath());
  54. viewer.setList(true);
  55. viewer.run();
  56. } catch (RuntimeException re) {
  57. String m = re.getMessage();
  58. if (m.startsWith("toFormulaString") || m.startsWith("3D references")) {
  59. // TODO: fix those cases, but ignore them for now ...
  60. assumeTrue(true);
  61. } else {
  62. throw re;
  63. }
  64. } finally {
  65. System.setOut(save);
  66. }
  67. }
  68. }