You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2011/10/18 10:33:40 UTC
svn commit: r1185530 [11/14] - in
/xmlgraphics/fop/branches/Temp_ComplexScripts: ./
src/documentation/content/xdocs/trunk/ src/foschema/
src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/
src/java/org/apache/fop/cli/ src/java/org/apache/fop/fo...
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java Tue Oct 18 08:33:32 2011
@@ -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));
- }
-
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java Tue Oct 18 08:33:32 2011
@@ -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 {
}
Added: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java?rev=1185530&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java (added)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java Tue Oct 18 08:33:32 2011
@@ -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;
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java Tue Oct 18 08:33:32 2011
@@ -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.intermediat
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();
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/ResultCheck.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/ResultCheck.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/ResultCheck.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/layoutengine/ResultCheck.java Tue Oct 18 08:33:32 2011
@@ -40,9 +40,7 @@ public class ResultCheck implements Layo
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 Layo
}
- /** @see java.lang.Object#toString() */
+ @Override
public String toString() {
return "Property: " + property;
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java Tue Oct 18 08:33:32 2011
@@ -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 FileIDGeneratorTes
}
/** 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 FileIDGeneratorTes
}
/** 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 FileIDGeneratorTes
/**
* 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"));
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java Tue Oct 18 08:33:32 2011
@@ -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 ex
}
}
+ @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 ex
runEncryptionTests();
}
+ @Test
public void test128bit() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setVersion(2)
@@ -306,6 +312,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void testDisableRev2Permissions() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setPermissions(-64)
@@ -320,6 +327,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void testDisableRev3Permissions() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setVersion(2)
@@ -337,6 +345,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void test128bitDisableSomePermissions() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setVersion(2)
@@ -355,6 +364,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void testDifferentPasswords() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setOwnerEntry("D11C233C65E9DC872E858ABBD8B62198771167ADCE7AB8DC7AE0A1A7E21A1E25")
@@ -367,6 +377,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void testNoOwnerPassword() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setOwnerEntry("5163AAF3EE74C76D7C223593A84C8702FEA8AA4493E4933FF5B5A5BBB20AE4BB")
@@ -379,6 +390,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void test128bitDisableSomePermissionsDifferentPasswords() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setVersion(2)
@@ -399,6 +411,7 @@ public class PDFEncryptionJCETestCase ex
runEncryptionTests();
}
+ @Test
public void test128bitNoPermissionNoOwnerPassword() throws IOException {
EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester()
.setVersion(2)
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java Tue Oct 18 08:33:32 2011
@@ -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
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFObjectTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFObjectTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFObjectTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/pdf/PDFObjectTestCase.java Tue Oct 18 08:33:32 2011
@@ -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 T
* Tests PDF object references.
* @throws Exception if an error occurs
*/
+ @Test
public void testReference() throws Exception {
PDFDictionary dict = new PDFDictionary();
dict.setObjectNumber(7);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/AbstractRenderingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/AbstractRenderingTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/AbstractRenderingTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/AbstractRenderingTestCase.java Tue Oct 18 08:33:32 2011
@@ -31,11 +31,8 @@ import javax.xml.transform.TransformerFa
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>();
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/RendererFactoryTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/RendererFactoryTest.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/RendererFactoryTest.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/RendererFactoryTest.java Tue Oct 18 08:33:32 2011
@@ -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.intermediat
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
}
}
+ @Test
public void testRendererLevel() throws Exception {
FopFactory fopFactory = FopFactory.newInstance();
RendererFactory factory = fopFactory.getRendererFactory();
@@ -98,6 +101,7 @@ public class RendererFactoryTest extends
}
}
+ @Test
public void testFOEventHandlerLevel() throws Exception {
FopFactory fopFactory = FopFactory.newInstance();
RendererFactory factory = fopFactory.getRendererFactory();
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/AFPTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/AFPTestSuite.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/AFPTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/AFPTestSuite.java Tue Oct 18 08:33:32 2011
@@ -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;
- }
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/NoOperationTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/NoOperationTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/NoOperationTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/afp/NoOperationTestCase.java Tue Oct 18 08:33:32 2011
@@ -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
* 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
return field;
}
} while (field != null);
- Assert.fail("Structured field not found: " + Integer.toHexString(typeID));
+ fail("Structured field not found: " + Integer.toHexString(typeID));
return null;
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTest.java Tue Oct 18 08:33:32 2011
@@ -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
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
}
/** 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
}
/** 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
}
/** 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
}
/** 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
}
/** 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
}
/** 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
}
/** Units must be specified. */
+ @Test
public void testBoundariesFail() {
try {
new PageBoundaries(TEST_AREA_SIZE, "0", null, null);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/extensions/prepress/PageScaleTest.java Tue Oct 18 08:33:32 2011
@@ -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 TestC
}
/** 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 TestC
}
/** Scale must not contain units. */
+ @Test
public void testScaleFail() {
try {
PageScale.getScale("0.5mm 0.5cm");
@@ -69,6 +60,7 @@ public class PageScaleTest extends TestC
}
/** @{code null} is returned when scale is unspecified. */
+ @Test
public void testScaleNull() {
Point2D res = PageScale.getScale(null);
assertNull("Result should be null", res);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java Tue Oct 18 08:33:32 2011
@@ -28,16 +28,14 @@ import javax.xml.transform.TransformerFa
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 Abs
/**
* Main constructor
- * @param name the name of the test case
*/
- protected BasePDFTestCase(String name) {
- super(name);
+ protected BasePDFTestCase() {
init();
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java Tue Oct 18 08:33:32 2011
@@ -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 ext
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 ext
* 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 ext
* 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 ext
* 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 ext
* 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);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java Tue Oct 18 08:33:32 2011
@@ -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.schema
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 extend
assertEquals(cal2.getTime(), info.getModDate());
}
+ @Test
public void testXMPUpdate() throws Exception {
PDFDocument doc = new PDFDocument("SuperFOP");
PDFInfo info = doc.getInfo();
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java Tue Oct 18 08:33:32 2011
@@ -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
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java Tue Oct 18 08:33:32 2011
@@ -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
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
* 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
* @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
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java Tue Oct 18 08:33:32 2011
@@ -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 PDFRendererConfiguratorTest
*
* @throws Exception if an error occurs
*/
+ @Test
public void testRoundUp() throws Exception {
runTest("roundUp", 55, 56);
}
@@ -76,6 +79,7 @@ public class PDFRendererConfiguratorTest
*
* @throws Exception if an error occurs
*/
+ @Test
public void testRoundDown() throws Exception {
runTest("roundDown", 67, 64);
}
@@ -85,6 +89,7 @@ public class PDFRendererConfiguratorTest
*
* @throws Exception if an error occurs
*/
+ @Test
public void testBelow40() throws Exception {
runTest("below40", 32, 40);
}
@@ -94,6 +99,7 @@ public class PDFRendererConfiguratorTest
*
* @throws Exception if an error occurs
*/
+ @Test
public void testAbove128() throws Exception {
runTest("above128", 233, 128);
}
@@ -103,11 +109,12 @@ public class PDFRendererConfiguratorTest
*
* @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();
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java Tue Oct 18 08:33:32 2011
@@ -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 ext
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 ext
* 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 {
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java Tue Oct 18 08:33:32 2011
@@ -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;
- }
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java Tue Oct 18 08:33:32 2011
@@ -19,6 +19,8 @@
package org.apache.fop.render.ps;
+import static org.junit.Assert.assertEquals;
+
import java.io.File;
import java.io.IOException;
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java Tue Oct 18 08:33:32 2011
@@ -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.eve
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 exten
* Tests JPEG handling.
* @throws Exception if an error occurs
*/
+ @Test
public void testJPEGImageLevel3() throws Exception {
innerTestJPEGImage(3);
}
@@ -54,6 +56,7 @@ public class ImageHandlingTestCase exten
* Tests JPEG handling.
* @throws Exception if an error occurs
*/
+ @Test
public void testJPEGImageLevel2() throws Exception {
innerTestJPEGImage(2);
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/PSTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/PSTestSuite.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/PSTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/PSTestSuite.java Tue Oct 18 08:33:32 2011
@@ -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;
- }
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java Tue Oct 18 08:33:32 2011
@@ -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.eve
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 ResourceOptimizationTestCas
* Tests resource optimization.
* @throws Exception if an error occurs
*/
+ @Test
public void testResourceOptimization() throws Exception {
FOUserAgent ua = fopFactory.newFOUserAgent();
PSDocumentHandler handler = new PSDocumentHandler();
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java Tue Oct 18 08:33:32 2011
@@ -27,18 +27,18 @@ import org.apache.fop.render.rtf.rtflib.
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);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java Tue Oct 18 08:33:32 2011
@@ -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;
- }
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java Tue Oct 18 08:33:32 2011
@@ -19,14 +19,15 @@
package org.apache.fop.text.linebreak;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
/**
* JUnit test case for the LineBreakStatus class
*/
-public class LineBreakStatusTest extends TestCase {
+public class LineBreakStatusTest {
/*
* These symbols are used to indicate the break action returned
@@ -37,27 +38,9 @@ public class LineBreakStatusTest extends
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
* 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");
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java Tue Oct 18 08:33:32 2011
@@ -19,22 +19,18 @@
package org.apache.fop.text.linebreak;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
/**
* TODO add javadoc
*
*
*/
-public class LineBreakUtilsTest extends TestCase {
-
- /**
- * @param name
- */
- public LineBreakUtilsTest(String name) {
- super(name);
- }
+public class LineBreakUtilsTest {
+ @Test
public void testLineBreakProperty() {
assertEquals(LineBreakUtils.getLineBreakProperty('A'), LineBreakUtils.LINE_BREAK_PROPERTY_AL);
assertEquals(LineBreakUtils.getLineBreakProperty('1'), LineBreakUtils.LINE_BREAK_PROPERTY_NU);
@@ -44,6 +40,7 @@ public class LineBreakUtilsTest extends
assertEquals(LineBreakUtils.getLineBreakProperty('\u1F7E'), 0);
}
+ @Test
public void testLineBreakPair() {
assertEquals(
LineBreakUtils.getLineBreakPairProperty(
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/BorderPropsTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/BorderPropsTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/BorderPropsTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/BorderPropsTestCase.java Tue Oct 18 08:33:32 2011
@@ -19,25 +19,27 @@
package org.apache.fop.traits;
-import java.awt.Color;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.awt.Color;
import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives;
import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace;
import org.apache.fop.fo.Constants;
import org.apache.fop.util.ColorUtil;
+import org.junit.Test;
/**
* Tests the BorderProps class.
*/
-public class BorderPropsTestCase extends TestCase {
+public class BorderPropsTestCase {
/**
* Test serialization and deserialization to/from String.
* @throws Exception if an error occurs
*/
+ @Test
public void testSerialization() throws Exception {
Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f);
//Normalize: Avoid false alarms due to color conversion (rounding)
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/MinOptMaxTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/MinOptMaxTest.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/MinOptMaxTest.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/traits/MinOptMaxTest.java Tue Oct 18 08:33:32 2011
@@ -19,20 +19,27 @@
package org.apache.fop.traits;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
/**
* Tests the {@link MinOptMaxTest} class.
*/
-public class MinOptMaxTest extends TestCase {
+public class MinOptMaxTest {
/**
* Tests that the constant <code>MinOptMax.ZERO</code> is really zero.
*/
+ @Test
public void testZero() {
assertEquals(MinOptMax.getInstance(0), MinOptMax.ZERO);
}
+ @Test
public void testNewStiffMinOptMax() {
MinOptMax value = MinOptMax.getInstance(1);
assertTrue(value.isStiff());
@@ -41,6 +48,7 @@ public class MinOptMaxTest extends TestC
assertEquals(1, value.getMax());
}
+ @Test
public void testNewMinOptMax() {
MinOptMax value = MinOptMax.getInstance(1, 2, 3);
assertTrue(value.isElastic());
@@ -52,6 +60,7 @@ public class MinOptMaxTest extends TestC
/**
* Test that it is possible to create stiff instances with the normal factory method.
*/
+ @Test
public void testNewMinOptMaxStiff() {
MinOptMax value = MinOptMax.getInstance(1, 1, 1);
assertTrue(value.isStiff());
@@ -60,6 +69,7 @@ public class MinOptMaxTest extends TestC
assertEquals(1, value.getMax());
}
+ @Test
public void testNewMinOptMaxMinGreaterOpt() {
try {
MinOptMax.getInstance(1, 0, 2);
@@ -69,6 +79,7 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testNewMinOptMaxMaxSmallerOpt() {
try {
MinOptMax.getInstance(0, 1, 0);
@@ -78,18 +89,21 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testShrinkablility() {
assertEquals(0, MinOptMax.getInstance(1).getShrink());
assertEquals(1, MinOptMax.getInstance(1, 2, 2).getShrink());
assertEquals(2, MinOptMax.getInstance(1, 3, 3).getShrink());
}
+ @Test
public void testStrechablilty() {
assertEquals(0, MinOptMax.getInstance(1).getStretch());
assertEquals(1, MinOptMax.getInstance(1, 1, 2).getStretch());
assertEquals(2, MinOptMax.getInstance(1, 1, 3).getStretch());
}
+ @Test
public void testPlus() {
assertEquals(MinOptMax.ZERO,
MinOptMax.ZERO.plus(MinOptMax.ZERO));
@@ -100,6 +114,7 @@ public class MinOptMaxTest extends TestC
assertEquals(MinOptMax.getInstance(4, 5, 6), MinOptMax.getInstance(1, 2, 3).plus(3));
}
+ @Test
public void testMinus() {
assertEquals(MinOptMax.ZERO,
MinOptMax.ZERO.minus(MinOptMax.ZERO));
@@ -110,6 +125,7 @@ public class MinOptMaxTest extends TestC
assertEquals(MinOptMax.getInstance(1, 2, 3), MinOptMax.getInstance(5, 6, 7).minus(4));
}
+ @Test
public void testMinusFail1() {
try {
MinOptMax.ZERO.minus(MinOptMax.getInstance(1, 2, 3));
@@ -119,6 +135,7 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testMinusFail2() {
try {
MinOptMax.getInstance(1, 2, 3).minus(MinOptMax.getInstance(1, 3, 3));
@@ -128,6 +145,7 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testMinusFail3() {
try {
MinOptMax.ZERO.minus(MinOptMax.getInstance(1, 1, 2));
@@ -137,6 +155,7 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testMinusFail4() {
try {
MinOptMax.getInstance(1, 2, 3).minus(MinOptMax.getInstance(1, 1, 3));
@@ -146,12 +165,14 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testMult() {
assertEquals(MinOptMax.ZERO, MinOptMax.ZERO.mult(0));
assertEquals(MinOptMax.getInstance(1, 2, 3), MinOptMax.getInstance(1, 2, 3).mult(1));
assertEquals(MinOptMax.getInstance(2, 4, 6), MinOptMax.getInstance(1, 2, 3).mult(2));
}
+ @Test
public void testMultFail() {
try {
MinOptMax.getInstance(1, 2, 3).mult(-1);
@@ -161,12 +182,14 @@ public class MinOptMaxTest extends TestC
}
}
+ @Test
public void testNonZero() {
assertFalse(MinOptMax.ZERO.isNonZero());
assertTrue(MinOptMax.getInstance(1).isNonZero());
assertTrue(MinOptMax.getInstance(1, 2, 3).isNonZero());
}
+ @Test
public void testExtendMinimum() {
assertEquals(MinOptMax.getInstance(1, 1, 1),
MinOptMax.ZERO.extendMinimum(1));
@@ -180,6 +203,7 @@ public class MinOptMaxTest extends TestC
MinOptMax.getInstance(1, 2, 3).extendMinimum(4));
}
+ @Test
public void testEquals() {
MinOptMax number = MinOptMax.getInstance(1, 3, 5);
assertEquals(number, number);
@@ -191,6 +215,7 @@ public class MinOptMaxTest extends TestC
assertFalse(number.equals(new Integer(1)));
}
+ @Test
public void testHashCode() {
MinOptMax number = MinOptMax.getInstance(1, 2, 3);
assertEquals(number.hashCode(), number.hashCode());
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java Tue Oct 18 08:33:32 2011
@@ -19,20 +19,21 @@
package org.apache.fop.util;
-import java.util.Map;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-import org.xml.sax.helpers.LocatorImpl;
+import java.util.Map;
import org.apache.fop.events.model.EventSeverity;
import org.apache.fop.util.text.AdvancedMessageFormat;
+import org.junit.Test;
+import org.xml.sax.helpers.LocatorImpl;
/**
* Tests for EventFormatter.
*/
-public class AdvancedMessageFormatTestCase extends TestCase {
+public class AdvancedMessageFormatTestCase {
+ @Test
public void testFormatting() throws Exception {
String msg;
AdvancedMessageFormat format;
@@ -74,6 +75,7 @@ public class AdvancedMessageFormatTestCa
assertEquals("Multi-conditional: case1: value1", msg);
}
+ @Test
public void testObjectFormatting() throws Exception {
String msg;
AdvancedMessageFormat format;
@@ -92,6 +94,7 @@ public class AdvancedMessageFormatTestCa
assertEquals("Here\'s a Locator: 12:7", msg);
}
+ @Test
public void testIfFormatting() throws Exception {
String msg;
AdvancedMessageFormat format;
@@ -139,6 +142,7 @@ public class AdvancedMessageFormatTestCa
assertEquals("You are very, very nice!", msg);
}
+ @Test
public void testEqualsFormatting() throws Exception {
String msg;
AdvancedMessageFormat format;
@@ -157,6 +161,7 @@ public class AdvancedMessageFormatTestCa
assertEquals("Error\nSome explanation!", msg);
}
+ @Test
public void testChoiceFormatting() throws Exception {
String msg;
AdvancedMessageFormat format;
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java Tue Oct 18 08:33:32 2011
@@ -19,6 +19,8 @@
package org.apache.fop.util;
+import static org.junit.Assert.assertEquals;
+
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
@@ -29,21 +31,18 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
-import junit.framework.TestCase;
-
import org.apache.commons.io.IOUtils;
-
+import org.apache.fop.util.bitmap.BitmapImageUtil;
+import org.apache.fop.util.bitmap.MonochromeBitmapConverter;
import org.apache.xmlgraphics.image.writer.ImageWriterUtil;
import org.apache.xmlgraphics.util.WriterOutputStream;
import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream;
-
-import org.apache.fop.util.bitmap.BitmapImageUtil;
-import org.apache.fop.util.bitmap.MonochromeBitmapConverter;
+import org.junit.Test;
/**
* Tests {@link BitmapImageUtil}.
*/
-public class BitmapImageUtilTestCase extends TestCase {
+public class BitmapImageUtilTestCase {
private static final boolean DEBUG = true;
private static final boolean TEST_PIXELS = false;
@@ -52,6 +51,7 @@ public class BitmapImageUtilTestCase ext
* Tests the convertTo* methods.
* @throws Exception if an error occurs
*/
+ @Test
public void testConvertToMono() throws Exception {
BufferedImage testImage = createTestImage();
saveAsPNG(testImage, "test-image");
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org