org.apache.cactus.sample.servlet.unit
public class: TestClientServerSynchronization [javadoc |
source]
java.lang.Object
junit.framework.TestCase
org.apache.cactus.internal.AbstractCactusTestCase
org.apache.cactus.ServletTestCase
org.apache.cactus.sample.servlet.unit.TestClientServerSynchronization
All Implemented Interfaces:
CactusTestCase
Verify that the Cactus client side only reads the test result *after* the
test is finished (ie after the test result has been saved in the application
scope). This JUnit test need to be the first one to be run. Otherwise, the
test result might be that of the previous test and not the current test one,
thus proving nothing !!
- version:
$ - Id: TestClientServerSynchronization.java 238816 2004-02-29 16:36:46Z vmassol $
| Method from org.apache.cactus.sample.servlet.unit.TestClientServerSynchronization Detail: |
public void testLongProcess() throws Exception {
ServletOutputStream os = response.getOutputStream();
os.print("< html >< head >< Long Process >< /head >< body >");
os.flush();
// do some processing that takes a while ...
Thread.sleep(3000);
os.println("Some data< /body >< /html >");
}
Verify that the test result can be returned correctly even when the
logic in the method to test takes a long time and thus it verifies that
the test result is only returned after it has been written in the
application scope on the server side. |
public void testLotsOfData() throws Exception {
ServletOutputStream os = response.getOutputStream();
os.println("< html >< head >Lots of Data< /head >< body >");
os.flush();
for (int i = 0; i < 5000; i++)
{
os.println("< p >Lots and lots of data here");
}
os.println("< /body >< /html >");
}
Verify that when big amount of data is returned by the servlet output
stream, it does not io-block. |