Commit f0493c58 authored by Maxime Sinclair's avatar Maxime Sinclair
Browse files

[FEATURE] PNG added to the url format

The old URL format http://server/plantuml/img/... is now relaced by
http://server/plantuml/png/...
parent 0212f941
......@@ -34,7 +34,7 @@ public class ImgServlet extends UmlDiagramService {
@Override
public String getSource(String uri) {
String[] result = uri.split("/img/", 2);
String[] result = uri.split("/img/|/png/", 2);
if (result.length != 2) {
return "";
} else {
......
......@@ -52,6 +52,10 @@
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/form</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>imgservlet</servlet-name>
<url-pattern>/png/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>imgservlet</servlet-name>
<url-pattern>/img/*</url-pattern>
......
......@@ -7,7 +7,7 @@
<c:set var="hostpath" value="http://${pageContext.request.serverName}${contextroot}" />
</c:if>
<c:if test="${!empty encoded}">
<c:set var="imgurl" value="${hostpath}/img/${encoded}" />
<c:set var="imgurl" value="${hostpath}/png/${encoded}" />
<c:set var="svgurl" value="${hostpath}/svg/${encoded}" />
<c:set var="txturl" value="${hostpath}/txt/${encoded}" />
<c:if test="${!empty mapneeded}">
......
......@@ -20,7 +20,7 @@ public class TestForm extends WebappTestCase {
WebForm forms[] = response.getForms();
assertEquals(2, forms.length);
assertEquals("url", forms[1].getParameterNames()[0]);
assertTrue(forms[1].getParameterValue("url").endsWith("/img/" + TestUtils.SEQBOB));
assertTrue(forms[1].getParameterValue("url").endsWith("/png/" + TestUtils.SEQBOB));
// Ensure the generated image is present
assertEquals(1, response.getImages().length);
......@@ -43,7 +43,7 @@ public class TestForm extends WebappTestCase {
// Ensure the Text field is correct
assertEquals("version", forms[0].getParameterValue("text"));
// Ensure the URL field is correct
assertTrue(forms[1].getParameterValue("url").endsWith("/img/" + TestUtils.VERSION));
assertTrue(forms[1].getParameterValue("url").endsWith("/png/" + TestUtils.VERSION));
// Ensure the image is present
assertEquals(1, response.getImages().length);
}
......@@ -109,7 +109,7 @@ public class TestForm extends WebappTestCase {
// Ensure the Text field is correct
assertTrue(forms[0].getParameterValue("text").startsWith("@startditaa"));
// Ensure the URL field is correct
assertTrue(forms[1].getParameterValue("url").endsWith("/img/SoWkIImgISaiIKnKuDBIrRLJu798pKi12m00"));
assertTrue(forms[1].getParameterValue("url").endsWith("/png/SoWkIImgISaiIKnKuDBIrRLJu798pKi12m00"));
// Ensure the image is present
assertEquals(1, response.getImages().length);
}
......@@ -148,7 +148,7 @@ public class TestForm extends WebappTestCase {
// Ensure the Text field is filled
assertEquals(forms[0].getParameterValue("text"), "@startuml\nBob -> Alice : hello\n@enduml");
// Ensure the URL field is filled
assertEquals(forms[1].getParameterValue("url"), getServerUrl() + "img/" + TestUtils.SEQBOB);
assertEquals(forms[1].getParameterValue("url"), getServerUrl() + "png/" + TestUtils.SEQBOB);
// Ensure the the image is present
assertEquals(1, response.getImages().length);
}
......
......@@ -17,7 +17,7 @@ public class TestImage extends WebappTestCase {
*/
public void testVersionImage() throws Exception {
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(getServerUrl() + "img/" + TestUtils.VERSION);
WebRequest request = new GetMethodWebRequest(getServerUrl() + "png/" + TestUtils.VERSION);
WebResponse response = conversation.getResource(request);
// Analyze response
// Verifies the Content-Type header
......@@ -44,7 +44,7 @@ public class TestImage extends WebappTestCase {
public void testDiagramHttpHeader() throws Exception {
WebConversation conversation = new WebConversation();
// Bob -> Alice : hello
WebRequest request = new GetMethodWebRequest(getServerUrl() + "img/" + TestUtils.SEQBOB);
WebRequest request = new GetMethodWebRequest(getServerUrl() + "png/" + TestUtils.SEQBOB);
WebResponse response = conversation.getResource(request);
// Analyze response
// Verifies the Content-Type header
......@@ -63,4 +63,22 @@ public class TestImage extends WebappTestCase {
; // Do nothing
}
}
/**
* Verifies that the HTTP header of a diagram incites the browser to cache it.
*/
public void testOldImgURL() throws Exception {
WebConversation conversation = new WebConversation();
// Bob -> Alice : hello
WebRequest request = new GetMethodWebRequest(getServerUrl() + "img/" + TestUtils.SEQBOB);
WebResponse response = conversation.getResource(request);
// Analyze response
// Verifies the Content-Type header
assertEquals("Response content type is not PNG", "image/png", response.getContentType());
// Consume the response
InputStream responseStream = response.getInputStream();
while (responseStream.read() != -1) {
; // Do nothing
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment