2014-01-18 00:38:04 +00:00
|
|
|
/* ====================================================================
|
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
==================================================================== */
|
2013-10-25 21:57:48 +00:00
|
|
|
package org.apache.poi.hssf.dev;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
2015-09-11 00:56:16 +00:00
|
|
|
import java.io.OutputStreamWriter;
|
2015-09-01 21:46:30 +00:00
|
|
|
import java.io.PrintWriter;
|
2013-10-25 21:57:48 +00:00
|
|
|
|
2016-06-30 22:59:46 +00:00
|
|
|
import org.apache.poi.hssf.OldExcelFormatException;
|
2018-08-31 00:25:50 +00:00
|
|
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
2015-09-11 00:56:16 +00:00
|
|
|
import org.apache.poi.util.LocaleUtil;
|
2020-08-17 20:25:08 +00:00
|
|
|
import org.apache.poi.util.NullOutputStream;
|
2017-07-14 20:47:40 +00:00
|
|
|
import org.apache.poi.util.RecordFormatException;
|
2020-12-24 18:42:29 +00:00
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
2015-08-29 14:41:12 +00:00
|
|
|
|
2020-07-22 22:08:33 +00:00
|
|
|
public class TestBiffViewer extends BaseTestIteratingXLS {
|
2020-12-24 18:42:29 +00:00
|
|
|
@BeforeAll
|
2016-06-30 22:59:46 +00:00
|
|
|
public static void setup() {
|
|
|
|
|
EXCLUDED.clear();
|
2020-08-18 13:50:31 +00:00
|
|
|
EXCLUDED.put("35897-type4.xls", IllegalArgumentException.class); // unsupported crypto api header
|
|
|
|
|
EXCLUDED.put("51832.xls", IllegalArgumentException.class);
|
|
|
|
|
EXCLUDED.put("xor-encryption-abc.xls", RecordFormatException.class);
|
|
|
|
|
EXCLUDED.put("password.xls", IllegalArgumentException.class);
|
2016-06-30 22:59:46 +00:00
|
|
|
EXCLUDED.put("46904.xls", OldExcelFormatException.class);
|
|
|
|
|
EXCLUDED.put("59074.xls", OldExcelFormatException.class);
|
|
|
|
|
EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2
|
|
|
|
|
EXCLUDED.put("testEXCEL_3.xls", OldExcelFormatException.class); // Biff 3 / Excel 3, pre-OLE2
|
|
|
|
|
EXCLUDED.put("testEXCEL_4.xls", OldExcelFormatException.class); // Biff 4 / Excel 4, pre-OLE2
|
|
|
|
|
EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
|
2016-12-11 20:56:03 +00:00
|
|
|
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
|
2016-06-30 22:59:46 +00:00
|
|
|
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
|
2020-08-18 13:50:31 +00:00
|
|
|
EXCLUDED.put("43493.xls", RecordFormatException.class); // HSSFWorkbook cannot open it as well
|
2016-06-30 22:59:46 +00:00
|
|
|
// EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
|
|
|
|
|
EXCLUDED.put("50833.xls", IllegalArgumentException.class); // "Name is too long" when setting username
|
|
|
|
|
EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"
|
2020-08-18 13:50:31 +00:00
|
|
|
EXCLUDED.put("61300.xls", IndexOutOfBoundsException.class);
|
2020-02-10 17:38:29 +00:00
|
|
|
EXCLUDED.put("64130.xls", OldExcelFormatException.class); //Biff 5
|
2016-02-26 23:32:54 +00:00
|
|
|
}
|
2013-10-25 21:57:48 +00:00
|
|
|
|
2016-02-26 23:32:54 +00:00
|
|
|
@Override
|
|
|
|
|
void runOneFile(File fileIn) throws IOException {
|
2018-08-31 00:25:50 +00:00
|
|
|
try (POIFSFileSystem fs = new POIFSFileSystem(fileIn, true);
|
|
|
|
|
InputStream is = BiffViewer.getPOIFSInputStream(fs)) {
|
|
|
|
|
// use a NullOutputStream to not write the bytes anywhere for best runtime
|
2020-08-17 20:25:08 +00:00
|
|
|
PrintWriter dummy = new PrintWriter(new OutputStreamWriter(new NullOutputStream(), LocaleUtil.CHARSET_1252));
|
2018-08-31 00:25:50 +00:00
|
|
|
BiffViewer.runBiffViewer(dummy, is, true, true, true, false);
|
2016-02-26 23:32:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-07-03 22:59:41 +00:00
|
|
|
|
2020-08-18 13:50:31 +00:00
|
|
|
// @Test
|
2020-12-30 21:39:56 +00:00
|
|
|
// @Disabled("only used for manual tests")
|
2020-08-18 13:50:31 +00:00
|
|
|
// @SuppressWarnings("java:S2699")
|
2021-01-08 23:50:02 +00:00
|
|
|
// void testOneFile() throws Exception {
|
2020-08-18 13:50:31 +00:00
|
|
|
// POIDataSamples samples = POIDataSamples.getSpreadSheetInstance();
|
|
|
|
|
// runOneFile(samples.getFile("43493.xls"));
|
|
|
|
|
// }
|
2013-10-25 21:57:48 +00:00
|
|
|
}
|