aboutsummaryrefslogtreecommitdiffstats
path: root/test/java/org/apache/fop/fo
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2007-10-31 15:06:35 +0000
committerVincent Hennebert <vhennebert@apache.org>2007-10-31 15:06:35 +0000
commitfc34b198fd486c5db87e4982b118ba558dcbbedd (patch)
tree3e11525e613b51e7732691a31a8535a3cff0081a /test/java/org/apache/fop/fo
parente340490662dcbb38c1ef6771435b8ff4e3721cc1 (diff)
downloadxmlgraphics-fop-fc34b198fd486c5db87e4982b118ba558dcbbedd.tar.gz
xmlgraphics-fop-fc34b198fd486c5db87e4982b118ba558dcbbedd.zip
- Enforced check for proper number of columns in a table. Now if a table has explicit table-columns, those fix the total number of columns and any row having more columns will lead to an error.
- Set up a framework for unit-testing classes from the FO tree, and added some first testcases for the number of columns in tables. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@590705 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org/apache/fop/fo')
-rw-r--r--test/java/org/apache/fop/fo/flow/TableHandler.java45
-rw-r--r--test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java60
2 files changed, 105 insertions, 0 deletions
diff --git a/test/java/org/apache/fop/fo/flow/TableHandler.java b/test/java/org/apache/fop/fo/flow/TableHandler.java
new file mode 100644
index 000000000..c29c33d73
--- /dev/null
+++ b/test/java/org/apache/fop/fo/flow/TableHandler.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.fo.flow.Table;
+
+public class TableHandler extends FOEventHandler {
+
+ /** All the tables encountered in the FO file. List of Table objects. */
+ private List tables = new LinkedList();
+
+ TableHandler(FOUserAgent foUserAgent) {
+ super(foUserAgent);
+ }
+
+ public void endTable(Table tbl) {
+ tables.add(tbl);
+ }
+
+ List getTables() {
+ return tables;
+ }
+}
diff --git a/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java b/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java
new file mode 100644
index 000000000..8c08ddf10
--- /dev/null
+++ b/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fotreetest.FOTreeUnitTester;
+
+public class TooManyColumnsTestCase extends FOTreeUnitTester {
+
+ private FOTreeUnitTester.FOEventHandlerFactory tableHandlerFactory;
+
+ public TooManyColumnsTestCase() throws Exception {
+ super();
+ tableHandlerFactory = new FOTreeUnitTester.FOEventHandlerFactory() {
+ public FOEventHandler createFOEventHandler(FOUserAgent ua) {
+ return new TableHandler(ua);
+ }
+ };
+ }
+
+ private void launchTest(String filename) throws Exception {
+ try {
+ setUp(filename, tableHandlerFactory);
+ fail();
+ } catch (ValidationException e) {
+ // TODO check location
+ }
+ }
+
+ public void testBody1() throws Exception {
+ launchTest("table/too-many-columns_body_1.fo");
+ }
+
+ public void testBody2() throws Exception {
+ launchTest("table/too-many-columns_body_2.fo");
+ }
+
+ public void testBody3() throws Exception {
+ launchTest("table/too-many-columns_body_3.fo");
+ }
+}