aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2018-05-01 18:22:00 +0000
committerAndreas Beeker <kiwiwings@apache.org>2018-05-01 18:22:00 +0000
commit28e662c5a72180e39c28b9d8cf457ea90185de50 (patch)
tree6cd4023aeaebb261123f6a8ded942c496591a3fe /src/testcases/org/apache/poi/poifs
parente73282a9e8425d5bc320696f68683a70c9de137e (diff)
downloadpoi-28e662c5a72180e39c28b9d8cf457ea90185de50.tar.gz
poi-28e662c5a72180e39c28b9d8cf457ea90185de50.zip
Cleanup Biff8EncryptionKey usage and use HPSF constants instead of duplicated strings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1830705 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/poifs')
-rw-r--r--src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java26
-rw-r--r--src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java6
-rw-r--r--src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java7
3 files changed, 19 insertions, 20 deletions
diff --git a/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java b/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java
index 20dec4552f..002318b0eb 100644
--- a/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java
+++ b/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java
@@ -21,6 +21,7 @@ import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import java.io.File;
import java.io.IOException;
import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -36,12 +37,6 @@ public class TestXorEncryption {
private static final HSSFTestDataSamples samples = new HSSFTestDataSamples();
- // to not affect other tests running in the same JVM
- @After
- public void resetPassword() {
- Biff8EncryptionKey.setCurrentUserPassword(null);
- }
-
@Test
public void testXorEncryption() throws IOException {
// Xor-Password: abc
@@ -61,15 +56,16 @@ public class TestXorEncryption {
@SuppressWarnings("static-access")
@Test
public void testUserFile() throws IOException {
+ File f = samples.getSampleFile("xor-encryption-abc.xls");
Biff8EncryptionKey.setCurrentUserPassword("abc");
- NPOIFSFileSystem fs = new NPOIFSFileSystem(samples.getSampleFile("xor-encryption-abc.xls"), true);
- HSSFWorkbook hwb = new HSSFWorkbook(fs.getRoot(), true);
-
- HSSFSheet sh = hwb.getSheetAt(0);
- assertEquals(1.0, sh.getRow(0).getCell(0).getNumericCellValue(), 0.0);
- assertEquals(2.0, sh.getRow(1).getCell(0).getNumericCellValue(), 0.0);
- assertEquals(3.0, sh.getRow(2).getCell(0).getNumericCellValue(), 0.0);
- hwb.close();
- fs.close();
+ try (NPOIFSFileSystem fs = new NPOIFSFileSystem(f, true);
+ HSSFWorkbook hwb = new HSSFWorkbook(fs.getRoot(), true)) {
+ HSSFSheet sh = hwb.getSheetAt(0);
+ assertEquals(1.0, sh.getRow(0).getCell(0).getNumericCellValue(), 0.0);
+ assertEquals(2.0, sh.getRow(1).getCell(0).getNumericCellValue(), 0.0);
+ assertEquals(3.0, sh.getRow(2).getCell(0).getNumericCellValue(), 0.0);
+ } finally {
+ Biff8EncryptionKey.setCurrentUserPassword(null);
+ }
}
}
diff --git a/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java b/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
index bd0b30edde..d4442e859a 100644
--- a/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
+++ b/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
@@ -20,6 +20,8 @@ package org.apache.poi.poifs.property;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import org.apache.poi.hpsf.DocumentSummaryInformation;
+import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.poifs.storage.RawDataUtil;
import org.apache.poi.util.LocaleUtil;
@@ -68,8 +70,8 @@ public final class TestDocumentProperty extends TestCase {
byte[] input = RawDataUtil.decode(hexData);
verifyReadingProperty(1, input, 128, "Workbook");
- verifyReadingProperty(2, input, 256, "\005SummaryInformation");
- verifyReadingProperty(3, input, 384, "\005DocumentSummaryInformation");
+ verifyReadingProperty(2, input, 256, SummaryInformation.DEFAULT_STREAM_NAME);
+ verifyReadingProperty(3, input, 384, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
}
private void verifyReadingProperty(int index, byte[] input, int offset, String name)
diff --git a/src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java b/src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java
index 3950ce07e2..74cc83f879 100644
--- a/src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java
+++ b/src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java
@@ -25,6 +25,8 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import org.apache.poi.hpsf.DocumentSummaryInformation;
+import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
import org.apache.poi.poifs.storage.HeaderBlock;
@@ -79,11 +81,10 @@ public final class TestPropertyTable {
DocumentProperty workbook = new DocumentProperty("Workbook", 0x00046777);
workbook.setStartBlock(0);
- DocumentProperty summary1 = new DocumentProperty("\005SummaryInformation", 0x00001000);
+ DocumentProperty summary1 = new DocumentProperty(SummaryInformation.DEFAULT_STREAM_NAME, 0x00001000);
summary1.setStartBlock(0x00000234);
- DocumentProperty summary2 = new DocumentProperty("\005DocumentSummaryInformation",
- 0x00001000);
+ DocumentProperty summary2 = new DocumentProperty(DocumentSummaryInformation.DEFAULT_STREAM_NAME, 0x00001000);
summary2.setStartBlock(0x0000023C);
table.addProperty(workbook);