pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1664985 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
Date Sun, 08 Mar 2015 12:45:47 GMT
Author: lehmi
Date: Sun Mar  8 12:45:46 2015
New Revision: 1664985

URL: http://svn.apache.org/r1664985
Log:
PDFBOX-2099: added a test for get/setVersion

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java?rev=1664985&r1=1664984&r2=1664985&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java Sun Mar
 8 12:45:46 2015
@@ -45,6 +45,7 @@ public class TestPDDocument extends Test
 
     /**
      * Test document save/load using a stream.
+     * @throws IOException if something went wrong
      */
     public void testSaveLoadStream() throws IOException
     {
@@ -71,6 +72,7 @@ public class TestPDDocument extends Test
 
     /**
      * Test document save/load using a file.
+     * @throws IOException if something went wrong
      */
     public void testSaveLoadFile() throws IOException
     {
@@ -100,6 +102,7 @@ public class TestPDDocument extends Test
 
     /**
      * Test document save/loadNonSeq using a stream.
+     * @throws IOException if something went wrong
      */
     public void testSaveLoadNonSeqStream() throws IOException
     {
@@ -126,6 +129,7 @@ public class TestPDDocument extends Test
 
     /**
      * Test document save/loadNonSeq using a file.
+     * @throws IOException if something went wrong
      */
     public void testSaveLoadNonSeqFile() throws IOException
     {
@@ -152,4 +156,43 @@ public class TestPDDocument extends Test
         assertEquals(1, loadDoc.getNumberOfPages());
         loadDoc.close();
     }
+    
+    /**
+     * Test get/setVersion.
+     * @throws IOException if something went wrong
+     */
+    public void testVersions() throws IOException
+    {
+        PDDocument document = new PDDocument();
+        // test default version
+        assertEquals(1.4f, document.getVersion());
+        assertEquals(1.4f, document.getDocument().getVersion());
+        assertEquals("1.4", document.getDocumentCatalog().getVersion());
+        // force downgrading version (header)
+        document.getDocument().setVersion(1.3f);
+        document.getDocumentCatalog().setVersion(null);
+        // test new version (header)
+        assertEquals(1.3f, document.getVersion());
+        assertEquals(1.3f, document.getDocument().getVersion());
+        assertNull(document.getDocumentCatalog().getVersion());
+        document.close();
+
+        // check if version downgrade is denied
+        document = new PDDocument();
+        document.setVersion(1.3f);
+        // all versions shall have their default value
+        assertEquals(1.4f, document.getVersion());
+        assertEquals(1.4f, document.getDocument().getVersion());
+        assertEquals("1.4", document.getDocumentCatalog().getVersion());
+        
+        // check version upgrade
+        document.setVersion(1.5f);
+        // overall version has to be 1.5f
+        assertEquals(1.5f, document.getVersion());
+        // header version has to be unchanged
+        assertEquals(1.4f, document.getDocument().getVersion());
+        // catalog version version has to be 1.5
+        assertEquals("1.5", document.getDocumentCatalog().getVersion());
+        document.close();
+    }
 }



Mime
View raw message