mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
add test
This commit is contained in:
parent
c38f5f9577
commit
9f9ff14e56
@ -19,7 +19,8 @@ package org.apache.poi.xslf;
|
||||
import org.apache.poi.POIException;
|
||||
|
||||
/**
|
||||
* An exception that indicates a problem reading a pptx file.
|
||||
* An exception that indicates a problem reading a pptx file. Usually, a more
|
||||
* specific exception will be wrapped as the cause.
|
||||
* <p>This exception is only used by some new methods.
|
||||
* Historically, POI has used {@link RuntimeException} for most of its
|
||||
* exceptions, but this is not a good practice. This class is a checked
|
||||
|
||||
@ -19,7 +19,8 @@ package org.apache.poi.xssf;
|
||||
import org.apache.poi.POIException;
|
||||
|
||||
/**
|
||||
* An exception that indicates a problem reading an xlsx file.
|
||||
* An exception that indicates a problem reading an xlsx file. Usually, a more
|
||||
* specific exception will be wrapped as the cause.
|
||||
* <p>This exception is only used by some new methods.
|
||||
* Historically, POI has used {@link RuntimeException} for most of its
|
||||
* exceptions, but this is not a good practice. This class is a checked
|
||||
|
||||
@ -19,7 +19,8 @@ package org.apache.poi.xwpf;
|
||||
import org.apache.poi.POIException;
|
||||
|
||||
/**
|
||||
* An exception that indicates a problem reading a docx file.
|
||||
* An exception that indicates a problem reading a docx file. Usually, a more
|
||||
* specific exception will be wrapped as the cause.
|
||||
* <p>This exception is only used by some new methods.
|
||||
* Historically, POI has used {@link RuntimeException} for most of its
|
||||
* exceptions, but this is not a good practice. This class is a checked
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class TestXSSFParser {
|
||||
@Test
|
||||
void testXlsx() throws Exception {
|
||||
final File file = HSSFTestDataSamples.getSampleFile("HeaderFooterComplexFormats.xlsx");
|
||||
try (XSSFWorkbook wb = XSSFParser.parse(file)) {
|
||||
assertNotNull(wb);
|
||||
assertEquals(3, wb.getNumberOfSheets());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailOnXls() throws Exception {
|
||||
final File file = HSSFTestDataSamples.getSampleFile("44010-SingleChart.xls");
|
||||
XSSFReadException xre = assertThrows(XSSFReadException.class, () -> XSSFParser.parse(file));
|
||||
assertInstanceOf(OLE2NotOfficeXmlFileException.class, xre.getCause());
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,8 @@ package org.apache.poi.hslf;
|
||||
import org.apache.poi.POIException;
|
||||
|
||||
/**
|
||||
* An exception that indicates a problem reading a ppt file.
|
||||
* An exception that indicates a problem reading a ppt file. Usually, a more
|
||||
* specific exception will be wrapped as the cause.
|
||||
* <p>This exception is only used by some new methods.
|
||||
* Historically, POI has used {@link RuntimeException} for most of its
|
||||
* exceptions, but this is not a good practice. This class is a checked
|
||||
|
||||
@ -19,7 +19,8 @@ package org.apache.poi.hwpf;
|
||||
import org.apache.poi.POIException;
|
||||
|
||||
/**
|
||||
* An exception that indicates a problem reading a doc file.
|
||||
* An exception that indicates a problem reading a doc file. Usually, a more
|
||||
* specific exception will be wrapped as the cause.
|
||||
* <p>This exception is only used by some new methods.
|
||||
* Historically, POI has used {@link RuntimeException} for most of its
|
||||
* exceptions, but this is not a good practice. This class is a checked
|
||||
|
||||
@ -19,7 +19,8 @@ package org.apache.poi.hssf;
|
||||
import org.apache.poi.POIException;
|
||||
|
||||
/**
|
||||
* An exception that indicates a problem reading an xls file.
|
||||
* An exception that indicates a problem reading an xls file. Usually, a more
|
||||
* specific exception will be wrapped as the cause.
|
||||
* <p>This exception is only used by some new methods.
|
||||
* Historically, POI has used {@link RuntimeException} for most of its
|
||||
* exceptions, but this is not a good practice. This class is a checked
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user