| version 1.1.1.1, 1999/09/09 16:29:07 |
version 1.1.1.2, 1999/09/09 16:30:15 |
|
|
|
|
| import junit.textui.*; |
import junit.textui.*; |
| |
|
| public class TestServlets extends TestCase { |
public class TestServlets extends TestCase { |
| |
private static final String PORT_STRING = "8081"; |
| |
|
| public TestServlets (String name) { |
public TestServlets (String name) { |
| |
|
|
|
|
|
| |
|
| public void run() |
public void run() |
| { |
{ |
| String[] args = new String[]{ "-p","8081" }; |
String[] args = new String[]{ "-p",PORT_STRING}; |
| System.out.println("Running webserver" |
System.out.println("Running webserver" |
| ); |
); |
| // static method needs no tear-down |
// static method needs no tear-down |
|
|
|
|
| * Exercise the PageSaver |
* Exercise the PageSaver |
| * Send a request and check the response contains the expected String. |
* Send a request and check the response contains the expected String. |
| */ |
*/ |
| public void testDisplaying() |
public void testDisplayingAKnownString() |
| { |
{ |
| |
|
| try { |
try { |
| |
String result = "My known input"; |
| |
PageSaver.save(result); |
| |
|
| String servletName = PageSaver.class.getName(); |
String servletName = PageSaver.class.getName(); |
| String actualResponse = getServerResponse("http://127.0.0.1:8081/servlet/"+servletName); |
String actualResponse = getServerResponse("http://127.0.0.1:"+PORT_STRING+"/servlet/"+servletName); |
| assert(actualResponse.equals("Empty")); |
assert(actualResponse.equals(result)); |
| } |
} |
| catch (Exception exception) { |
catch (Exception exception) { |
| exception.printStackTrace(); |
exception.printStackTrace(); |