diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-12-03 13:21:06 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-12-03 13:21:06 +0000 |
commit | c2470b27315d12923454c795141732f23b203b48 (patch) | |
tree | df232f3eec4743a424a39274c50e0fe15cbc149a /test/java/org/apache/fop/memory | |
parent | ded24c942b053a82b60d462028449da1fc316b6e (diff) | |
download | xmlgraphics-fop-c2470b27315d12923454c795141732f23b203b48.tar.gz xmlgraphics-fop-c2470b27315d12923454c795141732f23b203b48.zip |
Added a possibility to rerun the whole run a defined number of times to test for possible issues outside a single rendering run.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@600521 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org/apache/fop/memory')
-rw-r--r-- | test/java/org/apache/fop/memory/MemoryEater.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/test/java/org/apache/fop/memory/MemoryEater.java b/test/java/org/apache/fop/memory/MemoryEater.java index ed8f46441..ae51f2c27 100644 --- a/test/java/org/apache/fop/memory/MemoryEater.java +++ b/test/java/org/apache/fop/memory/MemoryEater.java @@ -23,15 +23,19 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.net.MalformedURLException; import javax.xml.transform.Result; import javax.xml.transform.Source; +import javax.xml.transform.Templates; import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamSource; import org.apache.commons.io.output.NullOutputStream; + import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; @@ -41,17 +45,23 @@ import org.apache.fop.apps.MimeConstants; */ public class MemoryEater { - private static void eatMemory(File foFile, int replicatorRepeats) throws Exception { - - SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - FopFactory fopFactory = FopFactory.newInstance(); - + private SAXTransformerFactory tFactory + = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); + private FopFactory fopFactory = FopFactory.newInstance(); + private Templates replicatorTemplates; + + public MemoryEater() throws TransformerConfigurationException, MalformedURLException { File xsltFile = new File("test/xsl/fo-replicator.xsl"); Source xslt = new StreamSource(xsltFile); + replicatorTemplates = tFactory.newTemplates(xslt); + fopFactory.setBaseURL("C:/Dev/FOP/testing/xslt-1.0-book"); + } + + private void eatMemory(File foFile, int replicatorRepeats) throws Exception { Source src = new StreamSource(foFile); - Transformer transformer = tFactory.newTransformer(xslt); + Transformer transformer = replicatorTemplates.newTransformer(); transformer.setParameter("repeats", new Integer(replicatorRepeats)); OutputStream out = new NullOutputStream(); //write to /dev/nul @@ -78,13 +88,17 @@ public class MemoryEater { boolean doPrompt = true; //true if you want a chance to start the monitoring console try { int replicatorRepeats = 2; + int runRepeats = 1; if (args.length > 0) { replicatorRepeats = Integer.parseInt(args[0]); } + if (args.length > 1) { + runRepeats = Integer.parseInt(args[1]); + } File testFile = new File("examples/fo/basic/readme.fo"); System.out.println("MemoryEater! About to replicate the test file " - + replicatorRepeats + " times..."); + + replicatorRepeats + " times and run it " + runRepeats + " times..."); if (doPrompt) { prompt(); } @@ -92,7 +106,10 @@ public class MemoryEater { System.out.println("Processing..."); long start = System.currentTimeMillis(); - eatMemory(testFile, replicatorRepeats); + MemoryEater app = new MemoryEater(); + for (int i = 0; i < runRepeats; i++) { + app.eatMemory(testFile, replicatorRepeats); + } long duration = System.currentTimeMillis() - start; System.out.println("Success! Job took " + duration + " ms"); |