KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.tonbeller.wcf.web;
2
3 import com.meterware.httpunit.GetMethodWebRequest;
4 import com.meterware.httpunit.WebForm;
5 import com.meterware.httpunit.WebResponse;
6
7 /**
8  * tests integration of JSF with WCF
9  *
10  * @author av
11  */

12 public class JsfInteropTest extends HttpUnitTestCase {
13
14   public JsfInteropTest(String JavaDoc arg0) {
15     super(arg0);
16   }
17
18   /** juint complains if this file is empty */
19   public void testNothing() {
20   }
21   
22   /**
23    * run form tests in faces context. This runs a JSF page
24    * that contains a WCF form and a WCF table
25    */

26   public void dont_testJsfForm() throws Exception JavaDoc {
27     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/jsfgreeting.faces"));
28
29     // add text to jsf form
30
WebForm wf = wc.getCurrentPage().getFormWithID("form01");
31     wf = wc.getCurrentPage().getFormWithID("form01");
32     wf.setParameter("form01:userNo", "12345");
33     // add text to wcf form
34
wf.setParameter("string", "abcdefg");
35     // submit form via table: check all table rows
36
utils.submitCell("form01", "jsfTableComp", 1, 0, 0);
37     
38     wf = wc.getCurrentPage().getFormWithID("form01");
39     String JavaDoc jsfValue = wf.getParameterValue("form01:userNo");
40     assertEquals("12345", jsfValue);
41     String JavaDoc wcfValue = wf.getParameterValue("string");
42     assertEquals("abcdefg", wcfValue);
43     utils.assertChecked("form01", "jsfTableComp", 2, 0, 0, true);
44
45     // remember this form
46
wf = wc.getCurrentPage().getFormWithID("form01");
47
48     // forward to non JSF page
49
wf.submit(wf.getSubmitButtonWithID("button02"));
50     WebResponse wr = wc.getCurrentPage();
51     assertEquals("WCF Testpage", wr.getTitle());
52
53     // forward to JSF page
54
wf.submit(wf.getSubmitButtonWithID("button03"));
55     wr = wc.getCurrentPage();
56     assertEquals("Guess The Number", wr.getTitle());
57   }
58
59 }
60
Popular Tags