[FEATURE] PNG added to the url format
The old URL format http://server/plantuml/img/... is now relaced by http://server/plantuml/png/...
This commit is contained in:
@@ -34,7 +34,7 @@ public class ImgServlet extends UmlDiagramService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSource(String uri) {
|
public String getSource(String uri) {
|
||||||
String[] result = uri.split("/img/", 2);
|
String[] result = uri.split("/img/|/png/", 2);
|
||||||
if (result.length != 2) {
|
if (result.length != 2) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -52,6 +52,10 @@
|
|||||||
<servlet-name>plantumlservlet</servlet-name>
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
<url-pattern>/form</url-pattern>
|
<url-pattern>/form</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>imgservlet</servlet-name>
|
||||||
|
<url-pattern>/png/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>imgservlet</servlet-name>
|
<servlet-name>imgservlet</servlet-name>
|
||||||
<url-pattern>/img/*</url-pattern>
|
<url-pattern>/img/*</url-pattern>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<c:set var="hostpath" value="http://${pageContext.request.serverName}${contextroot}" />
|
<c:set var="hostpath" value="http://${pageContext.request.serverName}${contextroot}" />
|
||||||
</c:if>
|
</c:if>
|
||||||
<c:if test="${!empty encoded}">
|
<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="svgurl" value="${hostpath}/svg/${encoded}" />
|
||||||
<c:set var="txturl" value="${hostpath}/txt/${encoded}" />
|
<c:set var="txturl" value="${hostpath}/txt/${encoded}" />
|
||||||
<c:if test="${!empty mapneeded}">
|
<c:if test="${!empty mapneeded}">
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class TestForm extends WebappTestCase {
|
|||||||
WebForm forms[] = response.getForms();
|
WebForm forms[] = response.getForms();
|
||||||
assertEquals(2, forms.length);
|
assertEquals(2, forms.length);
|
||||||
assertEquals("url", forms[1].getParameterNames()[0]);
|
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
|
// Ensure the generated image is present
|
||||||
assertEquals(1, response.getImages().length);
|
assertEquals(1, response.getImages().length);
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class TestForm extends WebappTestCase {
|
|||||||
// Ensure the Text field is correct
|
// Ensure the Text field is correct
|
||||||
assertEquals("version", forms[0].getParameterValue("text"));
|
assertEquals("version", forms[0].getParameterValue("text"));
|
||||||
// Ensure the URL field is correct
|
// 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
|
// Ensure the image is present
|
||||||
assertEquals(1, response.getImages().length);
|
assertEquals(1, response.getImages().length);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ public class TestForm extends WebappTestCase {
|
|||||||
// Ensure the Text field is correct
|
// Ensure the Text field is correct
|
||||||
assertTrue(forms[0].getParameterValue("text").startsWith("@startditaa"));
|
assertTrue(forms[0].getParameterValue("text").startsWith("@startditaa"));
|
||||||
// Ensure the URL field is correct
|
// 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
|
// Ensure the image is present
|
||||||
assertEquals(1, response.getImages().length);
|
assertEquals(1, response.getImages().length);
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ public class TestForm extends WebappTestCase {
|
|||||||
// Ensure the Text field is filled
|
// Ensure the Text field is filled
|
||||||
assertEquals(forms[0].getParameterValue("text"), "@startuml\nBob -> Alice : hello\n@enduml");
|
assertEquals(forms[0].getParameterValue("text"), "@startuml\nBob -> Alice : hello\n@enduml");
|
||||||
// Ensure the URL field is filled
|
// 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
|
// Ensure the the image is present
|
||||||
assertEquals(1, response.getImages().length);
|
assertEquals(1, response.getImages().length);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class TestImage extends WebappTestCase {
|
|||||||
*/
|
*/
|
||||||
public void testVersionImage() throws Exception {
|
public void testVersionImage() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
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);
|
WebResponse response = conversation.getResource(request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
@@ -44,7 +44,7 @@ public class TestImage extends WebappTestCase {
|
|||||||
public void testDiagramHttpHeader() throws Exception {
|
public void testDiagramHttpHeader() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Bob -> Alice : hello
|
// Bob -> Alice : hello
|
||||||
WebRequest request = new GetMethodWebRequest(getServerUrl() + "img/" + TestUtils.SEQBOB);
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "png/" + TestUtils.SEQBOB);
|
||||||
WebResponse response = conversation.getResource(request);
|
WebResponse response = conversation.getResource(request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
@@ -63,4 +63,22 @@ public class TestImage extends WebappTestCase {
|
|||||||
; // Do nothing
|
; // 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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user