You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2013/08/18 17:02:42 UTC
svn commit: r1515128 - in
/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox:
pdmodel/font/PDSimpleFontTest.java util/TestImageIOUtils.java
Author: lehmi
Date: Sun Aug 18 15:02:42 2013
New Revision: 1515128
URL: http://svn.apache.org/r1515128
Log:
PDFBOX-1698: (re)move the print and rendering stuff
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java?rev=1515128&r1=1515127&r2=1515128&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java Sun Aug 18 15:02:42 2013
@@ -1,26 +1,29 @@
/*
* Copyright 2011 adam.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.pdfbox.pdmodel.font;
-import java.awt.image.BufferedImage;
import java.util.List;
+
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.util.RenderUtil;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -28,44 +31,54 @@ import org.junit.BeforeClass;
import org.junit.Test;
/**
- *
+ *
* @author adam
*/
-public class PDSimpleFontTest {
+public class PDSimpleFontTest
+{
- public PDSimpleFontTest() {
+ public PDSimpleFontTest()
+ {
}
@BeforeClass
- public static void setUpClass() throws Exception {
+ public static void setUpClass() throws Exception
+ {
}
@AfterClass
- public static void tearDownClass() throws Exception {
+ public static void tearDownClass() throws Exception
+ {
}
@Before
- public void setUp() {
+ public void setUp()
+ {
}
@After
- public void tearDown() {
+ public void tearDown()
+ {
}
/**
* Test of the error reported in PDFBox-998
*/
@Test
- public void testPDFBox988() throws Exception {
+ public void testPDFBox988() throws Exception
+ {
PDDocument doc = null;
- try {
- doc = PDDocument.load(PDSimpleFontTest.class.getResourceAsStream("F001u_3_7j.pdf"));
- List pages = doc.getDocumentCatalog().getAllPages();
- PDPage page = (PDPage)pages.get(0);
- BufferedImage image = page.convertToImage();
- // The alligation is that convertToImage() will crash the JVM or hang
- } finally {
- if(doc != null) {
+ try
+ {
+ doc = PDDocument.load(PDSimpleFontTest.class.getResourceAsStream("F001u_3_7j.pdf"));
+ List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
+ RenderUtil.convertToImage(pages.get(0));
+ // The alligation is that convertToImage() will crash the JVM or hang
+ }
+ finally
+ {
+ if (doc != null)
+ {
doc.close();
}
}
@@ -75,18 +88,22 @@ public class PDSimpleFontTest {
* Test of the error reported in PDFBox-1019
*/
@Test
- public void testPDFBox1019() throws Exception {
+ public void testPDFBox1019() throws Exception
+ {
PDDocument doc = null;
- try {
- doc = PDDocument.load(PDSimpleFontTest.class.getResourceAsStream("256.pdf"));
- List pages = doc.getDocumentCatalog().getAllPages();
- PDPage page = (PDPage)pages.get(0);
- BufferedImage image = page.convertToImage();
- // The alligation is that convertToImage() will crash the JVM or hang
- } finally {
- if(doc != null) {
+ try
+ {
+ doc = PDDocument.load(PDSimpleFontTest.class.getResourceAsStream("256.pdf"));
+ List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
+ RenderUtil.convertToImage(pages.get(0));
+ // The alligation is that convertToImage() will crash the JVM or hang
+ }
+ finally
+ {
+ if (doc != null)
+ {
doc.close();
}
}
}
-}
\ No newline at end of file
+}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java?rev=1515128&r1=1515127&r2=1515128&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java Sun Aug 18 15:02:42 2013
@@ -31,8 +31,7 @@ import org.apache.pdfbox.pdmodel.PDPage;
/**
* Test suite for ImageIOUtil.
- *
- * @version $Revision: 1.0 $
+ *
*/
public class TestImageIOUtils extends TestCase
{
@@ -46,14 +45,13 @@ public class TestImageIOUtils extends Te
/**
* Validate page rendering for all supported image formats (JDK5).
- *
+ *
* @param file The file to validate
* @param inDir Name of the input directory
* @param outDir Name of the output directory
* @throws Exception when there is an exception
*/
- private void doTestFile(File file, String inDir, String outDir)
- throws Exception
+ private void doTestFile(File file, String inDir, String outDir) throws Exception
{
PDDocument document = null;
String imageType = "png";
@@ -61,25 +59,21 @@ public class TestImageIOUtils extends Te
try
{
int resolution = 120;
- document = PDDocument.load(file);
+ document = PDDocument.load(file);
// testing PNG
- writeImage(document, imageType, outDir + file.getName() + "-",
- BufferedImage.TYPE_INT_RGB, resolution);
+ writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_INT_RGB, resolution);
// testing JPG/JPEG
imageType = "jpg";
- writeImage(document, imageType, outDir + file.getName() + "-",
- BufferedImage.TYPE_INT_RGB, resolution);
+ writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_INT_RGB, resolution);
// testing BMP
imageType = "bmp";
- writeImage(document, imageType, outDir + file.getName() + "-",
- BufferedImage.TYPE_INT_RGB, resolution);
+ writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_INT_RGB, resolution);
// testing WBMP
imageType = "wbmp";
- writeImage(document, imageType, outDir + file.getName() + "-",
- BufferedImage.TYPE_BYTE_BINARY, resolution);
+ writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_BYTE_BINARY, resolution);
}
- catch(Exception e)
- {
+ catch (Exception e)
+ {
testFailed = true;
LOG.error("Error converting file " + file.getName() + " using image type " + imageType, e);
}
@@ -91,44 +85,42 @@ public class TestImageIOUtils extends Te
}
private void writeImage(PDDocument document, String imageFormat, String outputPrefix, int imageType, int resolution)
- throws IOException
+ throws IOException
{
- List pages = document.getDocumentCatalog().getAllPages();
- PDPage page = (PDPage)pages.get( 0 );
- BufferedImage image = page.convertToImage(imageType, resolution);
+ List<PDPage> pages = document.getDocumentCatalog().getAllPages();
+ BufferedImage image = RenderUtil.convertToImage(pages.get(0), imageType, resolution);
String fileName = outputPrefix + 1;
- System.out.println( "Writing: " + fileName + "." +imageFormat);
+ System.out.println("Writing: " + fileName + "." + imageFormat);
ImageIOUtil.writeImage(image, imageFormat, fileName, imageType, resolution);
}
/**
* Test to validate image rendering of file set.
- *
+ *
* @throws Exception when there is an exception
*/
- public void testRenderImage()
- throws Exception
+ public void testRenderImage() throws Exception
{
String inDir = "src/test/resources/input/rendering";
String outDir = "target/test-output/";
- File[] testFiles = new File(inDir).listFiles(new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return (name.endsWith(".pdf") || name.endsWith(".ai"));
- }
- });
-
- for (int n = 0; n < testFiles.length; n++)
+ File[] testFiles = new File(inDir).listFiles(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
{
- doTestFile(testFiles[n], inDir, outDir);
+ return (name.endsWith(".pdf") || name.endsWith(".ai"));
}
+ });
- if (testFailed)
- {
- fail("One or more failures, see test log for details");
- }
+ for (int n = 0; n < testFiles.length; n++)
+ {
+ doTestFile(testFiles[n], inDir, outDir);
+ }
+
+ if (testFailed)
+ {
+ fail("One or more failures, see test log for details");
+ }
}
}