Patch by Mehdi Houshmand, applied with minor cosmetics and error fixes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1178747 13f79535-47bb-0310-9956-ffa450edef68pull/24/head
@@ -252,7 +252,7 @@ list of possible build targets. | |||
<echo message="${jce.message}"/> | |||
<available property="jdk14.present" classname="java.lang.CharSequence"/> | |||
<fail message="${Name} requires at least Java 1.4!" unless="jdk14.present"/> | |||
<available property="junit.present" classname="junit.framework.TestCase" classpathref="libs-tools-build-classpath"/> | |||
<available property="junit.present" classname="org.junit.Test" classpathref="libs-tools-build-classpath"/> | |||
<condition property="junit.message" value="JUnit Support PRESENT"> | |||
<equals arg1="${junit.present}" arg2="true"/> | |||
</condition> |
@@ -60,6 +60,9 @@ | |||
documents. Example: the fix of marks layering will be such a case when it's done. | |||
--> | |||
<release version="FOP Trunk" date="TBD"> | |||
<action context="Code" dev="VH" type="add" fixes-bug="51928" due-to="Mehdi Houshmand"> | |||
Upgraded all tests to JUnit 4. | |||
</action> | |||
<action context="Fonts" dev="PH" type="fix" fixes-bug="48696"> | |||
Bugfix for color model in IOCA IDE structure parameter for 4- and 8-bit grayscale images. | |||
Revision 4. |
@@ -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 | |||
@@ -33,13 +36,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(); |
@@ -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); |
@@ -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 | |||
@@ -43,17 +46,11 @@ 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"); |
@@ -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; | |||
} | |||
} |
@@ -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(); | |||
} |
@@ -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(); | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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, |
@@ -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"); |
@@ -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); |
@@ -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; | |||
} | |||
} |
@@ -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"); | |||
@@ -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; | |||
} | |||
} |
@@ -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(); | |||
@@ -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; | |||
} | |||
} |
@@ -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(); |
@@ -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; |
@@ -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(); |
@@ -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) { |
@@ -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(); | |||
@@ -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 |
@@ -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; |
@@ -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; |
@@ -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()); |
@@ -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; | |||
} | |||
} |
@@ -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; |
@@ -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(); |
@@ -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(); |
@@ -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 | |||
@@ -46,13 +44,6 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { | |||
protected Log log = LogFactory.getLog(BaseUserConfigTestCase.class); | |||
/** | |||
* @see junit.framework.TestCase#TestCase(String) | |||
*/ | |||
public BaseUserConfigTestCase(String name) { | |||
super(name); | |||
} | |||
/** | |||
* @see org.apache.fop.render.pdf.BasePDFTestCase#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(); |
@@ -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")); |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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"; | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
@@ -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(); | |||
@@ -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; | |||
@@ -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; | |||
} | |||
} |
@@ -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; |
@@ -19,6 +19,8 @@ | |||
package org.apache.fop.fo.flow.table; | |||
import static org.junit.Assert.fail; | |||
import org.apache.fop.fo.ValidationException; | |||
/** |
@@ -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"); | |||
} |
@@ -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"); | |||
} |
@@ -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); |
@@ -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"); | |||
} |
@@ -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()); | |||
} |
@@ -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")); |
@@ -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); |
@@ -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); | |||
} | |||
} | |||
} |
@@ -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; | |||
@@ -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; | |||
@@ -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); | |||
} | |||
} |
@@ -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"; | |||
@@ -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 { | |||
@@ -218,6 +218,13 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { | |||
protected abstract void parseAndRender(Source src, OutputStream out) | |||
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 |
@@ -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,24 +33,38 @@ 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 | |||
@@ -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; | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
}); | |||
} | |||
} |
@@ -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); | |||
} |
@@ -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,8 +45,20 @@ 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 | |||
@@ -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; | |||
} | |||
} | |||
} |
@@ -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 |
@@ -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; | |||
} | |||
} |
@@ -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)); | |||
} | |||
} |
@@ -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 { | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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(); | |||
@@ -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; | |||
} |
@@ -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")); | |||
} | |||
@@ -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) |
@@ -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 |
@@ -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); |
@@ -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>(); | |||
@@ -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(); |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
@@ -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); |
@@ -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); |
@@ -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(); | |||
} | |||
@@ -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); |
@@ -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(); |
@@ -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 |
@@ -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 |
@@ -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(); |
@@ -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 { |
@@ -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; | |||
} | |||
} |
@@ -19,6 +19,8 @@ | |||
package org.apache.fop.render.ps; | |||
import static org.junit.Assert.assertEquals; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -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); | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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(); |
@@ -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); |
@@ -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; | |||
} | |||
} |
@@ -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 | |||
@@ -36,28 +37,10 @@ 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"); | |||