aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-23 10:11:42 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-23 10:11:42 +0200
commit29ad9ed4a2ab2743c78316c0adccaa532b7cd0a7 (patch)
tree178c90bf0e38d5010c2c3fc9f07dad1d182e311a
parent5501deb7a20fc61901ecd629ae15337e497bb4fd (diff)
downloadpdf-as-4-29ad9ed4a2ab2743c78316c0adccaa532b7cd0a7.tar.gz
pdf-as-4-29ad9ed4a2ab2743c78316c0adccaa532b7cd0a7.tar.bz2
pdf-as-4-29ad9ed4a2ab2743c78316c0adccaa532b7cd0a7.zip
File handle close test
-rw-r--r--pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/KeystoreFileHandleClosed.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/KeystoreFileHandleClosed.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/KeystoreFileHandleClosed.java
new file mode 100644
index 00000000..3dc9a269
--- /dev/null
+++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/KeystoreFileHandleClosed.java
@@ -0,0 +1,44 @@
+package at.gv.egiz.pdfas.cli.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.sigs.pades.PAdESSignerKeystore;
+
+public class KeystoreFileHandleClosed {
+
+ // -ksf /home/afitzek/devel/pdfas_neu/test.p12 -kst PKCS12 -ksa ecc_test
+ // -kskp 123456 -kssp 123456
+ private static final String origFile = "/home/afitzek/devel/pdfas_neu/test.p12";
+ private static final String keyAlias = "ecc_test";
+ private static final String keyStorePassword = "123456";
+ private static final String keyPassword = "123456";
+ private static final String keyStoreType = "PKCS12";
+
+ @Test
+ public void test() throws IOException, PdfAsException {
+
+ File origFileFile = new File(origFile);
+ File tmpKeyStoreFile = new File("/tmp/test.ks");
+ FileUtils.copyFile(origFileFile, tmpKeyStoreFile);
+ try {
+ PAdESSignerKeystore pAdESSignerKeystore = new PAdESSignerKeystore(
+ tmpKeyStoreFile.getCanonicalPath(), keyAlias,
+ keyStorePassword, keyPassword, keyStoreType);
+ } finally {
+ if (tmpKeyStoreFile != null && tmpKeyStoreFile.exists()) {
+ if (!FileUtils.deleteQuietly(tmpKeyStoreFile)) {
+ fail("Unable to remove temporary keystore file '"
+ + tmpKeyStoreFile.getAbsolutePath() + "'.");
+ }
+ }
+ }
+ }
+
+}