001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017: package org.apache.poi.hssf.usermodel;
018:
019: import java.io.ByteArrayInputStream;
020: import java.io.ByteArrayOutputStream;
021: import java.io.File;
022: import java.io.FileInputStream;
023:
024: import junit.framework.TestCase;
025:
026: /**
027: * @author aviks
028: *
029: * This testcase contains tests for bugs that are yet to be fixed.
030: * Therefore, the standard ant test target does not run these tests.
031: * Run this testcase with the single-test target.
032: * The names of the tests usually correspond to the Bugzilla id's
033: * PLEASE MOVE tests from this class to TestBugs once the bugs are fixed,
034: * so that they are then run automatically.
035: */
036: public class TestUnfixedBugs extends TestCase {
037:
038: public TestUnfixedBugs(String arg0) {
039: super (arg0);
040:
041: }
042:
043: protected String cwd = System.getProperty("HSSF.testdata.path");
044:
045: /* ArrayIndexOutOfBound in BOFRecord */
046: public void test28772() throws java.io.IOException {
047: String filename = System.getProperty("HSSF.testdata.path");
048: filename = filename + "/28772.xls";
049: FileInputStream in = new FileInputStream(filename);
050: HSSFWorkbook wb = new HSSFWorkbook(in);
051: assertTrue("Read book fine!", true);
052: }
053:
054: /**
055: * Bug 37684: Unhandled Continue Record Error
056: *
057: * BUT NOW(Jan07): It triggers bug 41026!!
058: *
059: * java.lang.ArrayIndexOutOfBoundsException: 30
060: at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.rowHasCells(ValueRecordsAggregate.java:219)
061: */
062: public void test37684() throws Exception {
063: FileInputStream in = new FileInputStream(new File(cwd,
064: "37684.xls"));
065: HSSFWorkbook wb = new HSSFWorkbook(in);
066: in.close();
067:
068: HSSFSheet sheet = wb.getSheetAt(0);
069: assertNotNull(sheet);
070:
071: assertTrue("No Exceptions while reading file", true);
072:
073: //serialize and read again
074: ByteArrayOutputStream out = new ByteArrayOutputStream();
075: wb.write(out);
076: out.close();
077:
078: wb = new HSSFWorkbook(new ByteArrayInputStream(out
079: .toByteArray()));
080: assertTrue("No Exceptions while reading file", true);
081:
082: }
083:
084: /**
085: * Bug 41139: Constructing HSSFWorkbook is failed,threw threw ArrayIndexOutOfBoundsException for creating UnknownRecord
086: *
087: * BUT NOW (Jan07): It throws the following in write!!
088: * java.lang.RuntimeException: Coding Error: This method should never be called. This ptg should be converted
089: at org.apache.poi.hssf.record.formula.AreaNPtg.writeBytes(AreaNPtg.java:54)
090: at org.apache.poi.hssf.record.formula.Ptg.serializePtgStack(Ptg.java:384)
091: at org.apache.poi.hssf.record.NameRecord.serialize(NameRecord.java:544)
092: at org.apache.poi.hssf.model.Workbook.serialize(Workbook.java:757)
093: at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:952)
094: at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:898)
095:
096: */
097: public void test41139() throws Exception {
098: FileInputStream in = new FileInputStream(new File(cwd,
099: "41139.xls"));
100: HSSFWorkbook wb = new HSSFWorkbook(in);
101: in.close();
102:
103: assertTrue("No Exceptions while reading file", true);
104:
105: //serialize and read again
106: ByteArrayOutputStream out = new ByteArrayOutputStream();
107: wb.write(out);
108: out.close();
109:
110: wb = new HSSFWorkbook(new ByteArrayInputStream(out
111: .toByteArray()));
112: assertTrue("No Exceptions while reading file", true);
113:
114: }
115:
116: }
|