diff options
Diffstat (limited to 'test/java')
108 files changed, 1179 insertions, 1217 deletions
diff --git a/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java b/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java index 4a65b77b5..e249a8a23 100644 --- a/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java +++ b/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.InputStream; @@ -26,6 +28,7 @@ import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.commons.io.output.ByteArrayOutputStream; +import org.junit.Test; /** * Basic runtime test for FOP's transcoders. It is used to verify that @@ -34,13 +37,6 @@ import org.apache.commons.io.output.ByteArrayOutputStream; public abstract class AbstractBasicTranscoderTestCase extends AbstractFOPTestCase { /** - * @see junit.framework.TestCase#TestCase(String) - */ - public AbstractBasicTranscoderTestCase(String name) { - super(name); - } - - /** * Creates the transcoder to test. * @return the newly instantiated transcoder */ @@ -51,6 +47,7 @@ public abstract class AbstractBasicTranscoderTestCase extends AbstractFOPTestCas * Without special configuration stuff. * @throws Exception if a problem occurs */ + @Test public void testGenericPDFTranscoder() throws Exception { //Create transcoder Transcoder transcoder = createTranscoder(); diff --git a/test/java/org/apache/fop/AbstractFOPTestCase.java b/test/java/org/apache/fop/AbstractFOPTestCase.java index 7d6fee984..58108a036 100644 --- a/test/java/org/apache/fop/AbstractFOPTestCase.java +++ b/test/java/org/apache/fop/AbstractFOPTestCase.java @@ -21,25 +21,16 @@ package org.apache.fop; import java.io.File; -import junit.framework.TestCase; - /** * Abstract base test class for FOP's tests. */ -public abstract class AbstractFOPTestCase extends TestCase { - - /** - * @see junit.framework.TestCase#TestCase(String) - */ - public AbstractFOPTestCase(String name) { - super(name); - } +public abstract class AbstractFOPTestCase { /** * Returns the base directory to use for the tests. * @return the base directory */ - protected File getBaseDir() { + protected static File getBaseDir() { String basedir = System.getProperty("basedir"); if (basedir != null) { return new File(basedir); diff --git a/test/java/org/apache/fop/BasicDriverTestCase.java b/test/java/org/apache/fop/BasicDriverTestCase.java index 0ae6da048..f02debd1d 100644 --- a/test/java/org/apache/fop/BasicDriverTestCase.java +++ b/test/java/org/apache/fop/BasicDriverTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop; +import static org.junit.Assert.assertTrue; + import java.io.File; import javax.xml.transform.Result; @@ -34,6 +36,7 @@ import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; import org.apache.fop.cli.InputHandler; +import org.junit.Test; /** * Basic runtime test for the old Fop class. It is used to verify that @@ -44,16 +47,10 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { private FopFactory fopFactory = FopFactory.newInstance(); /** - * @see junit.framework.TestCase#TestCase(String) - */ - public BasicDriverTestCase(String name) { - super(name); - } - - /** * Tests Fop with JAXP and OutputStream generating PDF. * @throws Exception if anything fails */ + @Test public void testFO2PDFWithJAXP() throws Exception { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); @@ -73,6 +70,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { * Tests Fop with JAXP and OutputStream generating PostScript. * @throws Exception if anything fails */ + @Test public void testFO2PSWithJAXP() throws Exception { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); @@ -92,6 +90,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { * Tests Fop with JAXP and OutputStream generating RTF. * @throws Exception if anything fails */ + @Test public void testFO2RTFWithJAXP() throws Exception { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); @@ -111,6 +110,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { * Tests Fop with XsltInputHandler and OutputStream. * @throws Exception if anything fails */ + @Test public void testFO2PDFWithXSLTInputHandler() throws Exception { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); File xmlFile = new File(getBaseDir(), "test/xml/1.xml"); diff --git a/test/java/org/apache/fop/BasicDriverTestSuite.java b/test/java/org/apache/fop/BasicDriverTestSuite.java index 92fb07a8d..8330a5f7f 100644 --- a/test/java/org/apache/fop/BasicDriverTestSuite.java +++ b/test/java/org/apache/fop/BasicDriverTestSuite.java @@ -19,24 +19,14 @@ package org.apache.fop; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for basic functionality of FOP's Driver API. */ +@RunWith(Suite.class) +@SuiteClasses({ BasicDriverTestCase.class }) public class BasicDriverTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Basic functionality test suite for FOP's Driver API"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(BasicDriverTestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java b/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java index 44668d004..61fbdb5a4 100644 --- a/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java +++ b/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java @@ -28,16 +28,7 @@ import org.apache.fop.svg.PDFTranscoder; */ public class BasicPDFTranscoderTestCase extends AbstractBasicTranscoderTestCase { - /** - * @see junit.framework.TestCase#TestCase(String) - */ - public BasicPDFTranscoderTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.AbstractBasicTranscoderTestCase#createTranscoder() - */ + @Override protected Transcoder createTranscoder() { return new PDFTranscoder(); } diff --git a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java b/test/java/org/apache/fop/BasicPSTranscoderTestCase.java index 69be94b60..40429a44f 100644 --- a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java +++ b/test/java/org/apache/fop/BasicPSTranscoderTestCase.java @@ -28,16 +28,7 @@ import org.apache.fop.render.ps.PSTranscoder; */ public class BasicPSTranscoderTestCase extends AbstractBasicTranscoderTestCase { - /** - * @see junit.framework.TestCase#TestCase(String) - */ - public BasicPSTranscoderTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.AbstractBasicTranscoderTestCase#createTranscoder() - */ + @Override protected Transcoder createTranscoder() { return new PSTranscoder(); } diff --git a/test/java/org/apache/fop/BasicTranscoderTestSuite.java b/test/java/org/apache/fop/BasicTranscoderTestSuite.java index ed70afd82..a372f737a 100644 --- a/test/java/org/apache/fop/BasicTranscoderTestSuite.java +++ b/test/java/org/apache/fop/BasicTranscoderTestSuite.java @@ -19,25 +19,17 @@ package org.apache.fop; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for basic functionality of FOP's transcoders. */ +@RunWith(Suite.class) +@SuiteClasses({ + BasicPDFTranscoderTestCase.class, + BasicPSTranscoderTestCase.class +}) public class BasicTranscoderTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Basic functionality test suite for FOP's transcoders"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(BasicPDFTranscoderTestCase.class)); - suite.addTest(new TestSuite(BasicPSTranscoderTestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/DigestFilterTestCase.java b/test/java/org/apache/fop/DigestFilterTestCase.java index 47fa34839..5606c2b66 100644 --- a/test/java/org/apache/fop/DigestFilterTestCase.java +++ b/test/java/org/apache/fop/DigestFilterTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.io.StringReader; import java.security.NoSuchAlgorithmException; @@ -26,9 +28,9 @@ import java.security.NoSuchAlgorithmException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; -import junit.framework.TestCase; - import org.apache.fop.util.DigestFilter; +import org.junit.Before; +import org.junit.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -37,12 +39,12 @@ import org.xml.sax.XMLReader; * Test case for digesting SAX filter. * */ -public class DigestFilterTestCase extends TestCase { +public class DigestFilterTestCase { private SAXParserFactory parserFactory; - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() { + @Before + public void setUp() { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(true); } @@ -95,6 +97,7 @@ public class DigestFilterTestCase extends TestCase { return digestFilter.getDigestValue(); } + @Test public final void testLineFeed() throws NoSuchAlgorithmException, @@ -111,6 +114,7 @@ public class DigestFilterTestCase extends TestCase { compareDigest(lfDigest, crlfDigest)); } + @Test public final void testAttributeOrder() throws NoSuchAlgorithmException, @@ -134,6 +138,7 @@ public class DigestFilterTestCase extends TestCase { compareDigest(sortDigest, reverseDigest)); } + @Test public final void testNamespacePrefix() throws NoSuchAlgorithmException, diff --git a/test/java/org/apache/fop/GenericFOPTestCase.java b/test/java/org/apache/fop/GenericFOPTestCase.java index 5b51a34e1..26fa296a7 100644 --- a/test/java/org/apache/fop/GenericFOPTestCase.java +++ b/test/java/org/apache/fop/GenericFOPTestCase.java @@ -18,6 +18,7 @@ /* $Id$ */ package org.apache.fop; +import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.StringReader; @@ -27,10 +28,8 @@ import java.util.Date; import javax.xml.parsers.SAXParserFactory; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - +import org.junit.Before; +import org.junit.Test; import org.xml.sax.InputSource; import org.apache.fop.apps.FOUserAgent; @@ -47,33 +46,20 @@ import org.apache.fop.util.DigestFilter; * PDF currently supported) and a MD5 for the result. * */ -public final class GenericFOPTestCase extends TestCase { +public final class GenericFOPTestCase { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - protected SAXParserFactory parserFactory; - - public static Test suite() { - TestSuite suite = new TestSuite(GenericFOPTestCase.class); - suite.setName("Fop regression tests"); - return suite; - } - - /** - * Constructor for FopTest. - * @param name the name of the test suite - */ - public GenericFOPTestCase(String name) { - super(name); - } + private SAXParserFactory parserFactory; - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(true); } + @org.junit.Test public void testSimple() throws Exception { final String digestIn = "17bf13298796065f7775db8707133aeb"; final String digestOut = "e2761f51152f6663911e567901596707"; @@ -119,8 +105,7 @@ public final class GenericFOPTestCase extends TestCase { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); foUserAgent.setCreationDate(new Date(10000)); MessageDigest outDigest = MessageDigest.getInstance("MD5"); - DigestOutputStream out - = new DigestOutputStream(new ByteArrayOutputStream(), outDigest); + DigestOutputStream out = new DigestOutputStream(new ByteArrayOutputStream(), outDigest); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); InputSource source = new InputSource(new StringReader(fo)); DigestFilter filter = new DigestFilter("MD5"); diff --git a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java index 5a5523642..18176117c 100644 --- a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java +++ b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop; +import static org.junit.Assert.assertEquals; + import java.util.List; import org.apache.fop.layoutmgr.BlockKnuthSequence; @@ -28,17 +30,16 @@ import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthGlue; import org.apache.fop.layoutmgr.KnuthPenalty; import org.apache.fop.layoutmgr.KnuthSequence; - -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; /** * Tests the Knuth algorithm implementation. */ -public class KnuthAlgorithmTestCase extends TestCase { +public class KnuthAlgorithmTestCase { - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { DebugHelper.registerStandardElementListObservers(); } @@ -67,6 +68,7 @@ public class KnuthAlgorithmTestCase extends TestCase { * possibility. * @throws Exception if an error occurs */ + @Test public void test1() throws Exception { MyBreakingAlgorithm algo = new MyBreakingAlgorithm(0, 0, true, true, 0); algo.setConstantLineWidth(30000); diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java index a49cc7f2e..1dacd9614 100644 --- a/test/java/org/apache/fop/StandardTestSuite.java +++ b/test/java/org/apache/fop/StandardTestSuite.java @@ -19,8 +19,9 @@ package org.apache.fop; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; import org.apache.fop.afp.fonts.CharactersetEncoderTest; import org.apache.fop.afp.parser.MODCAParserTestCase; @@ -36,6 +37,7 @@ import org.apache.fop.render.pdf.PDFAConformanceTestCase; import org.apache.fop.render.pdf.PDFCMapTestCase; import org.apache.fop.render.pdf.PDFEncodingTestCase; import org.apache.fop.render.pdf.PDFsRGBSettingsTestCase; +import org.apache.fop.render.pdf.RenderPDFTestSuite; import org.apache.fop.render.ps.PSTestSuite; import org.apache.fop.render.rtf.RichTextFormatTestSuite; import org.apache.fop.traits.MinOptMaxTest; @@ -43,37 +45,30 @@ import org.apache.fop.traits.MinOptMaxTest; /** * Test suite for basic functionality of FOP. */ +@RunWith(Suite.class) +@SuiteClasses({ + BasicDriverTestSuite.class, + UtilityCodeTestSuite.class, + PDFAConformanceTestCase.class, + PDFEncodingTestCase.class, + PDFCMapTestCase.class, + PDFsRGBSettingsTestCase.class, + DejaVuLGCSerifTest.class, + RichTextFormatTestSuite.class, + ImageLoaderTestCase.class, + ImagePreloaderTestCase.class, + IFMimickingTestCase.class, + PageBoundariesTest.class, + PageScaleTest.class, + org.apache.fop.afp.AFPTestSuite.class, + GlyfTableTestCase.class, + ViewportTestSuite.class, + RenderPDFTestSuite.class, + MODCAParserTestCase.class, + CharactersetEncoderTest.class, + org.apache.fop.render.afp.AFPTestSuite.class, + PSTestSuite.class, + MinOptMaxTest.class +}) public class StandardTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite("Basic functionality test suite for FOP"); - //$JUnit-BEGIN$ - suite.addTest(BasicDriverTestSuite.suite()); - suite.addTest(UtilityCodeTestSuite.suite()); - suite.addTest(org.apache.fop.afp.AFPTestSuite.suite()); - suite.addTest(new TestSuite(PDFAConformanceTestCase.class)); - suite.addTest(new TestSuite(PDFEncodingTestCase.class)); - suite.addTest(new TestSuite(PDFCMapTestCase.class)); - suite.addTest(new TestSuite(PDFsRGBSettingsTestCase.class)); - suite.addTest(new TestSuite(DejaVuLGCSerifTest.class)); - suite.addTest(new TestSuite(MODCAParserTestCase.class)); - suite.addTest(new TestSuite(CharactersetEncoderTest.class)); - suite.addTest(org.apache.fop.render.afp.AFPTestSuite.suite()); - suite.addTest(PSTestSuite.suite()); - suite.addTest(new TestSuite(GlyfTableTestCase.class)); - suite.addTest(RichTextFormatTestSuite.suite()); - suite.addTest(new TestSuite(ImageLoaderTestCase.class)); - suite.addTest(new TestSuite(ImagePreloaderTestCase.class)); - suite.addTest(new TestSuite(IFMimickingTestCase.class)); - suite.addTest(new TestSuite(PageBoundariesTest.class)); - suite.addTest(new TestSuite(PageScaleTest.class)); - suite.addTest(new TestSuite(MinOptMaxTest.class)); - suite.addTest(ViewportTestSuite.suite()); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/URIResolutionTestCase.java b/test/java/org/apache/fop/URIResolutionTestCase.java index 0a197722b..16968e1b7 100644 --- a/test/java/org/apache/fop/URIResolutionTestCase.java +++ b/test/java/org/apache/fop/URIResolutionTestCase.java @@ -19,6 +19,9 @@ package org.apache.fop; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.FileNotFoundException; import java.io.OutputStream; @@ -36,19 +39,19 @@ import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.w3c.dom.Document; - import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.xml.XMLRenderer; +import org.apache.xpath.XPathAPI; +import org.apache.xpath.objects.XObject; +import org.junit.BeforeClass; +import org.junit.Test; +import org.w3c.dom.Document; /** * Tests URI resolution facilities. @@ -61,11 +64,10 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { private SAXTransformerFactory tfactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - private File backupDir = new File(getBaseDir(), "build/test-results"); + private final static File backupDir = new File(getBaseDir(), "build/test-results"); - /** @see junit.framework.TestCase#TestCase(String) */ - public URIResolutionTestCase(String name) { - super(name); + @BeforeClass + public static void makeDirs() { backupDir.mkdirs(); } @@ -73,6 +75,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { * Test custom URI resolution with a hand-written URIResolver. * @throws Exception if anything fails */ + @Test public void testFO1a() throws Exception { innerTestFO1(false); } @@ -81,6 +84,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { * Test custom URI resolution with a hand-written URIResolver. * @throws Exception if anything fails */ + @Test public void testFO1b() throws Exception { innerTestFO1(true); } @@ -112,7 +116,8 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { * Test custom URI resolution with a hand-written URIResolver. * @throws Exception if anything fails */ - public void DISABLEDtestFO2() throws Exception { + @Test + public void testFO2() throws Exception { //TODO This will only work when we can do URI resolution inside Batik! File foFile = new File(getBaseDir(), "test/xml/uri-resolution2.fo"); diff --git a/test/java/org/apache/fop/UtilityCodeTestSuite.java b/test/java/org/apache/fop/UtilityCodeTestSuite.java index ac0ea00ad..37826954e 100644 --- a/test/java/org/apache/fop/UtilityCodeTestSuite.java +++ b/test/java/org/apache/fop/UtilityCodeTestSuite.java @@ -19,8 +19,9 @@ package org.apache.fop; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; import org.apache.fop.events.BasicEventTestCase; import org.apache.fop.pdf.FileIDGeneratorTestCase; @@ -37,29 +38,20 @@ import org.apache.fop.util.XMLResourceBundleTestCase; /** * Test suite for FOP's utility classes. */ +@RunWith(Suite.class) +@SuiteClasses({ + PDFNumberTestCase.class, + PDFObjectTestCase.class, + ColorUtilTestCase.class, + BorderPropsTestCase.class, + ElementListUtilsTestCase.class, + BasicEventTestCase.class, + XMLResourceBundleTestCase.class, + URIResolutionTestCase.class, + FileIDGeneratorTestCase.class, + PDFFactoryTestCase.class, + PDFEncryptionJCETestCase.class, + BitmapImageUtilTestCase.class +}) public class UtilityCodeTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Test suite for FOP's utility classes"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(PDFNumberTestCase.class)); - suite.addTest(new TestSuite(PDFObjectTestCase.class)); - suite.addTest(FileIDGeneratorTestCase.suite()); - suite.addTest(new TestSuite(PDFFactoryTestCase.class)); - suite.addTest(new TestSuite(ColorUtilTestCase.class)); - suite.addTest(new TestSuite(BorderPropsTestCase.class)); - suite.addTest(new TestSuite(ElementListUtilsTestCase.class)); - suite.addTest(new TestSuite(BasicEventTestCase.class)); - suite.addTest(new TestSuite(XMLResourceBundleTestCase.class)); - suite.addTest(new TestSuite(URIResolutionTestCase.class)); - suite.addTest(new TestSuite(BitmapImageUtilTestCase.class)); - suite.addTest(new TestSuite(PDFEncryptionJCETestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java b/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java index da3e023a4..6ab7f475d 100644 --- a/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java +++ b/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java @@ -19,20 +19,20 @@ package org.apache.fop.afp; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Arrays; -import junit.framework.TestCase; - import org.apache.commons.io.IOUtils; - import org.apache.fop.afp.util.AFPResourceUtil; +import org.junit.Test; /** * Tests the {@link AFPResourceUtil} class. */ -public class AFPResourceUtilTestCase extends TestCase { +public class AFPResourceUtilTestCase { private static final String RESOURCE_FILENAME = "expected_resource.afp"; @@ -44,6 +44,7 @@ public class AFPResourceUtilTestCase extends TestCase { * Tests copyResourceFile() * @throws Exception - */ + @Test public void testCopyResourceFile() throws Exception { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -74,6 +75,7 @@ public class AFPResourceUtilTestCase extends TestCase { * Tests copyNamedResource() * @throws Exception - */ + @Test public void testCopyNamedResource() throws Exception { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/test/java/org/apache/fop/afp/AFPTestSuite.java b/test/java/org/apache/fop/afp/AFPTestSuite.java index cb57a92ed..8fa3e819d 100644 --- a/test/java/org/apache/fop/afp/AFPTestSuite.java +++ b/test/java/org/apache/fop/afp/AFPTestSuite.java @@ -19,27 +19,18 @@ package org.apache.fop.afp; -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.fop.afp.modca.AbstractStructuredObjectTestCase; -import org.apache.fop.afp.modca.AbstractTripletStructuredObjectTestCase; import org.apache.fop.afp.modca.IncludeObjectTestCase; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for FOP's AFP classes. */ +@RunWith(Suite.class) +@SuiteClasses({ + IncludeObjectTestCase.class, + AFPResourceUtilTestCase.class +}) public class AFPTestSuite { - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite("Test suite for FOP's AFP classes"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(IncludeObjectTestCase.class)); - suite.addTest(new TestSuite(AFPResourceUtilTestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTest.java b/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTest.java index 5999a04d6..3b5c945d8 100644 --- a/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTest.java +++ b/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTest.java @@ -19,19 +19,25 @@ package org.apache.fop.afp.fonts; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.CharacterCodingException; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; /** * Test {@link CharactersetEncoder} */ -public class CharactersetEncoderTest extends TestCase { +public class CharactersetEncoderTest { private CharactersetEncoder singlebyteEncoder; private CharactersetEncoder doublebyteEncoder; + @Before public void setUp() { singlebyteEncoder = CharactersetEncoder.newInstance("cp500", false); doublebyteEncoder = CharactersetEncoder.newInstance("cp937", true); @@ -71,6 +77,7 @@ public class CharactersetEncoderTest extends TestCase { /** * Tests canEncode() - tests that canEncode() responds properly to various input characters. */ + @Test public void testCanEncode() { // Both SBCS and DBCS should support Latin characters for (char c = '!'; c < '~'; c++) { @@ -86,6 +93,7 @@ public class CharactersetEncoderTest extends TestCase { assertFalse(doublebyteEncoder.canEncode('\u00BB')); } + @Test public void testEncode() throws CharacterCodingException, IOException { CharactersetEncoder.EncodedChars encChars;// = doublebyteEncoder.encode(testCJKText); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); diff --git a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTestCase.java b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTestCase.java index 815939da4..b987a13f7 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTestCase.java +++ b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTestCase.java @@ -19,6 +19,10 @@ package org.apache.fop.afp.modca; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -26,15 +30,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import junit.framework.TestCase; - import org.apache.fop.afp.Streamable; +import org.junit.Test; /** * Tests the {@link AbstractAFPObject} class. */ -public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> - extends TestCase { +public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> { private S sut; @@ -61,7 +63,7 @@ public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> 0x00 // Reserved }; - + @Test public void testCopySFStatic() { byte[] actual = new byte[9]; Arrays.fill(actual, (byte)-1); @@ -85,6 +87,7 @@ public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> assertTrue(Arrays.equals(actual, expected2)); } + @Test public void testCopySF() { byte[] expected = new byte[9]; S.copySF(expected, (byte) 0xD3, (byte)0, (byte)0); @@ -112,6 +115,7 @@ public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> /** * */ + @Test public void testwriteObjects() { final byte[][] expected = {{(byte)0, (byte)1}, {(byte)2, (byte)3}, {(byte)4, (byte)5}}; @@ -144,6 +148,7 @@ public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> /** * */ + @Test public void testTruncate() { String expected = "abc"; assertTrue(AbstractAFPObject.truncate(expected, 4) == expected); @@ -161,6 +166,7 @@ public abstract class AbstractAFPObjectTestCase<S extends AbstractAFPObject> /** * */ + @Test public void testWriteChunksToStream() throws IOException { final byte[] data = new byte[256]; int counter = 0; diff --git a/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTestCase.java b/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTestCase.java index 975c26994..4b03b87d8 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTestCase.java +++ b/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTestCase.java @@ -19,14 +19,18 @@ package org.apache.fop.afp.modca; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; +import org.junit.Test; + /** * Tests the {@linkplain AbstractAFPObject} class. */ public abstract class AbstractNamedAFPObjectTestCase<S extends AbstractNamedAFPObject> extends AbstractAFPObjectTestCase<S> { - + @Test public void testCopySF() { final S sut = getSut(); diff --git a/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTestCase.java b/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTestCase.java index ebb0f42e9..f43eb0646 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTestCase.java +++ b/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTestCase.java @@ -19,6 +19,10 @@ package org.apache.fop.afp.modca; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -31,6 +35,7 @@ import org.apache.fop.afp.modca.triplets.AttributeQualifierTriplet; import org.apache.fop.afp.modca.triplets.CommentTriplet; import org.apache.fop.afp.modca.triplets.ObjectAreaSizeTriplet; import org.apache.fop.afp.modca.triplets.Triplet; +import org.junit.Before; /** * Test {@link AbstractTripletStructuredObject} @@ -55,10 +60,8 @@ public abstract class AbstractTripletStructuredObjectTestCase<S extends Abstract private AbstractTripletStructuredObject emptyStructuredObject = new AbstractTripletStructuredObject() { }; - @Override + @Before public void setUp() throws Exception { - super.setUp(); - AbstractTripletStructuredObject sut = getSut(); for (AbstractTriplet triplet : TRIPLETS) { diff --git a/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java b/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java index 5e28f00bd..32bad5248 100644 --- a/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java +++ b/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java @@ -19,27 +19,31 @@ package org.apache.fop.afp.modca; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; import org.apache.fop.afp.util.BinaryUtils; +import org.junit.Before; +import org.junit.Test; /** * Test {@link IncludeObject} */ public class IncludeObjectTestCase extends AbstractNamedAFPObjectTestCase<IncludeObject> { - @Override + @Before public void setUp() throws Exception { setSut(new IncludeObject("8__chars")); - super.setUp(); } /** * Test writeToStream() * @throws IOException - */ + @Test public void testWriteToStream() throws IOException { final IncludeObject sut = getSut(); @@ -53,6 +57,7 @@ public class IncludeObjectTestCase extends AbstractNamedAFPObjectTestCase<Includ * handed with a 180 x-axis * @throws IOException - */ + @Test public void testWriteToStreamForOrientation() throws IOException { final IncludeObject sut = getSut(); diff --git a/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java b/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java index e079820b7..c80ef086c 100644 --- a/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java +++ b/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java @@ -19,18 +19,23 @@ package org.apache.fop.afp.parser; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.EOFException; import java.io.InputStream; import java.util.Arrays; -import junit.framework.TestCase; +import org.junit.Test; /** * MODCAParser and MODCAParser.UnparsedStructuredField Unit tests */ -public class MODCAParserTestCase extends TestCase { +public class MODCAParserTestCase { /** The carriage control character (0x5A) used to indicate the start of a structured field. */ public static final byte CARRIAGE_CONTROL_CHAR = (byte)0x5A; @@ -47,6 +52,7 @@ public class MODCAParserTestCase extends TestCase { * * @throws Exception * */ + @Test public void testReadNextStructuredField1() throws Exception { // carriage control (0x5A) delimits structured fields, @@ -87,6 +93,7 @@ public class MODCAParserTestCase extends TestCase { * * @throws Exception * */ + @Test public void testReadNextStructuredField2() throws Exception { // no extension data diff --git a/test/java/org/apache/fop/area/BlockViewportTestCase.java b/test/java/org/apache/fop/area/BlockViewportTestCase.java index a2a897322..8cca4b244 100644 --- a/test/java/org/apache/fop/area/BlockViewportTestCase.java +++ b/test/java/org/apache/fop/area/BlockViewportTestCase.java @@ -19,12 +19,14 @@ package org.apache.fop.area; +import org.junit.Test; /** * Tests the {@linkplain BlockViewport} class. */ public class BlockViewportTestCase extends ViewportTestCase { + @Test public void testNonClip() throws Exception { BlockViewport bv = new BlockViewport(); bv.setIPD(100); @@ -32,6 +34,7 @@ public class BlockViewportTestCase extends ViewportTestCase { checkNonClip(bv); } + @Test public void testClip() throws Exception { BlockViewport bv = new BlockViewport(); int ipd = 100; diff --git a/test/java/org/apache/fop/area/RegionViewportTestCase.java b/test/java/org/apache/fop/area/RegionViewportTestCase.java index f55d08b66..e6cd8fe36 100644 --- a/test/java/org/apache/fop/area/RegionViewportTestCase.java +++ b/test/java/org/apache/fop/area/RegionViewportTestCase.java @@ -22,6 +22,8 @@ package org.apache.fop.area; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; +import org.junit.Test; + /** * Tests the {@linkplain RegionViewport} class. */ @@ -35,11 +37,13 @@ public class RegionViewportTestCase extends ViewportTestCase { return viewport; } + @Test public void testNonClip() throws Exception { RegionViewport viewport = createRegionViewport(10, 10, 100, 20); checkNonClip(viewport); } + @Test public void testClip() throws Exception { int ipd = 150; int bpd = 20; diff --git a/test/java/org/apache/fop/area/ViewportTestCase.java b/test/java/org/apache/fop/area/ViewportTestCase.java index 335ca2f8d..d09b327b9 100644 --- a/test/java/org/apache/fop/area/ViewportTestCase.java +++ b/test/java/org/apache/fop/area/ViewportTestCase.java @@ -19,14 +19,17 @@ package org.apache.fop.area; -import java.awt.Rectangle; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; +import java.awt.Rectangle; /** * Tests implementations of the {@linkplain Viewport} interface. */ -public abstract class ViewportTestCase extends TestCase { +public abstract class ViewportTestCase { protected void checkNonClip(Viewport v) throws Exception { assertFalse(v.hasClip()); diff --git a/test/java/org/apache/fop/area/ViewportTestSuite.java b/test/java/org/apache/fop/area/ViewportTestSuite.java index babbe8910..065e07bf9 100644 --- a/test/java/org/apache/fop/area/ViewportTestSuite.java +++ b/test/java/org/apache/fop/area/ViewportTestSuite.java @@ -19,29 +19,19 @@ package org.apache.fop.area; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.fop.area.inline.InlineViewportTestCase; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * A suite of all the tests relating to the {@linkplain Viewport} interface. */ +@RunWith(Suite.class) +@SuiteClasses({ + RegionViewportTestCase.class, + BlockViewportTestCase.class, + InlineViewportTestCase.class +}) public final class ViewportTestSuite { - - private ViewportTestSuite() { } - - /** - * Returns the suite of {@linkplain Viewport} implementation tests. - * - * @return the tests - */ - public static Test suite() { - TestSuite suite = new TestSuite("Tests for viewport-areas"); - suite.addTestSuite(RegionViewportTestCase.class); - suite.addTestSuite(BlockViewportTestCase.class); - suite.addTestSuite(InlineViewportTestCase.class); - return suite; - } - } diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java index 811158273..d6d6c395e 100644 --- a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java +++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java @@ -20,12 +20,14 @@ package org.apache.fop.area.inline; import org.apache.fop.area.ViewportTestCase; +import org.junit.Test; /** * Tests the {@linkplain InlineViewport} class. */ public class InlineViewportTestCase extends ViewportTestCase { + @Test public void testNonClip() throws Exception { InlineViewport v = new InlineViewport(null); v.setIPD(50); @@ -33,6 +35,7 @@ public class InlineViewportTestCase extends ViewportTestCase { checkNonClip(v); } + @Test public void testClip() throws Exception { InlineViewport v = new InlineViewport(null); int ipd = 50; diff --git a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java index b94c47373..3583729e9 100644 --- a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java @@ -19,19 +19,20 @@ package org.apache.fop.config; -public abstract class BaseConstructiveUserConfigTestCase extends BaseUserConfigTestCase { +import static org.junit.Assert.fail; - /** - * @see junit.framework.TestCase#TestCase(String) - */ - public BaseConstructiveUserConfigTestCase(String name) { - super(name); - } +import org.junit.Test; + +/** + * Super class of several user config cases. + */ +public abstract class BaseConstructiveUserConfigTestCase extends BaseUserConfigTestCase { /** * Test using a standard FOP font * @throws Exception checkstyle wants a comment here, even a silly one */ + @Test public void testUserConfig() throws Exception { try { initConfig(); diff --git a/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java index 0d294d328..2ea259e78 100644 --- a/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java @@ -19,18 +19,21 @@ package org.apache.fop.config; +import static org.junit.Assert.fail; + import org.apache.fop.apps.FOPException; +import org.junit.Test; +/** + * Super class for several user configuration failure cases. + */ public abstract class BaseDestructiveUserConfigTestCase extends BaseUserConfigTestCase { /** - * @see junit.framework.TestCase#TestCase(String) + * Test the user configuration failure. */ - public BaseDestructiveUserConfigTestCase(String name) { - super(name); - } - - public void testUserConfig() throws Exception { + @Test + public void testUserConfig() { try { initConfig(); convertFO(); diff --git a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java index 6ce833312..ad884782d 100644 --- a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java @@ -23,16 +23,14 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import org.xml.sax.SAXException; - import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.render.pdf.BasePDFTestCase; +import org.xml.sax.SAXException; /** * Basic runtime test for FOP's font configuration. It is used to verify that @@ -47,13 +45,6 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { /** - * @see junit.framework.TestCase#TestCase(String) - */ - public BaseUserConfigTestCase(String name) { - super(name); - } - - /** * @see org.apache.fop.render.pdf.BasePDFTestCase#init() */ protected void init() { @@ -102,8 +93,8 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { */ protected abstract String getUserConfigFilename(); - /* - * @see junit.framework.TestCase#getName() + /** + * The name of this test. */ public String getName() { return getUserConfigFilename(); diff --git a/test/java/org/apache/fop/config/FOURIResolverTestCase.java b/test/java/org/apache/fop/config/FOURIResolverTestCase.java index e0f6d7f81..1ffe8b065 100644 --- a/test/java/org/apache/fop/config/FOURIResolverTestCase.java +++ b/test/java/org/apache/fop/config/FOURIResolverTestCase.java @@ -19,21 +19,23 @@ package org.apache.fop.config; -import java.net.MalformedURLException; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import java.net.MalformedURLException; import org.apache.fop.apps.FOURIResolver; +import org.junit.Test; /** * This tests some aspects of the {@link FOURIResolver} class. */ -public class FOURIResolverTestCase extends TestCase { +public class FOURIResolverTestCase { /** * Checks the {@link FOURIResolver#checkBaseURL(String)} method. * @throws Exception if an error occurs */ + @Test public void testCheckBaseURI() throws Exception { FOURIResolver resolver = new FOURIResolver(true); System.out.println(resolver.checkBaseURL("./test/config")); diff --git a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java index 00e9b181b..fe14a9928 100644 --- a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java @@ -19,18 +19,12 @@ package org.apache.fop.config; -/* +/** * this font is without a metrics-url or an embed-url */ public class FontAttributesMissingTestCase extends BaseDestructiveUserConfigTestCase { - public FontAttributesMissingTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_font_attributes_missing.xconf"; } diff --git a/test/java/org/apache/fop/config/FontBaseBadTestCase.java b/test/java/org/apache/fop/config/FontBaseBadTestCase.java index 792acf59a..bffda3055 100644 --- a/test/java/org/apache/fop/config/FontBaseBadTestCase.java +++ b/test/java/org/apache/fop/config/FontBaseBadTestCase.java @@ -19,16 +19,12 @@ package org.apache.fop.config; -/* +/** * This font base does not exist and a relative font path is used. */ public class FontBaseBadTestCase extends BaseDestructiveUserConfigTestCase { - public FontBaseBadTestCase(String name) { - super(name); - } - - /** {@inheritDoc} */ + @Override public String getUserConfigFilename() { return "test_fontbase_bad.xconf"; } diff --git a/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java b/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java index aa8b9e000..1640024fb 100644 --- a/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java +++ b/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java @@ -24,13 +24,7 @@ package org.apache.fop.config; */ public class FontEmbedUrlBadTestCase extends BaseDestructiveUserConfigTestCase { - public FontEmbedUrlBadTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_font_embedurl_bad.xconf"; } diff --git a/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java index 6d41b0a13..b45df16bc 100644 --- a/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java +++ b/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java @@ -24,13 +24,7 @@ package org.apache.fop.config; */ public class FontEmbedUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase { - public FontEmbedUrlMalformedTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_font_embedurl_malformed.xconf"; } diff --git a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java index 166274452..c22cd3eb2 100644 --- a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java +++ b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java @@ -19,21 +19,12 @@ package org.apache.fop.config; -/* +/** * this font has a metrics-url that does not exist on filesystem */ public class FontMetricsUrlBadTestCase extends BaseDestructiveUserConfigTestCase { - /** - * @see junit.framework.TestCase#TestCase(String) - */ - public FontMetricsUrlBadTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_font_metricsurl_bad.xconf"; } diff --git a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java index ae4dde886..27853adf9 100644 --- a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java +++ b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java @@ -19,18 +19,12 @@ package org.apache.fop.config; -/* +/** * this font has a malformed metrics-url */ public class FontMetricsUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase { - public FontMetricsUrlMalformedTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_font_metricsurl_malformed.xconf"; } diff --git a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java index dcc0098be..186dd85df 100644 --- a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java @@ -19,18 +19,12 @@ package org.apache.fop.config; -/* +/** * this font has a missing font triplet attribute */ public class FontTripletAttributeMissingTestCase extends BaseDestructiveUserConfigTestCase { - public FontTripletAttributeMissingTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_font_tripletattribute_missing.xconf"; } diff --git a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java index 403bf3282..c435a08cf 100644 --- a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java +++ b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java @@ -21,13 +21,7 @@ package org.apache.fop.config; public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTestCase { - public FontsAutoDetectTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_fonts_autodetect.xconf"; } diff --git a/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java index e83e5ca04..c19c161a3 100644 --- a/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java +++ b/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java @@ -19,23 +19,17 @@ package org.apache.fop.config; -/* +/** * this font has a metrics-url that does not exist on filesystem */ public class FontsDirectoryBadTestCase extends BaseDestructiveUserConfigTestCase { - public FontsDirectoryBadTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override public String getUserConfigFilename() { return "test_fonts_directory_bad.xconf"; } - /** get test FOP config File */ + @Override protected String getFontFOFilePath() { return "test/xml/bugtests/font-dir.fo"; } diff --git a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java index 3c0205d3d..7eec1cab6 100644 --- a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java +++ b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java @@ -24,13 +24,7 @@ package org.apache.fop.config; */ public class FontsDirectoryRecursiveTestCase extends BaseConstructiveUserConfigTestCase { - public FontsDirectoryRecursiveTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() - */ + @Override protected String getUserConfigFilename() { return "test_fonts_directory_recursive.xconf"; } diff --git a/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java b/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java index 725f0d4d7..7ae576e9b 100644 --- a/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java +++ b/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java @@ -38,17 +38,7 @@ import org.apache.fop.render.PrintRenderer; public class FontsSubstitutionTestCase extends BaseConstructiveUserConfigTestCase { - /** - * Main constructor - * @param name test case name - */ - public FontsSubstitutionTestCase(String name) { - super(name); - } - - /** - * {@inheritDoc} - */ + @Override protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile) throws Exception { PrintRenderer renderer = (PrintRenderer) ua.getRendererFactory() @@ -72,9 +62,7 @@ public class FontsSubstitutionTestCase extends return null; } - /** - * {@inheritDoc} - */ + @Override public String getUserConfigFilename() { return "test_fonts_substitution.xconf"; } diff --git a/test/java/org/apache/fop/config/UserConfigTestSuite.java b/test/java/org/apache/fop/config/UserConfigTestSuite.java index 168d87d51..d90efe37b 100644 --- a/test/java/org/apache/fop/config/UserConfigTestSuite.java +++ b/test/java/org/apache/fop/config/UserConfigTestSuite.java @@ -19,35 +19,26 @@ package org.apache.fop.config; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for font configuration. */ +@RunWith(Suite.class) +@SuiteClasses({ + FontBaseBadTestCase.class, + FontAttributesMissingTestCase.class, + FontTripletAttributeMissingTestCase.class, + FontMetricsUrlBadTestCase.class, + FontEmbedUrlBadTestCase.class, + FontMetricsUrlMalformedTestCase.class, + FontMetricsUrlMalformedTestCase.class, + FontsDirectoryRecursiveTestCase.class, + FontsAutoDetectTestCase.class, + FontsSubstitutionTestCase.class, + FOURIResolverTestCase.class +}) public class UserConfigTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Basic functionality test suite for user configuration"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(FontBaseBadTestCase.class)); - suite.addTest(new TestSuite(FontAttributesMissingTestCase.class)); - suite.addTest(new TestSuite(FontTripletAttributeMissingTestCase.class)); - suite.addTest(new TestSuite(FontMetricsUrlBadTestCase.class)); - suite.addTest(new TestSuite(FontEmbedUrlBadTestCase.class)); - suite.addTest(new TestSuite(FontMetricsUrlMalformedTestCase.class)); - suite.addTest(new TestSuite(FontEmbedUrlMalformedTestCase.class)); - suite.addTest(new TestSuite(FontsDirectoryRecursiveTestCase.class)); - suite.addTest(new TestSuite(FontsAutoDetectTestCase.class)); - suite.addTest(new TestSuite(FontsSubstitutionTestCase.class)); - suite.addTest(new TestSuite(FOURIResolverTestCase.class)); - //$JUnit-END$ - return suite; - } - } diff --git a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java index 45470aeee..23af20a1a 100644 --- a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java +++ b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java @@ -19,13 +19,16 @@ package org.apache.fop.datatypes; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; /** * Tests for URISpecification. */ -public class URISpecificationTestCase extends TestCase { +public class URISpecificationTestCase { + @Test public void testGetURL() throws Exception { String actual; @@ -42,6 +45,7 @@ public class URISpecificationTestCase extends TestCase { assertEquals("http://localhost/test", actual); } + @Test public void testEscapeURI() throws Exception { String actual; diff --git a/test/java/org/apache/fop/events/BasicEventTestCase.java b/test/java/org/apache/fop/events/BasicEventTestCase.java index c69dad081..87fc04329 100644 --- a/test/java/org/apache/fop/events/BasicEventTestCase.java +++ b/test/java/org/apache/fop/events/BasicEventTestCase.java @@ -19,12 +19,18 @@ package org.apache.fop.events; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.apache.fop.events.model.EventSeverity; +import org.junit.Test; -public class BasicEventTestCase extends TestCase { +public class BasicEventTestCase { + @Test public void testBasics() throws Exception { MyEventListener listener = new MyEventListener(); @@ -54,6 +60,7 @@ public class BasicEventTestCase extends TestCase { broadcaster.broadcastEvent(ev); } + @Test public void testEventProducer() throws Exception { MyEventListener listener = new MyEventListener(); diff --git a/test/java/org/apache/fop/events/EventChecker.java b/test/java/org/apache/fop/events/EventChecker.java index afef11d87..85193c01b 100644 --- a/test/java/org/apache/fop/events/EventChecker.java +++ b/test/java/org/apache/fop/events/EventChecker.java @@ -19,12 +19,12 @@ package org.apache.fop.events; -import junit.framework.Assert; +import static org.junit.Assert.fail; /** * Class that checks that an expected event is produced, and only this one. */ -class EventChecker extends Assert implements EventListener { +class EventChecker implements EventListener { private final String expectedEventID; diff --git a/test/java/org/apache/fop/events/EventProcessingTestCase.java b/test/java/org/apache/fop/events/EventProcessingTestCase.java index 0c42ec5e1..9660e5b79 100644 --- a/test/java/org/apache/fop/events/EventProcessingTestCase.java +++ b/test/java/org/apache/fop/events/EventProcessingTestCase.java @@ -29,14 +29,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.apache.commons.io.output.NullOutputStream; - -import org.apache.xmlgraphics.util.MimeConstants; - import org.apache.fop.ResourceEventProducer; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.Fop; @@ -47,11 +40,13 @@ import org.apache.fop.fo.flow.table.TableEventProducer; import org.apache.fop.fonts.FontEventProducer; import org.apache.fop.layoutmgr.BlockLevelEventProducer; import org.apache.fop.layoutmgr.inline.InlineLevelEventProducer; +import org.apache.xmlgraphics.util.MimeConstants; +import org.junit.Test; /** * Tests that the event notification system runs smoothly. */ -public class EventProcessingTestCase extends TestCase { +public class EventProcessingTestCase { private final FopFactory fopFactory = FopFactory.newInstance(); @@ -59,8 +54,7 @@ public class EventProcessingTestCase extends TestCase { private final File basedir; - public EventProcessingTestCase(String name) { - super(name); + public EventProcessingTestCase() { String base = System.getProperty("basedir"); if (base != null) { basedir = new File(base); @@ -81,45 +75,45 @@ public class EventProcessingTestCase extends TestCase { eventChecker.end(); } + @Test public void testArea() throws FOPException, TransformerException { doTest("area.fo", AreaEventProducer.class.getName() + ".unresolvedIDReferenceOnPage"); } + @Test public void testResource() throws FOPException, TransformerException { doTest("resource.fo", ResourceEventProducer.class.getName() + ".imageNotFound"); } + @Test public void testValidation() throws FOPException, TransformerException { doTest("validation.fo", FOValidationEventProducer.class.getName() + ".invalidPropertyValue"); } + @Test public void testTable() throws FOPException, TransformerException { doTest("table.fo", TableEventProducer.class.getName() + ".noTablePaddingWithCollapsingBorderModel"); } + @Test public void testBlockLevel() throws FOPException, TransformerException { doTest("block-level.fo", BlockLevelEventProducer.class.getName() + ".overconstrainedAdjustEndIndent"); } + @Test public void testInlineLevel() throws FOPException, TransformerException { doTest("inline-level.fo", InlineLevelEventProducer.class.getName() + ".lineOverflows"); } + @Test public void testFont() throws FOPException, TransformerException { doTest("font.fo", FontEventProducer.class.getName() + ".fontSubstituted"); } - - - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(EventProcessingTestCase.class); - return suite; - } } diff --git a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java index 8bddfd095..7501c1b9a 100644 --- a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.fo.flow.table; +import static org.junit.Assert.assertEquals; + import java.awt.Color; import java.util.Iterator; import java.util.List; @@ -26,6 +28,7 @@ import java.util.List; 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 @@ -130,6 +133,7 @@ public class CollapsedConditionalBorderTestCase extends AbstractTableTestCase { (Color) resolvedBorder[1]); } + @Test public void testCollapsedConditionalBorders() throws Exception { setUp("table/collapsed-conditional-borders.fo"); int tableNum = 0; @@ -154,6 +158,7 @@ public class CollapsedConditionalBorderTestCase extends AbstractTableTestCase { } while (tableIterator.hasNext()); } + @Test public void testCollapsedConditionalBordersHeaderFooter() throws Exception { setUp("table/collapsed-conditional-borders_header-footer.fo"); int tableNum = 0; diff --git a/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java b/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java index 5dbb66a12..a3a6b9e71 100644 --- a/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.fo.flow.table; +import static org.junit.Assert.fail; + import org.apache.fop.fo.ValidationException; /** diff --git a/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java b/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java index bc3d2b4c8..5473f098a 100644 --- a/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.fo.flow.table; +import org.junit.Test; + /** * Testcase checking that cells spanning further than their parent element aren't * accepted. @@ -29,18 +31,22 @@ public class IllegalRowSpanTestCase extends ErrorCheckTestCase { super(); } + @Test public void testBody1() throws Exception { launchTest("table/illegal-row-span_body_1.fo"); } + @Test public void testBody2() throws Exception { launchTest("table/illegal-row-span_body_2.fo"); } + @Test public void testHeader() throws Exception { launchTest("table/illegal-row-span_header.fo"); } + @Test public void testFooter() throws Exception { launchTest("table/illegal-row-span_footer.fo"); } diff --git a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java index 6d2c4f85c..48c25faca 100644 --- a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java @@ -19,9 +19,16 @@ package org.apache.fop.fo.flow.table; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; import java.util.List; +import org.junit.Test; + /** * Tests that RowGroupBuilder returns, for each part of a table, the expected number of * row-groups with the expected number or rows in each. @@ -137,34 +144,42 @@ public class RowGroupBuilderTestCase extends AbstractTableTestCase { checkNextTableRowGroups(tableIter, new int[] {2}, new int[] {1, 3}, new int[][] {{2, 1, 3}}); } + @Test public void testWithRowsSimple() throws Exception { checkSimple("table/RowGroupBuilder_simple.fo"); } + @Test public void testWithRowsSpans() throws Exception { checkSpans("table/RowGroupBuilder_spans.fo"); } + @Test public void testNoRowSimple() throws Exception { checkSimple("table/RowGroupBuilder_no-row_simple.fo"); } + @Test public void testNoRowSpans() throws Exception { checkSpans("table/RowGroupBuilder_no-row_spans.fo"); } + @Test public void testNoColWithRowsSimple() throws Exception { checkSimple("table/RowGroupBuilder_no-col_simple.fo"); } + @Test public void testNoColWithRowsSpans() throws Exception { checkSpans("table/RowGroupBuilder_no-col_spans.fo"); } + @Test public void testNoColNoRowSimple() throws Exception { checkSimple("table/RowGroupBuilder_no-col_no-row_simple.fo"); } + @Test public void testNoColNoRowSpans() throws Exception { checkSpans("table/RowGroupBuilder_no-col_no-row_spans.fo"); } diff --git a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java index dc61b1dc2..0f24ae68c 100644 --- a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java @@ -19,10 +19,13 @@ package org.apache.fop.fo.flow.table; +import static org.junit.Assert.assertEquals; + import java.util.Iterator; import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FObj; +import org.junit.Test; public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { @@ -61,6 +64,7 @@ public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { assertEquals(width, c.getColumnWidth().getValue(percentBaseContext)); } + @Test public void testColumnNumber() throws Exception { setUp("table/table-column_column-number.fo"); Iterator tableIter = getTableIterator(); @@ -97,6 +101,7 @@ public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { } } + @Test public void testImplicitColumns() throws Exception { setUp("table/implicit_columns_column-number.fo"); percentBaseContext.setUnitaryWidth(100000); diff --git a/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java b/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java index 0c7effd5b..665a88759 100644 --- a/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java @@ -19,6 +19,7 @@ package org.apache.fop.fo.flow.table; +import org.junit.Test; public class TooManyColumnsTestCase extends ErrorCheckTestCase { @@ -26,26 +27,32 @@ public class TooManyColumnsTestCase extends ErrorCheckTestCase { super(); } + @Test public void testBody1() throws Exception { launchTest("table/too-many-columns_body_1.fo"); } + @Test public void testBody2() throws Exception { launchTest("table/too-many-columns_body_2.fo"); } + @Test public void testBody3() throws Exception { launchTest("table/too-many-columns_body_3.fo"); } + @Test public void testBody4() throws Exception { launchTest("table/too-many-columns_body_4.fo"); } + @Test public void testHeader() throws Exception { launchTest("table/too-many-columns_header.fo"); } + @Test public void testFooter() throws Exception { launchTest("table/too-many-columns_footer.fo"); } diff --git a/test/java/org/apache/fop/fonts/DejaVuLGCSerifTest.java b/test/java/org/apache/fop/fonts/DejaVuLGCSerifTest.java index fb0c3a795..013d04d13 100644 --- a/test/java/org/apache/fop/fonts/DejaVuLGCSerifTest.java +++ b/test/java/org/apache/fop/fonts/DejaVuLGCSerifTest.java @@ -19,14 +19,17 @@ package org.apache.fop.fonts; +import static org.junit.Assert.assertEquals; + import java.io.File; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; /** * */ -public class DejaVuLGCSerifTest extends TestCase { +public class DejaVuLGCSerifTest { private FontResolver fontResolver = FontManager.createMinimalFontResolver(); private CustomFont font; @@ -37,6 +40,7 @@ public class DejaVuLGCSerifTest extends TestCase { * @throws Exception * if the test fails. */ + @Before public void setUp() throws Exception { File file = new File("test/resources/fonts/DejaVuLGCSerif.ttf"); font = FontLoader.loadFont(file, "", true, EncodingMode.AUTO, @@ -46,6 +50,7 @@ public class DejaVuLGCSerifTest extends TestCase { /** * Simple test to see if font name was detected correctly. */ + @Test public void testFontName() { assertEquals("DejaVuLGCSerif", font.getFontName()); } diff --git a/test/java/org/apache/fop/fonts/EncodingModeTest.java b/test/java/org/apache/fop/fonts/EncodingModeTest.java index 4e81c46d6..310916a04 100644 --- a/test/java/org/apache/fop/fonts/EncodingModeTest.java +++ b/test/java/org/apache/fop/fonts/EncodingModeTest.java @@ -19,15 +19,20 @@ package org.apache.fop.fonts; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; -public class EncodingModeTest extends TestCase { +import org.junit.Test; + +public class EncodingModeTest { + + @Test public void testGetName() { assertEquals("auto", EncodingMode.AUTO.getName()); assertEquals("single-byte", EncodingMode.SINGLE_BYTE.getName()); assertEquals("cid", EncodingMode.CID.getName()); } + @Test public void testGetValue() { assertEquals(EncodingMode.AUTO, EncodingMode.getEncodingMode("auto")); assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getEncodingMode("single-byte")); diff --git a/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java b/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java index 89527a775..a55d94e80 100644 --- a/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.fonts.truetype; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -26,12 +28,13 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; /** * Tests {@link GlyfTable}. */ -public class GlyfTableTestCase extends TestCase { +public class GlyfTableTestCase { private final static class DirData { @@ -50,7 +53,7 @@ public class GlyfTableTestCase extends TestCase { private FontFileReader originalFontReader; - @Override + @Before public void setUp() throws IOException { originalFontReader = new FontFileReader("test/resources/fonts/DejaVuLGCSerif.ttf"); } @@ -60,6 +63,7 @@ public class GlyfTableTestCase extends TestCase { * * @throws IOException if an I/O error occurs */ + @Test public void testPopulateGlyphsWithComposites() throws IOException { // Glyph 408 -> U+01D8 "uni01D8" this is a composite glyph. int[] composedIndices = setupTest(408); @@ -77,6 +81,7 @@ public class GlyfTableTestCase extends TestCase { * * @throws IOException if an I/O error occurs */ + @Test public void testPopulateNoCompositeGlyphs() throws IOException { int[] composedIndices = setupTest(36, 37, 38); // "A", "B", "C" int[] expected = new int[composedIndices.length]; @@ -90,6 +95,7 @@ public class GlyfTableTestCase extends TestCase { * * @throws IOException if an I/O error occurs */ + @Test public void testGlyphsNotRemappedTwice() throws IOException { int composedGlyph = 12; // The order of these glyph indices, must NOT be changed! (see javadoc above) @@ -108,6 +114,7 @@ public class GlyfTableTestCase extends TestCase { * * @throws IOException if an I/O error occurs */ + @Test public void testSingleRecursionStep() throws IOException { // Glyph 2077 -> U+283F "uni283F" this is composed of a composite glyph (recursive). int[] composedIndices = setupTest(2077); diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java index 76faa21c9..6e6f62b92 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java @@ -19,129 +19,20 @@ package org.apache.fop.fotreetest; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.NameFileFilter; -import org.apache.commons.io.filefilter.PrefixFileFilter; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.io.filefilter.TrueFileFilter; - -import org.apache.fop.DebugHelper; import org.apache.fop.fo.flow.table.CollapsedConditionalBorderTestCase; import org.apache.fop.fo.flow.table.IllegalRowSpanTestCase; import org.apache.fop.fo.flow.table.RowGroupBuilderTestCase; import org.apache.fop.fo.flow.table.TableColumnColumnNumberTestCase; import org.apache.fop.fo.flow.table.TooManyColumnsTestCase; -import org.apache.fop.layoutengine.LayoutEngineTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * JUnit test suit for running layout engine test under JUnit control. */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ TooManyColumnsTestCase.class, IllegalRowSpanTestCase.class, + RowGroupBuilderTestCase.class, TableColumnColumnNumberTestCase.class, + CollapsedConditionalBorderTestCase.class, FOTreeTester.class }) public final class FOTreeTestSuite { - - static { - DebugHelper.registerStandardElementListObservers(); - } - - private FOTreeTestSuite() { - //don't instantiate! - } - - /** - * @return the test suite with all the tests (one for each XML file) - * @throws IOException in case of an I/O problem - */ - public static Test suite() throws IOException { - TestSuite suite = new TestSuite(); - addXMLTestCases(suite); - addUnitTestCases(suite); - return suite; - } - - private static void addXMLTestCases(TestSuite suite) throws IOException { - File mainDir = new File("test/fotree"); - - final FOTreeTester tester = new FOTreeTester(); - - IOFileFilter filter; - String single = System.getProperty("fop.fotree.single"); - String startsWith = System.getProperty("fop.fotree.starts-with"); - if (single != null) { - filter = new NameFileFilter(single); - } else if (startsWith != null) { - filter = new PrefixFileFilter(startsWith); - filter = new AndFileFilter(filter, new SuffixFileFilter(".fo")); - } else { - filter = new SuffixFileFilter(".fo"); - filter = LayoutEngineTestSuite.decorateWithDisabledList(filter); - } - Collection files = FileUtils.listFiles(new File(mainDir, "testcases"), - filter, TrueFileFilter.INSTANCE); - String privateTests = System.getProperty("fop.fotree.private"); - if ("true".equalsIgnoreCase(privateTests)) { - Collection privateFiles = FileUtils.listFiles( - new File(mainDir, "private-testcases"), - filter, TrueFileFilter.INSTANCE); - files.addAll(privateFiles); - } - Iterator i = files.iterator(); - while (i.hasNext()) { - File f = (File)i.next(); - addTestCase(suite, tester, f); - } - } - - private static void addTestCase(TestSuite suite, - final FOTreeTester tester, final File f) { - suite.addTest(new FOTreeTestCase(f.getName()) { - public void runTest() throws Exception { - try { - prepare(tester, f); - testMain(); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog(this.getClass()).info( - "Error on " + f.getName()); - throw e; - } - } - }); - } - - private static void addUnitTestCases(TestSuite suite) { - suite.addTestSuite(TooManyColumnsTestCase.class); - suite.addTestSuite(IllegalRowSpanTestCase.class); - suite.addTestSuite(RowGroupBuilderTestCase.class); - suite.addTestSuite(TableColumnColumnNumberTestCase.class); - suite.addTestSuite(CollapsedConditionalBorderTestCase.class); - } - - private static class FOTreeTestCase extends TestCase { - - private FOTreeTester tester; - private File testFile; - - public FOTreeTestCase(String name) { - super(name); - } - - public void prepare(FOTreeTester tester, File testFile) { - //super(testFile.getName()); - this.tester = tester; - this.testFile = testFile; - } - - public void testMain() throws Exception { - tester.runTest(testFile); - } - } } diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTester.java b/test/java/org/apache/fop/fotreetest/FOTreeTester.java index ba9fde4f9..80bf44034 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeTester.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeTester.java @@ -20,88 +20,154 @@ package org.apache.fop.fotreetest; import java.io.File; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.AndFileFilter; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.filefilter.NameFileFilter; +import org.apache.commons.io.filefilter.PrefixFileFilter; +import org.apache.commons.io.filefilter.SuffixFileFilter; +import org.apache.commons.io.filefilter.TrueFileFilter; + +import org.apache.fop.DebugHelper; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FopFactoryConfigurator; import org.apache.fop.fotreetest.ext.TestElementMapping; +import org.apache.fop.layoutengine.LayoutEngineTestUtils; import org.apache.fop.util.ConsoleEventListenerForTests; /** * Test driver class for FO tree tests. */ +@RunWith(Parameterized.class) public class FOTreeTester { + @BeforeClass + public static void registerElementListObservers() { + DebugHelper.registerStandardElementListObservers(); + } + + @Parameters + public static Collection<File[]> testXMLTestCases() throws Exception { + File mainDir = new File("test/fotree"); + + IOFileFilter filter; + String single = System.getProperty("fop.fotree.single"); + String startsWith = System.getProperty("fop.fotree.starts-with"); + if (single != null) { + filter = new NameFileFilter(single); + } else if (startsWith != null) { + filter = new PrefixFileFilter(startsWith); + filter = new AndFileFilter(filter, new SuffixFileFilter(".fo")); + } else { + filter = new SuffixFileFilter(".fo"); + filter = LayoutEngineTestUtils.decorateWithDisabledList(filter); + } + Collection<File> files = FileUtils.listFiles(new File(mainDir, "testcases"), filter, + TrueFileFilter.INSTANCE); + String privateTests = System.getProperty("fop.fotree.private"); + if ("true".equalsIgnoreCase(privateTests)) { + Collection privateFiles = FileUtils.listFiles(new File(mainDir, "private-testcases"), + filter, TrueFileFilter.INSTANCE); + files.addAll(privateFiles); + } + // Unfortunately JUnit forces us to return a collection of arrays. + Collection<File[]> parameters = new ArrayList<File[]>(); + for (File f : files) { + parameters.add(new File[] { f }); + } + return parameters; + } + private FopFactory fopFactory = FopFactory.newInstance(); + private final File testFile; + /** * Main constructor + * + * @param testFile the FO file to test */ - public FOTreeTester() { + public FOTreeTester(File testFile) { fopFactory.addElementMapping(new TestElementMapping()); + this.testFile = testFile; } /** * Runs a test. - * @param testFile the test file. * @throws Exception if a test or FOP itself fails */ - public void runTest(File testFile) throws Exception { - ResultCollector collector = ResultCollector.getInstance(); - collector.reset(); - - SAXParserFactory spf = SAXParserFactory.newInstance(); - spf.setNamespaceAware(true); - spf.setValidating(false); - SAXParser parser = spf.newSAXParser(); - XMLReader reader = parser.getXMLReader(); - - //Resetting values modified by processing instructions - fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary( - FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE); - fopFactory.setSourceResolution(FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION); - - FOUserAgent ua = fopFactory.newFOUserAgent(); - ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString()); - ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua)); - ua.getEventBroadcaster().addEventListener( - new ConsoleEventListenerForTests(testFile.getName())); - - //Used to set values in the user agent through processing instructions - reader = new PIListener(reader, ua); - - Fop fop = fopFactory.newFop(ua); - - reader.setContentHandler(fop.getDefaultHandler()); - reader.setDTDHandler(fop.getDefaultHandler()); - reader.setErrorHandler(fop.getDefaultHandler()); - reader.setEntityResolver(fop.getDefaultHandler()); + @Test + public void runTest() throws Exception { try { - reader.parse(testFile.toURI().toURL().toExternalForm()); - } catch (Exception e) { - collector.notifyError(e.getLocalizedMessage()); - throw e; - } + ResultCollector collector = ResultCollector.getInstance(); + collector.reset(); + + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + spf.setValidating(false); + SAXParser parser = spf.newSAXParser(); + XMLReader reader = parser.getXMLReader(); + + // Resetting values modified by processing instructions + fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary( + FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE); + fopFactory.setSourceResolution(FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION); + + FOUserAgent ua = fopFactory.newFOUserAgent(); + ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString()); + ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua)); + ua.getEventBroadcaster().addEventListener( + new ConsoleEventListenerForTests(testFile.getName())); + + // Used to set values in the user agent through processing instructions + reader = new PIListener(reader, ua); + + Fop fop = fopFactory.newFop(ua); + + reader.setContentHandler(fop.getDefaultHandler()); + reader.setDTDHandler(fop.getDefaultHandler()); + reader.setErrorHandler(fop.getDefaultHandler()); + reader.setEntityResolver(fop.getDefaultHandler()); + try { + reader.parse(testFile.toURI().toURL().toExternalForm()); + } catch (Exception e) { + collector.notifyError(e.getLocalizedMessage()); + throw e; + } - List results = collector.getResults(); - if (results.size() > 0) { - for (int i = 0; i < results.size(); i++) { - System.out.println((String)results.get(i)); + List results = collector.getResults(); + if (results.size() > 0) { + for (int i = 0; i < results.size(); i++) { + System.out.println((String) results.get(i)); + } + throw new IllegalStateException((String) results.get(0)); } - throw new IllegalStateException((String)results.get(0)); + } catch (Exception e) { + org.apache.commons.logging.LogFactory.getLog(this.getClass()).info( + "Error on " + testFile.getName()); + throw e; } } - private class PIListener extends XMLFilterImpl { + private static class PIListener extends XMLFilterImpl { private FOUserAgent userAgent; diff --git a/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java b/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java index 5513a89ab..0906c266d 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java @@ -24,15 +24,12 @@ import java.io.File; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import junit.framework.TestCase; - -import org.xml.sax.XMLReader; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.util.ConsoleEventListenerForTests; +import org.xml.sax.XMLReader; /** @@ -40,7 +37,7 @@ import org.apache.fop.util.ConsoleEventListenerForTests; * to parse an FO file and register a proper {@link FOEventHandler}. That handler will be * the entry point to test classes from the FObj hierarchy. */ -public abstract class FOTreeUnitTester extends TestCase { +public abstract class FOTreeUnitTester { private XMLReader foReader; diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java index 97bfb4d5c..bab328911 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -19,12 +19,14 @@ package org.apache.fop.image.loader.batik; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + import java.awt.image.Raster; import java.awt.image.RenderedImage; import java.io.File; -import junit.framework.TestCase; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; import org.apache.xmlgraphics.image.loader.Image; @@ -35,23 +37,24 @@ import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; import org.apache.xmlgraphics.image.writer.ImageWriterUtil; +import org.junit.Test; /** * Tests for bundled ImageLoader implementations. */ -public class ImageLoaderTestCase extends TestCase { +public class ImageLoaderTestCase { private static final File DEBUG_TARGET_DIR = null; //new File("D:/"); private FopFactory fopFactory; - public ImageLoaderTestCase(String name) { - super(name); + public ImageLoaderTestCase() { fopFactory = FopFactory.newInstance(); fopFactory.setSourceResolution(72); fopFactory.setTargetResolution(300); } + @Test public void testSVG() throws Exception { String uri = "test/resources/images/img-w-size.svg"; @@ -90,6 +93,7 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(16000, info.getSize().getHeightMpt()); } + @Test public void testSVGNoViewbox() throws Exception { String uri = "test/resources/images/circles.svg"; @@ -135,6 +139,7 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(340158, info.getSize().getHeightMpt()); } + @Test public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; @@ -162,6 +167,7 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(612000, info.getSize().getHeightMpt()); } + @Test public void testSVGWithReferences() throws Exception { String uri = "test/resources/fop/svg/images.svg"; FopFactory ff = FopFactory.newInstance(); @@ -213,7 +219,4 @@ public class ImageLoaderTestCase extends TestCase { } assertFalse("Embedding JPG into SVG failed", same); } - - - } diff --git a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java index 057866eb9..691a2872e 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java @@ -19,6 +19,9 @@ package org.apache.fop.image.loader.batik; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.io.IOException; import javax.xml.transform.Source; @@ -26,42 +29,39 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; -import junit.framework.TestCase; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - import org.apache.batik.dom.svg.SVGDOMImplementation; - -import org.apache.xmlgraphics.image.loader.ImageException; -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.ImageManager; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; +import org.apache.xmlgraphics.image.loader.ImageException; +import org.apache.xmlgraphics.image.loader.ImageInfo; +import org.apache.xmlgraphics.image.loader.ImageManager; +import org.junit.Test; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; /** * Tests for bundled image preloader implementations. */ -public class ImagePreloaderTestCase extends TestCase { +public class ImagePreloaderTestCase { private FopFactory fopFactory; - public ImagePreloaderTestCase(String name) { - super(name); + public ImagePreloaderTestCase() { fopFactory = FopFactory.newInstance(); fopFactory.setSourceResolution(72); fopFactory.setTargetResolution(300); } + @Test public void testSVG() throws Exception { String uri = "test/resources/images/img-w-size.svg"; checkSVGFile(uri); } + @Test public void testSVGZ() throws Exception { String uri = "test/resources/images/img-w-size.svgz"; @@ -83,6 +83,7 @@ public class ImagePreloaderTestCase extends TestCase { assertEquals(16000, info.getSize().getHeightMpt()); } + @Test public void testSVGNoSize() throws Exception { String uri = "test/resources/images/img.svg"; FOUserAgent userAgent = fopFactory.newFOUserAgent(); @@ -99,6 +100,7 @@ public class ImagePreloaderTestCase extends TestCase { assertEquals(100000, info.getSize().getHeightMpt()); } + @Test public void testSVGWithDOM() throws Exception { String uri = "my:SVGImage"; FOUserAgent userAgent = fopFactory.newFOUserAgent(); @@ -143,6 +145,7 @@ public class ImagePreloaderTestCase extends TestCase { assertEquals(20000, info.getSize().getHeightMpt()); } + @Test public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; diff --git a/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java b/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java index d16621382..6705d7e3d 100644 --- a/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java +++ b/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java @@ -33,7 +33,9 @@ import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; -import org.custommonkey.xmlunit.XMLTestCase; +import org.custommonkey.xmlunit.XMLAssert; +import org.junit.After; +import org.junit.Before; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -49,7 +51,7 @@ import org.apache.fop.util.ConsoleEventListenerForTests; /** * Abstract base class for intermediate format tests. */ -public abstract class AbstractIntermediateTestCase extends XMLTestCase { +public abstract class AbstractIntermediateTestCase { /** the test environment */ protected static TestAssistant testAssistant = new TestAssistant(); @@ -76,30 +78,27 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { */ public AbstractIntermediateTestCase(File testFile) throws IOException { - super(testFile.getName()); this.testFile = testFile; } - /** {@inheritDoc} */ - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { setupOutputDirectory(); this.testDoc = testAssistant.loadTestCase(testFile); this.fopFactory = testAssistant.getFopFactory(testDoc); intermediate = buildIntermediateDocument(testAssistant.getTestcase2FOStylesheet()); if (outputDir != null) { testAssistant.saveDOM(intermediate, new File(outputDir, - getName() + ".1" + getIntermediateFileExtension())); + testFile.getName() + ".1" + getIntermediateFileExtension())); } } - /** {@inheritDoc} */ - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { //Release memory this.intermediate = null; this.fopFactory = null; this.testDoc = null; - super.tearDown(); } /** @@ -172,11 +171,12 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { Source src = new DOMSource(intermediate); Document doc = parseAndRenderToIntermediateFormat(src); if (outputDir != null) { - File tgtFile = new File(outputDir, getName() + ".2" + getIntermediateFileExtension()); + File tgtFile = new File(outputDir, testFile.getName() + ".2" + + getIntermediateFileExtension()); testAssistant.saveDOM(doc, tgtFile); } - assertXMLEqual(intermediate, doc); + XMLAssert.assertXMLEqual(intermediate, doc); } /** @@ -195,7 +195,7 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { public void testParserToPDF() throws Exception { OutputStream out; if (outputDir != null) { - File tgtFile = new File(outputDir, getName() + ".pdf"); + File tgtFile = new File(outputDir, testFile.getName() + ".pdf"); out = new FileOutputStream(tgtFile); out = new BufferedOutputStream(out); } else { @@ -219,6 +219,13 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { throws Exception; /** + * Run the test. + * + * @throws Exception if an error occurs during the test + */ + public abstract void runTest() throws Exception; + + /** * Sets an error listener which doesn't swallow errors like Xalan's default one. * @param transformer the transformer to set the error listener on */ diff --git a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java index e3135c5a3..645183844 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java @@ -22,6 +22,7 @@ package org.apache.fop.intermediate; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.util.Collection; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -32,25 +33,39 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.TransformerHandler; -import org.w3c.dom.Document; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.AreaTreeModel; import org.apache.fop.area.AreaTreeParser; import org.apache.fop.area.RenderPagesModel; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.layoutengine.LayoutEngineTestUtils; import org.apache.fop.render.Renderer; import org.apache.fop.render.xml.XMLRenderer; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.w3c.dom.Document; /** * Tests the area tree parser. */ +@RunWith(Parameterized.class) public class AreaTreeParserTestCase extends AbstractIntermediateTestCase { /** + * Creates the parameters for this test. + * + * @return the list of file arrays populated with test files + * @throws IOException if an I/O error occurs while reading the test file + */ + @Parameters + public static Collection<File[]> getParameters() throws IOException { + return LayoutEngineTestUtils.getTestFiles(); + } + /** * Constructor for the test suite that is used for each test file. * @param testFile the test file to run * @throws IOException @@ -132,4 +147,17 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTestCase { return (Document)domResult.getNode(); } + @Override + @Test + public void runTest() throws Exception { + try { + testParserToIntermediateFormat(); + testParserToPDF(); + } catch (Exception e) { + org.apache.commons.logging.LogFactory.getLog(this.getClass()).error( + "Error on " + testFile.getName()); + throw e; + } + } + } diff --git a/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java b/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java index 661dbadf3..3fc855cef 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java @@ -19,53 +19,14 @@ package org.apache.fop.intermediate; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.fop.layoutengine.LayoutEngineTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * JUnit test suite for the area tree XML format */ +@RunWith(Suite.class) +@SuiteClasses({ AreaTreeParserTestCase.class }) public class AreaTreeXMLFormatTestSuite { - - /** - * @return the test suite with all the tests (one for each XML file) - * @throws IOException in case of an I/O problem - */ - public static Test suite() throws IOException { - TestSuite suite = new TestSuite(); - - Collection files = LayoutEngineTestSuite.getTestFiles(); - - Iterator i = files.iterator(); - while (i.hasNext()) { - File f = (File)i.next(); - addATTestCase(suite, f); - } - - return suite; - } - - private static void addATTestCase(TestSuite suite, - final File f) throws IOException { - suite.addTest(new AreaTreeParserTestCase(f) { - public void runTest() throws Exception { - try { - testParserToIntermediateFormat(); - testParserToPDF(); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog( - this.getClass()).error("Error on " + f.getName()); - throw e; - } - } - }); - } - } diff --git a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java index 226bfc64e..7c03a2898 100644 --- a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.intermediate; +import static org.junit.Assert.fail; + import java.io.File; import javax.xml.transform.ErrorListener; @@ -29,7 +31,8 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; @@ -48,13 +51,12 @@ import org.apache.fop.render.intermediate.IFSerializer; /** * This test checks the correct mimicking of a different output format. */ -public class IFMimickingTestCase extends TestCase { +public class IFMimickingTestCase { private FopFactory fopFactory; - /** {@inheritDoc} */ - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { fopFactory = FopFactory.newInstance(); File configFile = new File("test/test-no-xml-metrics.xconf"); fopFactory.setUserConfig(configFile); @@ -64,6 +66,7 @@ public class IFMimickingTestCase extends TestCase { * Tests IF document handler mimicking with PDF output. * @throws Exception if an error occurs */ + @Test public void testMimickingPDF() throws Exception { doTestMimicking(MimeConstants.MIME_PDF); } @@ -72,6 +75,7 @@ public class IFMimickingTestCase extends TestCase { * Tests IF document handler mimicking with PostScript output. * @throws Exception if an error occurs */ + @Test public void testMimickingPS() throws Exception { doTestMimicking(MimeConstants.MIME_POSTSCRIPT); } @@ -80,6 +84,7 @@ public class IFMimickingTestCase extends TestCase { * Tests IF document handler mimicking with TIFF output. * @throws Exception if an error occurs */ + @Test public void testMimickingTIFF() throws Exception { doTestMimicking(MimeConstants.MIME_TIFF); } diff --git a/test/java/org/apache/fop/intermediate/IFParserTestCase.java b/test/java/org/apache/fop/intermediate/IFParserTestCase.java index afdd757c9..08a96a506 100644 --- a/test/java/org/apache/fop/intermediate/IFParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFParserTestCase.java @@ -22,15 +22,21 @@ package org.apache.fop.intermediate; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.util.Collection; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamResult; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import org.w3c.dom.Document; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.layoutengine.LayoutEngineTestUtils; import org.apache.fop.render.intermediate.IFContext; import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFParser; @@ -39,9 +45,21 @@ import org.apache.fop.render.intermediate.IFSerializer; /** * Tests the intermediate format parser. */ +@RunWith(Parameterized.class) public class IFParserTestCase extends AbstractIFTestCase { /** + * Gets the parameters for this test + * + * @return a collection of file arrays containing the test files + * @throws IOException if an error occurs when trying to read the test files + */ + @Parameters + public static Collection<File[]> getParameters() throws IOException { + return LayoutEngineTestUtils.getTestFiles(); + } + + /** * Constructor for the test suite that is used for each test file. * @param testFile the test file to run * @throws IOException if an I/O error occurs while loading the test case @@ -81,11 +99,16 @@ public class IFParserTestCase extends AbstractIFTestCase { return (Document)domResult.getNode(); } - /** {@inheritDoc} */ @Override + @Test public void runTest() throws Exception { - testParserToIntermediateFormat(); - testParserToPDF(); + try { + testParserToIntermediateFormat(); + testParserToPDF(); + } catch (Exception e) { + org.apache.commons.logging.LogFactory.getLog(this.getClass()).error( + "Error on " + testFile.getName()); + throw e; + } } - } diff --git a/test/java/org/apache/fop/intermediate/IFTestCase.java b/test/java/org/apache/fop/intermediate/IFTestCase.java index 30cb56b07..a6ff171e3 100644 --- a/test/java/org/apache/fop/intermediate/IFTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFTestCase.java @@ -20,11 +20,20 @@ package org.apache.fop.intermediate; import java.io.File; +import java.io.FilenameFilter; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; import javax.xml.transform.Source; +import javax.xml.transform.TransformerFactory; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -33,9 +42,40 @@ import org.w3c.dom.NodeList; /** * Test case for the IF output. */ +@RunWith(Parameterized.class) public class IFTestCase extends AbstractIFTestCase { - private final IFTester ifTester; + /** + * Gets the files for this test. + * + * @return a collection of file arrays containing the files to test + * @throws IOException if an error occurs when reading the test files + */ + @Parameters + public static Collection<File[]> getParameters() throws IOException { + File testDir = new File("test/intermediate"); + String[] tests = testDir.list(new FilenameFilter() { + + public boolean accept(File dir, String name) { + return name.endsWith(".xml"); + } + }); + + Collection<File[]> parameters = new ArrayList<File[]>(); + for (String test : tests) { + parameters.add(new File[] { new File(testDir, test) }); + } + return parameters; + } + + private static IFTester ifTester; + + @BeforeClass + public static void setupTestEnvironment() { + File backupDir = new File("build/test-results/intermediate"); + backupDir.mkdirs(); + ifTester = new IFTester(TransformerFactory.newInstance(), backupDir); + } /** * Creates a new test case. @@ -44,15 +84,14 @@ public class IFTestCase extends AbstractIFTestCase { * @param ifTester the helper instance that will perform checks * @throws IOException if an I/O error occurs while loading the test case */ - public IFTestCase(File test, IFTester ifTester) throws IOException { + public IFTestCase(File test) throws IOException { super(test); - this.ifTester = ifTester; this.testDir = test.getParentFile(); } - /** {@inheritDoc} */ @Override - protected void runTest() throws Exception { + @Test + public void runTest() throws Exception { Element testRoot = testAssistant.getTestRoot(testFile); NodeList nodes = testRoot.getElementsByTagName("if-checks"); if (nodes.getLength() == 0) { @@ -61,7 +100,7 @@ public class IFTestCase extends AbstractIFTestCase { Element ifChecks = (Element) nodes.item(0); Document doc = buildIntermediateDocument(testAssistant.getTestcase2FOStylesheet()); - ifTester.doIFChecks(getName(), ifChecks, doc); + ifTester.doIFChecks(testFile.getName(), ifChecks, doc); } @Override diff --git a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java index 824fee6fd..f960990b2 100644 --- a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java +++ b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java @@ -19,49 +19,14 @@ package org.apache.fop.intermediate; -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; - -import javax.xml.transform.TransformerFactory; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * A test suite for testing the Intermediate Format output. */ +@RunWith(Suite.class) +@SuiteClasses({ IFTestCase.class }) public final class IntermediateFormatTestSuite { - - private IntermediateFormatTestSuite() { - // This is a utility class - } - - /** - * Creates a suite of Intermediate Format tests. - * - * @return the test suite - * @throws IOException if an I/O error occurs while loading one of the tests - */ - public static Test suite() throws IOException { - - File backupDir = new File("build/test-results/intermediate"); - backupDir.mkdirs(); - - IFTester ifTester = new IFTester(TransformerFactory.newInstance(), backupDir); - - TestSuite suite = new TestSuite(); - File testDir = new File("test/intermediate"); - String[] tests = testDir.list(new FilenameFilter() { - - public boolean accept(File dir, String name) { - return name.endsWith(".xml"); - } - }); - for (String test : tests) { - File testFile = new File(testDir, test); - suite.addTest(new IFTestCase(testFile, ifTester)); - } - return suite; - } } diff --git a/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java b/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java index 720556a6b..5d87df1a5 100644 --- a/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java +++ b/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java @@ -19,46 +19,14 @@ package org.apache.fop.intermediate; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.fop.layoutengine.LayoutEngineTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * JUnit test suite for the intermediate format */ +@RunWith(Suite.class) +@SuiteClasses({ IFParserTestCase.class }) public final class LayoutIFTestSuite { - - private LayoutIFTestSuite() { - // This is a utility class - } - - /** - * @return the test suite with all the tests (one for each XML file) - * @throws IOException in case of an I/O problem - */ - public static Test suite() throws IOException { - TestSuite suite = new TestSuite(); - - Collection files = LayoutEngineTestSuite.getTestFiles(); - - Iterator i = files.iterator(); - while (i.hasNext()) { - File f = (File)i.next(); - addIFTestCase(suite, f); - } - - return suite; - } - - private static void addIFTestCase(TestSuite suite, - final File f) throws IOException { - suite.addTest(new IFParserTestCase(f)); - } - } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java index 397374657..00a660999 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java @@ -19,196 +19,14 @@ package org.apache.fop.layoutengine; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.NameFileFilter; -import org.apache.commons.io.filefilter.NotFileFilter; -import org.apache.commons.io.filefilter.PrefixFileFilter; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.io.filefilter.TrueFileFilter; - -import org.apache.fop.DebugHelper; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * JUnit test suit for running layout engine test under JUnit control. */ -public final class LayoutEngineTestSuite { - - static { - DebugHelper.registerStandardElementListObservers(); - } - - private LayoutEngineTestSuite() { - // This is a utility class - } - - public static String[] readDisabledTestcases(File f) throws IOException { - List lines = new java.util.ArrayList(); - Source stylesheet = new StreamSource( - new File("test/layoutengine/disabled-testcase2filename.xsl")); - Source source = new StreamSource(f); - Result result = new SAXResult(new FilenameHandler(lines)); - try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesheet); - transformer.transform(source, result); - } catch (TransformerConfigurationException tce) { - throw new RuntimeException(tce.getMessage()); - } catch (TransformerException te) { - throw new RuntimeException(te.getMessage()); - } - return (String[])lines.toArray(new String[lines.size()]); - } - - private static class FilenameHandler extends DefaultHandler { - private StringBuffer buffer = new StringBuffer(128); - private boolean readingFilename = false; - private List filenames; - - public FilenameHandler(List filenames) { - this.filenames = filenames; - } - - public void startElement(String namespaceURI, String localName, String qName, - Attributes atts) throws SAXException { - if (qName != null && qName.equals("file")) { - buffer.setLength(0); - readingFilename = true; - } else { - throw new RuntimeException( - "Unexpected element while reading disabled testcase file names: " + qName); - } - } - - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { - if (qName != null && qName.equals("file")) { - readingFilename = false; - filenames.add(buffer.toString()); - } else { - throw new RuntimeException( - "Unexpected element while reading disabled testcase file names: " + qName); - } - } - - public void characters(char[] ch, int start, int length) throws SAXException { - if (readingFilename) { - buffer.append(ch, start, length); - } - } - } - - public static IOFileFilter decorateWithDisabledList(IOFileFilter filter) throws IOException { - String disabled = System.getProperty("fop.layoutengine.disabled"); - if (disabled != null && disabled.length() > 0) { - filter = new AndFileFilter(new NotFileFilter( - new NameFileFilter(readDisabledTestcases(new File(disabled)))), - filter); - } - return filter; - } - - /** - * @return a Collection of File instances containing all the test cases set up for processing. - * @throws IOException if there's a problem gathering the list of test files - */ - public static Collection getTestFiles() throws IOException { - File mainDir = new File("test/layoutengine"); - IOFileFilter filter; - String single = System.getProperty("fop.layoutengine.single"); - String startsWith = System.getProperty("fop.layoutengine.starts-with"); - if (single != null) { - filter = new NameFileFilter(single); - } else if (startsWith != null) { - filter = new PrefixFileFilter(startsWith); - filter = new AndFileFilter(filter, new SuffixFileFilter(".xml")); - filter = decorateWithDisabledList(filter); - } else { - filter = new SuffixFileFilter(".xml"); - filter = decorateWithDisabledList(filter); - } - String testset = System.getProperty("fop.layoutengine.testset"); - if (testset == null) { - testset = "standard"; - } - Collection files = FileUtils.listFiles(new File(mainDir, testset + "-testcases"), - filter, TrueFileFilter.INSTANCE); - String privateTests = System.getProperty("fop.layoutengine.private"); - if ("true".equalsIgnoreCase(privateTests)) { - Collection privateFiles = FileUtils.listFiles( - new File(mainDir, "private-testcases"), - filter, TrueFileFilter.INSTANCE); - files.addAll(privateFiles); - } - return files; - } - - /** - * @return the test suite with all the tests (one for each XML file) - * @throws IOException in case of an I/O problem - */ - public static Test suite() throws IOException { - TestSuite suite = new TestSuite(); - - File backupDir = new File("build/test-results/layoutengine"); - backupDir.mkdirs(); - - Collection files = getTestFiles(); - - final LayoutEngineTester tester = new LayoutEngineTester(backupDir); - Iterator i = files.iterator(); - while (i.hasNext()) { - File f = (File)i.next(); - suite.addTest(new LayoutEngineTestCase(f, tester)); - } - - return suite; - } - - private static class LayoutEngineTestCase extends TestCase { - - private final File testFile; - - private final LayoutEngineTester tester; - - LayoutEngineTestCase(File testFile, LayoutEngineTester tester) { - super(testFile.getName()); - this.testFile = testFile; - this.tester = tester; - } - - @Override - protected void runTest() throws Throwable { - try { - tester.runTest(testFile); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog( - this.getClass()).error("Error on " + getName()); - throw e; - } - } - } +@RunWith(Suite.class) +@SuiteClasses({ LayoutEngineTester.class }) +public class LayoutEngineTestSuite { } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java new file mode 100644 index 000000000..6beda1f30 --- /dev/null +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java @@ -0,0 +1,165 @@ +/* + * 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.layoutengine; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.stream.StreamSource; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.AndFileFilter; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.filefilter.NameFileFilter; +import org.apache.commons.io.filefilter.NotFileFilter; +import org.apache.commons.io.filefilter.PrefixFileFilter; +import org.apache.commons.io.filefilter.SuffixFileFilter; +import org.apache.commons.io.filefilter.TrueFileFilter; + +/** + * Utility class for layout engine tests. + */ +public final class LayoutEngineTestUtils { + + private LayoutEngineTestUtils() { + } + + private static class FilenameHandler extends DefaultHandler { + private StringBuffer buffer = new StringBuffer(128); + private boolean readingFilename = false; + private List filenames; + + public FilenameHandler(List filenames) { + this.filenames = filenames; + } + + public void startElement(String namespaceURI, String localName, String qName, + Attributes atts) throws SAXException { + if (qName != null && qName.equals("file")) { + buffer.setLength(0); + readingFilename = true; + } else { + throw new RuntimeException( + "Unexpected element while reading disabled testcase file names: " + qName); + } + } + + public void endElement(String namespaceURI, String localName, String qName) + throws SAXException { + if (qName != null && qName.equals("file")) { + readingFilename = false; + filenames.add(buffer.toString()); + } else { + throw new RuntimeException( + "Unexpected element while reading disabled testcase file names: " + qName); + } + } + + public void characters(char[] ch, int start, int length) throws SAXException { + if (readingFilename) { + buffer.append(ch, start, length); + } + } + } + + public static IOFileFilter decorateWithDisabledList(IOFileFilter filter) throws IOException { + String disabled = System.getProperty("fop.layoutengine.disabled"); + if (disabled != null && disabled.length() > 0) { + filter = new AndFileFilter(new NotFileFilter( + new NameFileFilter(LayoutEngineTestUtils.readDisabledTestcases(new File( + disabled)))), + filter); + } + return filter; + } + + public static String[] readDisabledTestcases(File f) throws IOException { + List lines = new java.util.ArrayList(); + Source stylesheet = new StreamSource( + new File("test/layoutengine/disabled-testcase2filename.xsl")); + Source source = new StreamSource(f); + Result result = new SAXResult(new FilenameHandler(lines)); + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesheet); + transformer.transform(source, result); + } catch (TransformerConfigurationException tce) { + throw new RuntimeException(tce.getMessage()); + } catch (TransformerException te) { + throw new RuntimeException(te.getMessage()); + } + return (String[]) lines.toArray(new String[lines.size()]); + } + + /** + * @return a Collection of File instances containing all the test cases set up for processing. + * @throws IOException if there's a problem gathering the list of test files + */ + public static Collection<File[]> getTestFiles() throws IOException { + File mainDir = new File("test/layoutengine"); + IOFileFilter filter; + String single = System.getProperty("fop.layoutengine.single"); + String startsWith = System.getProperty("fop.layoutengine.starts-with"); + if (single != null) { + filter = new NameFileFilter(single); + } else if (startsWith != null) { + filter = new PrefixFileFilter(startsWith); + filter = new AndFileFilter(filter, new SuffixFileFilter(".xml")); + filter = decorateWithDisabledList(filter); + } else { + filter = new SuffixFileFilter(".xml"); + filter = decorateWithDisabledList(filter); + } + String testset = System.getProperty("fop.layoutengine.testset"); + if (testset == null) { + testset = "standard"; + } + Collection<File> files = FileUtils.listFiles(new File(mainDir, testset + "-testcases"), + filter, TrueFileFilter.INSTANCE); + String privateTests = System.getProperty("fop.layoutengine.private"); + if ("true".equalsIgnoreCase(privateTests)) { + Collection privateFiles = FileUtils.listFiles( + new File(mainDir, "private-testcases"), + filter, TrueFileFilter.INSTANCE); + files.addAll(privateFiles); + } + + Collection<File[]> parametersForJUnit4 = new ArrayList<File[]>(); + for (File f : files) { + parametersForJUnit4.add(new File[] { f }); + } + + return parametersForJUnit4; + } + +} diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java index 51c05a95f..867602cce 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java @@ -21,6 +21,7 @@ package org.apache.fop.layoutengine; import java.io.File; import java.io.IOException; +import java.util.Collection; import java.util.List; import javax.xml.parsers.ParserConfigurationException; @@ -33,12 +34,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.TransformerHandler; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - +import org.apache.fop.DebugHelper; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; @@ -57,41 +53,74 @@ import org.apache.fop.render.intermediate.IFSerializer; import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.util.ConsoleEventListenerForTests; import org.apache.fop.util.DelegatingContentHandler; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; /** * Class for testing the FOP's layout engine using testcases specified in XML * files. */ +@RunWith(Parameterized.class) public class LayoutEngineTester { + private static File areaTreeBackupDir; + /** + * Sets up the class, this is invoked only once. + */ + @BeforeClass + public static void makeDirAndRegisterDebugHelper() { + DebugHelper.registerStandardElementListObservers(); + areaTreeBackupDir = new File("build/test-results/layoutengine"); + areaTreeBackupDir.mkdirs(); + } + + /** + * Creates the parameters for this test. + * + * @return the list of file arrays populated with test files + * @throws IOException if an I/O error occurs while reading the test file + */ + @Parameters + public static Collection<File[]> getParameters() throws IOException { + return LayoutEngineTestUtils.getTestFiles(); + } private TestAssistant testAssistant = new TestAssistant(); private LayoutEngineChecksFactory layoutEngineChecksFactory = new LayoutEngineChecksFactory(); - private File areaTreeBackupDir; + private IFTester ifTester; + private File testFile; private TransformerFactory tfactory = TransformerFactory.newInstance(); /** * Constructs a new instance. - * @param areaTreeBackupDir Optional directory that receives the generated - * area tree XML files. May be null. + * + * @param testFile the test file */ - public LayoutEngineTester(File areaTreeBackupDir) { - this.areaTreeBackupDir = areaTreeBackupDir; + public LayoutEngineTester(File testFile) { this.ifTester = new IFTester(tfactory, areaTreeBackupDir); + this.testFile = testFile; } /** * Runs a single layout engine test case. - * @param testFile Test case to run * @throws TransformerException In case of an XSLT/JAXP problem * @throws IOException In case of an I/O problem * @throws SAXException In case of a problem during SAX processing * @throws ParserConfigurationException In case of a problem with the XML parser setup */ - public void runTest(File testFile) - throws TransformerException, SAXException, IOException, ParserConfigurationException { + @Test + public void runTest() throws TransformerException, SAXException, IOException, + ParserConfigurationException { DOMResult domres = new DOMResult(); diff --git a/test/java/org/apache/fop/layoutengine/ResultCheck.java b/test/java/org/apache/fop/layoutengine/ResultCheck.java index ce95c5024..3b3a9cd98 100644 --- a/test/java/org/apache/fop/layoutengine/ResultCheck.java +++ b/test/java/org/apache/fop/layoutengine/ResultCheck.java @@ -40,9 +40,7 @@ public class ResultCheck implements LayoutEngineCheck { this.property = node.getAttributes().getNamedItem("property").getNodeValue(); } - /* (non-Javadoc) - * @see LayoutEngineCheck#check(LayoutResult) - */ + /** {@inheritDoc} */ public void check(LayoutResult result) { FormattingResults results = result.getResults(); String actual; @@ -59,7 +57,7 @@ public class ResultCheck implements LayoutEngineCheck { } - /** @see java.lang.Object#toString() */ + @Override public String toString() { return "Property: " + property; } diff --git a/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java b/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java index 3e9617743..a9d7bf4f6 100644 --- a/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java +++ b/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java @@ -19,41 +19,57 @@ package org.apache.fop.pdf; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; /** * Tests the {@link FileIDGenerator} class. */ -public abstract class FileIDGeneratorTestCase extends TestCase { - - /** - * Returns a suite containing all the {@link FileIDGenerator} test cases. - * - * @return the test suite - */ - public static final Test suite() { - TestSuite suite = new TestSuite(new Class[] { - RandomFileIDGeneratorTestCase.class, - DigestFileIDGeneratorTestCase.class }, - FileIDGeneratorTestCase.class.getName()); - return suite; - } +@RunWith(Parameterized.class) +public class FileIDGeneratorTestCase { /** The generator under test. */ protected FileIDGenerator fileIDGenerator; + private TestGetter initializer; + + @Parameters + public static Collection<TestGetter[]> getParameters() { + ArrayList<TestGetter[]> params = new ArrayList<TestGetter[]>(); + params.add(new TestGetter[] { new RandomFileIDGeneratorTest() }); + params.add(new TestGetter[] { new DigestFileIDGeneratorTest() }); + return params; + } + + public FileIDGeneratorTestCase(TestGetter initializer) { + this.initializer = initializer; + } + + @Before + public void setUp() throws Exception { + fileIDGenerator = initializer.getSut(); + } /** Tests that the getOriginalFileID method generates valid output. */ + @Test public void testOriginal() { byte[] fileID = fileIDGenerator.getOriginalFileID(); fileIDMustBeValid(fileID); } /** Tests that the getUpdatedFileID method generates valid output. */ + @Test public void testUpdated() { byte[] fileID = fileIDGenerator.getUpdatedFileID(); fileIDMustBeValid(fileID); @@ -65,6 +81,7 @@ public abstract class FileIDGeneratorTestCase extends TestCase { } /** Tests that multiple calls to getOriginalFileID method always return the same value. */ + @Test public void testOriginalMultipleCalls() { byte[] fileID1 = fileIDGenerator.getUpdatedFileID(); byte[] fileID2 = fileIDGenerator.getUpdatedFileID(); @@ -72,20 +89,24 @@ public abstract class FileIDGeneratorTestCase extends TestCase { } /** Tests that getUpdatedFileID returns the same value as getOriginalFileID. */ + @Test public void testUpdateEqualsOriginal() { byte[] originalFileID = fileIDGenerator.getOriginalFileID(); byte[] updatedFileID = fileIDGenerator.getUpdatedFileID(); assertTrue(Arrays.equals(originalFileID, updatedFileID)); } + private static interface TestGetter { + FileIDGenerator getSut() throws Exception; + } + /** * Tests the random file ID generator. */ - public static class RandomFileIDGeneratorTestCase extends FileIDGeneratorTestCase { + private static class RandomFileIDGeneratorTest implements TestGetter { - @Override - protected void setUp() throws Exception { - fileIDGenerator = FileIDGenerator.getRandomFileIDGenerator(); + public FileIDGenerator getSut() throws Exception { + return FileIDGenerator.getRandomFileIDGenerator(); } } @@ -93,11 +114,10 @@ public abstract class FileIDGeneratorTestCase extends TestCase { /** * Tests the file ID generator based on an MD5 digest. */ - public static class DigestFileIDGeneratorTestCase extends FileIDGeneratorTestCase { + private static class DigestFileIDGeneratorTest implements TestGetter { - @Override - protected void setUp() throws Exception { - fileIDGenerator = FileIDGenerator.getDigestFileIDGenerator( + public FileIDGenerator getSut() throws Exception { + return FileIDGenerator.getDigestFileIDGenerator( new PDFDocument("Apache FOP")); } diff --git a/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java b/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java index c85018166..235db7045 100644 --- a/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java +++ b/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java @@ -19,6 +19,9 @@ package org.apache.fop.pdf; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -26,12 +29,12 @@ import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests the {@link PDFEncryptionJCE} class. */ -public class PDFEncryptionJCETestCase extends TestCase { +public class PDFEncryptionJCETestCase { private EncryptionTest test; @@ -271,12 +274,14 @@ public class PDFEncryptionJCETestCase extends TestCase { } } + @Test public final void testMake() { PDFEncryption testEncryptionObj = createEncryptionObject(new PDFEncryptionParams()); assertTrue(testEncryptionObj instanceof PDFEncryptionJCE); assertEquals(1, ((PDFEncryptionJCE) testEncryptionObj).getObjectNumber()); } + @Test public void testBasic() throws IOException { test = new EncryptionTest(); test.setData(0x00).setEncryptedData(0x56); @@ -292,6 +297,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void test128bit() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setVersion(2) @@ -306,6 +312,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void testDisableRev2Permissions() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setPermissions(-64) @@ -320,6 +327,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void testDisableRev3Permissions() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setVersion(2) @@ -337,6 +345,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void test128bitDisableSomePermissions() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setVersion(2) @@ -355,6 +364,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void testDifferentPasswords() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setOwnerEntry("D11C233C65E9DC872E858ABBD8B62198771167ADCE7AB8DC7AE0A1A7E21A1E25") @@ -367,6 +377,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void testNoOwnerPassword() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setOwnerEntry("5163AAF3EE74C76D7C223593A84C8702FEA8AA4493E4933FF5B5A5BBB20AE4BB") @@ -379,6 +390,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void test128bitDisableSomePermissionsDifferentPasswords() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setVersion(2) @@ -399,6 +411,7 @@ public class PDFEncryptionJCETestCase extends TestCase { runEncryptionTests(); } + @Test public void test128bitNoPermissionNoOwnerPassword() throws IOException { EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() .setVersion(2) diff --git a/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java b/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java index d81eb228a..4a570e7b5 100644 --- a/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java @@ -19,20 +19,22 @@ package org.apache.fop.pdf; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; import org.apache.fop.fonts.CIDSubset; import org.apache.fop.fonts.MultiByteFont; +import org.junit.Test; /** * Test case for {@link PDFFactory}. */ -public class PDFFactoryTestCase extends TestCase { +public class PDFFactoryTestCase { /** * This tests that when a font is subset embedded in a PDF, the font name is prefixed with a * pseudo-random tag as per the PDF spec. */ + @Test public void testSubsetFontNamePrefix() { class MockedFont extends MultiByteFont { @Override diff --git a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java index d41a0f0f3..2e1f452af 100644 --- a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java @@ -19,22 +19,25 @@ package org.apache.fop.pdf; +import static org.junit.Assert.assertEquals; + import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests the PDFObject class. */ -public class PDFObjectTestCase extends TestCase { +public class PDFObjectTestCase { /** * Tests date/time formatting in PDFObject. * @throws Exception if an error occurs */ + @Test public void testDateFormatting() throws Exception { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); cal.set(2008, Calendar.FEBRUARY, 07, 15, 11, 07); @@ -60,6 +63,7 @@ public class PDFObjectTestCase extends TestCase { * Tests PDF object references. * @throws Exception if an error occurs */ + @Test public void testReference() throws Exception { PDFDictionary dict = new PDFDictionary(); dict.setObjectNumber(7); diff --git a/test/java/org/apache/fop/render/AbstractRenderingTestCase.java b/test/java/org/apache/fop/render/AbstractRenderingTestCase.java index daaa94e41..9eecfb106 100644 --- a/test/java/org/apache/fop/render/AbstractRenderingTestCase.java +++ b/test/java/org/apache/fop/render/AbstractRenderingTestCase.java @@ -31,11 +31,8 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; -import junit.framework.TestCase; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; @@ -44,7 +41,7 @@ import org.apache.fop.apps.MimeConstants; /** * Abstract base class for rendering (output) verification tests. */ -public abstract class AbstractRenderingTestCase extends TestCase { +public abstract class AbstractRenderingTestCase { private static final Map<String, String> MIME_MAP = new java.util.HashMap<String, String>(); diff --git a/test/java/org/apache/fop/render/RendererFactoryTest.java b/test/java/org/apache/fop/render/RendererFactoryTest.java index 6b8e8f5f3..4f1c50986 100644 --- a/test/java/org/apache/fop/render/RendererFactoryTest.java +++ b/test/java/org/apache/fop/render/RendererFactoryTest.java @@ -19,10 +19,10 @@ package org.apache.fop.render; -import junit.framework.TestCase; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.apache.commons.io.output.NullOutputStream; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; @@ -34,12 +34,14 @@ import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFRenderer; import org.apache.fop.render.pdf.PDFDocumentHandler; import org.apache.fop.render.rtf.RTFHandler; +import org.junit.Test; /** * Tests for {@link RendererFactory}. */ -public class RendererFactoryTest extends TestCase { +public class RendererFactoryTest { + @Test public void testDocumentHandlerLevel() throws Exception { FopFactory fopFactory = FopFactory.newInstance(); RendererFactory factory = fopFactory.getRendererFactory(); @@ -67,6 +69,7 @@ public class RendererFactoryTest extends TestCase { } } + @Test public void testRendererLevel() throws Exception { FopFactory fopFactory = FopFactory.newInstance(); RendererFactory factory = fopFactory.getRendererFactory(); @@ -98,6 +101,7 @@ public class RendererFactoryTest extends TestCase { } } + @Test public void testFOEventHandlerLevel() throws Exception { FopFactory fopFactory = FopFactory.newInstance(); RendererFactory factory = fopFactory.getRendererFactory(); diff --git a/test/java/org/apache/fop/render/afp/AFPTestSuite.java b/test/java/org/apache/fop/render/afp/AFPTestSuite.java index 3f12746bf..16b6651a6 100644 --- a/test/java/org/apache/fop/render/afp/AFPTestSuite.java +++ b/test/java/org/apache/fop/render/afp/AFPTestSuite.java @@ -19,24 +19,14 @@ package org.apache.fop.render.afp; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for FOP's AFP output. */ +@RunWith(Suite.class) +@SuiteClasses({ NoOperationTestCase.class }) public class AFPTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Test suite for AFP output"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(NoOperationTestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/render/afp/NoOperationTestCase.java b/test/java/org/apache/fop/render/afp/NoOperationTestCase.java index 56e4551d1..eadc14f48 100644 --- a/test/java/org/apache/fop/render/afp/NoOperationTestCase.java +++ b/test/java/org/apache/fop/render/afp/NoOperationTestCase.java @@ -19,19 +19,20 @@ package org.apache.fop.render.afp; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import junit.framework.Assert; - import org.apache.commons.io.IOUtils; - import org.apache.fop.afp.AFPConstants; import org.apache.fop.afp.parser.MODCAParser; import org.apache.fop.afp.parser.UnparsedStructuredField; import org.apache.fop.apps.FOUserAgent; +import org.junit.Test; /** * Tests generation of afp:no-operation (NOPs). @@ -42,6 +43,7 @@ public class NoOperationTestCase extends AbstractAFPTestCase { * Tests afp:no-operation. * @throws Exception if an error occurs */ + @Test public void testNoOperation() throws Exception { FOUserAgent ua = fopFactory.newFOUserAgent(); File outputFile = renderFile(ua, "nops.fo", ""); @@ -116,7 +118,7 @@ public class NoOperationTestCase extends AbstractAFPTestCase { return field; } } while (field != null); - Assert.fail("Structured field not found: " + Integer.toHexString(typeID)); + fail("Structured field not found: " + Integer.toHexString(typeID)); return null; } diff --git a/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java b/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java index 5cd23c17e..7ec515ece 100644 --- a/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java +++ b/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java @@ -19,15 +19,19 @@ package org.apache.fop.render.extensions.prepress; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.awt.Dimension; import java.awt.Rectangle; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests for the fox:bleed, fox:crop-offset, fox:crop-box extension properties. */ -public class PageBoundariesTest extends TestCase { +public class PageBoundariesTest { private static final Dimension TEST_AREA_SIZE = new Dimension(20000, 15000); @@ -37,22 +41,8 @@ public class PageBoundariesTest extends TestCase { private static final String CROP_OFFSET = "8pt"; - /** - * Default constructor. - */ - public PageBoundariesTest() { - } - - /** - * Creates a test case with the given name. - * - * @param name name for the test case - */ - public PageBoundariesTest(String name) { - super(name); - } - /** Test for page boundaries. */ + @Test public void testBoundaries1() { PageBoundaries boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, null); assertEquals(TEST_AREA, boundaries.getTrimBox()); @@ -73,6 +63,7 @@ public class PageBoundariesTest extends TestCase { } /** Test for page boundaries. */ + @Test public void testBoundaries2() { PageBoundaries boundaries = new PageBoundaries( TEST_AREA_SIZE, BLEED, null, null); @@ -86,6 +77,7 @@ public class PageBoundariesTest extends TestCase { } /** Two values for the properties. */ + @Test public void testBoundaries2Values() { PageBoundaries boundaries = new PageBoundaries( TEST_AREA_SIZE, "5pt 10pt", "6pt \t 12pt", null); @@ -103,6 +95,7 @@ public class PageBoundariesTest extends TestCase { } /** Three values for the properties. */ + @Test public void testBoundaries3Values() { PageBoundaries boundaries = new PageBoundaries( TEST_AREA_SIZE, "5pt 10pt 7pt", "6pt \t 12pt 14pt", null); @@ -120,6 +113,7 @@ public class PageBoundariesTest extends TestCase { } /** Four values for the properties. */ + @Test public void testBoundaries4Values() { PageBoundaries boundaries = new PageBoundaries( TEST_AREA_SIZE, "5pt 6pt 7pt 8pt", "9pt 10pt 11pt 12pt", null); @@ -137,6 +131,7 @@ public class PageBoundariesTest extends TestCase { } /** Test for the different values of crop-box. */ + @Test public void testCropBox() { PageBoundaries boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, null); assertEquals(boundaries.getMediaBox(), boundaries.getCropBox()); @@ -155,6 +150,7 @@ public class PageBoundariesTest extends TestCase { } /** Test for default values returned when properties are null. */ + @Test public void testBoundariesNull() { PageBoundaries b = new PageBoundaries(TEST_AREA_SIZE, null, null, null); @@ -165,6 +161,7 @@ public class PageBoundariesTest extends TestCase { } /** Units must be specified. */ + @Test public void testBoundariesFail() { try { new PageBoundaries(TEST_AREA_SIZE, "0", null, null); diff --git a/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java b/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java index cbf6f5226..0908e869e 100644 --- a/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java +++ b/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java @@ -19,32 +19,21 @@ package org.apache.fop.render.extensions.prepress; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.awt.geom.Point2D; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests for the fox:scale extension property. */ -public class PageScaleTest extends TestCase { - - /** - * Default constructor. - */ - public PageScaleTest() { - super(); - } - - /** - * Creates a test case with the given name. - * - * @param name name for the test case - */ - public PageScaleTest(String name) { - super(name); - } +public class PageScaleTest { /** 1 value is used for both x and y. */ + @Test public void testScale1() { Point2D res = PageScale.getScale(".5"); assertEquals(0.5, res.getX(), 0.0); @@ -52,6 +41,7 @@ public class PageScaleTest extends TestCase { } /** Two values, used resp. for x and y. */ + @Test public void testScale2() { Point2D res = PageScale.getScale("1. \t \n 1.2"); assertEquals(1.0, res.getX(), 0.0); @@ -59,6 +49,7 @@ public class PageScaleTest extends TestCase { } /** Scale must not contain units. */ + @Test public void testScaleFail() { try { PageScale.getScale("0.5mm 0.5cm"); @@ -69,6 +60,7 @@ public class PageScaleTest extends TestCase { } /** @{code null} is returned when scale is unspecified. */ + @Test public void testScaleNull() { Point2D res = PageScale.getScale(null); assertNull("Result should be null", res); diff --git a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java index 7aaf61ea4..256f78839 100644 --- a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java +++ b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java @@ -28,16 +28,14 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; -import org.xml.sax.SAXException; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.output.ByteArrayOutputStream; - import org.apache.fop.AbstractFOPTestCase; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; +import org.xml.sax.SAXException; /** * Base class for automated tests that create PDF files @@ -52,10 +50,8 @@ public class BasePDFTestCase extends AbstractFOPTestCase { /** * Main constructor - * @param name the name of the test case */ - protected BasePDFTestCase(String name) { - super(name); + protected BasePDFTestCase() { init(); } diff --git a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java index 6585a0c39..67c4df280 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java @@ -19,10 +19,13 @@ package org.apache.fop.render.pdf; +import static org.junit.Assert.fail; + import java.io.File; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.pdf.PDFConformanceException; +import org.junit.Test; /** * Tests PDF/A-1 functionality. @@ -32,13 +35,6 @@ public class PDFAConformanceTestCase extends BasePDFTestCase { private File foBaseDir = new File("test/xml/pdf-a"); private boolean dumpPDF = Boolean.getBoolean("PDFAConformanceTestCase.dumpPDF"); - /** - * Main constructor - * @param name the name of the test case - */ - public PDFAConformanceTestCase(String name) { - super(name); - } /** create an FOUserAgent for our tests * @return an initialized FOUserAgent @@ -53,6 +49,7 @@ public class PDFAConformanceTestCase extends BasePDFTestCase { * Test exception when PDF/A-1 is enabled and everything is as it should. * @throws Exception if the test fails */ + @Test public void testAllOk() throws Exception { File foFile = new File(foBaseDir, "minimal-pdf-a.fo"); convertFO(foFile, getUserAgent(), dumpPDF); @@ -62,6 +59,7 @@ public class PDFAConformanceTestCase extends BasePDFTestCase { * Test exception when PDF/A-1 is enabled together with encryption. * @throws Exception if the test fails */ + @Test public void testNoEncryption() throws Exception { final FOUserAgent ua = getUserAgent(); ua.getRendererOptions().put("owner-password", "mypassword"); //To enabled encryption @@ -78,6 +76,7 @@ public class PDFAConformanceTestCase extends BasePDFTestCase { * Test exception when PDF/A-1 is enabled and a font is used which is not embedded. * @throws Exception if the test fails */ + @Test public void testFontNotEmbedded() throws Exception { File foFile = new File(foBaseDir, "base14-font.fo"); try { @@ -92,6 +91,7 @@ public class PDFAConformanceTestCase extends BasePDFTestCase { * Test exception when PDF/A-1 is enabled and images. * @throws Exception if the test fails */ + @Test public void testImages() throws Exception { File foFile = new File(foBaseDir, "with-rgb-images.fo"); convertFO(foFile, getUserAgent(), dumpPDF); diff --git a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java index 886a2b97e..1606bf073 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java @@ -19,6 +19,9 @@ package org.apache.fop.render.pdf; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.Calendar; import java.util.TimeZone; @@ -32,14 +35,14 @@ import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter; import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFAdapter; import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema; - -import junit.framework.TestCase; +import org.junit.Test; /** * Test case for PDF/A metadata handling. */ -public class PDFAMetadataTestCase extends TestCase { +public class PDFAMetadataTestCase { + @Test public void testInfoUpdate() throws Exception { Metadata meta = new Metadata(); DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta); @@ -76,6 +79,7 @@ public class PDFAMetadataTestCase extends TestCase { assertEquals(cal2.getTime(), info.getModDate()); } + @Test public void testXMPUpdate() throws Exception { PDFDocument doc = new PDFDocument("SuperFOP"); PDFInfo info = doc.getInfo(); diff --git a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java index bd5c8ade1..fee2c07aa 100644 --- a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java @@ -19,16 +19,18 @@ package org.apache.fop.render.pdf; -import java.io.StringWriter; +import static org.junit.Assert.assertEquals; -import junit.framework.TestCase; +import java.io.StringWriter; import org.apache.fop.pdf.CMapBuilder; +import org.junit.Test; /** Simple sanity test of the PDFCmap class */ -public class PDFCMapTestCase extends TestCase { +public class PDFCMapTestCase { private static final String EOL = "\n"; + @Test public void testPDFCMapFillInPDF() throws Exception { final String expected = "%!PS-Adobe-3.0 Resource-CMap" + EOL diff --git a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java index b3098b859..b385e5598 100644 --- a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java @@ -19,11 +19,16 @@ package org.apache.fop.render.pdf; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.util.StringTokenizer; import org.apache.fop.apps.FOUserAgent; +import org.junit.Ignore; +import org.junit.Test; /** Test that characters are correctly encoded in a generated PDF file */ public class PDFEncodingTestCase extends BasePDFTestCase { @@ -32,12 +37,6 @@ public class PDFEncodingTestCase extends BasePDFTestCase { static final String INPUT_FILE = "test/xml/pdf-encoding/pdf-encoding-test.xconf"; static final String TEST_MARKER = "PDFE_TEST_MARK_"; - /** - * @param name the name of the test case - */ - public PDFEncodingTestCase(String name) { - super(name); - } /** * create an FOUserAgent for our tests @@ -57,6 +56,7 @@ public class PDFEncodingTestCase extends BasePDFTestCase { * Test using a standard FOP font * @throws Exception checkstyle wants a comment here, even a silly one */ + @Test public void testPDFEncodingWithStandardFont() throws Exception { /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) @@ -82,7 +82,10 @@ public class PDFEncodingTestCase extends BasePDFTestCase { * @throws Exception * checkstyle wants a comment here, even a silly one */ - public void DISABLEDtestPDFEncodingWithCustomFont() throws Exception { + @Ignore("This should be tested using PDFBox. If PDFBox can extract the text correctly," + + "everything is fine. The tests here are too unstable.") + @Test + public void testPDFEncodingWithCustomFont() throws Exception { /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) * ...Tm [(PDFE_TEST_MARK_2:) ( ) (This) ( ) (is) ...(acute:) ( ) (XX_\351_XX) ] TJ diff --git a/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java index 01889e437..143f53ca0 100644 --- a/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java @@ -19,10 +19,11 @@ package org.apache.fop.render.pdf; -import java.io.File; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; +import java.io.File; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; @@ -30,11 +31,12 @@ import org.apache.fop.apps.FopFactory; import org.apache.fop.events.Event; import org.apache.fop.events.EventListener; import org.apache.fop.pdf.PDFEncryptionParams; +import org.junit.Test; /** * Tests that encryption length is properly set up. */ -public class PDFRendererConfiguratorTestCase extends TestCase { +public class PDFRendererConfiguratorTestCase { private FOUserAgent foUserAgent; @@ -67,6 +69,7 @@ public class PDFRendererConfiguratorTestCase extends TestCase { * * @throws Exception if an error occurs */ + @Test public void testRoundUp() throws Exception { runTest("roundUp", 55, 56); } @@ -76,6 +79,7 @@ public class PDFRendererConfiguratorTestCase extends TestCase { * * @throws Exception if an error occurs */ + @Test public void testRoundDown() throws Exception { runTest("roundDown", 67, 64); } @@ -85,6 +89,7 @@ public class PDFRendererConfiguratorTestCase extends TestCase { * * @throws Exception if an error occurs */ + @Test public void testBelow40() throws Exception { runTest("below40", 32, 40); } @@ -94,6 +99,7 @@ public class PDFRendererConfiguratorTestCase extends TestCase { * * @throws Exception if an error occurs */ + @Test public void testAbove128() throws Exception { runTest("above128", 233, 128); } @@ -103,11 +109,12 @@ public class PDFRendererConfiguratorTestCase extends TestCase { * * @throws Exception if an error occurs */ + @Test public void testCorrectValue() throws Exception { givenAConfigurationFile("correct", new EventListener() { public void processEvent(Event event) { - throw new AssertionFailedError("No event was expected"); + fail("No event was expected"); } }); whenCreatingAndConfiguringDocumentHandler(); diff --git a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java index 49b004e7c..6818537a8 100644 --- a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java @@ -19,9 +19,12 @@ package org.apache.fop.render.pdf; +import static org.junit.Assert.fail; + import java.io.File; import org.apache.fop.apps.FOUserAgent; +import org.junit.Test; /** * Tests the disables-srgb-colorspace setting. @@ -30,14 +33,6 @@ public class PDFsRGBSettingsTestCase extends BasePDFTestCase { private File foBaseDir = new File("test/xml/pdf-a"); - /** - * Main constructor - * @param name name of the test case - */ - public PDFsRGBSettingsTestCase(String name) { - super(name); - } - private FOUserAgent getUserAgent(boolean enablePDFA) { final FOUserAgent a = fopFactory.newFOUserAgent(); if (enablePDFA) { @@ -51,6 +46,7 @@ public class PDFsRGBSettingsTestCase extends BasePDFTestCase { * Verify that the PDFRenderer complains if PDF/A or PDF/X is used when sRGB is disabled. * @throws Exception if the test fails */ + @Test public void testPDFAWithDisabledSRGB() throws Exception { File foFile = new File(foBaseDir, "minimal-pdf-a.fo"); try { diff --git a/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java b/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java index c9a17da0b..2279e4fcc 100644 --- a/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java +++ b/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java @@ -19,27 +19,15 @@ package org.apache.fop.render.pdf; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * A test suite for org.apache.fop.render.pdf.* */ +@RunWith(Suite.class) +@SuiteClasses({ PDFRendererConfiguratorTestCase.class }) public final class RenderPDFTestSuite { - - private RenderPDFTestSuite() { } - - /** - * Creates the test suite. - * - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite(); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(PDFRendererConfiguratorTestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java b/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java index 30e499846..cdd1ee567 100644 --- a/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java +++ b/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.render.ps; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; diff --git a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java index c127d82a5..f4c3617e3 100644 --- a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java +++ b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java @@ -18,13 +18,16 @@ /* $Id$ */ package org.apache.fop.render.ps; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.IOUtils; - +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.render.intermediate.IFContext; import org.apache.xmlgraphics.ps.DSCConstants; import org.apache.xmlgraphics.ps.PSResource; import org.apache.xmlgraphics.ps.dsc.DSCException; @@ -33,9 +36,7 @@ import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage; import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages; import org.apache.xmlgraphics.ps.dsc.events.DSCCommentTitle; import org.apache.xmlgraphics.ps.dsc.events.DSCEvent; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.render.intermediate.IFContext; +import org.junit.Test; /** * Tests the image handling in PostScript output. @@ -46,6 +47,7 @@ public class ImageHandlingTestCase extends AbstractPostScriptTestCase { * Tests JPEG handling. * @throws Exception if an error occurs */ + @Test public void testJPEGImageLevel3() throws Exception { innerTestJPEGImage(3); } @@ -54,6 +56,7 @@ public class ImageHandlingTestCase extends AbstractPostScriptTestCase { * Tests JPEG handling. * @throws Exception if an error occurs */ + @Test public void testJPEGImageLevel2() throws Exception { innerTestJPEGImage(2); } diff --git a/test/java/org/apache/fop/render/ps/PSTestSuite.java b/test/java/org/apache/fop/render/ps/PSTestSuite.java index 05ba2dac7..cf66d4776 100644 --- a/test/java/org/apache/fop/render/ps/PSTestSuite.java +++ b/test/java/org/apache/fop/render/ps/PSTestSuite.java @@ -19,25 +19,17 @@ package org.apache.fop.render.ps; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for FOP's PostScript output. */ +@RunWith(Suite.class) +@SuiteClasses({ + ImageHandlingTestCase.class, + ResourceOptimizationTestCase.class +}) public class PSTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Test suite for PostScript output"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(ImageHandlingTestCase.class)); - suite.addTest(new TestSuite(ResourceOptimizationTestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java index 327c86548..91787aca1 100644 --- a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java +++ b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java @@ -19,6 +19,11 @@ package org.apache.fop.render.ps; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -27,7 +32,8 @@ import java.util.Collection; import java.util.Set; import org.apache.commons.io.IOUtils; - +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.render.intermediate.IFContext; import org.apache.xmlgraphics.ps.DSCConstants; import org.apache.xmlgraphics.ps.PSResource; import org.apache.xmlgraphics.ps.dsc.DSCException; @@ -43,9 +49,7 @@ import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndOfFile; import org.apache.xmlgraphics.ps.dsc.events.DSCCommentIncludeResource; import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage; import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.render.intermediate.IFContext; +import org.junit.Test; /** * Tests the PostScript resource optimization (selective de-duplication of @@ -57,6 +61,7 @@ public class ResourceOptimizationTestCase extends AbstractPostScriptTestCase { * Tests resource optimization. * @throws Exception if an error occurs */ + @Test public void testResourceOptimization() throws Exception { FOUserAgent ua = fopFactory.newFOUserAgent(); PSDocumentHandler handler = new PSDocumentHandler(); diff --git a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java index a7622bc0f..c5821fff1 100644 --- a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java +++ b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java @@ -27,18 +27,18 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; - -import junit.framework.TestCase; +import org.junit.Test; /** * Test for http://issues.apache.org/bugzilla/show_bug.cgi?id=39607 */ -public class Bug39607TestCase extends TestCase { +public class Bug39607TestCase { /** * Test for the NPE describes in bug 39607 * @throws Exception If an error occurs */ + @Test public void testForNPE() throws Exception { StringWriter writer = new StringWriter(); RtfFile f = new RtfFile(writer); diff --git a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java index 502604344..d8296fc33 100644 --- a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java +++ b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java @@ -19,24 +19,14 @@ package org.apache.fop.render.rtf; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Test suite for FOP's RTF library. */ +@RunWith(Suite.class) +@SuiteClasses({ Bug39607TestCase.class }) public class RichTextFormatTestSuite { - - /** - * Builds the test suite - * @return the test suite - */ - public static Test suite() { - TestSuite suite = new TestSuite( - "Test suite for RTF library"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(Bug39607TestCase.class)); - //$JUnit-END$ - return suite; - } } diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java index e9b2ff90d..97ac470e3 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java @@ -19,14 +19,15 @@ package org.apache.fop.text.linebreak; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + /** * JUnit test case for the LineBreakStatus class */ -public class LineBreakStatusTest extends TestCase { +public class LineBreakStatusTest { /* * These symbols are used to indicate the break action returned @@ -37,27 +38,9 @@ public class LineBreakStatusTest extends TestCase { private static final String BREAK_ACTION = "_%#@^!"; /** - * Creates the test with the given name. - * @param testName The name for this test. - */ - public LineBreakStatusTest(String testName) { - super(testName); - } - - /** - * Returns an TestSuite constructed from this class. - * @return the TestSuite - * @see junit.framework.TestSuite#TestSuite(class) - */ - public static Test suite() { - TestSuite suite = new TestSuite(LineBreakStatusTest.class); - - return suite; - } - - /** * Test of reset method, of class org.apache.commons.text.linebreak.LineBreakStatus. */ + @Test public void testReset() { System.out.println("testReset"); // TODO @@ -67,6 +50,7 @@ public class LineBreakStatusTest extends TestCase { * Test of nextChar method, of class org.apache.commons.text.linebreak.LineBreakStatus. * Runs tests for most of the Line Breaking Properties defined in the Unicode standard. */ + @Test public void testNextChar() { System.out.println("testNextChar"); diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java index bb6d209c2..9c5b0d8c6 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java @@ -19,22 +19,18 @@ package org.apache.fop.text.linebreak; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; /** * TODO add javadoc * * */ -public class LineBreakUtilsTest extends TestCase { - - /** - * @param name - */ - public LineBreakUtilsTest(String name) { - super(name); - } +public class LineBreakUtilsTest { + @Test public void testLineBreakProperty() { assertEquals(LineBreakUtils.getLineBreakProperty('A'), LineBreakUtils.LINE_BREAK_PROPERTY_AL); assertEquals(LineBreakUtils.getLineBreakProperty('1'), LineBreakUtils.LINE_BREAK_PROPERTY_NU); @@ -44,6 +40,7 @@ public class LineBreakUtilsTest extends TestCase { assertEquals(LineBreakUtils.getLineBreakProperty('\u1F7E'), 0); } + @Test public void testLineBreakPair() { assertEquals( LineBreakUtils.getLineBreakPairProperty( diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index 07e4cd68c..25227867b 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -19,25 +19,27 @@ package org.apache.fop.traits; -import java.awt.Color; +import static org.junit.Assert.assertEquals; -import junit.framework.TestCase; +import java.awt.Color; import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; import org.apache.fop.fo.Constants; import org.apache.fop.util.ColorUtil; +import org.junit.Test; /** * Tests the BorderProps class. */ -public class BorderPropsTestCase extends TestCase { +public class BorderPropsTestCase { /** * Test serialization and deserialization to/from String. * @throws Exception if an error occurs */ + @Test public void testSerialization() throws Exception { Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); //Normalize: Avoid false alarms due to color conversion (rounding) diff --git a/test/java/org/apache/fop/traits/MinOptMaxTest.java b/test/java/org/apache/fop/traits/MinOptMaxTest.java index 17f46b7b0..9e08a63cb 100644 --- a/test/java/org/apache/fop/traits/MinOptMaxTest.java +++ b/test/java/org/apache/fop/traits/MinOptMaxTest.java @@ -19,20 +19,27 @@ package org.apache.fop.traits; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Test; /** * Tests the {@link MinOptMaxTest} class. */ -public class MinOptMaxTest extends TestCase { +public class MinOptMaxTest { /** * Tests that the constant <code>MinOptMax.ZERO</code> is really zero. */ + @Test public void testZero() { assertEquals(MinOptMax.getInstance(0), MinOptMax.ZERO); } + @Test public void testNewStiffMinOptMax() { MinOptMax value = MinOptMax.getInstance(1); assertTrue(value.isStiff()); @@ -41,6 +48,7 @@ public class MinOptMaxTest extends TestCase { assertEquals(1, value.getMax()); } + @Test public void testNewMinOptMax() { MinOptMax value = MinOptMax.getInstance(1, 2, 3); assertTrue(value.isElastic()); @@ -52,6 +60,7 @@ public class MinOptMaxTest extends TestCase { /** * Test that it is possible to create stiff instances with the normal factory method. */ + @Test public void testNewMinOptMaxStiff() { MinOptMax value = MinOptMax.getInstance(1, 1, 1); assertTrue(value.isStiff()); @@ -60,6 +69,7 @@ public class MinOptMaxTest extends TestCase { assertEquals(1, value.getMax()); } + @Test public void testNewMinOptMaxMinGreaterOpt() { try { MinOptMax.getInstance(1, 0, 2); @@ -69,6 +79,7 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testNewMinOptMaxMaxSmallerOpt() { try { MinOptMax.getInstance(0, 1, 0); @@ -78,18 +89,21 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testShrinkablility() { assertEquals(0, MinOptMax.getInstance(1).getShrink()); assertEquals(1, MinOptMax.getInstance(1, 2, 2).getShrink()); assertEquals(2, MinOptMax.getInstance(1, 3, 3).getShrink()); } + @Test public void testStrechablilty() { assertEquals(0, MinOptMax.getInstance(1).getStretch()); assertEquals(1, MinOptMax.getInstance(1, 1, 2).getStretch()); assertEquals(2, MinOptMax.getInstance(1, 1, 3).getStretch()); } + @Test public void testPlus() { assertEquals(MinOptMax.ZERO, MinOptMax.ZERO.plus(MinOptMax.ZERO)); @@ -100,6 +114,7 @@ public class MinOptMaxTest extends TestCase { assertEquals(MinOptMax.getInstance(4, 5, 6), MinOptMax.getInstance(1, 2, 3).plus(3)); } + @Test public void testMinus() { assertEquals(MinOptMax.ZERO, MinOptMax.ZERO.minus(MinOptMax.ZERO)); @@ -110,6 +125,7 @@ public class MinOptMaxTest extends TestCase { assertEquals(MinOptMax.getInstance(1, 2, 3), MinOptMax.getInstance(5, 6, 7).minus(4)); } + @Test public void testMinusFail1() { try { MinOptMax.ZERO.minus(MinOptMax.getInstance(1, 2, 3)); @@ -119,6 +135,7 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testMinusFail2() { try { MinOptMax.getInstance(1, 2, 3).minus(MinOptMax.getInstance(1, 3, 3)); @@ -128,6 +145,7 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testMinusFail3() { try { MinOptMax.ZERO.minus(MinOptMax.getInstance(1, 1, 2)); @@ -137,6 +155,7 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testMinusFail4() { try { MinOptMax.getInstance(1, 2, 3).minus(MinOptMax.getInstance(1, 1, 3)); @@ -146,12 +165,14 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testMult() { assertEquals(MinOptMax.ZERO, MinOptMax.ZERO.mult(0)); assertEquals(MinOptMax.getInstance(1, 2, 3), MinOptMax.getInstance(1, 2, 3).mult(1)); assertEquals(MinOptMax.getInstance(2, 4, 6), MinOptMax.getInstance(1, 2, 3).mult(2)); } + @Test public void testMultFail() { try { MinOptMax.getInstance(1, 2, 3).mult(-1); @@ -161,12 +182,14 @@ public class MinOptMaxTest extends TestCase { } } + @Test public void testNonZero() { assertFalse(MinOptMax.ZERO.isNonZero()); assertTrue(MinOptMax.getInstance(1).isNonZero()); assertTrue(MinOptMax.getInstance(1, 2, 3).isNonZero()); } + @Test public void testExtendMinimum() { assertEquals(MinOptMax.getInstance(1, 1, 1), MinOptMax.ZERO.extendMinimum(1)); @@ -180,6 +203,7 @@ public class MinOptMaxTest extends TestCase { MinOptMax.getInstance(1, 2, 3).extendMinimum(4)); } + @Test public void testEquals() { MinOptMax number = MinOptMax.getInstance(1, 3, 5); assertEquals(number, number); @@ -191,6 +215,7 @@ public class MinOptMaxTest extends TestCase { assertFalse(number.equals(new Integer(1))); } + @Test public void testHashCode() { MinOptMax number = MinOptMax.getInstance(1, 2, 3); assertEquals(number.hashCode(), number.hashCode()); diff --git a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java index 3d7e72d87..c4b9446ac 100644 --- a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java +++ b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java @@ -19,20 +19,21 @@ package org.apache.fop.util; -import java.util.Map; - -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; -import org.xml.sax.helpers.LocatorImpl; +import java.util.Map; import org.apache.fop.events.model.EventSeverity; import org.apache.fop.util.text.AdvancedMessageFormat; +import org.junit.Test; +import org.xml.sax.helpers.LocatorImpl; /** * Tests for EventFormatter. */ -public class AdvancedMessageFormatTestCase extends TestCase { +public class AdvancedMessageFormatTestCase { + @Test public void testFormatting() throws Exception { String msg; AdvancedMessageFormat format; @@ -74,6 +75,7 @@ public class AdvancedMessageFormatTestCase extends TestCase { assertEquals("Multi-conditional: case1: value1", msg); } + @Test public void testObjectFormatting() throws Exception { String msg; AdvancedMessageFormat format; @@ -92,6 +94,7 @@ public class AdvancedMessageFormatTestCase extends TestCase { assertEquals("Here\'s a Locator: 12:7", msg); } + @Test public void testIfFormatting() throws Exception { String msg; AdvancedMessageFormat format; @@ -139,6 +142,7 @@ public class AdvancedMessageFormatTestCase extends TestCase { assertEquals("You are very, very nice!", msg); } + @Test public void testEqualsFormatting() throws Exception { String msg; AdvancedMessageFormat format; @@ -157,6 +161,7 @@ public class AdvancedMessageFormatTestCase extends TestCase { assertEquals("Error\nSome explanation!", msg); } + @Test public void testChoiceFormatting() throws Exception { String msg; AdvancedMessageFormat format; diff --git a/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java b/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java index 55a9fe4e4..3afcc3a2e 100644 --- a/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java +++ b/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.util; +import static org.junit.Assert.assertEquals; + import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; @@ -29,21 +31,18 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; -import junit.framework.TestCase; - import org.apache.commons.io.IOUtils; - +import org.apache.fop.util.bitmap.BitmapImageUtil; +import org.apache.fop.util.bitmap.MonochromeBitmapConverter; import org.apache.xmlgraphics.image.writer.ImageWriterUtil; import org.apache.xmlgraphics.util.WriterOutputStream; import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream; - -import org.apache.fop.util.bitmap.BitmapImageUtil; -import org.apache.fop.util.bitmap.MonochromeBitmapConverter; +import org.junit.Test; /** * Tests {@link BitmapImageUtil}. */ -public class BitmapImageUtilTestCase extends TestCase { +public class BitmapImageUtilTestCase { private static final boolean DEBUG = true; private static final boolean TEST_PIXELS = false; @@ -52,6 +51,7 @@ public class BitmapImageUtilTestCase extends TestCase { * Tests the convertTo* methods. * @throws Exception if an error occurs */ + @Test public void testConvertToMono() throws Exception { BufferedImage testImage = createTestImage(); saveAsPNG(testImage, "test-image"); diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java index 7b5995259..b16d72809 100644 --- a/test/java/org/apache/fop/util/ColorUtilTestCase.java +++ b/test/java/org/apache/fop/util/ColorUtilTestCase.java @@ -19,29 +19,33 @@ package org.apache.fop.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.awt.Color; import java.awt.color.ColorSpace; import java.net.URI; -import junit.framework.TestCase; - +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; import org.apache.xmlgraphics.java2d.color.NamedColorSpace; import org.apache.xmlgraphics.java2d.color.RenderingIntent; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; +import org.junit.Test; /** * Tests the ColorUtil class. */ -public class ColorUtilTestCase extends TestCase { +public class ColorUtilTestCase { /** * Test serialization to String. * @throws Exception if an error occurs */ + @Test public void testSerialization() throws Exception { Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); String s = ColorUtil.colorToString(col); @@ -59,6 +63,7 @@ public class ColorUtilTestCase extends TestCase { * Test deserialization from String. * @throws Exception if an error occurs */ + @Test public void testDeserialization() throws Exception { Color col = ColorUtil.parseColorString(null, "#ffff7f"); assertEquals(255, col.getRed()); @@ -77,6 +82,7 @@ public class ColorUtilTestCase extends TestCase { * Test equals(). * @throws Exception if an error occurs */ + @Test public void testEquals() throws Exception { Color col1 = ColorUtil.parseColorString(null, "#ff0000cc"); Color col2 = ColorUtil.parseColorString(null, "#ff0000cc"); @@ -97,6 +103,7 @@ public class ColorUtilTestCase extends TestCase { * Tests the rgb() function. * @throws Exception if an error occurs */ + @Test public void testRGB() throws Exception { FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent ua = fopFactory.newFOUserAgent(); @@ -114,6 +121,7 @@ public class ColorUtilTestCase extends TestCase { * Tests the fop-rgb-icc() function. * @throws Exception if an error occurs */ + @Test public void testRGBICC() throws Exception { FopFactory fopFactory = FopFactory.newInstance(); URI sRGBLoc = new URI( @@ -162,6 +170,7 @@ public class ColorUtilTestCase extends TestCase { * Tests the cmyk() function. * @throws Exception if an error occurs */ + @Test public void testCMYK() throws Exception { ColorWithAlternatives colActual; String colSpec; @@ -248,6 +257,7 @@ public class ColorUtilTestCase extends TestCase { * Tests color for the #Separation pseudo-colorspace. * @throws Exception if an error occurs */ + @Test public void testSeparationColor() throws Exception { ColorWithFallback colActual; String colSpec; @@ -281,6 +291,7 @@ public class ColorUtilTestCase extends TestCase { * Tests the fop-rgb-named-color() function. * @throws Exception if an error occurs */ + @Test public void testNamedColorProfile() throws Exception { FopFactory fopFactory = FopFactory.newInstance(); URI ncpLoc = new URI("file:test/resources/color/ncp-example.icc"); diff --git a/test/java/org/apache/fop/util/ElementListUtilsTestCase.java b/test/java/org/apache/fop/util/ElementListUtilsTestCase.java index bebad4422..701c1b299 100644 --- a/test/java/org/apache/fop/util/ElementListUtilsTestCase.java +++ b/test/java/org/apache/fop/util/ElementListUtilsTestCase.java @@ -19,6 +19,9 @@ package org.apache.fop.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.LinkedList; import org.apache.fop.layoutmgr.ElementListUtils; @@ -26,18 +29,18 @@ import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthGlue; import org.apache.fop.layoutmgr.KnuthPenalty; - -import junit.framework.TestCase; +import org.junit.Test; /** * Test class for ElementListUtils. */ -public class ElementListUtilsTestCase extends TestCase { +public class ElementListUtilsTestCase { /** * Tests ElementListUtils.removeLegalBreaks(). * @throws Exception if the test fails */ + @Test public void testRemoveElementPenalty1() throws Exception { LinkedList lst = new LinkedList(); lst.add(new KnuthBox(4000, null, false)); @@ -64,6 +67,7 @@ public class ElementListUtilsTestCase extends TestCase { * Tests ElementListUtils.removeLegalBreaks(). * @throws Exception if the test fails */ + @Test public void testRemoveElementPenalty2() throws Exception { LinkedList lst = new LinkedList(); lst.add(new KnuthBox(4000, null, false)); @@ -93,6 +97,7 @@ public class ElementListUtilsTestCase extends TestCase { * Tests ElementListUtils.removeLegalBreaksFromEnd(). * @throws Exception if the test fails */ + @Test public void testRemoveElementFromEndPenalty1() throws Exception { LinkedList lst = new LinkedList(); lst.add(new KnuthBox(4000, null, false)); @@ -119,6 +124,7 @@ public class ElementListUtilsTestCase extends TestCase { * Tests ElementListUtils.removeLegalBreaksFromEnd(). * @throws Exception if the test fails */ + @Test public void testRemoveElementFromEndPenalty2() throws Exception { LinkedList lst = new LinkedList(); lst.add(new KnuthBox(4000, null, false)); @@ -142,6 +148,4 @@ public class ElementListUtilsTestCase extends TestCase { assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(5)).getPenalty()); assertEquals(0, ((KnuthGlue)lst.get(6)).getWidth()); } - - }
\ No newline at end of file diff --git a/test/java/org/apache/fop/util/PDFNumberTestCase.java b/test/java/org/apache/fop/util/PDFNumberTestCase.java index 0f2fed138..73eb6fd77 100644 --- a/test/java/org/apache/fop/util/PDFNumberTestCase.java +++ b/test/java/org/apache/fop/util/PDFNumberTestCase.java @@ -19,19 +19,22 @@ package org.apache.fop.util; -import org.apache.fop.pdf.PDFNumber; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import org.apache.fop.pdf.PDFNumber; +import org.junit.Test; /** * This test tests PDFNumber's doubleOut() methods. */ -public class PDFNumberTestCase extends TestCase { +public class PDFNumberTestCase { /** * Tests PDFNumber.doubleOut(). * @throws Exception if the test fails */ + @Test public void testDoubleOut1() throws Exception { //Default is 6 decimal digits assertEquals("0", PDFNumber.doubleOut(0.0f)); @@ -51,6 +54,7 @@ public class PDFNumberTestCase extends TestCase { * Tests PDFNumber.doubleOut(). * @throws Exception if the test fails */ + @Test public void testDoubleOut2() throws Exception { //4 decimal digits in this case assertEquals("0", PDFNumber.doubleOut(0.0f, 4)); @@ -66,6 +70,7 @@ public class PDFNumberTestCase extends TestCase { * Tests PDFNumber.doubleOut(). * @throws Exception if the test fails */ + @Test public void testDoubleOut3() throws Exception { //0 decimal digits in this case assertEquals("0", PDFNumber.doubleOut(0.0f, 0)); @@ -79,6 +84,7 @@ public class PDFNumberTestCase extends TestCase { * Tests PDFNumber.doubleOut(). Special cases (former bugs). * @throws Exception if the test fails */ + @Test public void testDoubleOut4() throws Exception { double d = Double.parseDouble("5.7220458984375E-6"); assertEquals("0.000006", PDFNumber.doubleOut(d)); @@ -90,6 +96,7 @@ public class PDFNumberTestCase extends TestCase { * Tests PDFNumber.doubleOut(). Tests for wrong parameters. * @throws Exception if the test fails */ + @Test public void testDoubleOutWrongParameters() throws Exception { try { PDFNumber.doubleOut(0.1f, -1); diff --git a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java b/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java index bc201bfae..26cfa4406 100644 --- a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java +++ b/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java @@ -19,17 +19,21 @@ package org.apache.fop.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests for XMLResourceBundle. */ -public class XMLResourceBundleTestCase extends TestCase { +public class XMLResourceBundleTestCase { + @Test public void testWithValidFile() throws Exception { ResourceBundle bundle = XMLResourceBundle.getXMLBundle( getClass().getName(), Locale.ENGLISH, getClass().getClassLoader()); @@ -47,6 +51,7 @@ public class XMLResourceBundleTestCase extends TestCase { assertEquals("Untranslatable", bundleDE.getString("untranslatable")); } + @Test public void testWithInvalidFile() throws Exception { try { ResourceBundle bundle = XMLResourceBundle.getXMLBundle( diff --git a/test/java/org/apache/fop/util/XMLUtilTestCase.java b/test/java/org/apache/fop/util/XMLUtilTestCase.java index 3e86b978e..4c1b999e1 100644 --- a/test/java/org/apache/fop/util/XMLUtilTestCase.java +++ b/test/java/org/apache/fop/util/XMLUtilTestCase.java @@ -19,15 +19,19 @@ package org.apache.fop.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests {@link XMLUtil}. */ -public class XMLUtilTestCase extends TestCase { +public class XMLUtilTestCase { + @Test public void testLocaleToRFC3066() throws Exception { assertNull(XMLUtil.toRFC3066(null)); assertEquals("en", XMLUtil.toRFC3066(new Locale("en"))); @@ -35,6 +39,7 @@ public class XMLUtilTestCase extends TestCase { assertEquals("en-US", XMLUtil.toRFC3066(new Locale("EN", "us"))); } + @Test public void testRFC3066ToLocale() throws Exception { assertNull(XMLUtil.convertRFC3066ToLocale(null)); assertNull(XMLUtil.convertRFC3066ToLocale("")); diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java index 08ac886a2..0a0b6e11b 100644 --- a/test/java/org/apache/fop/visual/BatchDiffer.java +++ b/test/java/org/apache/fop/visual/BatchDiffer.java @@ -44,7 +44,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.writer.ImageWriterUtil; -import org.apache.fop.layoutengine.LayoutEngineTestSuite; +import org.apache.fop.layoutengine.LayoutEngineTestUtils; /** * This class is used to visually diff bitmap images created through various sources. @@ -164,7 +164,7 @@ public class BatchDiffer { IOFileFilter filter = new SuffixFileFilter(new String[] {".xml", ".fo"}); //Same filtering as in layout engine tests if (cfg.getChild("filter-disabled").getValueAsBoolean(true)) { - filter = LayoutEngineTestSuite.decorateWithDisabledList(filter); + filter = LayoutEngineTestUtils.decorateWithDisabledList(filter); } String manualFilter = cfg.getChild("manual-filter").getValue(null); if (manualFilter != null) { |