1 package com.tonbeller.wcf.web; 2 import junit.framework.TestCase; 3 4 import com.meterware.httpunit.GetMethodWebRequest; 5 import com.meterware.httpunit.WebConversation; 6 import com.meterware.httpunit.WebRequest; 7 import com.meterware.httpunit.WebResponse; 8 import com.tonbeller.tbutils.httpunit.HttpUnitUtils; 9 10 public class RolesTest extends TestCase { 11 12 String servletUrl; 13 WebConversation wc; 14 HttpUnitUtils utils; 15 16 public RolesTest(String arg0) { 17 super(arg0); 18 } 19 20 void check(String name) throws Exception { 21 WebResponse wr = wc.getCurrentPage(); 22 utils.saveHTML(name); 23 utils.saveXML(name, "filter.xsl", "form01", wr.getDOM()); 24 assertTrue("Files " + name + " differ!", utils.equalsXML(name)); 25 } 26 27 public void testToolbar() throws Exception { 28 wc.setAuthorization("tomcat", "tomcat"); 29 WebRequest req = new GetMethodWebRequest(servletUrl + "/secure/toolbdemo.jsp"); 30 wc.sendRequest(req); 31 check("roles-01"); 32 } 33 34 public void testFormfields() throws Exception { 35 wc.setAuthorization("tomcat", "tomcat"); 36 WebRequest req = new GetMethodWebRequest(servletUrl + "/secure/formdemo.jsp"); 37 wc.sendRequest(req); 38 check("roles-02"); 39 } 40 41 protected void setUp() throws Exception { 42 servletUrl = System.getProperty("httpunit.url"); 43 if (servletUrl == null) 44 throw new RuntimeException ("missing JVM Parameter httpunit.url, e.g. -Dhttpunit.url=http://localhost:8080/appname"); 45 wc = new WebConversation(); 46 wc.setHeaderField("accept-language", "de-DE"); 47 utils = new HttpUnitUtils(wc); 48 } 49 50 } 51 | Popular Tags |