diff --git a/pom.jdk8.xml b/pom.jdk8.xml
index ade7409..fe43e7c 100644
--- a/pom.jdk8.xml
+++ b/pom.jdk8.xml
@@ -74,7 +74,7 @@
5.9.3
1.9.3
- 4.9.0
+ 4.9.1
5.3.2
2.11.0
${jetty.version}
@@ -86,7 +86,7 @@
3.3.1
3.11.0
2.15.0
- 3.0.0
+ 3.1.0
3.3.2
3.1.1
3.1.1
@@ -108,11 +108,13 @@
net.sourceforge.plantuml
plantuml
${plantuml.version}
+ compile
org.webjars.npm
monaco-editor
${monaco-editor.version}
+ runtime
jakarta.servlet
@@ -153,31 +155,44 @@
org.scilab.forge
jlatexmath
${jlatexmath.version}
+ runtime
org.scilab.forge
jlatexmath-font-greek
${jlatexmath-font-greek.version}
+ runtime
org.scilab.forge
jlatexmath-font-cyrillic
${jlatexmath-font-cyrillic.version}
+ runtime
-
+
-
org.apache.xmlgraphics
- batik-all
+ batik-svgrasterizer
${batik-all.version}
- pom
+ runtime
+
+
+ org.apache.xmlgraphics
+ batik-svggen
+ ${batik-all.version}
+ runtime
-
org.apache.xmlgraphics
fop
${fop.version}
- pom
+ runtime
@@ -205,12 +220,6 @@
${selenium-webdrivermanager.version}
test
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
org.eclipse.jetty
jetty-server
diff --git a/pom.xml b/pom.xml
index c4a5d77..ef62d0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
5.9.3
1.9.3
- 4.9.0
+ 4.9.1
5.3.2
2.11.0
${jetty.version}
@@ -86,7 +86,7 @@
3.3.1
3.11.0
2.15.0
- 3.0.0
+ 3.1.0
3.3.2
3.1.1
3.1.1
@@ -108,11 +108,13 @@
net.sourceforge.plantuml
plantuml
${plantuml.version}
+ compile
org.webjars.npm
monaco-editor
${monaco-editor.version}
+ runtime
org.eclipse.jetty
@@ -131,31 +133,44 @@
org.scilab.forge
jlatexmath
${jlatexmath.version}
+ runtime
org.scilab.forge
jlatexmath-font-greek
${jlatexmath-font-greek.version}
+ runtime
org.scilab.forge
jlatexmath-font-cyrillic
${jlatexmath-font-cyrillic.version}
+ runtime
-
+
-
org.apache.xmlgraphics
- batik-all
+ batik-svgrasterizer
${batik-all.version}
- pom
+ runtime
+
+
+ org.apache.xmlgraphics
+ batik-svggen
+ ${batik-all.version}
+ runtime
-
org.apache.xmlgraphics
fop
${fop.version}
- pom
+ runtime
@@ -183,12 +198,6 @@
${selenium-webdrivermanager.version}
test
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
org.eclipse.jetty
jetty-server
diff --git a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java
index 7d541ec..f7d2cb1 100644
--- a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java
+++ b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java
@@ -29,10 +29,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -59,10 +56,6 @@ import net.sourceforge.plantuml.version.Version;
*/
public class DiagramResponse {
- /**
- * {@link FileFormat} to http content type mapping.
- */
- private static final Map CONTENT_TYPE;
/**
* X-Powered-By http header value included in every response by default.
*/
@@ -75,13 +68,6 @@ public class DiagramResponse {
if ("true".equalsIgnoreCase(System.getenv("ALLOW_PLANTUML_INCLUDE"))) {
OptionFlags.ALLOW_INCLUDE = true;
}
- CONTENT_TYPE = Collections.unmodifiableMap(new HashMap() {{
- put(FileFormat.PNG, "image/png");
- put(FileFormat.SVG, "image/svg+xml");
- put(FileFormat.EPS, "application/postscript");
- put(FileFormat.UTXT, "text/plain;charset=UTF-8");
- put(FileFormat.BASE64, "text/plain; charset=x-user-defined");
- }});
}
/**
@@ -282,7 +268,7 @@ public class DiagramResponse {
* @return response content type
*/
private String getContentType() {
- return CONTENT_TYPE.get(format);
+ return format.getMimeType();
}
}
diff --git a/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java
index e08796b..159d568 100644
--- a/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java
+++ b/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java
@@ -91,7 +91,6 @@ public class ProxyServlet extends HttpServlet {
try {
srcUrl = new URL(source);
} catch (MalformedURLException mue) {
- mue.printStackTrace();
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "URL malformed.");
return;
}
diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestPDF.java b/src/test/java/net/sourceforge/plantuml/servlet/TestPDF.java
new file mode 100644
index 0000000..baf9929
--- /dev/null
+++ b/src/test/java/net/sourceforge/plantuml/servlet/TestPDF.java
@@ -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);
+ }
+
+}