poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1745370 - in /poi/trunk/src/ooxml/testcases/org/apache/poi: openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java poifs/crypt/TestEncryptor.java
Date Tue, 24 May 2016 14:48:57 GMT
Author: centic
Date: Tue May 24 14:48:57 2016
New Revision: 1745370

URL: http://svn.apache.org/viewvc?rev=1745370&view=rev
Log:
Adjust two tests slightly

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java?rev=1745370&r1=1745369&r2=1745370&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java
Tue May 24 14:48:57 2016
@@ -111,7 +111,9 @@ public final class TestOPCComplianceCore
 	   try {
 	      extractInvalidFormatMessage("OnlyOneCorePropertiesPartFAIL.docx");
 	      fail("M4.1 should be being relaxed");
-	   } catch (AssertionFailedError e) {}
+	   } catch (AssertionFailedError e) {
+		   // expected here
+	   }
 	   
 	   // We will use the first core properties, and ignore the others
       InputStream is = OpenXML4JTestDataSamples.openSampleStream("MultipleCoreProperties.docx");
@@ -167,23 +169,16 @@ public final class TestOPCComplianceCore
 	/**
 	 * Test M4.1 rule.
 	 */
-	public void testOnlyOneCorePropertiesPart_AddPart() {
+	public void testOnlyOneCorePropertiesPart_AddPart() throws InvalidFormatException {
 		String sampleFileName = "OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx";
-		OPCPackage pkg = null;
-		try {
-			pkg = OPCPackage.open(POIDataSamples.getOpenXML4JInstance().getFile(sampleFileName).getPath());
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-		
+		OPCPackage pkg = OPCPackage.open(POIDataSamples.getOpenXML4JInstance().getFile(sampleFileName).getPath());
+
 		URI partUri = createURI("/docProps/core2.xml");
 		try {
 			pkg.createPart(PackagingURIHelper.createPartName(partUri),
 					ContentTypes.CORE_PROPERTIES_PART);
 			// no longer fail on compliance error
 			//fail("expected OPC compliance exception was not thrown");
-		} catch (InvalidFormatException e) {
-			throw new RuntimeException(e);
 		} catch (InvalidOperationException e) {
 			// expected during successful test
 			assertEquals("OPC Compliance error [M4.1]: you try to add more than one core properties
relationship in the package !", e.getMessage());
@@ -318,6 +313,6 @@ public final class TestOPCComplianceCore
 
         // Finish and tidy
         pkg.revert();
-        tmp.delete();
+        assertTrue(tmp.delete());
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java?rev=1745370&r1=1745369&r2=1745370&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java Tue May 24
14:48:57 2016
@@ -208,7 +208,6 @@ public class TestEncryptor {
         byte keySalt[] = infoExpected.getHeader().getKeySalt();
         
         
-        POIFSFileSystem fs = new POIFSFileSystem();
         EncryptionInfo infoActual = new EncryptionInfo(
               EncryptionMode.standard
             , infoExpected.getVerifier().getCipherAlgorithm()
@@ -227,7 +226,6 @@ public class TestEncryptor {
         // now we use a newly generated salt/verifier and check
         // if the file content is still the same 
 
-        fs = new POIFSFileSystem();
         infoActual = new EncryptionInfo(
               EncryptionMode.standard
             , infoExpected.getVerifier().getCipherAlgorithm()
@@ -239,7 +237,8 @@ public class TestEncryptor {
         
         e = Encryptor.getInstance(infoActual);
         e.confirmPassword(pass);
-        
+
+        POIFSFileSystem fs = new POIFSFileSystem();
         OutputStream os = e.getDataStream(fs);
         IOUtils.copy(new ByteArrayInputStream(payloadExpected), os);
         os.close();



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


Mime
View raw message