Fix integration test (#1607)
* upgrade to spring boot 1.5.2 * add full update to REST API * modify ratings controller * upgrade herold * fix integration test * fix integration test
This commit is contained in:
parent
6bf3659fb5
commit
f5437fefaa
|
@ -101,9 +101,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dbdoclet</groupId>
|
<groupId>org.dbdoclet</groupId>
|
||||||
<artifactId>herold</artifactId>
|
<artifactId>herold</artifactId>
|
||||||
<version>6.1.0</version>
|
<version>8.0.4</version>
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${basedir}/src/test/resources/jars/herold.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -19,21 +19,21 @@ import javax.xml.transform.stream.StreamSource;
|
||||||
import org.apache.fop.apps.Fop;
|
import org.apache.fop.apps.Fop;
|
||||||
import org.apache.fop.apps.FopFactory;
|
import org.apache.fop.apps.FopFactory;
|
||||||
import org.apache.xmlgraphics.util.MimeConstants;
|
import org.apache.xmlgraphics.util.MimeConstants;
|
||||||
import org.dbdoclet.trafo.html.docbook.DocBookTransformer;
|
import org.dbdoclet.trafo.html.docbook.HtmlDocBookTrafo;
|
||||||
import org.dbdoclet.trafo.script.Script;
|
import org.dbdoclet.trafo.script.Script;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.tidy.Tidy;
|
import org.w3c.tidy.Tidy;
|
||||||
|
|
||||||
public class ApacheFOPConvertHTMLIntegrationTest {
|
public class ApacheFOPConvertHTMLIntegrationTest {
|
||||||
private String inputFile = "src/test/resources/input.html";
|
private final String inputFile = "src/test/resources/input.html";
|
||||||
private String style = "src/test/resources/xhtml2fo.xsl";
|
private final String style = "src/test/resources/xhtml2fo.xsl";
|
||||||
private String style1 = "src/test/resources/docbook-xsl/fo/docbook.xsl";
|
private final String style1 = "src/test/resources/docbook-xsl/fo/docbook.xsl";
|
||||||
private String output_jtidy = "src/test/resources/output_jtidy.pdf";
|
private final String output_jtidy = "src/test/resources/output_jtidy.pdf";
|
||||||
private String output_html2fo = "src/test/resources/output_html2fo.pdf";
|
private final String output_html2fo = "src/test/resources/output_html2fo.pdf";
|
||||||
private String output_herold = "src/test/resources/output_herold.pdf";
|
private final String output_herold = "src/test/resources/output_herold.pdf";
|
||||||
private String foFile = "src/test/resources/input.fo";
|
private final String foFile = "src/test/resources/input.fo";
|
||||||
private String xmlFile = "src/test/resources/input.xml";
|
private final String xmlFile = "src/test/resources/input.xml";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenTransformHTMLToPDFUsingJTidy_thenCorrect() throws Exception {
|
public void whenTransformHTMLToPDFUsingJTidy_thenCorrect() throws Exception {
|
||||||
|
@ -114,8 +114,9 @@ public class ApacheFOPConvertHTMLIntegrationTest {
|
||||||
|
|
||||||
private void fromHTMLTOXMLUsingHerold() throws Exception {
|
private void fromHTMLTOXMLUsingHerold() throws Exception {
|
||||||
final Script script = new Script();
|
final Script script = new Script();
|
||||||
final DocBookTransformer transformer = new DocBookTransformer();
|
final HtmlDocBookTrafo transformer = new HtmlDocBookTrafo();
|
||||||
transformer.setScript(script);
|
transformer.setInputStream(new FileInputStream(inputFile));
|
||||||
transformer.convert(new FileInputStream(inputFile), new FileOutputStream(xmlFile));
|
transformer.setOutputStream(new FileOutputStream(xmlFile));
|
||||||
|
transformer.transform(script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
|
@ -25,19 +26,15 @@ import org.apache.fop.apps.Fop;
|
||||||
import org.apache.fop.apps.FopFactory;
|
import org.apache.fop.apps.FopFactory;
|
||||||
import org.apache.xmlgraphics.util.MimeConstants;
|
import org.apache.xmlgraphics.util.MimeConstants;
|
||||||
import org.dbdoclet.trafo.TrafoScriptManager;
|
import org.dbdoclet.trafo.TrafoScriptManager;
|
||||||
import org.dbdoclet.trafo.html.docbook.DocBookTransformer;
|
import org.dbdoclet.trafo.html.docbook.HtmlDocBookTrafo;
|
||||||
import org.dbdoclet.trafo.script.Script;
|
import org.dbdoclet.trafo.script.Script;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
public class ApacheFOPHeroldLiveTest {
|
public class ApacheFOPHeroldLiveTest {
|
||||||
private String[] inputUrls = {// @formatter:off
|
private final 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/spring-security-basic-authentication",
|
||||||
"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/spring-security-digest-authentication"
|
||||||
"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/spring-httpmessageconverter-rest",
|
||||||
//"http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/",
|
//"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/2011/11/13/rest-service-discoverability-with-spring-part-5/",
|
||||||
|
@ -49,10 +46,10 @@ public class ApacheFOPHeroldLiveTest {
|
||||||
//"http://www.baeldung.com/2013/01/18/testing-rest-with-multiple-mime-types/"
|
//"http://www.baeldung.com/2013/01/18/testing-rest-with-multiple-mime-types/"
|
||||||
}; // @formatter:on
|
}; // @formatter:on
|
||||||
|
|
||||||
private String style_file = "src/test/resources/docbook-xsl/fo/docbook.xsl";
|
private final String style_file = "src/test/resources/docbook-xsl/fo/docbook.xsl";
|
||||||
private String output_file = "src/test/resources/final_output.pdf";
|
private final String output_file = "src/test/resources/final_output.pdf";
|
||||||
private String xmlInput = "src/test/resources/input.xml";
|
private final String xmlInput = "src/test/resources/input.xml";
|
||||||
private String xmlOutput = "src/test/resources/output.xml";
|
private final String xmlOutput = "src/test/resources/output.xml";
|
||||||
|
|
||||||
// tests
|
// tests
|
||||||
|
|
||||||
|
@ -75,10 +72,11 @@ public class ApacheFOPHeroldLiveTest {
|
||||||
final TrafoScriptManager mgr = new TrafoScriptManager();
|
final TrafoScriptManager mgr = new TrafoScriptManager();
|
||||||
final File profileFile = new File("src/test/resources/default.her");
|
final File profileFile = new File("src/test/resources/default.her");
|
||||||
script = mgr.parseScript(profileFile);
|
script = mgr.parseScript(profileFile);
|
||||||
final DocBookTransformer transformer = new DocBookTransformer();
|
final HtmlDocBookTrafo transformer = new HtmlDocBookTrafo();
|
||||||
transformer.setScript(script);
|
transformer.setInputStream(getInputStream(input));
|
||||||
|
transformer.setOutputStream(new FileOutputStream(xmlInput, append));
|
||||||
|
|
||||||
transformer.convert(getInputStream(input), new FileOutputStream(xmlInput, append));
|
transformer.transform(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Document fromXMLFileToFO() throws Exception {
|
private Document fromXMLFileToFO() throws Exception {
|
||||||
|
@ -112,7 +110,9 @@ public class ApacheFOPHeroldLiveTest {
|
||||||
|
|
||||||
private InputStream getInputStream(final String input) throws IOException {
|
private InputStream getInputStream(final String input) throws IOException {
|
||||||
final URL url = new URL(input);
|
final URL url = new URL(input);
|
||||||
return url.openStream();
|
final HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
|
||||||
|
httpcon.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||||
|
return httpcon.getInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixXML(final String input, final String output) throws IOException {
|
private void fixXML(final String input, final String output) throws IOException {
|
||||||
|
@ -127,7 +127,7 @@ public class ApacheFOPHeroldLiveTest {
|
||||||
|
|
||||||
if (line.contains("info>")) {
|
if (line.contains("info>")) {
|
||||||
writer.write(line.replace("info>", "section>"));
|
writer.write(line.replace("info>", "section>"));
|
||||||
} else if (!((line.startsWith("<?xml") || line.startsWith("<article") || line.startsWith("</article")) && count > 4)) {
|
} else if (!((line.startsWith("<?xml") || line.startsWith("<article") || line.startsWith("</article")) && (count > 4))) {
|
||||||
writer.write(line.replaceAll("xml:id=\"", "xml:id=\"" + count));
|
writer.write(line.replaceAll("xml:id=\"", "xml:id=\"" + count));
|
||||||
}
|
}
|
||||||
writer.write("\n");
|
writer.write("\n");
|
||||||
|
|
Binary file not shown.
|
@ -4,7 +4,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("com.baeldung.autowire.sample")
|
@ComponentScan("org.baeldung.sample")
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,31 +10,31 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.neo4j</groupId>
|
<groupId>org.neo4j</groupId>
|
||||||
<artifactId>neo4j</artifactId>
|
<artifactId>neo4j</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>${neo4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.neo4j</groupId>
|
<groupId>org.neo4j</groupId>
|
||||||
<artifactId>neo4j-ogm-core</artifactId>
|
<artifactId>neo4j-ogm-core</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>${neo4j-ogm.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.neo4j</groupId>
|
<groupId>org.neo4j</groupId>
|
||||||
<artifactId>neo4j-ogm-embedded-driver</artifactId>
|
<artifactId>neo4j-ogm-embedded-driver</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>${neo4j-ogm.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.neo4j.driver</groupId>
|
<groupId>org.neo4j.driver</groupId>
|
||||||
<artifactId>neo4j-java-driver</artifactId>
|
<artifactId>neo4j-java-driver</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>${neo4j-java-driver.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-neo4j</artifactId>
|
<artifactId>spring-data-neo4j</artifactId>
|
||||||
<version>4.2.0.RELEASE</version>
|
<version>${spring-data-neo4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.neo4j</groupId>
|
<groupId>org.neo4j</groupId>
|
||||||
<artifactId>neo4j-ogm-test</artifactId>
|
<artifactId>neo4j-ogm-test</artifactId>
|
||||||
<version>${neo4j-ogm-test.version}</version>
|
<version>${neo4j-ogm.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -160,12 +160,13 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
|
<neo4j-java-driver.version>1.1.1</neo4j-java-driver.version>
|
||||||
<neo4j.version>3.1.0</neo4j.version>
|
<neo4j.version>3.1.0</neo4j.version>
|
||||||
<spring-data-neo4j.version>4.1.6.RELEASE</spring-data-neo4j.version>
|
<spring-data-neo4j.version>4.1.6.RELEASE</spring-data-neo4j.version>
|
||||||
<jackson-jsog.version>1.1</jackson-jsog.version>
|
<jackson-jsog.version>1.1</jackson-jsog.version>
|
||||||
<spring-boot.version>1.4.3.RELEASE</spring-boot.version>
|
<spring-boot.version>1.4.3.RELEASE</spring-boot.version>
|
||||||
<spring-test.version>4.3.5.RELEASE</spring-test.version>
|
<spring-test.version>4.3.5.RELEASE</spring-test.version>
|
||||||
<neo4j-ogm-test.version>2.1.1</neo4j-ogm-test.version>
|
<neo4j-ogm.version>2.1.1</neo4j-ogm.version>
|
||||||
|
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,22 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.data.neo4j.config.Neo4jConfiguration;
|
||||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@ComponentScan(basePackages = { "com.baeldung.spring.data.neo4j.services" })
|
@ComponentScan(basePackages = { "com.baeldung.spring.data.neo4j.services" })
|
||||||
@Configuration
|
|
||||||
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repostory")
|
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repostory")
|
||||||
@Profile({ "embedded", "test" })
|
@Profile({ "embedded", "test" })
|
||||||
public class MovieDatabaseNeo4jTestConfiguration {
|
public class MovieDatabaseNeo4jTestConfiguration extends Neo4jConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public org.neo4j.ogm.config.Configuration getConfiguration() {
|
public org.neo4j.ogm.config.Configuration getConfiguration() {
|
||||||
org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
|
final org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
|
||||||
config.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver");
|
config.driverConfiguration()
|
||||||
|
.setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver");
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,4 +28,5 @@ public class MovieDatabaseNeo4jTestConfiguration {
|
||||||
public SessionFactory getSessionFactory() {
|
public SessionFactory getSessionFactory() {
|
||||||
return new SessionFactory(getConfiguration(), "com.baeldung.spring.data.neo4j.domain");
|
return new SessionFactory(getConfiguration(), "com.baeldung.spring.data.neo4j.domain");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue