Encrypted test file for validator with expected exception, plus error message for none existent test file

git-svn-id: https://svn.apache.org/repos/asf/incubator/odf/trunk@1702611 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java b/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java
index a27a669..1cd55c8 100644
--- a/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java
+++ b/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java
@@ -21,6 +21,8 @@
  ************************************************************************/
 package org.odftoolkit.odfvalidator;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import junit.framework.Assert;
 import org.junit.Test;
 
@@ -107,4 +109,20 @@
 		Assert.assertTrue(output.contains("Error: The ODF package 'testInvalidPkg3.odt' shall contain the 'META-INF/manifest.xml' file"));
 		Assert.assertTrue(output.contains("testInvalidPkg3.odt:  Info: 2 errors, no warnings"));
 	}
+
+	@Test
+	public void validateEncryptedODT() {
+		String output = "";
+		try {
+            // password: hello
+            String name = "encrypted-with-pwd_hello.odt";
+			output = doValidation(name, null);
+		} catch (Throwable t) {
+                StringWriter errors = new StringWriter();
+                t.printStackTrace(new PrintWriter(errors));
+			Assert.fail(t.toString() + "\n" + errors.toString());
+		}
+		Assert.assertTrue(output.contains("Fatal: ZIP entry 'mimetype': only DEFLATED entries can have EXT descriptor"));
+        java.util.logging.Logger.getLogger(getClass().getName()).info("Test result:\n"+ output);
+	}
 }
diff --git a/validator/src/test/java/org/odftoolkit/odfvalidator/OdfValidatorTestBase.java b/validator/src/test/java/org/odftoolkit/odfvalidator/OdfValidatorTestBase.java
index d16d4c1..6c3bc7d 100644
--- a/validator/src/test/java/org/odftoolkit/odfvalidator/OdfValidatorTestBase.java
+++ b/validator/src/test/java/org/odftoolkit/odfvalidator/OdfValidatorTestBase.java
@@ -25,6 +25,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.PrintStream;
+import java.util.logging.Level;
 import org.junit.Ignore;
 
 @Ignore
@@ -38,14 +39,17 @@
         ByteArrayOutputStream aOut = new ByteArrayOutputStream();
         PrintStream aPOut = new PrintStream(aOut);
         InputStream aIn = getClass().getClassLoader().getResourceAsStream(aFileName);
+        if(aIn == null){
+            java.util.logging.Logger.getLogger(OdfValidatorTestBase.class.getName()).log(Level.SEVERE, "The input document '" + aFileName + "' could not be found!");
+        }
         aValidator.validateStream(aPOut, aIn, aFileName, OdfValidatorMode.VALIDATE, null);
         return aOut.toString();
     }
 
     String doValidation(String aFileName, OdfVersion aVersion, OdfValidatorMode odfValidatorMode) throws Exception {
-        return doValidation(aFileName, aVersion, odfValidatorMode, false);				
-	}		
-	
+        return doValidation(aFileName, aVersion, odfValidatorMode, false);
+	}
+
     String doValidation(String aFileName, OdfVersion aVersion, OdfValidatorMode odfValidatorMode, boolean htmlOutput) throws Exception {
         ODFValidator aValidator = new ODFValidator(null, Logger.LogLevel.INFO, htmlOutput, aVersion, true);
         ByteArrayOutputStream aOut = new ByteArrayOutputStream();
@@ -55,8 +59,8 @@
 		try {
 			aValidator.validateStream(aPOut, aIn, aFileName, odfValidatorMode, filter);
 		} catch (Exception e) {
-			e.printStackTrace(aPOut);			
+			e.printStackTrace(aPOut);
 		}
-        return aOut.toString();							
-	}				
+        return aOut.toString();
+	}
 }
diff --git a/validator/src/test/resources/encrypted-with-pwd_hello.odt b/validator/src/test/resources/encrypted-with-pwd_hello.odt
new file mode 100644
index 0000000..5de1a7d
--- /dev/null
+++ b/validator/src/test/resources/encrypted-with-pwd_hello.odt
Binary files differ