Fix some IntelliJ warnings

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1802629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-07-21 18:19:03 +00:00
parent 2a2ef074a4
commit db1b62efe7

View File

@ -20,6 +20,7 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -83,6 +84,7 @@ public class TestDocumentEncryption {
fail(pptFile+" can't be decrypted"); fail(pptFile+" can't be decrypted");
} }
} }
// password is reset in @After
} }
@Test @Test
@ -94,7 +96,9 @@ public class TestDocumentEncryption {
// need to cache data (i.e. read all data) before changing the key size // need to cache data (i.e. read all data) before changing the key size
List<HSLFPictureData> picsExpected = hss.getPictureData(); List<HSLFPictureData> picsExpected = hss.getPictureData();
hss.getDocumentSummaryInformation(); hss.getDocumentSummaryInformation();
EncryptionInfo ei = hss.getDocumentEncryptionAtom().getEncryptionInfo(); DocumentEncryptionAtom documentEncryptionAtom = hss.getDocumentEncryptionAtom();
assertNotNull(documentEncryptionAtom);
EncryptionInfo ei = documentEncryptionAtom.getEncryptionInfo();
((CryptoAPIEncryptionHeader) ei.getHeader()).setKeySize(0x78); ((CryptoAPIEncryptionHeader) ei.getHeader()).setKeySize(0x78);
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -112,6 +116,7 @@ public class TestDocumentEncryption {
} }
hss.close(); hss.close();
fs.close(); fs.close();
// password is reset in @After
} }
@Test @Test
@ -180,16 +185,20 @@ public class TestDocumentEncryption {
} }
DocumentEncryptionAtom dea = hss.getDocumentEncryptionAtom(); DocumentEncryptionAtom dea = hss.getDocumentEncryptionAtom();
assertNotNull(dea);
POIFSFileSystem fs2 = ((CryptoAPIDecryptor) dea.getEncryptionInfo().getDecryptor()).getSummaryEntries(fs.getRoot(), "EncryptedSummary"); POIFSFileSystem fs2 = ((CryptoAPIDecryptor) dea.getEncryptionInfo().getDecryptor()).getSummaryEntries(fs.getRoot(), "EncryptedSummary");
PropertySet ps = PropertySetFactory.create(fs2.getRoot(), SummaryInformation.DEFAULT_STREAM_NAME); PropertySet ps = PropertySetFactory.create(fs2.getRoot(), SummaryInformation.DEFAULT_STREAM_NAME);
assertNotNull(ps);
assertTrue(ps.isSummaryInformation()); assertTrue(ps.isSummaryInformation());
assertEquals("RC4 CryptoAPI Encryption", ps.getProperties()[1].getValue()); assertEquals("RC4 CryptoAPI Encryption", ps.getProperties()[1].getValue());
ps = PropertySetFactory.create(fs2.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME); ps = PropertySetFactory.create(fs2.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME);
assertNotNull(ps);
assertTrue(ps.isDocumentSummaryInformation()); assertTrue(ps.isDocumentSummaryInformation());
assertEquals("On-screen Show (4:3)", ps.getProperties()[1].getValue()); assertEquals("On-screen Show (4:3)", ps.getProperties()[1].getValue());
ss.close(); ss.close();
fs.close(); fs.close();
fs2.close(); fs2.close();
// password is reset in @After
} }
} }