Author: leleueri
Date: Sun Jun 23 09:11:55 2013
New Revision: 1495803
URL: http://svn.apache.org/r1495803
Log:
[PDFBOX-1643] allow to remove a ValiationProcess in the PreflightConfiguration
+ addition of TestCase
Added:
pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightConfiguration.java
(with props)
Modified:
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightConfiguration.java
Modified:
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightConfiguration.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightConfiguration.java?rev=1495803&r1=1495802&r2=1495803&view=diff
==============================================================================
---
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightConfiguration.java
(original)
+++
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightConfiguration.java
Sun Jun 23 09:11:55 2013
@@ -193,7 +193,14 @@ public class PreflightConfiguration
public void replaceProcess(String processName, Class<? extends
ValidationProcess> process)
{
- this.processes.put(processName, process);
+ if (process == null)
+ {
+ removeProcess(processName);
+ }
+ else
+ {
+ this.processes.put(processName, process);
+ }
}
public void removeProcess(String processName)
@@ -208,7 +215,12 @@ public class PreflightConfiguration
public void replacePageProcess(String processName, Class<? extends
ValidationProcess> process)
{
- this.innerProcesses.put(processName, process);
+ if (process == null) {
+ removePageProcess(processName);
+ }
+ else {
+ this.innerProcesses.put(processName, process);
+ }
}
public void removePageProcess(String processName)
Added:
pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightConfiguration.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightConfiguration.java?rev=1495803&view=auto
==============================================================================
---
pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightConfiguration.java
(added)
+++
pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightConfiguration.java
Sun Jun 23 09:11:55 2013
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ *
+ * 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.preflight;
+
+import org.apache.pdfbox.preflight.exception.ValidationException;
+import org.apache.pdfbox.preflight.process.BookmarkValidationProcess;
+import org.apache.pdfbox.preflight.process.EmptyValidationProcess;
+import org.apache.pdfbox.preflight.process.ValidationProcess;
+import org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestPreflightConfiguration
+{
+
+ @Test
+ public void testGetValidationProcess() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ ValidationProcess vp =
confg.getInstanceOfProcess(PreflightConfiguration.BOOKMARK_PROCESS);
+ Assert.assertNotNull(vp);
+ Assert.assertTrue(vp instanceof BookmarkValidationProcess);
+ }
+
+ @Test
+ public void testGetValidationPageProcess() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ ValidationProcess vp =
confg.getInstanceOfProcess(PreflightConfiguration.RESOURCES_PROCESS);
+ Assert.assertNotNull(vp);
+ Assert.assertTrue(vp instanceof ResourcesValidationProcess);
+ }
+
+ @Test
+ public void testGetValidationProcess_noError() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ confg.setErrorOnMissingProcess(false);
+ confg.removeProcess(PreflightConfiguration.BOOKMARK_PROCESS);
+ ValidationProcess vp =
confg.getInstanceOfProcess(PreflightConfiguration.BOOKMARK_PROCESS);
+ Assert.assertNotNull(vp);
+ Assert.assertTrue(vp instanceof EmptyValidationProcess);
+ }
+
+ @Test
+ public void testGetValidationPageProcess_noError() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ confg.setErrorOnMissingProcess(false);
+ confg.removePageProcess(PreflightConfiguration.RESOURCES_PROCESS);
+ ValidationProcess vp =
confg.getInstanceOfProcess(PreflightConfiguration.RESOURCES_PROCESS);
+ Assert.assertNotNull(vp);
+ Assert.assertTrue(vp instanceof EmptyValidationProcess);
+ }
+
+ @Test(expected=ValidationException.class)
+ public void testGetMissingValidationProcess() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ confg.removeProcess(PreflightConfiguration.BOOKMARK_PROCESS);
+ confg.getInstanceOfProcess(PreflightConfiguration.BOOKMARK_PROCESS);
+ Assert.fail();
+ }
+
+ @Test(expected=ValidationException.class)
+ public void testGetMissingValidationPageProcess() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ confg.removePageProcess(PreflightConfiguration.RESOURCES_PROCESS);
+ confg.getInstanceOfProcess(PreflightConfiguration.RESOURCES_PROCESS);
+ Assert.fail();
+ }
+
+ @Test(expected=ValidationException.class)
+ public void testGetMissingValidationProcess2() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ confg.replaceProcess(PreflightConfiguration.BOOKMARK_PROCESS, null);
+ confg.getInstanceOfProcess(PreflightConfiguration.BOOKMARK_PROCESS);
+ Assert.fail();
+ }
+
+ @Test(expected=ValidationException.class)
+ public void testGetMissingValidationPageProcess2() throws Exception {
+ PreflightConfiguration confg =
PreflightConfiguration.createPdfA1BConfiguration();
+ confg.replacePageProcess(PreflightConfiguration.RESOURCES_PROCESS,
null);
+ confg.getInstanceOfProcess(PreflightConfiguration.RESOURCES_PROCESS);
+ Assert.fail();
+ }
+}
Propchange:
pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native