KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > web > WizardTest


1 package com.tonbeller.wcf.web;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.xml.transform.TransformerException JavaDoc;
6
7 import org.jaxen.JaxenException;
8 import org.jaxen.dom.DOMXPath;
9 import org.w3c.dom.Document JavaDoc;
10 import org.xml.sax.SAXException JavaDoc;
11
12 import com.meterware.httpunit.GetMethodWebRequest;
13
14 public class WizardTest extends HttpUnitTestCase {
15   String JavaDoc formId = "form01";
16   public WizardTest(String JavaDoc arg0) {
17     super(arg0);
18   }
19   
20   private void check(String JavaDoc name) throws JaxenException, IOException JavaDoc, SAXException JavaDoc, TransformerException JavaDoc {
21     utils.check(name, "filter.xsl", formId);
22   }
23   
24   public void testStatusLine() throws Exception JavaDoc {
25     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/wizard.jsp"));
26     check("wizard-01");
27     
28     // Fehlermeldung erzeugen
29
utils.submitButton(formId, "wizform01.next");
30     check("wizard-02");
31     
32     // AB eintragen und weiter
33
utils.getForm(formId).setParameter("stringID", "AB");
34     utils.submitButton(formId, "wizform01.next");
35     check("wizard-03");
36     
37     // Fehlermeldung wg ungueltiger Zahl erzeugen
38
utils.getForm(formId).setParameter("intID", "xx");
39     utils.submitButton(formId, "wizform02.next");
40     check("wizard-04");
41
42     // Korrekte Zahl eingeben und weiter
43
utils.getForm(formId).setParameter("intID", "123");
44     utils.submitButton(formId, "wizform02.next");
45     check("wizard-05");
46     
47     // Fertigstellen
48
utils.submitButton(formId, "wizform03.finish");
49     Document JavaDoc dom = wc.getCurrentPage().getDOM();
50     DOMXPath dx = new DOMXPath("//body[@id='index']");
51     assertEquals("index page expected", 1, dx.selectNodes(dom).size());
52   }
53
54 }
55
Popular Tags