fix: PDF servlet
Since the update of `bastik` the PDF servlet didn't work anymore. Problems: - No PDF UnitTest existed - Pom dependency `org.apache.xmlgraphics.batik-all` change nearly every dependency to `optional` starting with version `1.15`, hence some important dependencies like the SVG converter were missing - `DiagramResponse.CONTENT_TYPE` had no mime type value for PDF Changes: - add PDF UnitTest - remove `batik-all` dependency and only include the dependencies PlantUML requires for the PDF generation: * batik-dom * batik-svgrasterizer (includes batik-dom) * batik-svggen * fop - remove own `DiagramResponse.CONTENT_TYPE` mapping and use `FileFormat.getMimeType()`
This commit is contained in:
38
src/test/java/net/sourceforge/plantuml/servlet/TestPDF.java
Normal file
38
src/test/java/net/sourceforge/plantuml/servlet/TestPDF.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package net.sourceforge.plantuml.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.plantuml.servlet.utils.TestUtils;
|
||||
import net.sourceforge.plantuml.servlet.utils.WebappTestCase;
|
||||
|
||||
|
||||
public class TestPDF extends WebappTestCase {
|
||||
|
||||
/**
|
||||
* Verifies the generation of the PDF for the Bob -> Alice sample
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleSequenceDiagram() throws IOException {
|
||||
final URL url = new URL(getServerUrl() + "/pdf/" + TestUtils.SEQBOB);
|
||||
final HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||
// Analyze response
|
||||
// Verifies HTTP status code and the Content-Type
|
||||
Assertions.assertEquals(200, conn.getResponseCode(), "Bad HTTP status received");
|
||||
Assertions.assertEquals(
|
||||
"application/pdf",
|
||||
conn.getContentType().toLowerCase(),
|
||||
"Response content type is not PDF"
|
||||
);
|
||||
// Get the content and verify its size
|
||||
String diagram = getContentText(conn);
|
||||
int diagramLen = diagram.length();
|
||||
Assertions.assertTrue(diagramLen > 1500);
|
||||
Assertions.assertTrue(diagramLen < 2000);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user