aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases/org/apache/poi
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2018-08-31 00:25:50 +0000
committerAndreas Beeker <kiwiwings@apache.org>2018-08-31 00:25:50 +0000
commit8ebfec4808cce673b1911d15950200f2d1449b3c (patch)
tree6e69e00bac5f9256648499d49f57d0853c556634 /src/scratchpad/testcases/org/apache/poi
parente284963051cf5bff3f6b160ae65b56c049c5bfdc (diff)
downloadpoi-8ebfec4808cce673b1911d15950200f2d1449b3c.tar.gz
poi-8ebfec4808cce673b1911d15950200f2d1449b3c.zip
#62649 - Remove OPOIFS* / rename NPOIFS* to POIFS*
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1839709 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java5
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java6
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java5
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java17
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java35
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java12
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java14
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java28
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java26
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java5
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java4
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java58
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java7
13 files changed, 100 insertions, 122 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java b/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
index 5cfb54d106..d10c6f084f 100644
--- a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
+++ b/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
@@ -33,7 +33,6 @@ import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
import org.apache.poi.hwpf.HWPFTestDataSamples;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.junit.Before;
import org.junit.Test;
@@ -89,7 +88,7 @@ public final class TestPOIDocumentScratchpad {
@Test
public void testWriteProperties() throws IOException {
// Just check we can write them back out into a filesystem
- NPOIFSFileSystem outFS = new NPOIFSFileSystem();
+ POIFSFileSystem outFS = new POIFSFileSystem();
doc.writeProperties(outFS);
// Should now hold them
@@ -103,7 +102,7 @@ public final class TestPOIDocumentScratchpad {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Write them out
- NPOIFSFileSystem outFS = new NPOIFSFileSystem();
+ POIFSFileSystem outFS = new POIFSFileSystem();
doc.writeProperties(outFS);
outFS.writeFilesystem(baos);
diff --git a/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java b/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java
index 4c5f63c4e6..06b7c98a81 100644
--- a/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java
+++ b/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java
@@ -26,7 +26,7 @@ import java.io.InputStream;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hpbf.HPBFDocument;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.junit.Test;
public final class TestPublisherTextExtractor {
@@ -97,7 +97,7 @@ public final class TestPublisherTextExtractor {
// And with NPOIFS
sample = _samples.openResourceAsStream("Sample.pub");
- NPOIFSFileSystem fs = new NPOIFSFileSystem(sample);
+ POIFSFileSystem fs = new POIFSFileSystem(sample);
HPBFDocument docNPOIFS = new HPBFDocument(fs);
ext = new PublisherTextExtractor(docNPOIFS);
assertEquals(SAMPLE_TEXT, ext.getText());
@@ -116,8 +116,6 @@ public final class TestPublisherTextExtractor {
/**
* We have the same file saved for Publisher 98, Publisher 2000 and
* Publisher 2007. Check they all agree.
- *
- * @throws Exception
*/
@Test
public void testMultipleVersions() throws Exception {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
index 5e42300f8b..78ca26ee3b 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
@@ -37,7 +37,6 @@ import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.sl.extractor.SlideShowExtractor;
import org.apache.poi.sl.usermodel.ObjectShape;
@@ -376,14 +375,14 @@ public final class TestExtractor {
/**
* Tests that we can work with both {@link POIFSFileSystem}
- * and {@link NPOIFSFileSystem}
+ * and {@link POIFSFileSystem}
*/
@SuppressWarnings("resource")
@Test
public void testDifferentPOIFS() throws IOException {
// Open the two filesystems
File pptFile = slTests.getFile("basic_test_ppt_file.ppt");
- try (final NPOIFSFileSystem npoifs = new NPOIFSFileSystem(pptFile, true)) {
+ try (final POIFSFileSystem npoifs = new POIFSFileSystem(pptFile, true)) {
// Open directly
try (SlideShow<?,?> ppt = SlideShowFactory.create(npoifs.getRoot());
SlideShowExtractor<?,?> extractor = new SlideShowExtractor<>(ppt)) {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
index 4fe1c4d051..fdba39d08c 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
@@ -47,17 +47,14 @@ import org.apache.poi.poifs.crypt.EncryptionInfo;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIDecryptor;
import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
/**
* Tests that DocumentEncryption works properly.
*/
public class TestDocumentEncryption {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
@Test
public void cryptoAPIDecryptionOther() throws Exception {
@@ -70,7 +67,7 @@ public class TestDocumentEncryption {
Biff8EncryptionKey.setCurrentUserPassword("hello");
try {
for (String pptFile : encPpts) {
- try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
+ try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
HSLFSlideShow ppt = new HSLFSlideShow(fs)) {
assertTrue(ppt.getSlides().size() > 0);
} catch (EncryptedPowerPointFileException e) {
@@ -86,7 +83,7 @@ public class TestDocumentEncryption {
public void cryptoAPIChangeKeySize() throws Exception {
String pptFile = "cryptoapi-proc2356.ppt";
Biff8EncryptionKey.setCurrentUserPassword("crypto");
- try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
+ try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
// need to cache data (i.e. read all data) before changing the key size
List<HSLFPictureData> picsExpected = hss.getPictureData();
@@ -99,7 +96,7 @@ public class TestDocumentEncryption {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
hss.write(bos);
- try (NPOIFSFileSystem fs2 = new NPOIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
+ try (POIFSFileSystem fs2 = new POIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
HSLFSlideShowImpl hss2 = new HSLFSlideShowImpl(fs2)) {
List<HSLFPictureData> picsActual = hss2.getPictureData();
@@ -121,7 +118,7 @@ public class TestDocumentEncryption {
ByteArrayOutputStream expected = new ByteArrayOutputStream();
ByteArrayOutputStream actual = new ByteArrayOutputStream();
try {
- try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
+ try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
hss.normalizeRecords();
@@ -135,7 +132,7 @@ public class TestDocumentEncryption {
// decrypted
ByteArrayInputStream bis = new ByteArrayInputStream(encrypted.toByteArray());
- try (NPOIFSFileSystem fs = new NPOIFSFileSystem(bis);
+ try (POIFSFileSystem fs = new POIFSFileSystem(bis);
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
Biff8EncryptionKey.setCurrentUserPassword(null);
hss.write(actual);
@@ -152,7 +149,7 @@ public class TestDocumentEncryption {
// taken from a msdn blog:
// http://blogs.msdn.com/b/openspecification/archive/2009/05/08/dominic-salemno.aspx
Biff8EncryptionKey.setCurrentUserPassword("crypto");
- try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile("cryptoapi-proc2356.ppt"));
+ try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile("cryptoapi-proc2356.ppt"));
HSLFSlideShow ss = new HSLFSlideShow(fs)) {
HSLFSlide slide = ss.getSlides().get(0);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
index aee64bd6f9..9da61bd13e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
@@ -56,7 +56,6 @@ import org.apache.poi.ddf.EscherColorRef;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hslf.model.HeadersFooters;
import org.apache.poi.hslf.record.DocInfoListContainer;
import org.apache.poi.hslf.record.Document;
@@ -68,7 +67,7 @@ import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.VBAInfoAtom;
import org.apache.poi.hslf.record.VBAInfoContainer;
import org.apache.poi.hssf.usermodel.DummyGraphics2d;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.macros.VBAMacroReader;
import org.apache.poi.sl.draw.DrawFactory;
import org.apache.poi.sl.draw.DrawPaint;
@@ -131,14 +130,14 @@ public final class TestBugs {
assertNotNull(notes);
txrun = notes.getTextParagraphs().get(0);
assertEquals("Notes-1", HSLFTextParagraph.getRawText(txrun));
- assertEquals(false, txrun.get(0).getTextRuns().get(0).isBold());
+ assertFalse(txrun.get(0).getTextRuns().get(0).isBold());
//notes for the second slide are in bold
notes = ppt.getSlides().get(1).getNotes();
assertNotNull(notes);
txrun = notes.getTextParagraphs().get(0);
assertEquals("Notes-2", HSLFTextParagraph.getRawText(txrun));
- assertEquals(true, txrun.get(0).getTextRuns().get(0).isBold());
+ assertTrue(txrun.get(0).getTextRuns().get(0).isBold());
ppt.close();
}
@@ -152,14 +151,14 @@ public final class TestBugs {
//map slide number and starting phrase of its notes
Map<Integer, String> notesMap = new HashMap<>();
- notesMap.put(Integer.valueOf(4), "For decades before calculators");
- notesMap.put(Integer.valueOf(5), "Several commercial applications");
- notesMap.put(Integer.valueOf(6), "There are three variations of LNS that are discussed here");
- notesMap.put(Integer.valueOf(7), "Although multiply and square root are easier");
- notesMap.put(Integer.valueOf(8), "The bus Z is split into Z_H and Z_L");
+ notesMap.put(4, "For decades before calculators");
+ notesMap.put(5, "Several commercial applications");
+ notesMap.put(6, "There are three variations of LNS that are discussed here");
+ notesMap.put(7, "Although multiply and square root are easier");
+ notesMap.put(8, "The bus Z is split into Z_H and Z_L");
for (HSLFSlide slide : ppt.getSlides()) {
- Integer slideNumber = Integer.valueOf(slide.getSlideNumber());
+ Integer slideNumber = slide.getSlideNumber();
HSLFNotes notes = slide.getNotes();
if (notesMap.containsKey(slideNumber)){
assertNotNull(notes);
@@ -412,7 +411,6 @@ public final class TestBugs {
/**
* PowerPoint 95 files should throw a more helpful exception
- * @throws IOException
*/
@Test(expected=OldPowerPointFormatException.class)
public void bug41711() throws IOException {
@@ -632,7 +630,7 @@ public final class TestBugs {
@Test
public void bug45124() throws IOException {
- SlideShow<?,?> ppt = open("bug45124.ppt");
+ HSLFSlideShow ppt = open("bug45124.ppt");
Slide<?,?> slide1 = ppt.getSlides().get(1);
TextBox<?,?> res = slide1.createTextBox();
@@ -647,7 +645,7 @@ public final class TestBugs {
tp.setBulletStyle(Color.red, 'A');
- SlideShow<?,?> ppt2 = HSLFTestDataSamples.writeOutAndReadBack((HSLFSlideShow)ppt);
+ SlideShow<?,?> ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt);
ppt.close();
res = (TextBox<?,?>)ppt2.getSlides().get(1).getShapes().get(1);
@@ -887,7 +885,7 @@ public final class TestBugs {
// For the test file, common sl draws textruns one by one and not mixed
// so we evaluate the whole iterator
Map<Attribute, Object> attributes = null;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (char c = iterator.first();
c != CharacterIterator.DONE;
@@ -994,10 +992,10 @@ public final class TestBugs {
//It isn't pretty, but it works...
private Map<String, String> getMacrosFromHSLF(String fileName) throws IOException {
InputStream is = null;
- NPOIFSFileSystem npoifs = null;
+ POIFSFileSystem npoifs = null;
try {
is = new FileInputStream(POIDataSamples.getSlideShowInstance().getFile(fileName));
- npoifs = new NPOIFSFileSystem(is);
+ npoifs = new POIFSFileSystem(is);
//TODO: should we run the VBAMacroReader on this npoifs?
//TBD: We know that ppt typically don't store macros in the regular place,
//but _can_ they?
@@ -1011,11 +1009,8 @@ public final class TestBugs {
long persistId = vbaAtom.getPersistIdRef();
for (HSLFObjectData objData : ppt.getEmbeddedObjects()) {
if (objData.getExOleObjStg().getPersistId() == persistId) {
- VBAMacroReader mr = new VBAMacroReader(objData.getInputStream());
- try {
+ try (VBAMacroReader mr = new VBAMacroReader(objData.getInputStream())) {
return mr.readMacros();
- } finally {
- mr.close();
}
}
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
index 9c978cb8c8..d50b2deda9 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
@@ -33,7 +33,7 @@ import java.util.List;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.SlideListWithText;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
import org.junit.After;
import org.junit.Before;
@@ -396,7 +396,7 @@ public final class TestRichTextRun {
*/
private static void assertMatchesFileC(HSLFSlideShow s) throws IOException {
// Grab the bytes of the file
- NPOIFSFileSystem fs = new NPOIFSFileSystem(HSLFTestDataSamples.openSampleFileStream(filenameC));
+ POIFSFileSystem fs = new POIFSFileSystem(HSLFTestDataSamples.openSampleFileStream(filenameC));
InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT);
byte[] raw_file = IOUtils.toByteArray(is);
is.close();
@@ -405,7 +405,7 @@ public final class TestRichTextRun {
// Now write out the slideshow
ByteArrayOutputStream baos = new ByteArrayOutputStream();
s.write(baos);
- fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
+ fs = new POIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT);
byte[] raw_ss = IOUtils.toByteArray(is);
is.close();
@@ -515,7 +515,7 @@ public final class TestRichTextRun {
slide.addShape(shape);
assertEquals(42.0, tr.getFontSize(), 0);
- assertEquals(true, rt.isBullet());
+ assertTrue(rt.isBullet());
assertEquals(50.0, rt.getLeftMargin(), 0);
assertEquals(0, rt.getIndent(), 0);
assertEquals('\u263A', (char)rt.getBulletChar());
@@ -530,7 +530,7 @@ public final class TestRichTextRun {
rt = shape.getTextParagraphs().get(0);
tr = rt.getTextRuns().get(0);
assertEquals(42.0, tr.getFontSize(), 0);
- assertEquals(true, rt.isBullet());
+ assertTrue(rt.isBullet());
assertEquals(50.0, rt.getLeftMargin(), 0);
assertEquals(0, rt.getIndent(), 0);
assertEquals('\u263A', (char)rt.getBulletChar());
@@ -615,7 +615,7 @@ public final class TestRichTextRun {
}
@Test
- public void testChineseParagraphs() throws Exception {
+ public void testChineseParagraphs() {
List<HSLFTextRun> rts;
HSLFTextRun rt;
List<List<HSLFTextParagraph>> txt;
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java
index 40266c3272..cb9c2ec0c6 100644
--- a/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java
@@ -43,7 +43,7 @@ import org.apache.poi.hsmf.datatypes.PropertyValue.LongPropertyValue;
import org.apache.poi.hsmf.datatypes.PropertyValue.TimePropertyValue;
import org.apache.poi.hsmf.dev.HSMFDump;
import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LocaleUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -58,8 +58,8 @@ public final class TestFixedSizedProperties {
private static final String messageFails = "53784_fails.msg";
private static MAPIMessage mapiMessageSucceeds;
private static MAPIMessage mapiMessageFails;
- private static NPOIFSFileSystem fsMessageSucceeds;
- private static NPOIFSFileSystem fsMessageFails;
+ private static POIFSFileSystem fsMessageSucceeds;
+ private static POIFSFileSystem fsMessageFails;
private static SimpleDateFormat messageDateFormat;
private static TimeZone userTimeZone;
@@ -69,8 +69,8 @@ public final class TestFixedSizedProperties {
@BeforeClass
public static void initMapi() throws Exception {
POIDataSamples samples = POIDataSamples.getHSMFInstance();
- fsMessageSucceeds = new NPOIFSFileSystem(samples.getFile(messageSucceeds));
- fsMessageFails = new NPOIFSFileSystem(samples.getFile(messageFails));
+ fsMessageSucceeds = new POIFSFileSystem(samples.getFile(messageSucceeds));
+ fsMessageFails = new POIFSFileSystem(samples.getFile(messageFails));
mapiMessageSucceeds = new MAPIMessage(fsMessageSucceeds);
mapiMessageFails = new MAPIMessage(fsMessageFails);
@@ -95,7 +95,7 @@ public final class TestFixedSizedProperties {
* of our test files
*/
@Test
- public void testPropertiesFound() throws Exception {
+ public void testPropertiesFound() {
Map<MAPIProperty,List<PropertyValue>> props;
props = mapiMessageSucceeds.getMainChunks().getProperties();
@@ -109,7 +109,7 @@ public final class TestFixedSizedProperties {
* Check we find properties of a variety of different types
*/
@Test
- public void testPropertyValueTypes() throws Exception {
+ public void testPropertyValueTypes() {
Chunks mainChunks = mapiMessageSucceeds.getMainChunks();
// Ask to have the values looked up
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java b/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java
index 51b60399f8..f2c5388ae7 100644
--- a/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java
@@ -29,7 +29,7 @@ import java.util.TimeZone;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hsmf.MAPIMessage;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LocaleUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -56,7 +56,7 @@ public final class TestOutlookTextExtractor {
@Test
public void testQuick() throws Exception {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("quick.msg"), true);
MAPIMessage msg = new MAPIMessage(poifs);
OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -81,7 +81,7 @@ public final class TestOutlookTextExtractor {
@Test
public void testSimple() throws Exception {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
MAPIMessage msg = new MAPIMessage(poifs);
OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -107,7 +107,7 @@ public final class TestOutlookTextExtractor {
ext.close();
fis.close();
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
ext = new OutlookTextExtactor(poifs);
String poifsTxt = ext.getText();
ext.close();
@@ -141,7 +141,7 @@ public final class TestOutlookTextExtractor {
"example_sent_regular.msg", "example_sent_unicode.msg"
};
for(String file : files) {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile(file), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile(file), true);
MAPIMessage msg = new MAPIMessage(poifs);
OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -181,7 +181,7 @@ public final class TestOutlookTextExtractor {
"example_received_regular.msg", "example_received_unicode.msg"
};
for(String file : files) {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile(file), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile(file), true);
MAPIMessage msg = new MAPIMessage(poifs);
@@ -204,10 +204,12 @@ public final class TestOutlookTextExtractor {
}
/**
- * See also {@link org.apache.poi.extractor.TestExtractorFactory#testEmbeded()}
+ * See also {@link org.apache.poi.extractor.ooxml.TestExtractorFactory#testEmbeded()}
*/
+ @SuppressWarnings("JavadocReference")
+ @Test
public void testWithAttachments() throws Exception {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
MAPIMessage msg = new MAPIMessage(poifs);
OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -230,9 +232,10 @@ public final class TestOutlookTextExtractor {
ext.close();
poifs.close();
}
-
+
+ @Test
public void testWithAttachedMessage() throws Exception {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("58214_with_attachment.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("58214_with_attachment.msg"), true);
MAPIMessage msg = new MAPIMessage(poifs);
OutlookTextExtactor ext = new OutlookTextExtactor(msg);
String text = ext.getText();
@@ -248,9 +251,10 @@ public final class TestOutlookTextExtractor {
ext.close();
poifs.close();
}
-
+
+ @Test
public void testEncodings() throws Exception {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("chinese-traditional.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("chinese-traditional.msg"), true);
MAPIMessage msg = new MAPIMessage(poifs);
OutlookTextExtactor ext = new OutlookTextExtactor(msg);
String text = ext.getText();
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java b/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
index cd2a55be10..3003845789 100644
--- a/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
@@ -20,9 +20,11 @@ package org.apache.poi.hsmf.parsers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Calendar;
@@ -38,7 +40,7 @@ import org.apache.poi.hsmf.datatypes.RecipientChunks.RecipientChunksSorter;
import org.apache.poi.hsmf.datatypes.StringChunk;
import org.apache.poi.hsmf.datatypes.Types;
import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LocaleUtil;
import org.junit.Test;
@@ -50,7 +52,7 @@ public final class TestPOIFSChunkParser {
@Test
public void testFindsCore() throws IOException, ChunkNotFoundException {
- NPOIFSFileSystem simple = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+ POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true);
// Check a few core things are present
simple.getRoot().getEntry(
@@ -77,7 +79,7 @@ public final class TestPOIFSChunkParser {
@Test
public void testFindsRecips() throws IOException, ChunkNotFoundException {
- NPOIFSFileSystem simple = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+ POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true);
simple.getRoot().getEntry("__recip_version1.0_#00000000");
@@ -92,7 +94,7 @@ public final class TestPOIFSChunkParser {
assertEquals("/O=HOSTEDSERVICE2/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=Kevin.roast@ben",
recips.recipientEmailChunk.getValue());
- String search = new String(recips.recipientSearchChunk.getValue(), "ASCII");
+ String search = new String(recips.recipientSearchChunk.getValue(), StandardCharsets.US_ASCII);
assertEquals("CN=KEVIN.ROAST@BEN\0", search.substring(search.length()-19));
// Now via MAPIMessage
@@ -116,14 +118,14 @@ public final class TestPOIFSChunkParser {
// Now look at another message
- simple = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
+ simple = new POIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
msg = new MAPIMessage(simple);
assertNotNull(msg.getRecipientDetailsChunks());
assertEquals(1, msg.getRecipientDetailsChunks().length);
assertEquals("SMTP", msg.getRecipientDetailsChunks()[0].deliveryTypeChunk.getValue());
- assertEquals(null, msg.getRecipientDetailsChunks()[0].recipientSMTPChunk);
- assertEquals(null, msg.getRecipientDetailsChunks()[0].recipientNameChunk);
+ assertNull(msg.getRecipientDetailsChunks()[0].recipientSMTPChunk);
+ assertNull(msg.getRecipientDetailsChunks()[0].recipientNameChunk);
assertEquals("travis@overwrittenstack.com", msg.getRecipientDetailsChunks()[0].recipientEmailChunk.getValue());
assertEquals("travis@overwrittenstack.com", msg.getRecipientEmailAddress());
@@ -133,7 +135,7 @@ public final class TestPOIFSChunkParser {
@Test
public void testFindsMultipleRecipients() throws IOException, ChunkNotFoundException {
- NPOIFSFileSystem multiple = new NPOIFSFileSystem(samples.getFile("example_received_unicode.msg"), true);
+ POIFSFileSystem multiple = new POIFSFileSystem(samples.getFile("example_received_unicode.msg"), true);
multiple.getRoot().getEntry("__recip_version1.0_#00000000");
multiple.getRoot().getEntry("__recip_version1.0_#00000001");
@@ -226,7 +228,7 @@ public final class TestPOIFSChunkParser {
@Test
public void testFindsNameId() throws IOException {
- NPOIFSFileSystem simple = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+ POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true);
simple.getRoot().getEntry("__nameid_version1.0");
@@ -250,8 +252,8 @@ public final class TestPOIFSChunkParser {
@Test
public void testFindsAttachments() throws IOException, ChunkNotFoundException {
- NPOIFSFileSystem with = new NPOIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
- NPOIFSFileSystem without = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+ POIFSFileSystem with = new POIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
+ POIFSFileSystem without = new POIFSFileSystem(samples.getFile("quick.msg"), true);
AttachmentChunks attachment;
@@ -326,7 +328,7 @@ public final class TestPOIFSChunkParser {
*/
@Test
public void testOlk10SideProps() throws IOException, ChunkNotFoundException {
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("51873.msg"), true);
+ POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("51873.msg"), true);
MAPIMessage msg = new MAPIMessage(poifs);
// Check core details came through
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
index 8c8dfa78e0..ea6fc3966e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
+++ b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
@@ -34,7 +34,6 @@ import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.hwpf.OldWordFileFormatException;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.Entry;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.StringUtil;
import org.junit.Test;
@@ -338,13 +337,13 @@ public final class TestWordExtractor {
/**
* Tests that we can work with both {@link POIFSFileSystem}
- * and {@link NPOIFSFileSystem}
+ * and {@link POIFSFileSystem}
*/
@Test
public void testDifferentPOIFS() throws Exception {
// Open the two filesystems
File file = docTests.getFile("test2.doc");
- try (NPOIFSFileSystem npoifs = new NPOIFSFileSystem(file, true)) {
+ try (POIFSFileSystem npoifs = new POIFSFileSystem(file, true)) {
DirectoryNode dir = npoifs.getRoot();
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
index dbb3a6f218..c605130a67 100644
--- a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
+++ b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
@@ -20,7 +20,7 @@ package org.apache.poi.hwpf.extractor;
import org.apache.poi.POIDataSamples;
import org.apache.poi.extractor.POITextExtractor;
import org.apache.poi.extractor.OLE2ExtractorFactory;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.junit.Test;
import java.io.IOException;
@@ -60,7 +60,7 @@ public final class TestWordExtractorBugs {
@Test
public void testBug60374() throws Exception {
- NPOIFSFileSystem fs = new NPOIFSFileSystem(SAMPLES.openResourceAsStream("cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC"));
+ POIFSFileSystem fs = new POIFSFileSystem(SAMPLES.openResourceAsStream("cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC"));
final POITextExtractor extractor = OLE2ExtractorFactory.createExtractor(fs);
// Check it gives text without error
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
index 4bced587d4..bb42d77125 100644
--- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
+++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
@@ -25,6 +25,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -39,7 +40,6 @@ import org.apache.poi.hwpf.converter.WordToTextConverter;
import org.apache.poi.hwpf.extractor.Word6Extractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.hwpf.model.*;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.POILogFactory;
@@ -56,8 +56,7 @@ public class TestBugs{
private static final POILogger logger = POILogFactory.getLogger(TestBugs.class);
- public static void assertEqualsIgnoreNewline(String expected, String actual )
- {
+ private static void assertEqualsIgnoreNewline(String expected, String actual) {
String newExpected = expected.replaceAll("\r\n", "\n" )
.replaceAll("\r", "\n").trim();
String newActual = actual.replaceAll("\r\n", "\n" )
@@ -110,17 +109,6 @@ public class TestBugs{
doc.close();
}
}
-
- private String getTextOldFile(String samplefile) throws IOException {
- HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile(samplefile);
- Word6Extractor extractor = new Word6Extractor(doc);
- try {
- return extractor.getText();
- } finally {
- extractor.close();
- doc.close();
- }
- }
/**
* Bug 33519 - HWPF fails to read a file
@@ -448,7 +436,7 @@ public class TestBugs{
try (InputStream is = POIDataSamples.getDocumentInstance()
.openResourceAsStream("Bug47742-text.txt")) {
byte[] expectedBytes = IOUtils.toByteArray(is);
- String expectedText = new String(expectedBytes, "utf-8")
+ String expectedText = new String(expectedBytes, StandardCharsets.UTF_8)
.substring(1); // strip-off the unicode marker
assertEqualsIgnoreNewline(expectedText, foundText);
@@ -486,11 +474,11 @@ public class TestBugs{
}
@Test
- public void test49933() throws IOException
- {
- String text = getTextOldFile("Bug49933.doc");
-
- assertContains(text, "best.wine.jump.ru");
+ public void test49933() throws IOException {
+ try (HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Bug49933.doc");
+ Word6Extractor extractor = new Word6Extractor(doc)) {
+ assertContains(extractor.getText(), "best.wine.jump.ru");
+ }
}
/**
@@ -544,8 +532,7 @@ public class TestBugs{
* release from download site )
*/
@Test
- public void test51604p2() throws Exception
- {
+ public void test51604p2() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug51604.doc");
Range range = doc.getRange();
@@ -627,7 +614,7 @@ public class TestBugs{
{
InputStream is = POIDataSamples.getDocumentInstance()
.openResourceAsStream("empty.doc");
- try (NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(is)) {
+ try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(is)) {
HWPFDocument hwpfDocument = new HWPFDocument(
npoifsFileSystem.getRoot());
hwpfDocument.write(new ByteArrayOutputStream());
@@ -679,8 +666,7 @@ public class TestBugs{
* corrupt document
*/
@Test
- public void testBug51834() throws Exception
- {
+ public void testBug51834() {
/*
* we don't have Java test for this file - it should be checked using
* Microsoft BFF Validator. But check read-write-read anyway. -- sergey
@@ -773,7 +759,7 @@ public class TestBugs{
* Disabled pending a fix for the bug
*/
@Test
- public void test56880() throws Exception {
+ public void test56880() {
HWPFDocument doc =
HWPFTestDataSamples.openSampleFile("56880.doc");
assertEqualsIgnoreNewline("Check Request", doc.getRange().text());
@@ -787,20 +773,12 @@ public class TestBugs{
{
assertNotNull(getText("Bug61268.doc"));
}
-
- // These are the values the are expected to be read when the file
- // is checked.
- private final int section1LeftMargin = 1440;
- private final int section1RightMargin = 1440;
- private final int section1TopMargin = 1440;
- private final int section1BottomMargin = 1440;
- private final int section1NumColumns = 1;
+
private int section2LeftMargin = 1440;
private int section2RightMargin = 1440;
private int section2TopMargin = 1440;
private int section2BottomMargin = 1440;
- private final int section2NumColumns = 3;
-
+
@Test
@SuppressWarnings("SuspiciousNameCombination")
public void testHWPFSections() {
@@ -854,10 +832,17 @@ public class TestBugs{
@SuppressWarnings("Duplicates")
private void assertSection1Margin(Section section) {
+ int section1BottomMargin = 1440;
assertEquals(section1BottomMargin, section.getMarginBottom());
+ // These are the values the are expected to be read when the file
+ // is checked.
+ int section1LeftMargin = 1440;
assertEquals(section1LeftMargin, section.getMarginLeft());
+ int section1RightMargin = 1440;
assertEquals(section1RightMargin, section.getMarginRight());
+ int section1TopMargin = 1440;
assertEquals(section1TopMargin, section.getMarginTop());
+ int section1NumColumns = 1;
assertEquals(section1NumColumns, section.getNumColumns());
}
@@ -867,6 +852,7 @@ public class TestBugs{
assertEquals(section2LeftMargin, section.getMarginLeft());
assertEquals(section2RightMargin, section.getMarginRight());
assertEquals(section2TopMargin, section.getMarginTop());
+ int section2NumColumns = 3;
assertEquals(section2NumColumns, section.getNumColumns());
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
index ea9cf893dd..8c57ffdd34 100644
--- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
+++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
@@ -31,7 +31,6 @@ import org.apache.poi.POIDataSamples;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFTestCase;
import org.apache.poi.hwpf.HWPFTestDataSamples;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.TempFile;
@@ -104,7 +103,7 @@ public final class TestHWPFWrite extends HWPFTestCase {
}
// Open from the temp file in read-write mode
- NPOIFSFileSystem poifs = new NPOIFSFileSystem(file, false);
+ POIFSFileSystem poifs = new POIFSFileSystem(file, false);
HWPFDocument doc = new HWPFDocument(poifs.getRoot());
Range r = doc.getRange();
assertEquals("I am a test document\r", r.getParagraph(0).text());
@@ -117,7 +116,7 @@ public final class TestHWPFWrite extends HWPFTestCase {
doc.close();
poifs.close();
- poifs = new NPOIFSFileSystem(file);
+ poifs = new POIFSFileSystem(file);
doc = new HWPFDocument(poifs.getRoot());
r = doc.getRange();
assertEquals("X XX a test document\r", r.getParagraph(0).text());
@@ -138,7 +137,7 @@ public final class TestHWPFWrite extends HWPFTestCase {
@Test(expected=IllegalStateException.class)
public void testInvalidInPlaceWriteNPOIFS() throws Exception {
// Can't work for Read-Only files
- NPOIFSFileSystem fs = new NPOIFSFileSystem(SAMPLES.getFile("SampleDoc.doc"), true);
+ POIFSFileSystem fs = new POIFSFileSystem(SAMPLES.getFile("SampleDoc.doc"), true);
HWPFDocument doc = new HWPFDocument(fs.getRoot());
try {
doc.write();