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.

TestUnfixedBugs.java 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.usermodel;
  16. import junit.framework.AssertionFailedError;
  17. import junit.framework.TestCase;
  18. import org.apache.poi.hssf.HSSFTestDataSamples;
  19. import org.apache.poi.hssf.record.RecordFormatException;
  20. import java.io.IOException;
  21. import java.io.FileInputStream;
  22. import java.io.File;
  23. /**
  24. * @author aviks
  25. *
  26. * This testcase contains tests for bugs that are yet to be fixed. Therefore,
  27. * the standard ant test target does not run these tests. Run this testcase with
  28. * the single-test target. The names of the tests usually correspond to the
  29. * Bugzilla id's PLEASE MOVE tests from this class to TestBugs once the bugs are
  30. * fixed, so that they are then run automatically.
  31. */
  32. public final class TestUnfixedBugs extends TestCase {
  33. public void test43493() {
  34. // Has crazy corrupt sub-records on
  35. // a EmbeddedObjectRefSubRecord
  36. try {
  37. HSSFTestDataSamples.openSampleWorkbook("43493.xls");
  38. } catch (RecordFormatException e) {
  39. if (e.getCause().getCause() instanceof ArrayIndexOutOfBoundsException) {
  40. throw new AssertionFailedError("Identified bug 43493");
  41. }
  42. throw e;
  43. }
  44. }
  45. public void test49612() throws IOException {
  46. HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49612.xls");
  47. HSSFSheet sh = wb.getSheetAt(0);
  48. HSSFRow row = sh.getRow(0);
  49. HSSFCell c1 = row.getCell(2);
  50. HSSFCell d1 = row.getCell(3);
  51. HSSFCell e1 = row.getCell(2);
  52. assertEquals("SUM(BOB+JIM)", c1.getCellFormula());
  53. // Problem 1: java.lang.ArrayIndexOutOfBoundsException in org.apache.poi.hssf.model.LinkTable$ExternalBookBlock.getNameText
  54. assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", d1.getCellFormula());
  55. //Problem 2
  56. //junit.framework.ComparisonFailure:
  57. //Expected :SUM('49612.xls'!BOB+'49612.xls'!JIM)
  58. //Actual :SUM(BOB+JIM)
  59. assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", e1.getCellFormula());
  60. HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
  61. assertEquals("evaluating c1", 30., eval.evaluate(c1).getNumberValue());
  62. //Problem 3: java.lang.RuntimeException: Unexpected arg eval type (org.apache.poi.hssf.record.formula.eval.NameXEval)
  63. assertEquals("evaluating d1", 30., eval.evaluate(d1).getNumberValue());
  64. assertEquals("evaluating e1", 30., eval.evaluate(e1).getNumberValue());
  65. }
  66. }