small FOP cleanup

This commit is contained in:
eugenp 2014-12-07 00:55:27 +02:00
parent c6cc4675c5
commit 229e262e54
2 changed files with 986 additions and 467 deletions

View File

@ -28,25 +28,43 @@ import org.junit.Test;
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);
@ -83,10 +101,9 @@ public class ApacheFOPHeroldTest {
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();
}
}

File diff suppressed because it is too large Load Diff