[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit FormSubmitTest.java,1.15,1.16
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-03-14 22:18:29
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv9348/test/com/meterware/httpunit Modified Files: FormSubmitTest.java Log Message: Added support for changing the action of a form Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- FormSubmitTest.java 4 Mar 2002 02:10:50 -0000 1.15 +++ FormSubmitTest.java 14 Mar 2002 22:18:26 -0000 1.16 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -38,8 +38,8 @@ public static void main(String args[]) { junit.textui.TestRunner.run( suite() ); } - - + + public static Test suite() { return new TestSuite( FormSubmitTest.class ); } @@ -54,8 +54,8 @@ super.setUp(); _wc = new WebConversation(); } - - + + public void testEmbeddedEquals() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=\"age=x\" value=12>" + @@ -91,6 +91,9 @@ WebForm form = page.getForms()[0]; assertEquals( "Form method", "GET", form.getMethod() ); assertEquals( "Form action", "/ask", form.getAction() ); + + form.getScriptableObject().setAction( "/tell" ); + assertEquals( "Form action", "/tell", form.getAction() ); } @@ -105,7 +108,7 @@ assertEquals( getHostPath() + "/ask?age=23", request.getURL().toExternalForm() ); } - + public void testNoNameSubmitString() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text value=dontSend>" + @@ -130,7 +133,7 @@ assertEquals( "num detected submit buttons", 2, buttons.length ); } - + public void testDisabledSubmitButtonDetection() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -180,7 +183,7 @@ assertEquals( "num detected submit buttons", 2, buttons.length ); } - + public void testImageButtonDetection() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -193,7 +196,7 @@ assertEquals( "num detected submit buttons", 2, buttons.length ); } - + public void testImageButtonDefaultSubmit() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -205,7 +208,7 @@ assertEquals( "Query", getHostPath() + "/ask?age=12&update=name&update.x=0&update.y=0", request.getURL().toExternalForm() ); } - + public void testUnnamedImageButtonDefaultSubmit() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -217,7 +220,7 @@ assertEquals( getHostPath() + "/ask?age=12", request.getURL().toExternalForm() ); } - + public void testImageButtonPositionalSubmit() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -245,7 +248,7 @@ assertEquals( "submit button value", "age", buttons[0].getValue() ); } - + public void testSubmitButtonSelectionByName() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -262,7 +265,7 @@ assertEquals( "submit button value", "age", button.getValue() ); } - + public void testSubmitButtonSelectionByNameAndValue() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -281,7 +284,7 @@ assertEquals( "submit button value", "name", button.getValue() ); } - + public void testNamedButtonSubmitString() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -306,7 +309,7 @@ } } - + public void testUnnamedButtonSubmit() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -319,10 +322,10 @@ WebRequest request = form.getRequest(); fail( "Should not allow submit with unnamed button" ); } catch (IllegalRequestParameterException e) { - } + } } - + public void testForeignSubmitButtonDetection() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + |