Fix whitespace

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1541005 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2013-11-12 11:32:10 +00:00
parent 9d570db422
commit e2e04b0ebc

View File

@ -16,37 +16,37 @@ import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class TestXWPFBugs extends TestCase { public class TestXWPFBugs extends TestCase {
/** /**
* A word document that's encrypted with non-standard * A word document that's encrypted with non-standard
* Encryption options, and no cspname section. See bug 53475 * Encryption options, and no cspname section. See bug 53475
*/ */
public void test53475() throws Exception { public void test53475() throws Exception {
try { try {
Biff8EncryptionKey.setCurrentUserPassword("solrcell"); Biff8EncryptionKey.setCurrentUserPassword("solrcell");
File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-solrcell.docx"); File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-solrcell.docx");
NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true); NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);
// Check the encryption details // Check the encryption details
EncryptionInfo info = new EncryptionInfo(filesystem); EncryptionInfo info = new EncryptionInfo(filesystem);
assertEquals(128, info.getHeader().getKeySize()); assertEquals(128, info.getHeader().getKeySize());
assertEquals(EncryptionHeader.ALGORITHM_AES_128, info.getHeader().getAlgorithm()); assertEquals(EncryptionHeader.ALGORITHM_AES_128, info.getHeader().getAlgorithm());
assertEquals(EncryptionHeader.HASH_SHA1, info.getHeader().getHashAlgorithm()); assertEquals(EncryptionHeader.HASH_SHA1, info.getHeader().getHashAlgorithm());
// Check it can be decoded // Check it can be decoded
Decryptor d = Decryptor.getInstance(info); Decryptor d = Decryptor.getInstance(info);
assertTrue("Unable to process: document is encrypted", d.verifyPassword("solrcell")); assertTrue("Unable to process: document is encrypted", d.verifyPassword("solrcell"));
// Check we can read the word document in that // Check we can read the word document in that
InputStream dataStream = d.getDataStream(filesystem); InputStream dataStream = d.getDataStream(filesystem);
OPCPackage opc = OPCPackage.open(dataStream); OPCPackage opc = OPCPackage.open(dataStream);
XWPFDocument doc = new XWPFDocument(opc); XWPFDocument doc = new XWPFDocument(opc);
XWPFWordExtractor ex = new XWPFWordExtractor(doc); XWPFWordExtractor ex = new XWPFWordExtractor(doc);
String text = ex.getText(); String text = ex.getText();
assertNotNull(text); assertNotNull(text);
assertEquals("This is password protected Word document.", text.trim()); assertEquals("This is password protected Word document.", text.trim());
ex.close(); ex.close();
} finally { } finally {
Biff8EncryptionKey.setCurrentUserPassword(null); Biff8EncryptionKey.setCurrentUserPassword(null);
} }
} }
} }