Browse Source

Remove more remnants of NPOIFSFileSystem, mostly in comments and variable names

This avoids confusion if people look at this code in the future without knowledge
about the historical transition from java.io to java.nio

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1855873 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_4_1_0
Dominik Stadler 5 years ago
parent
commit
40f8d119c7
32 changed files with 110 additions and 120 deletions
  1. 3
    3
      src/java/org/apache/poi/POIDocument.java
  2. 1
    1
      src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
  3. 1
    1
      src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java
  4. 2
    2
      src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java
  5. 13
    13
      src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
  6. 2
    2
      src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java
  7. 1
    1
      src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
  8. 4
    4
      src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java
  9. 4
    4
      src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
  10. 1
    1
      src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java
  11. 3
    3
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
  12. 1
    1
      src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
  13. 2
    2
      src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
  14. 1
    1
      src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowFactory.java
  15. 3
    3
      src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java
  16. 2
    2
      src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
  17. 5
    5
      src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
  18. 2
    2
      src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
  19. 3
    3
      src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
  20. 1
    1
      src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
  21. 2
    2
      src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
  22. 2
    2
      src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
  23. 1
    1
      src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
  24. 6
    11
      src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
  25. 9
    14
      src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
  26. 1
    1
      src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
  27. 10
    10
      src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java
  28. 1
    1
      src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java
  29. 2
    2
      src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
  30. 2
    2
      src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSStream.java
  31. 10
    10
      src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java
  32. 9
    9
      src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java

+ 3
- 3
src/java/org/apache/poi/POIDocument.java View File

@@ -236,7 +236,7 @@ public abstract class POIDocument implements Closeable {
/**
* Writes out the updated standard Document Information Properties (HPSF)
* into the currently open NPOIFSFileSystem
* into the currently open POIFSFileSystem
*
* @throws IOException if an error when writing to the open
* {@link POIFSFileSystem} occurs
@@ -258,7 +258,7 @@ public abstract class POIDocument implements Closeable {
}
/**
* Writes out the standard Document Information Properties (HPSF)
* @param outFS the NPOIFSFileSystem to write the properties into
* @param outFS the {@link POIFSFileSystem} to write the properties into
* @param writtenEntries a list of POIFS entries to add the property names too
*
* @throws IOException if an error when writing to the
@@ -314,7 +314,7 @@ public abstract class POIDocument implements Closeable {
*
* @param name the (POIFS Level) name of the property to write
* @param set the PropertySet to write out
* @param outFS the NPOIFSFileSystem to write the property into
* @param outFS the {@link POIFSFileSystem} to write the property into
*
* @throws IOException if an error when writing to the
* {@link POIFSFileSystem} occurs

+ 1
- 1
src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java View File

@@ -393,7 +393,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
* @see #HSSFWorkbook(POIFSFileSystem)
* @exception IOException if the stream cannot be read
*/
@SuppressWarnings("resource") // NPOIFSFileSystem always closes the stream
@SuppressWarnings("resource") // POIFSFileSystem always closes the stream
public HSSFWorkbook(InputStream s, boolean preserveNodes)
throws IOException
{

+ 1
- 1
src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java View File

@@ -41,7 +41,7 @@ public class HSSFWorkbookFactory extends WorkbookFactory {
}

/**
* Creates a HSSFWorkbook from the given NPOIFSFileSystem<p>
* Creates a HSSFWorkbook from the given {@link POIFSFileSystem}<p>
* Note that in order to properly release resources the
* Workbook should be closed after use.
*/

+ 2
- 2
src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java View File

@@ -78,9 +78,9 @@ public class POIFSReader
}

/**
* Read from a NPOIFSFileSystem and process the documents we get
* Read from a {@link POIFSFileSystem} and process the documents we get
*
* @param poifs the NPOIFSFileSystem from which to read the data
* @param poifs the POIFSFileSystem from which to read the data
*
* @exception IOException on errors reading, or on invalid data
*/

+ 13
- 13
src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java View File

@@ -49,8 +49,8 @@ public class DirectoryNode
// Our list of entries, kept sorted to preserve order
private final ArrayList<Entry> _entries = new ArrayList<>();

// the NPOIFSFileSytem we belong to
private final POIFSFileSystem _nfilesystem;
// the POIFSFileSystem we belong to
private final POIFSFileSystem _filesystem;

// the path described by this document
private final POIFSDocumentPath _path;
@@ -60,15 +60,15 @@ public class DirectoryNode
* is intended strictly for the internal use of this package
*
* @param property the DirectoryProperty for this DirectoryEntry
* @param nfilesystem the NPOIFSFileSystem we belong to
* @param filesystem the {@link POIFSFileSystem} we belong to
* @param parent the parent of this entry
*/
DirectoryNode(final DirectoryProperty property,
final POIFSFileSystem nfilesystem,
final POIFSFileSystem filesystem,
final DirectoryNode parent)
{
super(property, parent);
this._nfilesystem = nfilesystem;
this._filesystem = filesystem;

if (parent == null)
{
@@ -91,7 +91,7 @@ public class DirectoryNode
if (child.isDirectory())
{
DirectoryProperty childDir = (DirectoryProperty) child;
childNode = new DirectoryNode(childDir, _nfilesystem, this);
childNode = new DirectoryNode(childDir, _filesystem, this);
}
else
{
@@ -116,7 +116,7 @@ public class DirectoryNode
*/
public POIFSFileSystem getFileSystem()
{
return _nfilesystem;
return _filesystem;
}

/**
@@ -175,7 +175,7 @@ public class DirectoryNode
DocumentNode rval = new DocumentNode(property, this);

(( DirectoryProperty ) getProperty()).addChild(property);
_nfilesystem.addDocument(document);
_filesystem.addDocument(document);

_entries.add(rval);
_byname.put(property.getName(), rval);
@@ -228,7 +228,7 @@ public class DirectoryNode
_byname.remove(entry.getName());

try {
_nfilesystem.remove(entry);
_filesystem.remove(entry);
} catch (IOException e) {
// TODO Work out how to report this, given we can't change the method signature...
throw new RuntimeException(e);
@@ -349,7 +349,7 @@ public class DirectoryNode
final InputStream stream)
throws IOException
{
return createDocument(new POIFSDocument(name, _nfilesystem, stream));
return createDocument(new POIFSDocument(name, _filesystem, stream));
}

/**
@@ -368,7 +368,7 @@ public class DirectoryNode
final POIFSWriterListener writer)
throws IOException
{
return createDocument(new POIFSDocument(name, size, _nfilesystem, writer));
return createDocument(new POIFSDocument(name, size, _filesystem, writer));
}

/**
@@ -386,8 +386,8 @@ public class DirectoryNode
{
DirectoryProperty property = new DirectoryProperty(name);

DirectoryNode rval = new DirectoryNode(property, _nfilesystem, this);
_nfilesystem.addDirectory(property);
DirectoryNode rval = new DirectoryNode(property, _filesystem, this);
_filesystem.addDirectory(property);

(( DirectoryProperty ) getProperty()).addChild(property);
_entries.add(rval);

+ 2
- 2
src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java View File

@@ -38,7 +38,7 @@ public final class DocumentFactoryHelper {
}

/**
* Wrap the OLE2 data in the NPOIFSFileSystem into a decrypted stream by using
* Wrap the OLE2 data in the {@link POIFSFileSystem} into a decrypted stream by using
* the given password.
*
* @param fs The OLE2 stream for the document
@@ -48,7 +48,7 @@ public final class DocumentFactoryHelper {
*/
public static InputStream getDecryptedStream(final POIFSFileSystem fs, String password)
throws IOException {
// wrap the stream in a FilterInputStream to close the NPOIFSFileSystem
// wrap the stream in a FilterInputStream to close the POIFSFileSystem
// as well when the resulting OPCPackage is closed
return new FilterInputStream(getDecryptedStream(fs.getRoot(), password)) {
@Override

+ 1
- 1
src/java/org/apache/poi/poifs/macros/VBAMacroReader.java View File

@@ -104,7 +104,7 @@ public class VBAMacroReader implements Closeable {
while ((zipEntry = zis.getNextEntry()) != null) {
if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
try {
// Make a NPOIFS from the contents, and close the stream
// Make a POIFSFileSystem from the contents, and close the stream
this.fs = new POIFSFileSystem(zis);
return;
} catch (IOException e) {

+ 4
- 4
src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java View File

@@ -36,7 +36,7 @@ import org.apache.poi.util.IOUtils;

public class SlideShowFactory {
/**
* Creates a SlideShow from the given NPOIFSFileSystem.
* Creates a SlideShow from the given POIFSFileSystem.
*
* @param fs The {@link POIFSFileSystem} to read the document from
*
@@ -52,7 +52,7 @@ public class SlideShowFactory {
}

/**
* Creates a SlideShow from the given NPOIFSFileSystem, which may
* Creates a SlideShow from the given POIFSFileSystem, which may
* be password protected
*
* @param fs The {@link POIFSFileSystem} to read the document from
@@ -70,7 +70,7 @@ public class SlideShowFactory {
}

/**
* Creates a SlideShow from the given NPOIFSFileSystem.
* Creates a SlideShow from the given DirectoryNode.
*
* @param root The {@link DirectoryNode} to start reading the document from
*
@@ -87,7 +87,7 @@ public class SlideShowFactory {


/**
* Creates a SlideShow from the given NPOIFSFileSystem, which may
* Creates a SlideShow from the given DirectoryNode, which may
* be password protected
*
* @param root The {@link DirectoryNode} to start reading the document from

+ 4
- 4
src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java View File

@@ -62,7 +62,7 @@ public class WorkbookFactory {
}

/**
* Creates a HSSFWorkbook from the given NPOIFSFileSystem<p>
* Creates a HSSFWorkbook from the given POIFSFileSystem<p>
*
* Note that in order to properly release resources the
* Workbook should be closed after use.
@@ -78,7 +78,7 @@ public class WorkbookFactory {
}

/**
* Creates a Workbook from the given NPOIFSFileSystem, which may
* Creates a Workbook from the given POIFSFileSystem, which may
* be password protected
*
* @param fs The {@link POIFSFileSystem} to read the document from
@@ -94,7 +94,7 @@ public class WorkbookFactory {


/**
* Creates a Workbook from the given NPOIFSFileSystem.
* Creates a Workbook from the given DirectoryNode.
*
* @param root The {@link DirectoryNode} to start reading the document from
*
@@ -108,7 +108,7 @@ public class WorkbookFactory {


/**
* Creates a Workbook from the given NPOIFSFileSystem, which may
* Creates a Workbook from the given DirectoryNode, which may
* be password protected
*
* @param root The {@link DirectoryNode} to start reading the document from

+ 1
- 1
src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java View File

@@ -404,7 +404,7 @@ public final class ExtractorFactory {
} finally {
IOUtils.closeQuietly(is);

// also close the NPOIFSFileSystem here as we read all the data
// also close the POIFSFileSystem here as we read all the data
// while decrypting
fs.close();
}

+ 3
- 3
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java View File

@@ -1505,7 +1505,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {

@Test
public void bug55692_stream() throws IOException {
// Directly on a Stream, will go via NPOIFS and spot it's
// Directly on a Stream, will go via POIFS and spot it's
// actually a .xlsx file encrypted with the default password, and open
Workbook wb = WorkbookFactory.create(
POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
@@ -1515,8 +1515,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}

@Test
public void bug55692_npoifs() throws IOException {
// Via a NPOIFSFileSystem, will spot it's actually a .xlsx file
public void bug55692_poifs2() throws IOException {
// Via a POIFSFileSystem, will spot it's actually a .xlsx file
// encrypted with the default password, and open
POIFSFileSystem fsNP = new POIFSFileSystem(
POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));

+ 1
- 1
src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java View File

@@ -117,7 +117,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {

/**
* Creates a PowerPointExtractor, from a specific place
* inside an open NPOIFSFileSystem
* inside an open {@link POIFSFileSystem}
*
* @param dir the POIFS Directory containing the PowerPoint document
*/

+ 2
- 2
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java View File

@@ -148,8 +148,8 @@ public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagrap
* Constructs a Powerpoint document from an POIFSFileSystem.
*/
@SuppressWarnings("resource")
public HSLFSlideShow(POIFSFileSystem npoifs) throws IOException {
this(new HSLFSlideShowImpl(npoifs));
public HSLFSlideShow(POIFSFileSystem poifs) throws IOException {
this(new HSLFSlideShowImpl(poifs));
}

/**

+ 1
- 1
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowFactory.java View File

@@ -32,7 +32,7 @@ import org.apache.poi.util.Internal;
@Internal
public class HSLFSlideShowFactory extends SlideShowFactory {
/**
* Creates a HSLFSlideShow from the given NPOIFSFileSystem<p>
* Creates a HSLFSlideShow from the given {@link POIFSFileSystem}<p>
* Note that in order to properly release resources the
* SlideShow should be closed after use.
*/

+ 3
- 3
src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java View File

@@ -98,11 +98,11 @@ public final class TestPublisherTextExtractor {
// And with NPOIFS
sample = _samples.openResourceAsStream("Sample.pub");
POIFSFileSystem fs = new POIFSFileSystem(sample);
HPBFDocument docNPOIFS = new HPBFDocument(fs);
ext = new PublisherTextExtractor(docNPOIFS);
HPBFDocument docPOIFS = new HPBFDocument(fs);
ext = new PublisherTextExtractor(docPOIFS);
assertEquals(SAMPLE_TEXT, ext.getText());
ext.close();
docNPOIFS.close();
docPOIFS.close();
fs.close();
sample.close();


+ 2
- 2
src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java View File

@@ -394,9 +394,9 @@ public final class TestExtractor {
public void testDifferentPOIFS() throws IOException {
// Open the two filesystems
File pptFile = slTests.getFile("basic_test_ppt_file.ppt");
try (final POIFSFileSystem npoifs = new POIFSFileSystem(pptFile, true)) {
try (final POIFSFileSystem poifs = new POIFSFileSystem(pptFile, true)) {
// Open directly
try (SlideShow<?,?> ppt = SlideShowFactory.create(npoifs.getRoot());
try (SlideShow<?,?> ppt = SlideShowFactory.create(poifs.getRoot());
SlideShowExtractor<?,?> extractor = new SlideShowExtractor<>(ppt)) {
assertEquals(EXPECTED_PAGE1+EXPECTED_PAGE2, extractor.getText());
}

+ 5
- 5
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java View File

@@ -992,15 +992,15 @@ public final class TestBugs {
//It isn't pretty, but it works...
private Map<String, String> getMacrosFromHSLF(String fileName) throws IOException {
InputStream is = null;
POIFSFileSystem npoifs = null;
POIFSFileSystem poifs = null;
try {
is = new FileInputStream(POIDataSamples.getSlideShowInstance().getFile(fileName));
npoifs = new POIFSFileSystem(is);
//TODO: should we run the VBAMacroReader on this npoifs?
poifs = new POIFSFileSystem(is);
//TODO: should we run the VBAMacroReader on this poifs?
//TBD: We know that ppt typically don't store macros in the regular place,
//but _can_ they?

HSLFSlideShow ppt = new HSLFSlideShow(npoifs);
HSLFSlideShow ppt = new HSLFSlideShow(poifs);

//get macro persist id
DocInfoListContainer list = (DocInfoListContainer)ppt.getDocumentRecord().findFirstOfType(RecordTypes.List.typeID);
@@ -1018,7 +1018,7 @@ public final class TestBugs {
ppt.close();

} finally {
IOUtils.closeQuietly(npoifs);
IOUtils.closeQuietly(poifs);
IOUtils.closeQuietly(is);
}
return null;

+ 2
- 2
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java View File

@@ -343,9 +343,9 @@ public final class TestWordExtractor {
public void testDifferentPOIFS() throws Exception {
// Open the two filesystems
File file = docTests.getFile("test2.doc");
try (POIFSFileSystem npoifs = new POIFSFileSystem(file, true)) {
try (POIFSFileSystem poifs = new POIFSFileSystem(file, true)) {

DirectoryNode dir = npoifs.getRoot();
DirectoryNode dir = poifs.getRoot();

// Open directly
@SuppressWarnings("resource")

+ 3
- 3
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java View File

@@ -606,7 +606,7 @@ public class TestBugs{
}

/**
* [RESOLVED FIXED] Bug 51671 - HWPFDocument.write based on NPOIFSFileSystem
* [RESOLVED FIXED] Bug 51671 - HWPFDocument.write based on POIFSFileSystem
* throws a NullPointerException
*/
@Test
@@ -614,9 +614,9 @@ public class TestBugs{
{
InputStream is = POIDataSamples.getDocumentInstance()
.openResourceAsStream("empty.doc");
try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(is)) {
try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(is)) {
HWPFDocument hwpfDocument = new HWPFDocument(
npoifsFileSystem.getRoot());
poifsFileSystem.getRoot());
hwpfDocument.write(new ByteArrayOutputStream());
hwpfDocument.close();
}

+ 1
- 1
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java View File

@@ -135,7 +135,7 @@ public final class TestHWPFWrite extends HWPFTestCase {
}
@Test(expected=IllegalStateException.class)
public void testInvalidInPlaceWriteNPOIFS() throws Exception {
public void testInvalidInPlaceWritePOIFS() throws Exception {
// Can't work for Read-Only files
POIFSFileSystem fs = new POIFSFileSystem(SAMPLES.getFile("SampleDoc.doc"), true);
HWPFDocument doc = new HWPFDocument(fs.getRoot());

+ 2
- 2
src/testcases/org/apache/poi/hpsf/basic/TestWrite.java View File

@@ -495,11 +495,11 @@ public class TestWrite {
}

/**
* Tests that when using NPOIFS, we can do an in-place write
* Tests that when using POIFS, we can do an in-place write
* without needing to stream in + out the whole kitchen sink
*/
@Test
public void inPlaceNPOIFSWrite() throws Exception {
public void inPlacePOIFSWrite() throws Exception {
// We need to work on a File for in-place changes, so create a temp one
final File copy = TempFile.createTempFile("Test-HPSF", "ole2");
copy.deleteOnExit();

+ 2
- 2
src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java View File

@@ -183,9 +183,9 @@ public final class TestHPSFPropertiesExtractor {

@Test
public void test61300Extractor() throws IOException {
try (POIFSFileSystem npoifs = new POIFSFileSystem(
try (POIFSFileSystem poifs = new POIFSFileSystem(
POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) {
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(npoifs);
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(poifs);
assertContains(ext.getText(), "PID_CODEPAGE = 1252");
}
}

+ 1
- 1
src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java View File

@@ -283,7 +283,7 @@ public final class TestOldExcelExtractor {
}

@Test
public void testNPOIFSFileSystem() throws IOException {
public void testPOIFSFileSystem() throws IOException {
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
OldExcelExtractor extractor = new OldExcelExtractor(fs);

+ 6
- 11
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java View File

@@ -2331,34 +2331,29 @@ public final class TestBugs extends BaseTestBugzillaIssues {
* File with exactly 256 data blocks (+header block)
* shouldn't break on POIFS loading
*/
@SuppressWarnings("resource")
@Test
public void bug51461() throws Exception {
byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51461.xls");

HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(
new ByteArrayInputStream(data)).getRoot(), false);
HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new POIFSFileSystem(
HSSFWorkbook wbPOIFS2 = new HSSFWorkbook(new POIFSFileSystem(
new ByteArrayInputStream(data)).getRoot(), false);

assertEquals(2, wbPOIFS.getNumberOfSheets());
assertEquals(2, wbNPOIFS.getNumberOfSheets());
assertEquals(2, wbPOIFS2.getNumberOfSheets());
}

/**
* Large row numbers and NPOIFS vs POIFS
*/
@SuppressWarnings("resource")
@Test
public void bug51535() throws Exception {
byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51535.xls");

HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(
new ByteArrayInputStream(data)).getRoot(), false);
HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new POIFSFileSystem(
HSSFWorkbook wbPOIFS2 = new HSSFWorkbook(new POIFSFileSystem(
new ByteArrayInputStream(data)).getRoot(), false);

for (HSSFWorkbook wb : new HSSFWorkbook[]{wbPOIFS, wbNPOIFS}) {
for (HSSFWorkbook wb : new HSSFWorkbook[]{wbPOIFS, wbPOIFS2}) {
assertEquals(3, wb.getNumberOfSheets());

// Check directly
@@ -3095,10 +3090,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {

@Test(expected = RuntimeException.class)
public void test61300() throws Exception {
POIFSFileSystem npoifs = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls"));
POIFSFileSystem poifs = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls"));

DocumentEntry entry =
(DocumentEntry) npoifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
(DocumentEntry) poifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME);

// this will throw an Exception "RuntimeException: Can't read negative number of bytes"
new PropertySet(new DocumentInputStream(entry));

+ 9
- 14
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java View File

@@ -621,8 +621,8 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
DirectoryNode[] files = new DirectoryNode[2];
try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))) {
files[0] = poifsFileSystem.getRoot();
try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))) {
files[1] = npoifsFileSystem.getRoot();
try (POIFSFileSystem poifsFileSystem2 = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))) {
files[1] = poifsFileSystem2.getRoot();

// Open without preserving nodes
for (DirectoryNode dir : files) {
@@ -653,8 +653,8 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
DirectoryNode[] files = new DirectoryNode[2];
try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))) {
files[0] = poifsFileSystem.getRoot();
try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))) {
files[1] = npoifsFileSystem.getRoot();
try (POIFSFileSystem poifsFileSystem2 = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))) {
files[1] = poifsFileSystem2.getRoot();

// Check the embedded parts
for (DirectoryNode root : files) {
@@ -682,19 +682,18 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
}

/**
* Checks that we can open a workbook with NPOIFS, and write it out
* Checks that we can open a workbook with POIFS, and write it out
* again (via POIFS) and have it be valid
*/
@Test
public void writeWorkbookFromNPOIFS() throws IOException {
public void writeWorkbookFromPOIFS() throws IOException {
try (InputStream is = HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls");
POIFSFileSystem fs = new POIFSFileSystem(is)) {
// Start as NPOIFS
POIFSFileSystem fs = new POIFSFileSystem(is)) {
HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);
assertEquals(3, wb.getNumberOfSheets());
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());

// Will switch to POIFS
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
assertEquals(3, wbBack.getNumberOfSheets());
assertEquals("Root xls", wbBack.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
@@ -1151,11 +1150,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
final File file = POIDataSamples.getSpreadSheetInstance().getFile(filename);
Workbook wb;
// File via POIFileStream (java.io)
wb = new HSSFWorkbook(new POIFSFileSystem(file));
assertCloseDoesNotModifyFile(filename, wb);
// File via NPOIFileStream (java.nio)
// File via POIFileStream (java.nio)
wb = new HSSFWorkbook(new POIFSFileSystem(file));
assertCloseDoesNotModifyFile(filename, wb);

+ 1
- 1
src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java View File

@@ -43,7 +43,7 @@ public class TestDocument {
* Integration test -- really about all we can do
*/
@Test
public void testNPOIFSDocument() throws IOException {
public void testPOIFSDocument() throws IOException {

try (POIFSFileSystem poifs = new POIFSFileSystem()) {


+ 10
- 10
src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java View File

@@ -55,20 +55,20 @@ public final class TestDocumentInputStream {
_workbook_data[j] = (byte) (j * j);
}

// Now create the NPOIFS Version
// Now create the POIFS Version
byte[] _workbook_data_only = new byte[_workbook_size];
System.arraycopy(_workbook_data, 0, _workbook_data_only, 0, _workbook_size);

POIFSFileSystem npoifs = new POIFSFileSystem();
POIFSFileSystem poifs = new POIFSFileSystem();
// Make it easy when debugging to see what isn't the doc
byte[] minus1 = new byte[512];
Arrays.fill(minus1, (byte) -1);
npoifs.getBlockAt(-1).put(minus1);
npoifs.getBlockAt(0).put(minus1);
npoifs.getBlockAt(1).put(minus1);
poifs.getBlockAt(-1).put(minus1);
poifs.getBlockAt(0).put(minus1);
poifs.getBlockAt(1).put(minus1);

// Create the NPOIFS document
_workbook_n = (DocumentNode) npoifs.createDocument(
// Create the POIFS document
_workbook_n = (DocumentNode) poifs.createDocument(
new ByteArrayInputStream(_workbook_data_only),
"Workbook"
);
@@ -440,12 +440,12 @@ public final class TestDocumentInputStream {

DocumentInputStream stream;

try (POIFSFileSystem npoifs = new POIFSFileSystem(sample)) {
try (POIFSFileSystem poifs = new POIFSFileSystem(sample)) {
// Ensure we have what we expect on the root
assertEquals(npoifs, npoifs.getRoot().getFileSystem());
assertEquals(poifs, poifs.getRoot().getFileSystem());

// Check inside
DirectoryNode root = npoifs.getRoot();
DirectoryNode root = poifs.getRoot();
// Top Level
Entry top = root.getEntry("Contents");
assertTrue(top.isDocumentEntry());

+ 1
- 1
src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java View File

@@ -123,7 +123,7 @@ public class TestEntryUtils {
assertTrue(EntryUtils.areDocumentsIdentical(entryA1, entryB1));
// Can work with NPOIFS + POIFS
// Can work with POIFS
ByteArrayOutputStream tmpO = new ByteArrayOutputStream();
fs.writeFilesystem(tmpO);

+ 2
- 2
src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java View File

@@ -34,7 +34,7 @@ import org.junit.After;
import org.junit.Test;

/**
* Tests bugs across both POIFSFileSystem and NPOIFSFileSystem
* Tests bugs for POIFSFileSystem
*/
public final class TestFileSystemBugs {
private static POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
@@ -115,7 +115,7 @@ public final class TestFileSystemBugs {
* Ensure that a file with a corrupted property in the
* properties table can still be loaded, and the remaining
* properties used
* Note - only works for NPOIFSFileSystem, POIFSFileSystem
* Note - only works for POIFSFileSystem
* can't cope with this level of corruption
*/
@Test

+ 2
- 2
src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSStream.java View File

@@ -2605,11 +2605,11 @@ public final class TestPOIFSStream {
}

/**
* Test that we can read a file with NPOIFS, create a new NPOIFS instance,
* Test that we can read a file with POIFS, create a new POIFS instance,
* write it out, read it with POIFS, and see the original data
*/
@Test
public void NPOIFSReadCopyWritePOIFSRead() throws IOException {
public void POIFSReadCopyWritePOIFSRead() throws IOException {
File testFile = POIDataSamples.getSpreadSheetInstance().getFile("Simple.xls");
POIFSFileSystem src = new POIFSFileSystem(testFile);
byte[] wbDataExp = IOUtils.toByteArray(src.createDocumentInputStream("Workbook"));

+ 10
- 10
src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java View File

@@ -148,24 +148,24 @@ public class TestVBAMacroReader {
fromFile(POIDataSamples.getDiagramInstance(), "SimpleMacro.vsdm");
}

//////////////////////////////// From NPOIFS /////////////////////////////
//////////////////////////////// From POIFS /////////////////////////////
@Test
public void HSSFFromNPOIFS() throws Exception {
fromNPOIFS(POIDataSamples.getSpreadSheetInstance(), "SimpleMacro.xls");
public void HSSFFromPOIFS() throws Exception {
fromPOIFS(POIDataSamples.getSpreadSheetInstance(), "SimpleMacro.xls");
}
@Ignore("bug 59302: Found 0 macros")
@Test
public void HSLFFromNPOIFS() throws Exception {
fromNPOIFS(POIDataSamples.getSlideShowInstance(), "SimpleMacro.ppt");
public void HSLFFromPOIFS() throws Exception {
fromPOIFS(POIDataSamples.getSlideShowInstance(), "SimpleMacro.ppt");
}
@Test
public void HWPFFromNPOIFS() throws Exception {
fromNPOIFS(POIDataSamples.getDocumentInstance(), "SimpleMacro.doc");
public void HWPFFromPOIFS() throws Exception {
fromPOIFS(POIDataSamples.getDocumentInstance(), "SimpleMacro.doc");
}
@Ignore("Found 0 macros")
@Test
public void HDGFFromNPOIFS() throws Exception {
fromNPOIFS(POIDataSamples.getDiagramInstance(), "SimpleMacro.vsd");
public void HDGFFromPOIFS() throws Exception {
fromPOIFS(POIDataSamples.getDiagramInstance(), "SimpleMacro.vsd");
}

private void fromFile(POIDataSamples dataSamples, String filename) throws IOException {
@@ -183,7 +183,7 @@ public class TestVBAMacroReader {
}
}

private void fromNPOIFS(POIDataSamples dataSamples, String filename) throws IOException {
private void fromPOIFS(POIDataSamples dataSamples, String filename) throws IOException {
File f = dataSamples.getFile(filename);
try (POIFSFileSystem fs = new POIFSFileSystem(f)) {
try (VBAMacroReader r = new VBAMacroReader(fs)) {

+ 9
- 9
src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java View File

@@ -55,12 +55,12 @@ public abstract class BaseTestSlideShowFactory {
@SuppressWarnings("resource")
protected static void testFactoryFromNative(String file) throws Exception {
SlideShow<?,?> ss;
// from NPOIFS
// from POIFS
if (file.endsWith(".ppt")) {
POIFSFileSystem npoifs = new POIFSFileSystem(fromFile(file));
ss = SlideShowFactory.create(npoifs);
POIFSFileSystem poifs = new POIFSFileSystem(fromFile(file));
ss = SlideShowFactory.create(poifs);
assertNotNull(ss);
npoifs.close();
poifs.close();
assertCloseDoesNotModifyFile(file, ss);
}
// from OPCPackage
@@ -92,15 +92,15 @@ public abstract class BaseTestSlideShowFactory {
@SuppressWarnings("resource")
protected static void testFactoryFromProtectedNative(String protectedFile, String password) throws Exception {
SlideShow<?,?> ss;
// Encryption layer is a BIFF8 binary format that can be read by NPOIFSFileSystem,
// Encryption layer is a BIFF8 binary format that can be read by POIFSFileSystem,
// used for both HSLF and XSLF

// from protected NPOIFS
// from protected POIFS
if (protectedFile.endsWith(".ppt") || protectedFile.endsWith(".pptx")) {
POIFSFileSystem npoifs = new POIFSFileSystem(fromFile(protectedFile));
ss = SlideShowFactory.create(npoifs, password);
POIFSFileSystem poifs = new POIFSFileSystem(fromFile(protectedFile));
ss = SlideShowFactory.create(poifs, password);
assertNotNull(ss);
npoifs.close();
poifs.close();
assertCloseDoesNotModifyFile(protectedFile, ss);
}
else {

Loading…
Cancel
Save