From 8372eb89ecc27fa75d7a031c5f61afa99e9e58e4 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Wed, 25 Dec 2013 23:24:04 +0000 Subject: [PATCH] javadoc and compiler warning house-keeping git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1553428 13f79535-47bb-0310-9956-ffa450edef68 --- .../crypt/TestCertificateEncryption.java | 24 ++++++++++-------- .../poi/hslf/extractor/TestExtractor.java | 15 +++++------ .../poi/hslf/usermodel/TestRichTextRun.java | 2 +- .../poi/ss/formula/functions/TestMirr.java | 9 +++++-- test-data/poifs/poitest.pfx | Bin 0 -> 1534 bytes 5 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 test-data/poifs/poitest.pfx diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestCertificateEncryption.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestCertificateEncryption.java index 4b2ffb2b4e..589821ea0c 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestCertificateEncryption.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestCertificateEncryption.java @@ -27,26 +27,27 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.KeyPair; -import java.security.KeyPairGenerator; import java.security.KeyStore; import java.security.PrivateKey; import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.cert.Certificate; import java.security.cert.X509Certificate; -import java.util.Date; import org.apache.poi.POIDataSamples; import org.apache.poi.poifs.crypt.agile.AgileDecryptor; import org.apache.poi.poifs.crypt.agile.AgileEncryptionVerifier; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.IOUtils; -import org.junit.BeforeClass; import org.junit.Test; +/* +import org.junit.BeforeClass; +import java.util.Date; +import java.math.BigInteger; +import java.security.KeyPairGenerator; +import java.security.SecureRandom; +import java.security.cert.Certificate; import sun.security.x509.AlgorithmId; import sun.security.x509.CertificateAlgorithmId; import sun.security.x509.CertificateIssuerName; @@ -58,9 +59,10 @@ import sun.security.x509.CertificateX509Key; import sun.security.x509.X500Name; import sun.security.x509.X509CertImpl; import sun.security.x509.X509CertInfo; +*/ /** - * {@linkplain http://stackoverflow.com/questions/1615871/creating-an-x509-certificate-in-java-without-bouncycastle} + * @see creating a self-signed certificate */ public class TestCertificateEncryption { /** @@ -91,7 +93,7 @@ public class TestCertificateEncryption { * The keystore generation / loading is split, because normally the keystore would * already exist. */ - @BeforeClass + /* @BeforeClass public static void initKeystore() throws GeneralSecurityException, IOException { CertData certData = new CertData(); @@ -134,14 +136,16 @@ public class TestCertificateEncryption { ByteArrayOutputStream bos = new ByteArrayOutputStream(); keystore.store(bos, password.toCharArray()); pfxFileBytes = bos.toByteArray(); - } + } */ public CertData loadKeystore() throws GeneralSecurityException, IOException { KeyStore keystore = KeyStore.getInstance("PKCS12"); - InputStream fis = new ByteArrayInputStream(pfxFileBytes); + // InputStream fis = new ByteArrayInputStream(pfxFileBytes); + InputStream fis = POIDataSamples.getPOIFSInstance().openResourceAsStream("poitest.pfx"); keystore.load(fis, password.toCharArray()); + fis.close(); X509Certificate x509 = (X509Certificate)keystore.getCertificate(certAlias); PrivateKey privateKey = (PrivateKey)keystore.getKey(certAlias, password.toCharArray()); 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 ab1076c458..27fd702100 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java @@ -21,8 +21,6 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.List; -import junit.framework.TestCase; - import org.apache.poi.POIDataSamples; import org.apache.poi.POITestCase; import org.apache.poi.hslf.HSLFSlideShow; @@ -57,10 +55,6 @@ public final class TestExtractor extends POITestCase { ppe2 = new PowerPointExtractor(slTests.openResourceAsStream("with_textbox.ppt")); } - private static void assertContains(String reason, String haystack, String needle) { - assertTrue(reason, haystack.contains(needle)); - } - public void testReadSheetText() { // Basic 2 page example String sheetText = ppe.getText(); @@ -174,6 +168,7 @@ public final class TestExtractor extends POITestCase { /** * A powerpoint file with embeded powerpoint files */ + @SuppressWarnings("unused") public void testExtractFromOwnEmbeded() throws Exception { String path = "ppt_with_embeded.ppt"; ppe = new PowerPointExtractor(POIDataSamples.getSlideShowInstance().openResourceAsStream(path)); @@ -281,6 +276,7 @@ public final class TestExtractor extends POITestCase { assertContains(text, "test phrase"); } + @SuppressWarnings("unused") public void testSlideMasterText() throws Exception { String masterTitleText = "This is the Master Title"; String masterRandomText = "This text comes from the Master Slide"; @@ -337,10 +333,10 @@ public final class TestExtractor extends POITestCase { // Check for the english text in the mixed line assertContains(text, "Mix"); - // Check for the chinese text in the mixed line - 表 + // Check for the chinese text in the mixed line assertContains(text, "\u8868"); - // Check for the chinese only text line - ハンカク + // Check for the chinese only text line assertContains(text, "\uff8a\uff9d\uff76\uff78"); } @@ -348,6 +344,7 @@ public final class TestExtractor extends POITestCase { * Tests that we can work with both {@link POIFSFileSystem} * and {@link NPOIFSFileSystem} */ + @SuppressWarnings("resource") public void testDifferentPOIFS() throws Exception { // Open the two filesystems DirectoryNode[] files = new DirectoryNode[2]; @@ -356,7 +353,7 @@ public final class TestExtractor extends POITestCase { // Open directly for(DirectoryNode dir : files) { - PowerPointExtractor extractor = new PowerPointExtractor(dir, null); + PowerPointExtractor extractor = new PowerPointExtractor(dir); assertEquals(expectText, extractor.getText()); } 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 fe013f491a..a71b72a28b 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java @@ -649,7 +649,7 @@ if(false) { // Check we can get the english text out of that String text = rt.getText(); assertContains(text, "Single byte"); - // And the chinese - ハンカク + // And the chinese assertContains(text, "\uff8a\uff9d\uff76\uff78"); // It isn't bold or italic diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java b/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java index 6e1963b69a..a934202ed1 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java @@ -19,8 +19,13 @@ package org.apache.poi.ss.formula.functions; import junit.framework.AssertionFailedError; import junit.framework.TestCase; + import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.EvaluationException; import org.apache.poi.ss.usermodel.CellValue; @@ -29,7 +34,7 @@ import org.apache.poi.ss.usermodel.CellValue; * Tests for {@link org.apache.poi.ss.formula.functions.Mirr} * * @author Carlos Delgado (carlos dot del dot est at gmail dot com) - * @author Cédric Walter (cedric dot walter at gmail dot com) + * @author Cedric Walter (cedric dot walter at gmail dot com) * @see {@link org.apache.poi.ss.formula.functions.TestIrr} */ public final class TestMirr extends TestCase { diff --git a/test-data/poifs/poitest.pfx b/test-data/poifs/poitest.pfx new file mode 100644 index 0000000000000000000000000000000000000000..14be4d0a60e2874f1d84a847ffb5e0515d39a53f GIT binary patch literal 1534 zcmY+DX*3ji7{XBYGBJ{Xkmzbk$O53qm=tU*(OmFWFY#Q%8rb7?TL zO-?OFmvDP;1DDeBtdO1FHsw4E1cCuzDlihU88Az69qMcfa%^3wR^q~uLtj=@^lS0S z9eyS^uFoi@`yt3s4_t0^jDHtbE2|q_*TY_R*y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