pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1660825 - in /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox: TestAll.java pdmodel/TestPDDocumentCatalog.java
Date Thu, 19 Feb 2015 10:01:46 GMT
Author: msahyoun
Date: Thu Feb 19 10:01:45 2015
New Revision: 1660825

URL: http://svn.apache.org/r1660825
Log:
PDFBOX-2576 don't throw raw exception type; move to Junit 4 style; resolve Checkstyle warnings

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

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java?rev=1660825&r1=1660824&r2=1660825&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java Thu Feb 19 10:01:45 2015
@@ -30,7 +30,6 @@ import org.apache.pdfbox.filter.ccitt.Te
 import org.apache.pdfbox.filter.ccitt.TestPackedBitArray;
 import org.apache.pdfbox.pdmodel.TestFDF;
 import org.apache.pdfbox.pdmodel.TestPDDocument;
-import org.apache.pdfbox.pdmodel.TestPDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.TestPDDocumentInformation;
 import org.apache.pdfbox.pdmodel.common.TestPDNameTreeNode;
 import org.apache.pdfbox.pdmodel.common.TestPDNumberTreeNode;
@@ -88,7 +87,6 @@ public class TestAll extends TestCase
         suite.addTest( TestCOSInteger.suite() );
         suite.addTest( TestCOSFloat.suite() );
         suite.addTestSuite( TestPDDocument.class );
-        suite.addTestSuite( TestPDDocumentCatalog.class );
         suite.addTestSuite( TestPDDocumentInformation.class );
         suite.addTestSuite( TestOptionalContentGroups.class );
         suite.addTestSuite( org.apache.pdfbox.util.TestLayerUtility.class );

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java?rev=1660825&r1=1660824&r2=1660825&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java
Thu Feb 19 10:01:45 2015
@@ -16,23 +16,39 @@
  */
 package org.apache.pdfbox.pdmodel;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 
 import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-public class TestPDDocumentCatalog extends TestCase {
+import org.junit.Test;
+
+/**
+ * Test PDDocument Catalog functionality.
+ *
+ */
+public class TestPDDocumentCatalog
+{
 
     /**
+     * Test getPageLabels().
+     * 
      * Test case for
      * <a href="https://issues.apache.org/jira/browse/PDFBOX-90"
      *   >PDFBOX-90</a> - Support explicit retrieval of page labels.
+     *   
+     * @throws IOException in case the document can not be parsed.
      */
-    public void testPageLabels() throws Exception {
+    @Test
+    public void retrievePageLabels() throws IOException
+    {
         PDDocument doc = null;
-        try {
+        try
+        {
             doc = PDDocument.load(TestPDDocumentCatalog.class.getResourceAsStream("test_pagelabels.pdf"));
             PDDocumentCatalog cat = doc.getDocumentCatalog();
             String[] labels = cat.getPageLabels().getLabelsByPageIndices();
@@ -49,56 +65,84 @@ public class TestPDDocumentCatalog exten
             assertEquals("vii", labels[9]);
             assertEquals("Appendix I", labels[10]);
             assertEquals("Appendix II", labels[11]);
-        } finally {
+        }
+        finally
+        {
             if(doc != null)
+            {
                 doc.close();
+            }
         }
     }
 
     /**
+     * Test page labels for malformed PDF.
+     * 
      * Test case for
      * <a href="https://issues.apache.org/jira/browse/PDFBOX-900"
      *   >PDFBOX-900</a> - Handle malformed PDFs
+     *   
+     * @throws IOException in case the document can not be parsed.
      */
-    public void testLabelsOnMalformedPdf() throws Exception {
+    @Test
+    public void retrievePageLabelsOnMalformedPdf() throws IOException
+    {
         PDDocument doc = null;
-        try {
+        try
+        {
             doc = PDDocument.load(TestPDDocumentCatalog.class.getResourceAsStream("badpagelabels.pdf"));
             PDDocumentCatalog cat = doc.getDocumentCatalog();
             // getLabelsByPageIndices() should not throw an exception
             cat.getPageLabels().getLabelsByPageIndices();
-        } catch(Exception e) {
-            e.printStackTrace();
-            fail("Threw exception!" + e);
-        } finally {
+        }
+        finally
+        {
             if(doc != null)
+            {
                 doc.close();
+            }
         }
     }
 
     /**
+     * Test getNumberOfPages().
+     * 
      * Test case for
      * <a href="https://issues.apache.org/jira/browse/PDFBOX-911"
      *   >PDFBOX-911</a> - Method PDDocument.getNumberOfPages() returns wrong
      * number of pages
+     * 
+     * @throws IOException in case the document can not be parsed.
      */
-    public void testGetNumberOfPages() throws Exception {
+    @Test
+    public void retrieveNumberOfPages() throws IOException
+    {
         PDDocument doc = null;
-        try {
+        try
+        {
             doc = PDDocument.load(TestPDDocumentCatalog.class.getResourceAsStream("test.unc.pdf"));
             assertEquals(4, doc.getNumberOfPages());
-        } finally {
+        }
+        finally
+        {
             if(doc != null)
+            {
                 doc.close();
+            }
         }
     }
     
     /**
+     * Test OutputIntents functionality.
+     * 
      * Test case for
      * <a https://issues.apache.org/jira/browse/PDFBOX-2687">PDFBOX-2687</a>
-     * ClassCastException when trying to get OutputIntents or add to it
+     * ClassCastException when trying to get OutputIntents or add to it.
+     * 
+     * @throws IOException in case the document can not be parsed.
      */
-    public void testOutputIntents() throws Exception
+    @Test
+    public void handleOutputIntents() throws IOException
     {
         PDDocument doc = null;
         InputStream colorProfile = null;



Mime
View raw message