You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2013/03/06 17:46:37 UTC

svn commit: r1453416 [15/16] - in /pdfbox/trunk/preflight: ./ src/main/java/org/apache/pdfbox/preflight/ src/main/java/org/apache/pdfbox/preflight/action/ src/main/java/org/apache/pdfbox/preflight/annotation/ src/main/java/org/apache/pdfbox/preflight/a...

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java Wed Mar  6 16:46:35 2013
@@ -38,69 +38,88 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class TestInvalidDirectory {
+public class TestInvalidDirectory
+{
 
+    protected static File directory;
 
-	protected static File directory;
-
-	protected File target = null;
-
-
-	public TestInvalidDirectory (File file) {
-		this.target = file;
-	}
-
-	@Test
-	public void validate () throws Exception {
-		PreflightDocument document = null;
-
-		System.out.println(target);
-		ValidationResult result = null;
-		try {
-			PreflightParser parser = new PreflightParser(new FileDataSource(target));
-			parser.parse();
-			document = (PreflightDocument)parser.getPDDocument();
-			document.validate();
-			result = document.getResult();
-		} catch (SyntaxValidationException e) {
-			result = e.getResult();
-		} finally {
-			if (document != null) {
-				document.close();
-			}
-		}
-		Assert.assertFalse("Test of " + target, result.isValid());
-
-	}
-
-	@Parameters
-	public static Collection<Object[]> initializeParameters() throws Exception {
-		// check directory
-		File directory = null;
-		String pdfPath = System.getProperty("pdfa.invalid", null);
-		if ("${user.pdfa.invalid}".equals(pdfPath)) {pdfPath=null;}
-		if (pdfPath!=null) {
-			directory = new File(pdfPath);
-			if (!directory.exists()) throw new Exception ("directory does not exists : "+directory.getAbsolutePath());
-			if (!directory.isDirectory()) throw new Exception ("not a directory : "+directory.getAbsolutePath());
-		} else {
-			System.err.println("System property 'pdfa.invalid' not defined, will not run TestValidaDirectory");
-		}
-		// create list
-		if (directory==null) {
-			return new ArrayList<Object[]>(0);
-		} else {
-			File [] files = directory.listFiles();
-			List<Object[]> data = new ArrayList<Object[]>(files.length);
-			for (File file : files) {
-				if (file.isFile()) {
-					data.add(new Object [] {file});
-				}
-			}
-			return data;
-		}
-	}
-
+    protected File target = null;
 
+    public TestInvalidDirectory(File file)
+    {
+        this.target = file;
+    }
+
+    @Test
+    public void validate() throws Exception
+    {
+        PreflightDocument document = null;
+
+        System.out.println(target);
+        ValidationResult result = null;
+        try
+        {
+            PreflightParser parser = new PreflightParser(new FileDataSource(target));
+            parser.parse();
+            document = (PreflightDocument) parser.getPDDocument();
+            document.validate();
+            result = document.getResult();
+        }
+        catch (SyntaxValidationException e)
+        {
+            result = e.getResult();
+        }
+        finally
+        {
+            if (document != null)
+            {
+                document.close();
+            }
+        }
+        Assert.assertFalse("Test of " + target, result.isValid());
+
+    }
+
+    @Parameters
+    public static Collection<Object[]> initializeParameters() throws Exception
+    {
+        // check directory
+        File directory = null;
+        String pdfPath = System.getProperty("pdfa.invalid", null);
+        if ("${user.pdfa.invalid}".equals(pdfPath))
+        {
+            pdfPath = null;
+        }
+        if (pdfPath != null)
+        {
+            directory = new File(pdfPath);
+            if (!directory.exists())
+                throw new Exception("directory does not exists : " + directory.getAbsolutePath());
+            if (!directory.isDirectory())
+                throw new Exception("not a directory : " + directory.getAbsolutePath());
+        }
+        else
+        {
+            System.err.println("System property 'pdfa.invalid' not defined, will not run TestValidaDirectory");
+        }
+        // create list
+        if (directory == null)
+        {
+            return new ArrayList<Object[]>(0);
+        }
+        else
+        {
+            File[] files = directory.listFiles();
+            List<Object[]> data = new ArrayList<Object[]>(files.length);
+            for (File file : files)
+            {
+                if (file.isFile())
+                {
+                    data.add(new Object[] { file });
+                }
+            }
+            return data;
+        }
+    }
 
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java Wed Mar  6 16:46:35 2013
@@ -48,133 +48,162 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class TestIsartorValidationFromClasspath {
+public class TestIsartorValidationFromClasspath
+{
 
-	protected static FileOutputStream isartorResultFile = null;
+    protected static FileOutputStream isartorResultFile = null;
 
-	protected String expectedError;
+    protected String expectedError;
 
-	protected String path;
+    protected String path;
 
-	public TestIsartorValidationFromClasspath(String path, String error) {
-		this.path = path;
-		this.expectedError = error;
-	}
-
-	@BeforeClass
-	public static void beforeClass() throws Exception {
-
-		String irp = System.getProperty("isartor.results.path");
-		if (irp != null) {
-			File f = new File (irp);
-			if (f.exists() && f.isFile()) {
-				f.delete();
-				isartorResultFile = new FileOutputStream(f);
-			} else if (!f.exists()) {
-				isartorResultFile = new FileOutputStream(f);
-			} else {
-				throw new IllegalArgumentException("Invalid result file : " + irp);
-			}
-		}
-	}
-
-	@AfterClass
-	public static void afterClass() throws Exception {
-		if (isartorResultFile != null) {
-			IOUtils.closeQuietly(isartorResultFile);
-		}
-	}
-
-	@Test()
-	public void validate() throws Exception {
-		PreflightDocument document = null;
-		try {
-			System.out.println(path);
-			InputStream input = this.getClass().getResourceAsStream(path);
-
-			ValidationResult result = null;
-			try {
-				PreflightParser parser = new PreflightParser(new org.apache.pdfbox.preflight.utils.ByteArrayDataSource(input));
-				parser.parse();
-				document = (PreflightDocument)parser.getPDDocument();
-				document.validate();
-				result = document.getResult();
-			} catch (SyntaxValidationException e) {
-				result = e.getResult();
-			}
-
-			Assert.assertFalse(path + " : Isartor file should be invalid ("	+ path + ")", result.isValid());
-			Assert.assertTrue(path + " : Should find at least one error", result.getErrorsList().size() > 0);
-
-			// could contain more than one error
-			boolean found = false;
-			for (ValidationError error : result.getErrorsList()) {
-				if (error.getErrorCode().equals(this.expectedError)) {
-					found = true;
-					if (isartorResultFile == null) {
-						break;
-					}
-				}
-				if (isartorResultFile != null) {
-					String log = path.replace(".pdf", "") + "#" + error.getErrorCode()+"#"+error.getDetails()+"\n";
-					isartorResultFile.write(log.getBytes());
-				}
-			}
-
-			if (result.getErrorsList().size() > 1) {
-				if (!found) {
-					StringBuilder message = new StringBuilder(100);
-					message.append(path).append(
-							" : Invalid error code returned. Expected ");
-					message.append(this.expectedError).append(", found ");
-					for (ValidationError error : result.getErrorsList()) {
-						message.append(error.getErrorCode()).append(" ");
-					}
-					Assert.fail(message.toString());
-				}
-			} else {
-				Assert.assertEquals(path + " : Invalid error code returned.",
-						this.expectedError, 
-						result.getErrorsList().get(0).getErrorCode());
-			}
-		} catch (ValidationException e) {
-			throw new Exception(path + " :" + e.getMessage(), e);
-		} finally {
-			if (document != null) document.close();
-		}
-	}
-
-	@Parameters
-	public static Collection<Object[]> initializeParameters() throws Exception 
-	{
-		// load expected errors
-		File f = new File("src/test/resources/expected_errors.txt");
-		System.out.println(f.exists());
-		InputStream expected = new FileInputStream(f);
-		Properties props = new Properties();
-		props.load(expected);
-		IOUtils.closeQuietly(expected);
-		// prepare config
-		List<Object[]> data = new ArrayList<Object[]>();
-		InputStream is = Class.class.getResourceAsStream("/Isartor testsuite.list");
-		if (is != null)
-		{
-			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
-			String line = reader.readLine();
-			while (line!=null) 
-			{
-				String fn = new File(line).getName();
-				String error = new StringTokenizer(props.getProperty(fn), "//").nextToken().trim();
-				Object[] tmp = new Object[] { "/"+line, error };
-				data.add(tmp);
-				line = reader.readLine();
-			}
-		}
-		else
-		{
-			System.out.println("TestIsartorValidationFromClasspath2.initializeParameters(): No input files found");
-		}
-		return data;
-	}
+    public TestIsartorValidationFromClasspath(String path, String error)
+    {
+        this.path = path;
+        this.expectedError = error;
+    }
+
+    @BeforeClass
+    public static void beforeClass() throws Exception
+    {
+
+        String irp = System.getProperty("isartor.results.path");
+        if (irp != null)
+        {
+            File f = new File(irp);
+            if (f.exists() && f.isFile())
+            {
+                f.delete();
+                isartorResultFile = new FileOutputStream(f);
+            }
+            else if (!f.exists())
+            {
+                isartorResultFile = new FileOutputStream(f);
+            }
+            else
+            {
+                throw new IllegalArgumentException("Invalid result file : " + irp);
+            }
+        }
+    }
+
+    @AfterClass
+    public static void afterClass() throws Exception
+    {
+        if (isartorResultFile != null)
+        {
+            IOUtils.closeQuietly(isartorResultFile);
+        }
+    }
+
+    @Test()
+    public void validate() throws Exception
+    {
+        PreflightDocument document = null;
+        try
+        {
+            System.out.println(path);
+            InputStream input = this.getClass().getResourceAsStream(path);
+
+            ValidationResult result = null;
+            try
+            {
+                PreflightParser parser = new PreflightParser(new org.apache.pdfbox.preflight.utils.ByteArrayDataSource(
+                        input));
+                parser.parse();
+                document = (PreflightDocument) parser.getPDDocument();
+                document.validate();
+                result = document.getResult();
+            }
+            catch (SyntaxValidationException e)
+            {
+                result = e.getResult();
+            }
+
+            Assert.assertFalse(path + " : Isartor file should be invalid (" + path + ")", result.isValid());
+            Assert.assertTrue(path + " : Should find at least one error", result.getErrorsList().size() > 0);
+
+            // could contain more than one error
+            boolean found = false;
+            for (ValidationError error : result.getErrorsList())
+            {
+                if (error.getErrorCode().equals(this.expectedError))
+                {
+                    found = true;
+                    if (isartorResultFile == null)
+                    {
+                        break;
+                    }
+                }
+                if (isartorResultFile != null)
+                {
+                    String log = path.replace(".pdf", "") + "#" + error.getErrorCode() + "#" + error.getDetails()
+                            + "\n";
+                    isartorResultFile.write(log.getBytes());
+                }
+            }
+
+            if (result.getErrorsList().size() > 1)
+            {
+                if (!found)
+                {
+                    StringBuilder message = new StringBuilder(100);
+                    message.append(path).append(" : Invalid error code returned. Expected ");
+                    message.append(this.expectedError).append(", found ");
+                    for (ValidationError error : result.getErrorsList())
+                    {
+                        message.append(error.getErrorCode()).append(" ");
+                    }
+                    Assert.fail(message.toString());
+                }
+            }
+            else
+            {
+                Assert.assertEquals(path + " : Invalid error code returned.", this.expectedError, result
+                        .getErrorsList().get(0).getErrorCode());
+            }
+        }
+        catch (ValidationException e)
+        {
+            throw new Exception(path + " :" + e.getMessage(), e);
+        }
+        finally
+        {
+            if (document != null)
+                document.close();
+        }
+    }
+
+    @Parameters
+    public static Collection<Object[]> initializeParameters() throws Exception
+    {
+        // load expected errors
+        File f = new File("src/test/resources/expected_errors.txt");
+        System.out.println(f.exists());
+        InputStream expected = new FileInputStream(f);
+        Properties props = new Properties();
+        props.load(expected);
+        IOUtils.closeQuietly(expected);
+        // prepare config
+        List<Object[]> data = new ArrayList<Object[]>();
+        InputStream is = Class.class.getResourceAsStream("/Isartor testsuite.list");
+        if (is != null)
+        {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+            String line = reader.readLine();
+            while (line != null)
+            {
+                String fn = new File(line).getName();
+                String error = new StringTokenizer(props.getProperty(fn), "//").nextToken().trim();
+                Object[] tmp = new Object[] { "/" + line, error };
+                data.add(tmp);
+                line = reader.readLine();
+            }
+        }
+        else
+        {
+            System.out.println("TestIsartorValidationFromClasspath2.initializeParameters(): No input files found");
+        }
+        return data;
+    }
 }
-

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java Wed Mar  6 16:46:35 2013
@@ -27,63 +27,65 @@ import static org.junit.Assert.assertTru
 
 import org.junit.Test;
 
-public class TestPreflightPath {
+public class TestPreflightPath
+{
 
-	@Test
-	public void test() {
-		PreflightPath path = new PreflightPath();
-
-		assertTrue(path.isEmpty());
-		assertEquals(0,path.size());
-
-		path.pushObject("a");
-		assertEquals(1,path.size());
-		assertFalse(path.isEmpty());
-		
-		int position = path.getClosestTypePosition(String.class);
-		assertEquals(0,position);
-		
-		path.pushObject(new Integer(6));
-		assertEquals(2,path.size());
-		
-		position = path.getClosestTypePosition(String.class);
-		assertEquals(0,position);
-		
-		position = path.getClosestTypePosition(Integer.class);
-		assertEquals(1,position);
-		
-		path.pushObject("b");
-		assertEquals(3,path.size());
-				
-		position = path.getClosestTypePosition(String.class);
-		assertEquals(2,position);
-		position = path.getClosestTypePosition(Integer.class);
-		assertEquals(1,position);
-		
-		Integer i = path.getPathElement(position, Integer.class);
-		assertEquals(new Integer(6), i);
-		
-		Object str = path.peek();
-		assertEquals(3,path.size());
-		assertEquals(String.class, str.getClass());
-		assertEquals("b", (String)str);
-		
-		str = path.pop();
-		assertEquals(2,path.size());
-		assertEquals(String.class, str.getClass());
-		assertEquals("b", (String)str);
-		
-		path.clear();
-		assertTrue(path.isEmpty());
-		assertEquals(0,path.size());
-	}
-
-	@Test
-	public void testPush() {
-		PreflightPath path = new PreflightPath();
-		assertTrue(path.pushObject("a"));
-		assertFalse(path.pushObject(null));
-	}
-	
-}
+    @Test
+    public void test()
+    {
+        PreflightPath path = new PreflightPath();
+
+        assertTrue(path.isEmpty());
+        assertEquals(0, path.size());
+
+        path.pushObject("a");
+        assertEquals(1, path.size());
+        assertFalse(path.isEmpty());
+
+        int position = path.getClosestTypePosition(String.class);
+        assertEquals(0, position);
+
+        path.pushObject(new Integer(6));
+        assertEquals(2, path.size());
+
+        position = path.getClosestTypePosition(String.class);
+        assertEquals(0, position);
+
+        position = path.getClosestTypePosition(Integer.class);
+        assertEquals(1, position);
+
+        path.pushObject("b");
+        assertEquals(3, path.size());
+
+        position = path.getClosestTypePosition(String.class);
+        assertEquals(2, position);
+        position = path.getClosestTypePosition(Integer.class);
+        assertEquals(1, position);
+
+        Integer i = path.getPathElement(position, Integer.class);
+        assertEquals(new Integer(6), i);
+
+        Object str = path.peek();
+        assertEquals(3, path.size());
+        assertEquals(String.class, str.getClass());
+        assertEquals("b", (String) str);
+
+        str = path.pop();
+        assertEquals(2, path.size());
+        assertEquals(String.class, str.getClass());
+        assertEquals("b", (String) str);
+
+        path.clear();
+        assertTrue(path.isEmpty());
+        assertEquals(0, path.size());
+    }
+
+    @Test
+    public void testPush()
+    {
+        PreflightPath path = new PreflightPath();
+        assertTrue(path.pushObject("a"));
+        assertFalse(path.pushObject(null));
+    }
 
+}

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java Wed Mar  6 16:46:35 2013
@@ -38,63 +38,84 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class TestValidDirectory {
-
-	protected File target = null;
-
-	public TestValidDirectory (File file) {
-		this.target = file;
-	}
-
-	@Test
-	public void validate () throws Exception {
-		PreflightDocument document = null;
-		System.out.println(target);
-		ValidationResult result = null;
-		try {
-			PreflightParser parser = new PreflightParser(new FileDataSource(target));
-			parser.parse();
-			document = (PreflightDocument)parser.getPDDocument();
-			document.validate();
-			result = document.getResult();
-		} catch (SyntaxValidationException e) {
-			result = e.getResult();
-		} finally {
-			if (document != null) {
-				document.close();
-			}
-		}
-		Assert.assertTrue("Validation of " + target , result.isValid());
-	}
-
-	@Parameters
-	public static Collection<Object[]> initializeParameters() throws Exception {
-		// check directory
-		File directory = null;
-		String pdfPath = System.getProperty("pdfa.valid", null);
-		if ("${user.pdfa.valid}".equals(pdfPath)) {pdfPath=null;}
-		if (pdfPath!=null) {
-			directory = new File(pdfPath);
-			if (!directory.exists()) throw new Exception ("directory does not exists : "+directory.getAbsolutePath());
-			if (!directory.isDirectory()) throw new Exception ("not a directory : "+directory.getAbsolutePath());
-		} else {
-			System.err.println("System property 'pdfa.valid' not defined, will not run TestValidaDirectory");
-		}
-		// create list
-		if (directory==null) {
-			return new ArrayList<Object[]>(0);
-		} else {
-			File [] files = directory.listFiles();
-			List<Object[]> data = new ArrayList<Object[]>(files.length);
-			for (File file : files) {
-				if (file.isFile()) {
-					data.add(new Object [] {file});
-				}
-			}
-			return data;
-		}
-	}
+public class TestValidDirectory
+{
 
+    protected File target = null;
 
+    public TestValidDirectory(File file)
+    {
+        this.target = file;
+    }
+
+    @Test
+    public void validate() throws Exception
+    {
+        PreflightDocument document = null;
+        System.out.println(target);
+        ValidationResult result = null;
+        try
+        {
+            PreflightParser parser = new PreflightParser(new FileDataSource(target));
+            parser.parse();
+            document = (PreflightDocument) parser.getPDDocument();
+            document.validate();
+            result = document.getResult();
+        }
+        catch (SyntaxValidationException e)
+        {
+            result = e.getResult();
+        }
+        finally
+        {
+            if (document != null)
+            {
+                document.close();
+            }
+        }
+        Assert.assertTrue("Validation of " + target, result.isValid());
+    }
+
+    @Parameters
+    public static Collection<Object[]> initializeParameters() throws Exception
+    {
+        // check directory
+        File directory = null;
+        String pdfPath = System.getProperty("pdfa.valid", null);
+        if ("${user.pdfa.valid}".equals(pdfPath))
+        {
+            pdfPath = null;
+        }
+        if (pdfPath != null)
+        {
+            directory = new File(pdfPath);
+            if (!directory.exists())
+                throw new Exception("directory does not exists : " + directory.getAbsolutePath());
+            if (!directory.isDirectory())
+                throw new Exception("not a directory : " + directory.getAbsolutePath());
+        }
+        else
+        {
+            System.err.println("System property 'pdfa.valid' not defined, will not run TestValidaDirectory");
+        }
+        // create list
+        if (directory == null)
+        {
+            return new ArrayList<Object[]>(0);
+        }
+        else
+        {
+            File[] files = directory.listFiles();
+            List<Object[]> data = new ArrayList<Object[]>(files.length);
+            for (File file : files)
+            {
+                if (file.isFile())
+                {
+                    data.add(new Object[] { file });
+                }
+            }
+            return data;
+        }
+    }
 
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java Wed Mar  6 16:46:35 2013
@@ -39,82 +39,101 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.action.AbstractActionManager;
 import org.apache.pdfbox.preflight.action.ActionManagerFactory;
 
-public abstract class AbstractTestAction {
+public abstract class AbstractTestAction
+{
 
-	/**
-	 * Read a simple PDF/A to create a valid Context
-	 * 
-	 * @return
-	 * @throws Exception
-	 */
-	protected PreflightContext createContext() throws Exception {
-		DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
-		PDDocument doc = PDDocument.load(ds.getInputStream());
-		PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
-		PreflightContext ctx = new PreflightContext(ds);
-		ctx.setDocument(preflightDocument);
-		preflightDocument.setContext(ctx);
-		return ctx;
-	}
-	
-	/**
-	 * Run the Action validation and check the result.
-	 * 
-	 * @param action action to check
-	 * @param valid true if the Action must be valid, false if the action contains mistakes
-	 * @throws Exception
-	 */
-	protected void valid(PDAction action, boolean valid) throws Exception {
-		valid(action, valid, null);
-	}
-
-	protected void valid(COSDictionary action, boolean valid) throws Exception {
-		valid(action, valid, null);
-	}
-	
-	/**
-	 * Run the Action validation and check the result.
-	 * 
-	 * @param action action to check
-	 * @param valid true if the Action must be valid, false if the action contains mistakes
-	 * @param expectedCode the expected error code (can be null)
-	 * @throws Exception
-	 */
-	protected void valid(PDAction action, boolean valid, String expectedCode) throws Exception {
-		valid(action.getCOSDictionary(), valid, expectedCode);
-	}
-	
-	protected void valid(COSDictionary action, boolean valid, String expectedCode) throws Exception {
-		ActionManagerFactory fact = new ActionManagerFactory();
-		PreflightContext ctx = createContext();
-		COSDictionary dict = new COSDictionary();
-		dict.setItem(COSName.A, action);
-		
-		// process the action validation
-		List<AbstractActionManager> actions = fact.getActionManagers(ctx, dict);
-		for (AbstractActionManager abstractActionManager : actions) {
-			abstractActionManager.valid();
-		}
-
-		// check the result
-		if (!valid) {
-			List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
-			assertFalse(errors.isEmpty());
-			if (expectedCode != null || !"".equals(expectedCode)) {
-				boolean found = false;
-				for (ValidationError err : errors) {
-					if (err.getErrorCode().equals(expectedCode)) {
-						found = true;
-						break;
-					}
-				}
-				assertTrue(found);
-			}
-		} else {
-			if (ctx.getDocument().getResult() != null) {
-				List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
-				assertTrue(errors.isEmpty());
-			}
-		}
-	}
+    /**
+     * Read a simple PDF/A to create a valid Context
+     * 
+     * @return
+     * @throws Exception
+     */
+    protected PreflightContext createContext() throws Exception
+    {
+        DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
+        PDDocument doc = PDDocument.load(ds.getInputStream());
+        PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
+        PreflightContext ctx = new PreflightContext(ds);
+        ctx.setDocument(preflightDocument);
+        preflightDocument.setContext(ctx);
+        return ctx;
+    }
+
+    /**
+     * Run the Action validation and check the result.
+     * 
+     * @param action
+     *            action to check
+     * @param valid
+     *            true if the Action must be valid, false if the action contains mistakes
+     * @throws Exception
+     */
+    protected void valid(PDAction action, boolean valid) throws Exception
+    {
+        valid(action, valid, null);
+    }
+
+    protected void valid(COSDictionary action, boolean valid) throws Exception
+    {
+        valid(action, valid, null);
+    }
+
+    /**
+     * Run the Action validation and check the result.
+     * 
+     * @param action
+     *            action to check
+     * @param valid
+     *            true if the Action must be valid, false if the action contains mistakes
+     * @param expectedCode
+     *            the expected error code (can be null)
+     * @throws Exception
+     */
+    protected void valid(PDAction action, boolean valid, String expectedCode) throws Exception
+    {
+        valid(action.getCOSDictionary(), valid, expectedCode);
+    }
+
+    protected void valid(COSDictionary action, boolean valid, String expectedCode) throws Exception
+    {
+        ActionManagerFactory fact = new ActionManagerFactory();
+        PreflightContext ctx = createContext();
+        COSDictionary dict = new COSDictionary();
+        dict.setItem(COSName.A, action);
+
+        // process the action validation
+        List<AbstractActionManager> actions = fact.getActionManagers(ctx, dict);
+        for (AbstractActionManager abstractActionManager : actions)
+        {
+            abstractActionManager.valid();
+        }
+
+        // check the result
+        if (!valid)
+        {
+            List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
+            assertFalse(errors.isEmpty());
+            if (expectedCode != null || !"".equals(expectedCode))
+            {
+                boolean found = false;
+                for (ValidationError err : errors)
+                {
+                    if (err.getErrorCode().equals(expectedCode))
+                    {
+                        found = true;
+                        break;
+                    }
+                }
+                assertTrue(found);
+            }
+        }
+        else
+        {
+            if (ctx.getDocument().getResult() != null)
+            {
+                List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
+                assertTrue(errors.isEmpty());
+            }
+        }
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestForbiddenAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestForbiddenAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestForbiddenAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestForbiddenAction.java Wed Mar  6 16:46:35 2013
@@ -26,48 +26,56 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestForbiddenAction extends AbstractTestAction {
-	
-	protected COSDictionary createAction(String type) {
-		COSDictionary action = new COSDictionary();
-		action.setItem(COSName.TYPE, COSName.getPDFName("Action"));
-		action.setItem(COSName.S, COSName.getPDFName(type));
-		return action;
-	}
-	
-	@Test
-	public void testLaunch() throws Exception {
-		COSDictionary action = createAction("Launch");
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
-
-	@Test
-	public void testSound() throws Exception {
-		COSDictionary action = createAction("Sound");
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
-
-	@Test
-	public void testMovie() throws Exception {
-		COSDictionary action = createAction("Movie");
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
-
-	@Test
-	public void testImportData() throws Exception {
-		COSDictionary action = createAction("ImportData");
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
-
-	@Test
-	public void testResetForm() throws Exception {
-		COSDictionary action = createAction("ResetForm");
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
-
-	@Test
-	public void testJS() throws Exception {
-		COSDictionary action = createAction("JavaScript");
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
+public class TestForbiddenAction extends AbstractTestAction
+{
+
+    protected COSDictionary createAction(String type)
+    {
+        COSDictionary action = new COSDictionary();
+        action.setItem(COSName.TYPE, COSName.getPDFName("Action"));
+        action.setItem(COSName.S, COSName.getPDFName(type));
+        return action;
+    }
+
+    @Test
+    public void testLaunch() throws Exception
+    {
+        COSDictionary action = createAction("Launch");
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
+
+    @Test
+    public void testSound() throws Exception
+    {
+        COSDictionary action = createAction("Sound");
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
+
+    @Test
+    public void testMovie() throws Exception
+    {
+        COSDictionary action = createAction("Movie");
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
+
+    @Test
+    public void testImportData() throws Exception
+    {
+        COSDictionary action = createAction("ImportData");
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
+
+    @Test
+    public void testResetForm() throws Exception
+    {
+        COSDictionary action = createAction("ResetForm");
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
+
+    @Test
+    public void testJS() throws Exception
+    {
+        COSDictionary action = createAction("JavaScript");
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoAction.java Wed Mar  6 16:46:35 2013
@@ -29,35 +29,43 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestGotoAction extends AbstractTestAction {
+public class TestGotoAction extends AbstractTestAction
+{
 
-	@Test
-	public void testGoto_OK() throws Exception {
-		PDActionGoTo gotoAction = new PDActionGoTo();
-		gotoAction.setDestination(new PDDestination() {
-			public COSBase getCOSObject() {
-				return COSName.getPDFName("ADest");
-			}
-		});
-
-		valid(gotoAction, true);
-	}
-
-	@Test
-	public void testGoto_KO_invalidContent() throws Exception {
-		PDActionGoTo gotoAction = new PDActionGoTo();
-		gotoAction.setDestination(new PDDestination() {
-			public COSBase getCOSObject() {
-				return new COSDictionary();
-			}
-		});
-
-		valid(gotoAction, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
-	}
-	
-	@Test
-	public void testGoto_KO_missingD() throws Exception {
-		PDActionGoTo gotoAction = new PDActionGoTo();
-		valid(gotoAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
+    @Test
+    public void testGoto_OK() throws Exception
+    {
+        PDActionGoTo gotoAction = new PDActionGoTo();
+        gotoAction.setDestination(new PDDestination()
+        {
+            public COSBase getCOSObject()
+            {
+                return COSName.getPDFName("ADest");
+            }
+        });
+
+        valid(gotoAction, true);
+    }
+
+    @Test
+    public void testGoto_KO_invalidContent() throws Exception
+    {
+        PDActionGoTo gotoAction = new PDActionGoTo();
+        gotoAction.setDestination(new PDDestination()
+        {
+            public COSBase getCOSObject()
+            {
+                return new COSDictionary();
+            }
+        });
+
+        valid(gotoAction, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
+    }
+
+    @Test
+    public void testGoto_KO_missingD() throws Exception
+    {
+        PDActionGoTo gotoAction = new PDActionGoTo();
+        valid(gotoAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoRemoteAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoRemoteAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoRemoteAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestGotoRemoteAction.java Wed Mar  6 16:46:35 2013
@@ -31,68 +31,91 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestGotoRemoteAction extends AbstractTestAction {
+public class TestGotoRemoteAction extends AbstractTestAction
+{
 
-	@Test
-	public void testGoto_OK() throws Exception {
-		PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
-		gotoAction.setD(COSName.getPDFName("ADest"));
-		gotoAction.setFile(new PDFileSpecification() {
-			public COSBase getCOSObject() {
-				return COSName.getPDFName("ADest");
-			}
-			@Override
-			public void setFile(String file) {
-			}
-			@Override
-			public String getFile() {
-				return "pouey";
-			}
-		});
-		valid(gotoAction, true);
-	}
-
-	@Test
-	public void testGoto_KO_InvalidContent() throws Exception {
-		PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
-		gotoAction.setD(new COSDictionary());
-		gotoAction.setFile(new PDFileSpecification() {
-			public COSBase getCOSObject() {
-				return COSName.getPDFName("ADest");
-			}
-			@Override
-			public void setFile(String file) {
-			}
-			@Override
-			public String getFile() {
-				return "pouey";
-			}
-		});
-		valid(gotoAction, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
-	}
-
-	@Test
-	public void testGoto_KO_MissingD() throws Exception {
-		PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
-		gotoAction.setFile(new PDFileSpecification() {
-			public COSBase getCOSObject() {
-				return COSName.getPDFName("ADest");
-			}
-			@Override
-			public void setFile(String file) {
-			}
-			@Override
-			public String getFile() {
-				return "pouey";
-			}
-		});
-		valid(gotoAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
-
-	@Test
-	public void testGoto_KO_MissingF() throws Exception {
-		PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
-		gotoAction.setD(COSName.getPDFName("ADest"));
-		valid(gotoAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
+    @Test
+    public void testGoto_OK() throws Exception
+    {
+        PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
+        gotoAction.setD(COSName.getPDFName("ADest"));
+        gotoAction.setFile(new PDFileSpecification()
+        {
+            public COSBase getCOSObject()
+            {
+                return COSName.getPDFName("ADest");
+            }
+
+            @Override
+            public void setFile(String file)
+            {
+            }
+
+            @Override
+            public String getFile()
+            {
+                return "pouey";
+            }
+        });
+        valid(gotoAction, true);
+    }
+
+    @Test
+    public void testGoto_KO_InvalidContent() throws Exception
+    {
+        PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
+        gotoAction.setD(new COSDictionary());
+        gotoAction.setFile(new PDFileSpecification()
+        {
+            public COSBase getCOSObject()
+            {
+                return COSName.getPDFName("ADest");
+            }
+
+            @Override
+            public void setFile(String file)
+            {
+            }
+
+            @Override
+            public String getFile()
+            {
+                return "pouey";
+            }
+        });
+        valid(gotoAction, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
+    }
+
+    @Test
+    public void testGoto_KO_MissingD() throws Exception
+    {
+        PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
+        gotoAction.setFile(new PDFileSpecification()
+        {
+            public COSBase getCOSObject()
+            {
+                return COSName.getPDFName("ADest");
+            }
+
+            @Override
+            public void setFile(String file)
+            {
+            }
+
+            @Override
+            public String getFile()
+            {
+                return "pouey";
+            }
+        });
+        valid(gotoAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
+
+    @Test
+    public void testGoto_KO_MissingF() throws Exception
+    {
+        PDActionRemoteGoTo gotoAction = new PDActionRemoteGoTo();
+        gotoAction.setD(COSName.getPDFName("ADest"));
+        valid(gotoAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestHideAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestHideAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestHideAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestHideAction.java Wed Mar  6 16:46:35 2013
@@ -26,41 +26,47 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestHideAction extends AbstractTestAction {
+public class TestHideAction extends AbstractTestAction
+{
 
-	protected COSDictionary createHideAction() {
-		COSDictionary hideAction = new COSDictionary();
-		hideAction.setItem(COSName.TYPE, COSName.getPDFName("Action"));
-		hideAction.setItem(COSName.S, COSName.getPDFName("Hide"));
-		hideAction.setBoolean(COSName.H, false);
-		hideAction.setString(COSName.T, "avalue");
-		return hideAction;
-	}
-	
-	@Test
-	public void testHideAction() throws Exception {
-		COSDictionary action = createHideAction();
-		valid(action, true);
-	}
-	
-	@Test
-	public void testHideAction_InvalideH() throws Exception {
-		COSDictionary action = createHideAction();
-		action.setBoolean(COSName.H, true);
-		valid(action, false, PreflightConstants.ERROR_ACTION_HIDE_H_INVALID);
-	}
-	
-	@Test
-	public void testHideAction_InvalideT() throws Exception {
-		COSDictionary action = createHideAction();
-		action.setBoolean(COSName.T, true);
-		valid(action, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
-	}
-	
-	@Test
-	public void testHideAction_MissingT() throws Exception {
-		COSDictionary action = createHideAction();
-		action.removeItem(COSName.T);
-		valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
+    protected COSDictionary createHideAction()
+    {
+        COSDictionary hideAction = new COSDictionary();
+        hideAction.setItem(COSName.TYPE, COSName.getPDFName("Action"));
+        hideAction.setItem(COSName.S, COSName.getPDFName("Hide"));
+        hideAction.setBoolean(COSName.H, false);
+        hideAction.setString(COSName.T, "avalue");
+        return hideAction;
+    }
+
+    @Test
+    public void testHideAction() throws Exception
+    {
+        COSDictionary action = createHideAction();
+        valid(action, true);
+    }
+
+    @Test
+    public void testHideAction_InvalideH() throws Exception
+    {
+        COSDictionary action = createHideAction();
+        action.setBoolean(COSName.H, true);
+        valid(action, false, PreflightConstants.ERROR_ACTION_HIDE_H_INVALID);
+    }
+
+    @Test
+    public void testHideAction_InvalideT() throws Exception
+    {
+        COSDictionary action = createHideAction();
+        action.setBoolean(COSName.T, true);
+        valid(action, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
+    }
+
+    @Test
+    public void testHideAction_MissingT() throws Exception
+    {
+        COSDictionary action = createHideAction();
+        action.removeItem(COSName.T);
+        valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestNamedAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestNamedAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestNamedAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestNamedAction.java Wed Mar  6 16:46:35 2013
@@ -26,53 +26,62 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestNamedAction extends AbstractTestAction {
-	protected COSDictionary createNamedAction() {
-		COSDictionary namedAction = new COSDictionary();
-		namedAction.setItem(COSName.TYPE, COSName.getPDFName("Action"));
-		namedAction.setItem(COSName.S, COSName.getPDFName("Named"));
-		
-		return namedAction;
-	}
-	
-	@Test
-	public void testFirstPage() throws Exception {
-		COSDictionary namedAction = createNamedAction();
-		namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_FIRST));
-		valid(namedAction, true);
-	}
-
-	@Test
-	public void testLastPage() throws Exception {
-		COSDictionary namedAction = createNamedAction();
-		namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_LAST));
-		valid(namedAction, true);
-	}
-
-	@Test
-	public void testNextPage() throws Exception {
-		COSDictionary namedAction = createNamedAction();
-		namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_NEXT));
-		valid(namedAction, true);
-	}
-
-	@Test
-	public void testPrevPage() throws Exception {
-		COSDictionary namedAction = createNamedAction();
-		namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_PREV));
-		valid(namedAction, true);
-	}
-
-	@Test
-	public void testMissingN() throws Exception {
-		COSDictionary namedAction = createNamedAction();
-		valid(namedAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
-	
-	@Test
-	public void testForbiddenN() throws Exception {
-		COSDictionary namedAction = createNamedAction();
-		namedAction.setItem(COSName.N, COSName.getPDFName("unknown"));
-		valid(namedAction, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED);
-	}
+public class TestNamedAction extends AbstractTestAction
+{
+    protected COSDictionary createNamedAction()
+    {
+        COSDictionary namedAction = new COSDictionary();
+        namedAction.setItem(COSName.TYPE, COSName.getPDFName("Action"));
+        namedAction.setItem(COSName.S, COSName.getPDFName("Named"));
+
+        return namedAction;
+    }
+
+    @Test
+    public void testFirstPage() throws Exception
+    {
+        COSDictionary namedAction = createNamedAction();
+        namedAction
+                .setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_FIRST));
+        valid(namedAction, true);
+    }
+
+    @Test
+    public void testLastPage() throws Exception
+    {
+        COSDictionary namedAction = createNamedAction();
+        namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_LAST));
+        valid(namedAction, true);
+    }
+
+    @Test
+    public void testNextPage() throws Exception
+    {
+        COSDictionary namedAction = createNamedAction();
+        namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_NEXT));
+        valid(namedAction, true);
+    }
+
+    @Test
+    public void testPrevPage() throws Exception
+    {
+        COSDictionary namedAction = createNamedAction();
+        namedAction.setItem(COSName.N, COSName.getPDFName(PreflightConstants.ACTION_DICTIONARY_VALUE_ATYPE_NAMED_PREV));
+        valid(namedAction, true);
+    }
+
+    @Test
+    public void testMissingN() throws Exception
+    {
+        COSDictionary namedAction = createNamedAction();
+        valid(namedAction, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
+
+    @Test
+    public void testForbiddenN() throws Exception
+    {
+        COSDictionary namedAction = createNamedAction();
+        namedAction.setItem(COSName.N, COSName.getPDFName("unknown"));
+        valid(namedAction, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestSubmitAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestSubmitAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestSubmitAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestSubmitAction.java Wed Mar  6 16:46:35 2013
@@ -28,38 +28,48 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestSubmitAction extends AbstractTestAction {
-	
-	protected COSDictionary createSubmitAction() {
-		COSDictionary action = new COSDictionary();
-		action.setItem(COSName.TYPE, COSName.getPDFName("Action"));
-		action.setItem(COSName.S, COSName.getPDFName("SubmitForm"));
-		action.setItem(COSName.F, new PDFileSpecification() {
-			public COSBase getCOSObject() {
-				return COSName.getPDFName("value");
-			}
-			@Override
-			public void setFile(String file) {
-			}
-			@Override
-			public String getFile() {
-				return null;
-			}
-		});
-		return action;
-	}
-	
-	@Test
-	public void test() throws Exception {
-		COSDictionary action = createSubmitAction();
-		valid(action, true);
-	}
-	
-	@Test
-	public void testMissngF() throws Exception {
-		COSDictionary action = createSubmitAction();
-		action.removeItem(COSName.F);
-		valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
+public class TestSubmitAction extends AbstractTestAction
+{
+
+    protected COSDictionary createSubmitAction()
+    {
+        COSDictionary action = new COSDictionary();
+        action.setItem(COSName.TYPE, COSName.getPDFName("Action"));
+        action.setItem(COSName.S, COSName.getPDFName("SubmitForm"));
+        action.setItem(COSName.F, new PDFileSpecification()
+        {
+            public COSBase getCOSObject()
+            {
+                return COSName.getPDFName("value");
+            }
+
+            @Override
+            public void setFile(String file)
+            {
+            }
+
+            @Override
+            public String getFile()
+            {
+                return null;
+            }
+        });
+        return action;
+    }
+
+    @Test
+    public void test() throws Exception
+    {
+        COSDictionary action = createSubmitAction();
+        valid(action, true);
+    }
+
+    @Test
+    public void testMissngF() throws Exception
+    {
+        COSDictionary action = createSubmitAction();
+        action.removeItem(COSName.F);
+        valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
 
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestThreadAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestThreadAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestThreadAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestThreadAction.java Wed Mar  6 16:46:35 2013
@@ -26,33 +26,38 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestThreadAction extends AbstractTestAction {
-	
-	protected COSDictionary createSubmitAction() {
-		COSDictionary action = new COSDictionary();
-		action.setItem(COSName.TYPE, COSName.getPDFName("Action"));
-		action.setItem(COSName.S, COSName.getPDFName("Thread"));
-		action.setInt(COSName.D, 1);
-		return action;
-	}
-	
-	@Test
-	public void test() throws Exception {
-		COSDictionary action = createSubmitAction();
-		valid(action, true);
-	}
-	
-	@Test
-	public void testMissingD() throws Exception {
-		COSDictionary action = createSubmitAction();
-		action.removeItem(COSName.D);
-		valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
-	
-	@Test
-	public void testInvalidD() throws Exception {
-		COSDictionary action = createSubmitAction();
-		action.setBoolean(COSName.D, false);
-		valid(action, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
-	}
+public class TestThreadAction extends AbstractTestAction
+{
+
+    protected COSDictionary createSubmitAction()
+    {
+        COSDictionary action = new COSDictionary();
+        action.setItem(COSName.TYPE, COSName.getPDFName("Action"));
+        action.setItem(COSName.S, COSName.getPDFName("Thread"));
+        action.setInt(COSName.D, 1);
+        return action;
+    }
+
+    @Test
+    public void test() throws Exception
+    {
+        COSDictionary action = createSubmitAction();
+        valid(action, true);
+    }
+
+    @Test
+    public void testMissingD() throws Exception
+    {
+        COSDictionary action = createSubmitAction();
+        action.removeItem(COSName.D);
+        valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
+
+    @Test
+    public void testInvalidD() throws Exception
+    {
+        COSDictionary action = createSubmitAction();
+        action.setBoolean(COSName.D, false);
+        valid(action, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestUriAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestUriAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestUriAction.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/TestUriAction.java Wed Mar  6 16:46:35 2013
@@ -30,44 +30,51 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.preflight.PreflightConstants;
 import org.junit.Test;
 
-public class TestUriAction extends AbstractTestAction {
-	
-	protected PDActionURI createAction() {
-		PDActionURI action = new PDActionURI();
-		action.setURI("http://www.apache.org");
-		return action;
-	}
-	
-	@Test
-	public void test() throws Exception {
-		PDAction action = createAction();
-		valid(action, true);
-	}
-	
-	@Test
-	public void testMissingURI() throws Exception {
-		PDActionURI action = new PDActionURI();
-		valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
-	}
-	
-	@Test
-	public void testInvalidURI() throws Exception {
-		PDActionURI action = new PDActionURI();
-		action.getCOSDictionary().setBoolean(COSName.URI, true);
-		valid(action, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
-	}
-	
-	@Test
-	public void testNextValid() throws Exception {
-		PDActionURI action = createAction();
-		action.setNext(Arrays.asList(createAction()));
-		valid(action, true);
-	}
-
-	@Test
-	public void testNextInvalid() throws Exception {
-		PDActionURI action = createAction();
-		action.setNext(Arrays.asList(new PDActionJavaScript()));
-		valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
-	}
+public class TestUriAction extends AbstractTestAction
+{
+
+    protected PDActionURI createAction()
+    {
+        PDActionURI action = new PDActionURI();
+        action.setURI("http://www.apache.org");
+        return action;
+    }
+
+    @Test
+    public void test() throws Exception
+    {
+        PDAction action = createAction();
+        valid(action, true);
+    }
+
+    @Test
+    public void testMissingURI() throws Exception
+    {
+        PDActionURI action = new PDActionURI();
+        valid(action, false, PreflightConstants.ERROR_ACTION_MISING_KEY);
+    }
+
+    @Test
+    public void testInvalidURI() throws Exception
+    {
+        PDActionURI action = new PDActionURI();
+        action.getCOSDictionary().setBoolean(COSName.URI, true);
+        valid(action, false, PreflightConstants.ERROR_ACTION_INVALID_TYPE);
+    }
+
+    @Test
+    public void testNextValid() throws Exception
+    {
+        PDActionURI action = createAction();
+        action.setNext(Arrays.asList(createAction()));
+        valid(action, true);
+    }
+
+    @Test
+    public void testNextInvalid() throws Exception
+    {
+        PDActionURI action = createAction();
+        action.setNext(Arrays.asList(new PDActionJavaScript()));
+        valid(action, false, PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN);
+    }
 }

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/AbstractInvalidFileTester.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/AbstractInvalidFileTester.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/AbstractInvalidFileTester.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/AbstractInvalidFileTester.java Wed Mar  6 16:46:35 2013
@@ -1,4 +1,5 @@
 package org.apache.pdfbox.preflight.integration;
+
 /*****************************************************************************
  * 
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +21,6 @@ package org.apache.pdfbox.preflight.inte
  * 
  ****************************************************************************/
 
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
@@ -43,7 +43,8 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
 @RunWith(Parameterized.class)
-public abstract class AbstractInvalidFileTester {
+public abstract class AbstractInvalidFileTester
+{
 
     /**
      * where result information are pushed
@@ -67,73 +68,93 @@ public abstract class AbstractInvalidFil
     /**
      * Prepare the test for one file
      * 
-     * @param path pdf/a file to test
-     * @param error expected error for this test
+     * @param path
+     *            pdf/a file to test
+     * @param error
+     *            expected error for this test
      */
-    public AbstractInvalidFileTester(File path, String error) {
+    public AbstractInvalidFileTester(File path, String error)
+    {
         this.path = path;
         this.expectedError = error;
         this.logger = Logger.getLogger(this.getClass());
     }
 
-
     @Test()
-    public final void validate() throws Exception {
-        if (path==null) {
+    public final void validate() throws Exception
+    {
+        if (path == null)
+        {
             logger.warn("This is an empty test");
             return;
         }
         PreflightDocument document = null;
-        try {
+        try
+        {
             FileDataSource bds = new FileDataSource(path);
             PreflightParser parser = new PreflightParser(bds);
             parser.parse();
             document = parser.getPreflightDocument();
             document.validate();
-            
+
             ValidationResult result = document.getResult();
             Assert.assertFalse(path + " : Isartor file should be invalid (" + path + ")", result.isValid());
-            Assert.assertTrue(path + " : Should find at least one error",result.getErrorsList().size() > 0);
+            Assert.assertTrue(path + " : Should find at least one error", result.getErrorsList().size() > 0);
             // could contain more than one error
             boolean found = false;
-            if (this.expectedError!=null) {
-                for (ValidationError error : result.getErrorsList()) {
-                    if (error.getErrorCode().equals(this.expectedError)) {
+            if (this.expectedError != null)
+            {
+                for (ValidationError error : result.getErrorsList())
+                {
+                    if (error.getErrorCode().equals(this.expectedError))
+                    {
                         found = true;
-                        if (outputResult == null) {
+                        if (outputResult == null)
+                        {
                             break;
                         }
                     }
-                    if (outputResult != null) {
-                        String log = path.getName().replace(".pdf", "") + "#" 
-                        +error.getErrorCode()+"#"+error.getDetails()+"\n";
+                    if (outputResult != null)
+                    {
+                        String log = path.getName().replace(".pdf", "") + "#" + error.getErrorCode() + "#"
+                                + error.getDetails() + "\n";
                         outputResult.write(log.getBytes());
                     }
                 }
             }
 
-            if (result.getErrorsList().size() > 0) {
-                if (this.expectedError == null) {
-                    logger.info("File invalid as expected (no expected code) :"+this.path.getAbsolutePath());
-                } else if (!found) {
+            if (result.getErrorsList().size() > 0)
+            {
+                if (this.expectedError == null)
+                {
+                    logger.info("File invalid as expected (no expected code) :" + this.path.getAbsolutePath());
+                }
+                else if (!found)
+                {
                     StringBuilder message = new StringBuilder(100);
-                    message.append(path).append(
-                    " : Invalid error code returned. Expected ");
+                    message.append(path).append(" : Invalid error code returned. Expected ");
                     message.append(this.expectedError).append(", found ");
-                    for (ValidationError error : result.getErrorsList()) {
+                    for (ValidationError error : result.getErrorsList())
+                    {
                         message.append(error.getErrorCode()).append(" ");
                     }
                     Assert.fail(message.toString());
                 }
-            } else {
-                Assert.assertEquals(path + " : Invalid error code returned.",
-                        this.expectedError, 
-                        result.getErrorsList().get(0).getErrorCode());
             }
-        } catch (ValidationException e) {
+            else
+            {
+                Assert.assertEquals(path + " : Invalid error code returned.", this.expectedError, result
+                        .getErrorsList().get(0).getErrorCode());
+            }
+        }
+        catch (ValidationException e)
+        {
             throw new Exception(path + " :" + e.getMessage(), e);
-        } finally {
-            if (document!=null) {
+        }
+        finally
+        {
+            if (document != null)
+            {
                 document.close();
             }
         }
@@ -142,21 +163,25 @@ public abstract class AbstractInvalidFil
     protected abstract String getResultFileKey();
 
     @Before
-    public  void before() throws Exception {
+    public void before() throws Exception
+    {
         String irp = System.getProperty(getResultFileKey());
 
-        if (irp==null) {
+        if (irp == null)
+        {
             // no log file defined, use system.err
             outputResult = System.err;
-        } else {
+        }
+        else
+        {
             outputResult = new FileOutputStream(irp);
         }
     }
 
     @After
-    public void after() throws Exception {
+    public void after() throws Exception
+    {
         IOUtils.closeQuietly(outputResult);
     }
 
 }
-

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java Wed Mar  6 16:46:35 2013
@@ -1,4 +1,5 @@
 package org.apache.pdfbox.preflight.integration;
+
 /*****************************************************************************
  * 
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +21,6 @@ package org.apache.pdfbox.preflight.inte
  * 
  ****************************************************************************/
 
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -38,7 +38,8 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class TestInvalidFiles extends AbstractInvalidFileTester {
+public class TestInvalidFiles extends AbstractInvalidFileTester
+{
 
     private static final String RESULTS_FILE = "results.file";
 
@@ -48,36 +49,43 @@ public class TestInvalidFiles extends Ab
 
     protected static Logger staticLogger = Logger.getLogger("Test");
 
-    public TestInvalidFiles(File path, String error) {
-        super(path,error);
+    public TestInvalidFiles(File path, String error)
+    {
+        super(path, error);
     }
 
-
-    protected static Collection<Object[]> stopIfExpected () throws Exception {
+    protected static Collection<Object[]> stopIfExpected() throws Exception
+    {
         List<Object[]> ret = new ArrayList<Object[]>();
-        ret.add(new Object[]{null,null});
+        ret.add(new Object[] { null, null });
         return ret;
     }
 
     @Parameters
-    public static Collection<Object[]> initializeParameters() throws Exception 
+    public static Collection<Object[]> initializeParameters() throws Exception
     {
         // find isartor files
         String isartor = System.getProperty(ISARTOR_FILES);
-        if (isartor==null) {
-            staticLogger.warn(ISARTOR_FILES+" (where are isartor pdf files) is not defined.");
+        if (isartor == null)
+        {
+            staticLogger.warn(ISARTOR_FILES + " (where are isartor pdf files) is not defined.");
             return stopIfExpected();
         }
         File root = new File(isartor);
         // load expected errors
         Properties props = new Properties();
         String expectedPath = System.getProperty(EXPECTED_ERRORS);
-        if (expectedPath==null) {
-            staticLogger.warn(EXPECTED_ERRORS+" not defined, only check if file is invalid");
-        } else {
+        if (expectedPath == null)
+        {
+            staticLogger.warn(EXPECTED_ERRORS + " not defined, only check if file is invalid");
+        }
+        else
+        {
             File expectedFile = new File(expectedPath);
-            if (!expectedFile.exists() || !expectedFile.isFile()) {
-                staticLogger.warn("'expected.errors' does not reference valid file, so cannot execute tests : "+expectedFile.getAbsolutePath());
+            if (!expectedFile.exists() || !expectedFile.isFile())
+            {
+                staticLogger.warn("'expected.errors' does not reference valid file, so cannot execute tests : "
+                        + expectedFile.getAbsolutePath());
                 return stopIfExpected();
             }
             InputStream expected = new FileInputStream(expectedPath);
@@ -86,16 +94,20 @@ public class TestInvalidFiles extends Ab
         }
         // prepare config
         List<Object[]> data = new ArrayList<Object[]>();
-        Collection<?> files= FileUtils.listFiles(root, new String [] {"pdf"}, true);
+        Collection<?> files = FileUtils.listFiles(root, new String[] { "pdf" }, true);
 
-        for (Object object : files) {
-            File file = (File)object;
+        for (Object object : files)
+        {
+            File file = (File) object;
             String fn = file.getName();
-            if (props.getProperty(fn)!=null) {
+            if (props.getProperty(fn) != null)
+            {
                 String error = new StringTokenizer(props.getProperty(fn), "//").nextToken().trim();
                 Object[] tmp = new Object[] { file, error };
                 data.add(tmp);
-            } else {
+            }
+            else
+            {
                 // no expected error
                 Object[] tmp = new Object[] { file, null };
                 data.add(tmp);
@@ -105,11 +117,10 @@ public class TestInvalidFiles extends Ab
         return data;
     }
 
-
     @Override
-    protected String getResultFileKey() {
+    protected String getResultFileKey()
+    {
         return RESULTS_FILE;
     }
 
 }
-

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java Wed Mar  6 16:46:35 2013
@@ -1,4 +1,5 @@
 package org.apache.pdfbox.preflight.integration;
+
 /*****************************************************************************
  * 
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +21,6 @@ package org.apache.pdfbox.preflight.inte
  * 
  ****************************************************************************/
 
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -38,7 +38,8 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class TestIsartorValidation extends AbstractInvalidFileTester {
+public class TestIsartorValidation extends AbstractInvalidFileTester
+{
 
     private static final String RESULTS_FILE = "results.file";
 
@@ -48,37 +49,41 @@ public class TestIsartorValidation exten
 
     protected static Logger staticLogger = Logger.getLogger("Test");
 
-
-    public TestIsartorValidation(File path, String error) {
-        super(path,error);
+    public TestIsartorValidation(File path, String error)
+    {
+        super(path, error);
     }
 
-
-    protected static Collection<Object[]> stopIfExpected () throws Exception {
+    protected static Collection<Object[]> stopIfExpected() throws Exception
+    {
         List<Object[]> ret = new ArrayList<Object[]>();
-        ret.add(new Object[]{null,null});
+        ret.add(new Object[] { null, null });
         return ret;
     }
 
     @Parameters
-    public static Collection<Object[]> initializeParameters() throws Exception 
+    public static Collection<Object[]> initializeParameters() throws Exception
     {
         // find isartor files
         String isartor = System.getProperty(ISARTOR_FILES);
-        if (isartor==null) {
-            staticLogger.warn(ISARTOR_FILES+" (where are isartor pdf files) is not defined.");
+        if (isartor == null)
+        {
+            staticLogger.warn(ISARTOR_FILES + " (where are isartor pdf files) is not defined.");
             return stopIfExpected();
         }
         File root = new File(isartor);
         // load expected errors
         String expectedPath = System.getProperty(EXPECTED_ERRORS);
-        if (expectedPath==null) {
+        if (expectedPath == null)
+        {
             staticLogger.warn("'expected.errors' not defined, so cannot execute tests");
             return stopIfExpected();
         }
         File expectedFile = new File(expectedPath);
-        if (!expectedFile.exists() || !expectedFile.isFile()) {
-            staticLogger.warn("'expected.errors' does not reference valid file, so cannot execute tests : "+expectedFile.getAbsolutePath());
+        if (!expectedFile.exists() || !expectedFile.isFile())
+        {
+            staticLogger.warn("'expected.errors' does not reference valid file, so cannot execute tests : "
+                    + expectedFile.getAbsolutePath());
             return stopIfExpected();
         }
         InputStream expected = new FileInputStream(expectedPath);
@@ -87,17 +92,22 @@ public class TestIsartorValidation exten
         IOUtils.closeQuietly(expected);
         // prepare config
         List<Object[]> data = new ArrayList<Object[]>();
-        Collection<?> files= FileUtils.listFiles(root, new String [] {"pdf"}, true);
+        Collection<?> files = FileUtils.listFiles(root, new String[] { "pdf" }, true);
 
-        for (Object object : files) {
-            File file = (File)object;
+        for (Object object : files)
+        {
+            File file = (File) object;
             String fn = file.getName();
-            if (props.getProperty(fn)!=null) {
+            if (props.getProperty(fn) != null)
+            {
                 String error = new StringTokenizer(props.getProperty(fn), "//").nextToken().trim();
                 Object[] tmp = new Object[] { file, error };
                 data.add(tmp);
-            } else {
-                System.err.println("No expected result for this file, will not try to validate : "+file.getAbsolutePath());
+            }
+            else
+            {
+                System.err.println("No expected result for this file, will not try to validate : "
+                        + file.getAbsolutePath());
             }
 
         }
@@ -105,9 +115,9 @@ public class TestIsartorValidation exten
     }
 
     @Override
-    protected String getResultFileKey() {
+    protected String getResultFileKey()
+    {
         return RESULTS_FILE;
     }
 
 }
-

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java Wed Mar  6 16:46:35 2013
@@ -1,4 +1,5 @@
 package org.apache.pdfbox.preflight.integration;
+
 /*****************************************************************************
  * 
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +21,6 @@ package org.apache.pdfbox.preflight.inte
  * 
  ****************************************************************************/
 
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
@@ -47,7 +47,8 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class TestValidFiles {
+public class TestValidFiles
+{
 
     private static final String RESULTS_FILE = "results.file";
 
@@ -61,37 +62,39 @@ public class TestValidFiles {
 
     protected Logger logger = null;
 
-
-    public TestValidFiles(File path) {
+    public TestValidFiles(File path)
+    {
         this.path = path;
-        this.logger = Logger.getLogger(path!=null?path.getName():"dummy");
+        this.logger = Logger.getLogger(path != null ? path.getName() : "dummy");
     }
 
-
-    protected static Collection<Object[]> stopIfExpected () throws Exception {
-        //		throw new Exception("Test badly configured");
+    protected static Collection<Object[]> stopIfExpected() throws Exception
+    {
+        // throw new Exception("Test badly configured");
         List<Object[]> ret = new ArrayList<Object[]>();
-        ret.add(new Object[]{null});
+        ret.add(new Object[] { null });
         return ret;
     }
 
     @Parameters
-    public static Collection<Object[]> initializeParameters() throws Exception 
+    public static Collection<Object[]> initializeParameters() throws Exception
     {
         // find isartor files
         String isartor = System.getProperty(ISARTOR_FILES);
-        if (isartor==null) {
-            staticLogger.warn(ISARTOR_FILES+" (where are isartor pdf files) is not defined.");
+        if (isartor == null)
+        {
+            staticLogger.warn(ISARTOR_FILES + " (where are isartor pdf files) is not defined.");
             return stopIfExpected();
         }
         File root = new File(isartor);
         // load expected errors
         // prepare config
         List<Object[]> data = new ArrayList<Object[]>();
-        Collection<?> files= FileUtils.listFiles(root, new String [] {"pdf"}, true);
+        Collection<?> files = FileUtils.listFiles(root, new String[] { "pdf" }, true);
 
-        for (Object object : files) {
-            File file = (File)object;
+        for (Object object : files)
+        {
+            File file = (File) object;
             Object[] tmp = new Object[] { file };
             data.add(tmp);
         }
@@ -99,51 +102,64 @@ public class TestValidFiles {
     }
 
     @BeforeClass
-    public static void beforeClass() throws Exception {
+    public static void beforeClass() throws Exception
+    {
         String irp = System.getProperty(RESULTS_FILE);
-        if (irp==null) {
+        if (irp == null)
+        {
             // no log file defined, use system.err
             System.err.println("No result file defined, will use standart error");
             isartorResultFile = System.err;
-        } else {
+        }
+        else
+        {
             isartorResultFile = new FileOutputStream(irp);
         }
     }
 
     @AfterClass
-    public static void afterClass() throws Exception {
+    public static void afterClass() throws Exception
+    {
         IOUtils.closeQuietly(isartorResultFile);
     }
 
     @Test()
-    public void validate() throws Exception {
-        if (path==null) {
+    public void validate() throws Exception
+    {
+        if (path == null)
+        {
             logger.warn("This is an empty test");
             return;
         }
         PreflightDocument document = null;
-        try {
+        try
+        {
             FileDataSource bds = new FileDataSource(path);
             PreflightParser parser = new PreflightParser(bds);
             parser.parse();
             document = parser.getPreflightDocument();
             document.validate();
-        
+
             ValidationResult result = document.getResult();
             Assert.assertFalse(path + " : Isartor file should be invalid (" + path + ")", result.isValid());
             Assert.assertTrue(path + " : Should find at least one error", result.getErrorsList().size() > 0);
             // could contain more than one error
-            if (result.getErrorsList().size() > 0) {
-                Assert.fail("File expected valid : "+path.getAbsolutePath());
+            if (result.getErrorsList().size() > 0)
+            {
+                Assert.fail("File expected valid : " + path.getAbsolutePath());
             }
-        } catch (ValidationException e) {
+        }
+        catch (ValidationException e)
+        {
             throw new Exception(path + " :" + e.getMessage(), e);
-        } finally {
-            if (document!=null) {
+        }
+        finally
+        {
+            if (document != null)
+            {
                 document.close();
             }
         }
     }
 
 }
-