poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1742422 - /poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
Date Thu, 05 May 2016 12:22:23 GMT
Author: centic
Date: Thu May  5 12:22:23 2016
New Revision: 1742422

URL: http://svn.apache.org/viewvc?rev=1742422&view=rev
Log:
Try to catch more network-unavailable cases in TestSignatureInfo

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java?rev=1742422&r1=1742421&r2=1742422&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java Thu May
 5 12:22:23 2016
@@ -36,10 +36,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.ConnectException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.net.*;
 import java.security.Key;
 import java.security.KeyPair;
 import java.security.KeyStore;
@@ -82,13 +79,13 @@ import org.apache.xmlbeans.XmlObject;
 import org.bouncycastle.asn1.x509.KeyUsage;
 import org.bouncycastle.cert.ocsp.OCSPResp;
 import org.etsi.uri.x01903.v13.DigestAlgAndValueType;
-import org.etsi.uri.x01903.v13.QualifyingPropertiesType;
-import org.junit.Assume;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.w3.x2000.x09.xmldsig.ReferenceType;
-import org.w3.x2000.x09.xmldsig.SignatureDocument;
+import org.etsi.uri.x01903.v13.QualifyingPropertiesType;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.w3.x2000.x09.xmldsig.ReferenceType;
+import org.w3.x2000.x09.xmldsig.SignatureDocument;
 import org.w3c.dom.Document;
 
 public class TestSignatureInfo {
@@ -105,6 +102,7 @@ public class TestSignatureInfo {
 
         /*** TODO : set cal to now ... only set to fixed date for debugging ... */ 
         cal = LocaleUtil.getLocaleCalendar(LocaleUtil.TIMEZONE_UTC);
+        assertNotNull(cal);
 //        cal.set(2014, 7, 6, 21, 42, 12);
 //        cal.clear(Calendar.MILLISECOND);
 
@@ -390,10 +388,11 @@ public class TestSignatureInfo {
             if(e.getCause() == null) {
                 throw e;
             }
-            if(!(e.getCause() instanceof ConnectException)) {
+            if(!(e.getCause() instanceof ConnectException) && !(e.getCause() instanceof
SocketTimeoutException)) {
                 throw e;
             }
-            assertTrue("Only allowing ConnectException with 'timed out' as message here,
but had: " + e, e.getCause().getMessage().contains("timed out"));
+            assertTrue("Only allowing ConnectException with 'timed out' as message here,
but had: " + e,
+                            e.getCause().getMessage().contains("timed out"));
         }
         
         // verify
@@ -577,28 +576,31 @@ public class TestSignatureInfo {
         si.confirmSignature();
         assertTrue("invalid signature", si.verifySignature());
         
-        pkg.close();
-    }
-    
-    @Test
-    @Ignore
-    public void testMultiSign() throws Exception {
-        initKeyPair("KeyA", "CN=KeyA");
-        KeyPair keyPairA = keyPair;
-        X509Certificate x509A = x509;
-        initKeyPair("KeyB", "CN=KeyB");
-        KeyPair keyPairB = keyPair;
-        X509Certificate x509B = x509;
-        
-        File tpl = copy(testdata.getFile("bug58630.xlsx"));
-        OPCPackage pkg = OPCPackage.open(tpl);
-        SignatureConfig signatureConfig = new SignatureConfig();
-        
-        
-    }
-    
-    private void sign(OPCPackage pkgCopy, String alias, String signerDn, int signerCount)
throws Exception {
-        initKeyPair(alias, signerDn);
+        pkg.close();
+    }
+    
+    @Test
+    @Ignore
+    public void testMultiSign() throws Exception {
+        initKeyPair("KeyA", "CN=KeyA");
+        //KeyPair keyPairA = keyPair;
+        //X509Certificate x509A = x509;
+        initKeyPair("KeyB", "CN=KeyB");
+        //KeyPair keyPairB = keyPair;
+        //X509Certificate x509B = x509;
+        
+        File tpl = copy(testdata.getFile("bug58630.xlsx"));
+        OPCPackage pkg = OPCPackage.open(tpl);
+        try {
+            //SignatureConfig signatureConfig = new SignatureConfig();
+            assertNotNull(pkg);
+        } finally {
+            pkg.close();
+        }
+    }
+    
+    private void sign(OPCPackage pkgCopy, String alias, String signerDn, int signerCount)
throws Exception {
+        initKeyPair(alias, signerDn);
 
         SignatureConfig signatureConfig = new SignatureConfig();
         signatureConfig.setKey(keyPair.getPrivate());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message