[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript ScriptingTest.java,1.47,1.48
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-12-13 12:57:15
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv16278/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
Added support for Document.cookie
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- ScriptingTest.java 29 Nov 2002 15:23:42 -0000 1.47
+++ ScriptingTest.java 13 Dec 2002 12:57:11 -0000 1.48
@@ -29,7 +29,7 @@
/**
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class ScriptingTest extends HttpUnitTest {
@@ -540,5 +540,31 @@
assertNull( "Alert should have been removed", wc.getNextAlert() );
}
+
+ public void testSimpleSetCookie() throws Exception {
+ defineResource( "OnCommand.html", "<html><head></head>\n" +
+ "<body onLoad='document.cookie=\"color=red;path=/\"'>\n" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "Cookie 'color'", "red", wc.getCookieValue( "color" ) );
+ }
+
+
+ public void testReadCookies() throws Exception {
+ defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
+ "function viewCookies() { \n" +
+ " alert( 'cookies: ' + document.cookie );\n" +
+ "}" +
+ "</script></head>\n" +
+ "<body onLoad='viewCookies()'>\n" +
+ "</body></html>" );
+ addResourceHeader( "OnCommand.html", "Set-Cookie: age=12");
+ WebConversation wc = new WebConversation();
+ wc.addCookie( "height", "tall" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "Alert message 1", "cookies: age=12;height=tall", wc.popNextAlert() );
+ assertNull( "Alert should have been removed", wc.getNextAlert() );
+ }
}
|