diff --git a/.classpath b/.classpath
index 7563761..a19d0e2 100644
--- a/.classpath
+++ b/.classpath
@@ -1,7 +1,9 @@
+
+
@@ -12,5 +14,6 @@
+
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 985afb9..d13cb29 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -3,6 +3,7 @@
+
diff --git a/test/lib/httpunit.jar b/test/lib/httpunit.jar
new file mode 100644
index 0000000..8656e8b
Binary files /dev/null and b/test/lib/httpunit.jar differ
diff --git a/test/lib/js-1.6R5.jar b/test/lib/js-1.6R5.jar
new file mode 100644
index 0000000..2b92650
Binary files /dev/null and b/test/lib/js-1.6R5.jar differ
diff --git a/test/lib/jtidy-4aug2000r7-dev.jar b/test/lib/jtidy-4aug2000r7-dev.jar
new file mode 100644
index 0000000..0eebfa6
Binary files /dev/null and b/test/lib/jtidy-4aug2000r7-dev.jar differ
diff --git a/test/lib/junit-3.8.1.jar b/test/lib/junit-3.8.1.jar
new file mode 100644
index 0000000..674d71e
Binary files /dev/null and b/test/lib/junit-3.8.1.jar differ
diff --git a/test/src/net/sourceforge/plantuml/servlet/TestForm.java b/test/src/net/sourceforge/plantuml/servlet/TestForm.java
new file mode 100644
index 0000000..f6c222d
--- /dev/null
+++ b/test/src/net/sourceforge/plantuml/servlet/TestForm.java
@@ -0,0 +1,70 @@
+package net.sourceforge.plantuml.servlet;
+
+import junit.framework.*;
+import com.meterware.httpunit.*;
+
+public class TestForm extends TestCase {
+
+ /**
+ * Verifies that the welcome page has exactly two form
+ * with the Bob --> Alice sample
+ */
+ public void testWelcomePage() throws Exception {
+ WebConversation conversation = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( "http://localhost/plantuml/" );
+ WebResponse response = tryGetResponse(conversation, request );
+
+ WebForm forms[] = response.getForms();
+ assertEquals( 2, forms.length );
+ assertEquals( "url", forms[1].getParameterNames()[0] );
+ FormControl urlInput = forms[1].getParameter("url").getControl();
+ assertEquals( "http://localhost:80/plantuml/img/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000",
+ forms[1].getParameterValue("url"));
+ assertEquals( "INPUT", urlInput.getTagName());
+ // Ensure the generated image is present
+ assertEquals( 1, response.getImages().length);
+
+ }
+
+ /**
+ * Verifies that when the UML text is empty, no image is generated
+ */
+ public void testEmptyText() throws Exception {
+ WebConversation conversation = new WebConversation();
+ // Fill the form and submit it
+ WebRequest request = new GetMethodWebRequest( "http://localhost/plantuml/form" );
+ WebResponse response = tryGetResponse(conversation, request );
+ WebForm formUMLText = response.getForms()[0];
+ formUMLText.setParameter("text", "");
+ response = tryGetResponse( conversation, formUMLText.getRequest());
+ // Analyze response
+ WebForm forms[] = response.getForms();
+ assertEquals( 2, forms.length );
+ // Ensure the Text field is empty
+ assertNull( forms[0].getParameterValue("text"));
+ // Ensure the URL field is empty
+ assertTrue( forms[1].getParameterValue("url").isEmpty());
+ // Ensure there is no image
+ assertEquals( 0, response.getImages().length);
+ }
+
+ /**
+ * try getting a response for the given Conversation and Request
+ * show an error message if a 404 error appears
+ * @param conversation - the conversation to use
+ * @param request
+ * @return the response
+ * @throws an Exception if getting the response fails
+ */
+ public WebResponse tryGetResponse(WebConversation conversation, WebRequest request) throws Exception {
+ WebResponse response=null;
+ try {
+ response = conversation.getResponse( request );
+ } catch (HttpNotFoundException nfe) {
+ System.err.println("The URL '"+request.getURL()+"' is not active any more");
+ throw nfe;
+ }
+ return response;
+ }
+
+}