mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-12-22 16:58:54 +00:00
Refactoring of the welcome diagram.
This commit is contained in:
parent
c98015f417
commit
5c149977fb
@ -5,7 +5,15 @@
|
|||||||
<servlet-name>plantumlservlet</servlet-name>
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.PlantUmlServlet</servlet-class>
|
<servlet-class>net.sourceforge.plantuml.servlet.PlantUmlServlet</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>welcome</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.Welcome</servlet-class>
|
||||||
|
</servlet>
|
||||||
<!-- Patterns of the servlet -->
|
<!-- Patterns of the servlet -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>welcome</servlet-name>
|
||||||
|
<url-pattern>/welcome</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
<url-pattern>/uml/*</url-pattern>
|
<url-pattern>/uml/*</url-pattern>
|
||||||
@ -27,7 +35,7 @@
|
|||||||
<url-pattern>/proxy/*</url-pattern>
|
<url-pattern>/proxy/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>index.jsp</welcome-file>
|
<welcome-file>welcome</welcome-file>
|
||||||
</welcome-file-list>
|
</welcome-file-list>
|
||||||
<error-page>
|
<error-page>
|
||||||
<exception-type>java.lang.Throwable</exception-type>
|
<exception-type>java.lang.Throwable</exception-type>
|
||||||
|
@ -14,10 +14,12 @@ if (encodedAttribute != null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object decodedAttribute = request.getAttribute("net.sourceforge.plantuml.servlet.decoded");
|
Object decodedAttribute = request.getAttribute("net.sourceforge.plantuml.servlet.decoded");
|
||||||
if (decodedAttribute == null) {
|
/*if (decodedAttribute == null) {
|
||||||
umltext = "Bob -> Alice : hello";
|
umltext = "Bob -> Alice : hello";
|
||||||
imgurl = host + contextRoot + "/img/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000";
|
imgurl = host + contextRoot + "/img/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000";
|
||||||
} else {
|
} else { */
|
||||||
|
|
||||||
|
if (decodedAttribute != null) {
|
||||||
umltext = decodedAttribute.toString();
|
umltext = decodedAttribute.toString();
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
|
30
src/net/sourceforge/plantuml/servlet/Welcome.java
Normal file
30
src/net/sourceforge/plantuml/servlet/Welcome.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Welcome servlet of the webapp.
|
||||||
|
* Displays the sample Bob and Alice sequence diagram.
|
||||||
|
*/
|
||||||
|
public class Welcome extends HttpServlet {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws IOException, ServletException {
|
||||||
|
|
||||||
|
// set the sample
|
||||||
|
request.setAttribute("net.sourceforge.plantuml.servlet.decoded", "Bob -> Alice : hello");
|
||||||
|
request.setAttribute("net.sourceforge.plantuml.servlet.encoded", "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
||||||
|
|
||||||
|
// forward to index.jsp
|
||||||
|
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
|
||||||
|
dispatcher.forward(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -73,7 +73,7 @@ public class TestForm extends TestCase {
|
|||||||
public void testEmptyUrl() throws Exception {
|
public void testEmptyUrl() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Fill the form and submit it
|
// Fill the form and submit it
|
||||||
WebRequest request = new GetMethodWebRequest( "http://localhost/plantuml/" );
|
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl() );
|
||||||
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
||||||
WebForm formUrl = response.getForms()[1];
|
WebForm formUrl = response.getForms()[1];
|
||||||
formUrl.setParameter("url", "");
|
formUrl.setParameter("url", "");
|
||||||
@ -82,11 +82,11 @@ public class TestForm extends TestCase {
|
|||||||
WebForm forms[] = response.getForms();
|
WebForm forms[] = response.getForms();
|
||||||
assertEquals( 2, forms.length );
|
assertEquals( 2, forms.length );
|
||||||
// Ensure the Text field is empty
|
// Ensure the Text field is empty
|
||||||
assertTrue( forms[0].getParameterValue("text").startsWith("Bob"));
|
assertNull( forms[0].getParameterValue("text"));
|
||||||
// Ensure the URL field is correct
|
// Ensure the URL field is empty
|
||||||
assertTrue( forms[1].getParameterValue("url").endsWith("/img/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000"));
|
assertTrue( forms[1].getParameterValue("url").isEmpty());
|
||||||
// Ensure the image is present
|
// Ensure there is no image
|
||||||
assertEquals( 1, response.getImages().length);
|
assertEquals( 0, response.getImages().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user