Skip to content

Commit

Permalink
small FOP cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenp committed Dec 6, 2014
1 parent c6cc467 commit 229e262
Show file tree
Hide file tree
Showing 2 changed files with 967 additions and 448 deletions.
45 changes: 31 additions & 14 deletions apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,43 @@
import org.w3c.dom.Document;

public class ApacheFOPHeroldTest {
private String[] inputUrls = { "http://inprogress.baeldung.com/?p=1430","http://www.baeldung.com/spring-events" };
private String[] inputUrls = {// @formatter:off
// "http://www.baeldung.com/2011/10/20/bootstraping-a-web-application-with-spring-3-1-and-java-based-configuration-part-1/",
// "http://www.baeldung.com/2011/10/25/building-a-restful-web-service-with-spring-3-1-and-java-based-configuration-part-2/",
"http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/",
// "http://www.baeldung.com/spring-security-basic-authentication",
// "http://www.baeldung.com/spring-security-digest-authentication",
//"http://www.baeldung.com/2011/11/20/basic-and-digest-authentication-for-a-restful-service-with-spring-security-3-1/",
//"http://www.baeldung.com/spring-httpmessageconverter-rest",
//"http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/",
//"http://www.baeldung.com/2011/11/13/rest-service-discoverability-with-spring-part-5/",
//"http://www.baeldung.com/2013/01/11/etags-for-rest-with-spring/",
//"http://www.baeldung.com/2012/01/18/rest-pagination-in-spring/",
//"http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/",
//"http://www.baeldung.com/rest-versioning",
//"http://www.baeldung.com/2013/01/18/testing-rest-with-multiple-mime-types/"
}; // @formatter:on

private String style1 = "src/test/resources/docbook-xsl/fo/docbook.xsl";
private String output_prefix = "src/test/resources/";
private String xmlFile = "src/test/resources/input.xml";

@Test
public void whenTransformFromHeroldToPDF_thenCorrect() throws Exception{
int len = inputUrls.length;
for (int i = 0; i < len; i++) {
fromHTMLTOXMLUsingHerold(inputUrls[i]);
final Document fo = fromXMLFileToFO();
fromFODocumentToPDF(fo, output_prefix + i + ".pdf");
}
public void whenTransformFromHeroldToPDF_thenCorrect() throws Exception {
final int len = inputUrls.length;
for (int i = 0; i < len; i++) {
fromHTMLTOXMLUsingHerold(inputUrls[i]);
final Document fo = fromXMLFileToFO();
fromFODocumentToPDF(fo, output_prefix + i + ".pdf");
}
}

private void fromHTMLTOXMLUsingHerold(String input) throws Exception {
// UTIL

private void fromHTMLTOXMLUsingHerold(final String input) throws Exception {
Script script;
TrafoScriptManager mgr = new TrafoScriptManager();
File profileFile = new File("src/test/resources/default.her");
final TrafoScriptManager mgr = new TrafoScriptManager();
final File profileFile = new File("src/test/resources/default.her");
script = mgr.parseScript(profileFile);
final DocBookTransformer transformer = new DocBookTransformer();
transformer.setScript(script);
Expand Down Expand Up @@ -83,10 +101,9 @@ private Transformer createTransformer(final String styleFile) throws Exception {
return transformer;
}

private InputStream getInputStream(String input) throws IOException {
URL url = new URL(input);
private InputStream getInputStream(final String input) throws IOException {
final URL url = new URL(input);
return url.openStream();
}

}

Loading

0 comments on commit 229e262

Please sign in to comment.