01: package org.directwebremoting.selenium;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05: import org.openqa.selenium.server.SeleniumServer;
06:
07: import com.thoughtworks.selenium.SeleneseTestCase;
08:
09: /**
10: * @author Joe Walker [joe at getahead dot ltd dot uk]
11: */
12: public class DhtmlTest extends SeleneseTestCase {
13: private static final String[] ONE_TO_FIVE = new String[] { "One",
14: "Two", "Three", "Four", "Five" };
15: private static final String[] EMPTY = new String[0];
16:
17: /* (non-Javadoc)
18: * @see com.thoughtworks.selenium.SeleneseTestCase#setUp()
19: */
20: @Override
21: public void setUp() throws Exception {
22: // default max is 200k; zero is infinite
23: System.setProperty(
24: "org.mortbay.http.HttpRequest.maxFormContentSize", "0");
25:
26: SeleniumServer server = new SeleniumServer();
27: server.start();
28:
29: super .setUp();
30: }
31:
32: /**
33: * @throws Exception
34: */
35: public void testNew() throws Exception {
36: selenium.open("http://localhost:8080/dwr-test/test/");
37: selenium.click("link=dhtml.html");
38: selenium.waitForPageToLoad("30000");
39:
40: verifyEquals(selenium.getSelectOptions("removeOptions"),
41: ONE_TO_FIVE);
42: selenium.click("//button[@onclick='testRemoveOptions();']");
43: verifyEquals(selenium.getSelectOptions("removeOptions"), EMPTY);
44:
45: verifyEquals(selenium.getSelectOptions("testAddOptionsBasic"),
46: EMPTY);
47: selenium.click("//button[@onclick='testAddOptionsBasic();']");
48: verifyEquals(selenium.getSelectOptions("testAddOptionsBasic"),
49: ONE_TO_FIVE);
50:
51: verifyEquals(
52: selenium.getSelectOptions("testAddOptionsObject1"),
53: EMPTY);
54: selenium.click("//button[@onclick='testAddOptionsObject1();']");
55: verifyEquals(
56: selenium.getSelectOptions("testAddOptionsObject1"),
57: ONE_TO_FIVE);
58:
59: verifyEquals(
60: selenium.getSelectOptions("testAddOptionsObject2"),
61: EMPTY);
62: selenium.click("//button[@onclick='testAddOptionsObject2();']");
63: verifyEquals(
64: selenium.getSelectOptions("testAddOptionsObject2"),
65: ONE_TO_FIVE);
66: }
67:
68: /**
69: * The log stream
70: */
71: protected static final Log log = LogFactory.getLog(DhtmlTest.class);
72: }
|