Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java?rev=1242848&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java Fri Feb 10 16:51:08 2012 @@ -0,0 +1,88 @@ +/* + * 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; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; + +import org.apache.xmlgraphics.image.loader.ImageException; +import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.image.loader.ImageSessionContext; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; + +/** + * A helper class for creating mocks of {@link FONode} and its descendants. + */ +public final class FONodeMocks { + + private FONodeMocks() { } + + /** + * Creates and returns a mock {@link FONode} configured with a mock + * {@link FOEventHandler}. The FO event handler returns a mock {@link FOUserAgent}, + * which in turn returns a mock {@link FopFactory}, which returns a mock + * {@link ImageManager}. + * + * @return a mock FO node + */ + public static FONode mockFONode() { + FONode mockFONode = mock(FONode.class); + mockGetFOEventHandler(mockFONode); + return mockFONode; + } + + private static void mockGetFOEventHandler(FONode mockFONode) { + FOEventHandler mockFOEventHandler = mock(FOEventHandler.class); + mockGetUserAgent(mockFOEventHandler); + when(mockFONode.getFOEventHandler()).thenReturn(mockFOEventHandler); + } + + private static void mockGetUserAgent(FOEventHandler mockFOEventHandler) { + FOUserAgent mockFOUserAgent = mock(FOUserAgent.class); + mockGetFactory(mockFOUserAgent); + when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent); + } + + private static void mockGetFactory(FOUserAgent mockFOUserAgent) { + FopFactory mockFopFactory = mock(FopFactory.class); + mockGetImageManager(mockFopFactory); + when(mockFOUserAgent.getFactory()).thenReturn(mockFopFactory); + } + + private static void mockGetImageManager(FopFactory mockFopFactory) { + try { + ImageManager mockImageManager = mock(ImageManager.class); + when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class))) + .thenReturn(null); + when(mockFopFactory.getImageManager()).thenReturn(mockImageManager); + } catch (ImageException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +}
Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/LoadingException.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/LoadingException.java?rev=1242848&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/LoadingException.java (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/LoadingException.java Fri Feb 10 16:51:08 2012 @@ -0,0 +1,34 @@ +/* + * 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; + +/** + * This class specifies an exceptional condition that occurred while an XSL-FO document + * was being parsed. + */ +public class LoadingException extends Exception { + + private static final long serialVersionUID = 7529029475875542916L; + + LoadingException(Throwable cause) { + super(cause); + } + +} Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/complete_document.fo URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/complete_document.fo?rev=1242848&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/complete_document.fo (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/complete_document.fo Fri Feb 10 16:51:08 2012 @@ -0,0 +1,176 @@ +<?xml version="1.0" standalone="no"?> +<!-- + 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$ --> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + + <fo:layout-master-set> + <fo:simple-page-master master-name="page" + page-height="400pt" page-width="300pt" margin="20pt" margin-top="10pt"> + <fo:region-body margin-top="20pt"/> + <fo:region-before extent="15pt"/> + </fo:simple-page-master> + </fo:layout-master-set> + + <fo:page-sequence master-reference="page"> + <fo:static-content flow-name="xsl-region-before"> + <fo:block id="1" font-size="7pt" text-align-last="justify" padding-bottom="2pt" + border-bottom="0.25pt solid black">This is the page header<fo:leader/>Page <fo:page-number + id="2"/></fo:block> + </fo:static-content> + <fo:static-content flow-name="xsl-footnote-separator"> + <fo:block id="3"><fo:leader leader-length="100pt" leader-pattern="rule"/></fo:block> + </fo:static-content> + <fo:flow flow-name="xsl-region-body"> + <fo:block id="4">This is a link to the <fo:wrapper id="5" color="blue"><fo:basic-link id="6" + internal-destination="second-start">next page-sequence</fo:basic-link></fo:wrapper> + (which starts on page <fo:page-number-citation id="7" ref-id="second-start"/> and ends on + page <fo:page-number-citation-last id="8" ref-id="second-end"/>).</fo:block> + <fo:block id="9" font-family="sans-serif" font-weight="bold" space-before="1em" + space-after="0.2em" role="H1"><fo:block id="10">A Title Block</fo:block></fo:block> + <fo:block id="11">This block of text contains a footnote<fo:footnote id="12"><fo:inline id="13" + baseline-shift="super" font-size="70%">1</fo:inline><fo:footnote-body id="14"><fo:block + id="15">A footnote with a link to the <fo:wrapper id="16" color="blue"><fo:basic-link + id="17" external-destination="http://xmlgraphics.apache.org/fop/">FOP + website</fo:basic-link></fo:wrapper></fo:block></fo:footnote-body></fo:footnote> + call.</fo:block> + <fo:table id="18" space-before="1em" width="100%" table-layout="fixed"> + <fo:table-column id="19" column-width="proportional-column-width(1)"/> + <fo:table-column id="20" column-width="proportional-column-width(2)"/> + <fo:table-header id="21"> + <fo:table-row id="22"> + <fo:table-cell id="23" border="2pt solid black" padding="2pt 2pt 0"> + <fo:block id="24">Header 1.1</fo:block> + </fo:table-cell> + <fo:table-cell id="25" border="2pt solid black" padding="2pt 2pt 0"> + <fo:block id="26">Header 1.2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-footer id="27"> + <fo:table-row id="28"> + <fo:table-cell id="29" border="2pt solid black" padding="2pt 2pt 0"> + <fo:block id="30">Footer 1.1</fo:block> + </fo:table-cell> + <fo:table-cell id="31" border="2pt solid black" padding="2pt 2pt 0"> + <fo:block id="32">Footer 1.2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-footer> + <fo:table-body id="33"> + <fo:table-row id="34"> + <fo:table-cell id="35" border="1pt solid black" padding="2pt 2pt 0"> + <fo:block id="36">Cell 1.1</fo:block> + </fo:table-cell> + <fo:table-cell id="37" border="1pt solid black" padding="2pt 2pt 0"> + <fo:block id="38">Cell 1.2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row id="39"> + <fo:table-cell id="40" border="1pt solid black" padding="2pt 2pt 0"> + <fo:block id="41">Cell 2.1</fo:block> + </fo:table-cell> + <fo:table-cell id="42" border="1pt solid black" padding="2pt 2pt 0"> + <fo:block id="43">Cell 2.2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + <fo:block-container id="44" space-before="1.2em"> + <fo:block-container id="45" absolute-position="absolute" top="6pt" right="2.5pt" + inline-progression-dimension="37%" padding="3pt 1pt 2pt 3pt" border="1.5pt solid + darkblue"> + <fo:block id="46" color="darkblue" font-size="80%">This is an absolutely positioned + block-container. Nullam interdum mattis ipsum sit amet molestie.</fo:block> + </fo:block-container> + <fo:block id="47" end-indent="37% + 15pt">Lorem ipsum dolor sit amet, consectetur adipiscing + elit. Integer vel lacinia diam. Etiam venenatis magna vel libero imperdiet + rhoncus.</fo:block> + </fo:block-container> + </fo:flow> + </fo:page-sequence> + + <fo:page-sequence master-reference="page"> + <fo:static-content id="48" flow-name="xsl-region-before"> + <fo:block id="49" font-size="7pt" text-align-last="justify" padding-bottom="2pt" + border-bottom="0.25pt solid black">This is the page header<fo:leader id="50"/>Page + <fo:page-number id="51"/></fo:block> + </fo:static-content> + <fo:flow flow-name="xsl-region-body" text-align="justify" space-before.minimum="8pt" + space-before.optimum="10pt" space-before.maximum="12pt"> + <fo:block id="second-start">Starting a new page-sequence.</fo:block> + <fo:block id="52" text-align="center">The <fo:external-graphic id="53" + src="test/resources/images/fop-logo-color-24bit.png" + inline-progression-dimension.maximum="50%" content-width="scale-to-fit" + alignment-adjust="-46%" alignment-baseline="middle" fox:alt-text="FOP Logo"/> + logo.</fo:block> + <fo:list-block id="54" provisional-distance-between-starts="15pt" + provisional-label-separation="0" space-before="inherit"> + <fo:list-item id="55"> + <fo:list-item-label id="56" end-indent="label-end()"> + <fo:block id="57">1.</fo:block> + </fo:list-item-label> + <fo:list-item-body id="58" start-indent="body-start()"> + <fo:block id="59">First item of a list</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item id="60"> + <fo:list-item-label id="61" end-indent="label-end()"> + <fo:block id="62">2.</fo:block> + </fo:list-item-label> + <fo:list-item-body id="63" start-indent="body-start()"> + <fo:block id="64">Second item of a list</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item id="65"> + <fo:list-item-label id="66" end-indent="label-end()"> + <fo:block id="67">3.</fo:block> + </fo:list-item-label> + <fo:list-item-body id="68" start-indent="body-start()"> + <fo:block id="69">Third item of a list</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block id="70" text-align="center"><fo:instream-foreign-object id="71" + inline-progression-dimension.maximum="50%" content-width="scale-to-fit" + fox:alt-text="An inline SVG"> + <svg xmlns="http://www.w3.org/2000/svg" width="319" height="286.6"> + <g style="fill-opacity:0.7; stroke:black; stroke-width:3" + transform="translate(0, 286.6) scale(1, -1) translate(100, 100)"> + <circle cx="50" cy="86.6" r="80" style="fill:red;"/> + <circle cx="0" cy="0" r="80" style="fill:green;"/> + <circle cx="100" cy="0" r="80" style="fill:blue;"/> + </g> + </svg> + </fo:instream-foreign-object></fo:block> + <fo:block id="72" space-before="inherit">A block containing an <fo:inline id="73" + border="0.5pt solid black" padding="2pt" padding-bottom="0">inline</fo:inline> + element.</fo:block> + <fo:block id="74" space-before="inherit">A block containing a fancy <fo:character id="75" + border="1pt solid black" padding="0 2pt 1pt 2pt" font-family="Symbol" character="â¦"/> + character.</fo:block> + <fo:block id="76" space-before="inherit" text-align-last="justify">A leader with special + content: <fo:leader id="77" leader-pattern="use-content"><fo:inline id="78"><fo:character + id="79" character=" "/><fo:inline id="80" border="0.5pt solid black" + padding-left="2pt" padding-right="2pt"><fo:character id="81" baseline-shift="-10%" + character="â¢"/></fo:inline></fo:inline></fo:leader>.</fo:block> + <fo:block id="second-end" space-before="inherit">Ending the page-sequence.</fo:block> + </fo:flow> + </fo:page-sequence> + +</fo:root> Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/extract-events.xsl URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/extract-events.xsl?rev=1242848&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/extract-events.xsl (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/extract-events.xsl Fri Feb 10 16:51:08 2012 @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + exclude-result-prefixes="fo"> + + <xsl:output indent="yes" omit-xml-declaration="yes"/> + + <xsl:template match="/"> + <event> + <xsl:text>start document</xsl:text> + </event> + <xsl:apply-templates/> + <event> + <xsl:text>end document</xsl:text> + </event> + </xsl:template> + + <xsl:template match="fo:root"> + <event>start root</event> + <xsl:apply-templates select="fo:page-sequence"/> + <event>end root</event> + </xsl:template> + + <xsl:template match="fo:*"> + <xsl:call-template name="process.node"> + <xsl:with-param name="id"> + <xsl:apply-templates select="@id"/> + </xsl:with-param> + </xsl:call-template> + </xsl:template> + + <!-- Those elements do not retrieve the id property. + This will have to be fixed at some point. --> + <xsl:template match="fo:footnote|fo:footnote-body"> + <xsl:call-template name="process.node"/> + </xsl:template> + + <xsl:template name="process.node"> + <xsl:param name="id" select="''"/> + <event> + <xsl:text>start </xsl:text> + <xsl:value-of select="local-name()"/> + <xsl:value-of select="$id"/> + </event> + <xsl:apply-templates/> + <event> + <xsl:text>end </xsl:text> + <xsl:value-of select="local-name()"/> + <xsl:value-of select="$id"/> + </event> + </xsl:template> + + <xsl:template match="@id"> + <xsl:text> id="</xsl:text> + <xsl:value-of select="."/> + <xsl:text>"</xsl:text> + </xsl:template> + + <xsl:template match="text()"/> + +</xsl:stylesheet> Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java Fri Feb 10 16:51:08 2012 @@ -19,33 +19,37 @@ package org.apache.fop.fo.flow.table; +import java.io.FileInputStream; import java.util.Iterator; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.fo.FODocumentParser; import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fotreetest.FOTreeUnitTester; +import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; +import org.apache.fop.util.ConsoleEventListenerForTests; /** * Superclass for testcases related to tables, factoring the common stuff. */ -abstract class AbstractTableTest extends FOTreeUnitTester { +abstract class AbstractTableTest { - private FOTreeUnitTester.FOEventHandlerFactory tableHandlerFactory; + private FODocumentParser documentParser; private TableHandler tableHandler; - public AbstractTableTest() throws Exception { - super(); - tableHandlerFactory = new FOEventHandlerFactory() { - public FOEventHandler createFOEventHandler(FOUserAgent foUserAgent) { + protected void setUp(String filename) throws Exception { + createDocumentParser(); + documentParser.setEventListener(new ConsoleEventListenerForTests(filename)); + documentParser.parse(new FileInputStream("test/fotree/unittests/" + filename)); + } + + private void createDocumentParser() { + documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() { + public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { tableHandler = new TableHandler(foUserAgent); return tableHandler; } - }; - } - - protected void setUp(String filename) throws Exception { - setUp(filename, tableHandlerFactory); + }); } protected TableHandler getTableHandler() { Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java Fri Feb 10 16:51:08 2012 @@ -25,10 +25,11 @@ import java.awt.Color; import java.util.Iterator; import java.util.List; +import org.junit.Test; + import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode.FONodeIterator; import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; -import org.junit.Test; /** * A testcase for the resolution of collapsed borders in the FO tree, taking @@ -107,10 +108,6 @@ public class CollapsedConditionalBorderT {{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.black}, {border8pt, Color.black}, {border8pt, Color.black}, {border8pt, Color.black}, {border4pt, Color.blue}, {border4pt, Color.red}, {border6pt, Color.magenta}, {border6pt, Color.magenta}, {border6pt, Color.magenta}} }; - public CollapsedConditionalBorderTestCase() throws Exception { - super(); - } - private static GridUnit getGridUnit(TablePart part) { return (GridUnit) ((List) ((List) part.getRowGroups().get(0)).get(0)).get(0); } Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java Fri Feb 10 16:51:08 2012 @@ -19,8 +19,10 @@ package org.apache.fop.fo.flow.table; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.fop.fo.LoadingException; import org.apache.fop.fo.ValidationException; /** @@ -28,16 +30,13 @@ import org.apache.fop.fo.ValidationExcep */ abstract class ErrorCheckTest extends AbstractTableTest { - public ErrorCheckTest() throws Exception { - super(); - } - protected void launchTest(String filename) throws Exception { try { setUp(filename); - fail(); - } catch (ValidationException e) { + fail("Expected ValidationException to be thrown"); + } catch (LoadingException e) { // TODO check location + assertTrue(e.getCause() instanceof ValidationException); } } Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java Fri Feb 10 16:51:08 2012 @@ -27,10 +27,6 @@ import org.junit.Test; */ public class IllegalRowSpanTestCase extends ErrorCheckTest { - public IllegalRowSpanTestCase() throws Exception { - super(); - } - @Test public void testBody1() throws Exception { launchTest("table/illegal-row-span_body_1.fo"); Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java Fri Feb 10 16:51:08 2012 @@ -35,10 +35,6 @@ import org.junit.Test; */ public class RowGroupBuilderTestCase extends AbstractTableTest { - public RowGroupBuilderTestCase() throws Exception { - super(); - } - /** * Checks that the given table-body(header,footer) will return row groups as expected. * More precisely, checks that the number of row groups corresponds to the size of the Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java Fri Feb 10 16:51:08 2012 @@ -23,9 +23,10 @@ import static org.junit.Assert.assertEqu import java.util.Iterator; +import org.junit.Test; + import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FObj; -import org.junit.Test; public class TableColumnColumnNumberTestCase extends AbstractTableTest { @@ -50,10 +51,6 @@ public class TableColumnColumnNumberTest private TablePercentBaseContext percentBaseContext = new TablePercentBaseContext(); - public TableColumnColumnNumberTestCase() throws Exception { - super(); - } - private void checkColumn(Table t, int number, boolean isImplicit, int spans, int repeated, int width) { TableColumn c = t.getColumn(number - 1); // TODO a repeated column has a correct number only for its first occurrence Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java Fri Feb 10 16:51:08 2012 @@ -23,10 +23,6 @@ import org.junit.Test; public class TooManyColumnsTestCase extends ErrorCheckTest { - public TooManyColumnsTestCase() throws Exception { - super(); - } - @Test public void testBody1() throws Exception { launchTest("table/too-many-columns_body_1.fo"); Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java?rev=1242848&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java Fri Feb 10 16:51:08 2012 @@ -0,0 +1,38 @@ +/* + * 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.table; + +/** + * This class aims at easing testing, by preventing the event notification system from + * getting in the way just to issue an Unimplemented Feature warning. + */ +public final class UnimplementedWarningNeutralizer { + + private UnimplementedWarningNeutralizer() { } + + /** + * Neutralizes Unimplemented Feature events from the {@link TableAndCaption} and + * {@link TableCaption} classes. + */ + public static void neutralizeUnimplementedWarning() { + TableAndCaption.notImplementedWarningGiven = true; + TableCaption.notImplementedWarningGiven = true; + } +} Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java?rev=1242848&r1=1242827&r2=1242848&view=diff ============================================================================== (empty) Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java?rev=1242848&r1=1242827&r2=1242848&view=diff ============================================================================== (empty) Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/PropertyListMocks.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/PropertyListMocks.java?rev=1242848&r1=1242827&r2=1242848&view=diff ============================================================================== (empty) Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/PropertyMocks.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/properties/PropertyMocks.java?rev=1242848&r1=1242827&r2=1242848&view=diff ============================================================================== (empty) Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java Fri Feb 10 16:51:08 2012 @@ -29,7 +29,9 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ org.apache.fop.fo.flow.table.AllTests.class, org.apache.fop.fo.pagination.AllTests.class, - FOTreeTestCase.class }) - + org.apache.fop.fotreetest.FOTreeTestCase.class, + org.apache.fop.fo.properties.CommonAccessibilityHolderTestCase.class, + org.apache.fop.fo.DelegatingFOEventHandlerTestCase.class +}) public final class FOTreeTestSuite { } Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java?rev=1242848&r1=1242847&r2=1242848&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java Fri Feb 10 16:51:08 2012 @@ -48,6 +48,9 @@ import org.apache.fop.render.intermediat @RunWith(Parameterized.class) public class IFParserTestCase extends AbstractIFTest { + /** Set this to true to get the correspondence between test number and test file. */ + private static final boolean DEBUG = false; + /** * Gets the parameters for this test * @@ -56,7 +59,19 @@ public class IFParserTestCase extends Ab */ @Parameters public static Collection<File[]> getParameters() throws IOException { - return LayoutEngineTestUtils.getLayoutTestFiles(); + Collection<File[]> testFiles = LayoutEngineTestUtils.getLayoutTestFiles(); + if (DEBUG) { + printFiles(testFiles); + } + return testFiles; + } + + private static void printFiles(Collection<File[]> files) { + int index = 0; + for (File[] file : files) { + assert file.length == 1; + System.out.println(String.format("%3d %s", index++, file[0])); + } } /** Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java?rev=1242848&r1=1242827&r2=1242848&view=diff ============================================================================== (empty) Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java?rev=1242848&r1=1242827&r2=1242848&view=diff ============================================================================== (empty) Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/util/LanguageTagsTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/util/LanguageTagsTestCase.java?rev=1242848&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/util/LanguageTagsTestCase.java (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/util/LanguageTagsTestCase.java Fri Feb 10 16:51:08 2012 @@ -0,0 +1,58 @@ +/* + * 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.util; + +import static org.junit.Assert.assertEquals; + +import java.util.Locale; + +import org.junit.Test; + +/** + * Tests {@link LanguageTags}. + */ +public class LanguageTagsTestCase { + + @Test(expected = NullPointerException.class) + public void toLanguageTagRejectsNull() { + LanguageTags.toLanguageTag(null); + } + + @Test + public void testToLanguageTag() throws Exception { + assertEquals("", LanguageTags.toLanguageTag(new Locale(""))); + assertEquals("en", LanguageTags.toLanguageTag(new Locale("en"))); + assertEquals("en-US", LanguageTags.toLanguageTag(new Locale("en", "US"))); + assertEquals("en-US", LanguageTags.toLanguageTag(new Locale("EN", "us"))); + } + + @Test(expected = NullPointerException.class) + public void toLocaleRejectsNull() { + LanguageTags.toLocale(null); + } + + @Test + public void testRFC3066ToLocale() throws Exception { + assertEquals(new Locale(""), LanguageTags.toLocale("")); + assertEquals(new Locale("en"), LanguageTags.toLocale("en")); + assertEquals(new Locale("en", "US"), LanguageTags.toLocale("en-US")); + assertEquals(new Locale("en", "US"), LanguageTags.toLocale("EN-us")); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
