Update of /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25149/src/net/sourceforge/jwebunit
Modified Files:
HttpUnitDialog.java WebTester.java WebTestCase.java
Log Message:
jew: patch 800660 integration - better support for submit button values
Index: WebTester.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** WebTester.java 16 Sep 2004 16:41:38 -0000 1.51
--- WebTester.java 20 Sep 2004 15:18:50 -0000 1.52
***************
*** 702,712 ****
*
* @param buttonName
! * @param expectedValue
*/
! public void assertSubmitButtonValue(String buttonName, String expectedValue) {
assertFormPresent();
! assertSubmitButtonPresent(buttonName);
! Assert.assertEquals(expectedValue, dialog
! .getSubmitButtonValue(buttonName));
}
--- 702,711 ----
*
* @param buttonName
! * @param buttonValue
*/
! public void assertSubmitButtonPresent(String buttonName, String buttonValue) {
assertFormPresent();
! Assert.assertTrue("Submit Button [" + buttonName + "] with value [" +
buttonValue + "] not found.",
! dialog.hasSubmitButton(buttonName, buttonValue));
}
***************
*** 1064,1067 ****
--- 1063,1079 ----
dialog.submit(buttonName);
}
+
+ /**
+ * Submit the form by pressing the named button with the given value (label).
+ * Useful if you have more than one submit button with same name.
+ *
+ * @author Dragos Manolescu
+ * @param buttonName
+ * @param buttonValue
+ */
+ public void submit(String buttonName, String buttonValue) {
+ assertSubmitButtonPresent(buttonName, buttonValue);
+ dialog.submit(buttonName, buttonValue);
+ }
/**
Index: HttpUnitDialog.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/HttpUnitDialog.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** HttpUnitDialog.java 14 Sep 2004 19:58:18 -0000 1.46
--- HttpUnitDialog.java 20 Sep 2004 15:18:49 -0000 1.47
***************
*** 452,455 ****
--- 452,465 ----
return getSubmitButton(buttonName).getValue().trim();
}
+
+ /**
+ * Return the HttpUnit SubmitButton with a given name and value.
+ * @param buttonName
+ * @pararm buttonValue
+ */
+ public SubmitButton getSubmitButton(String buttonName, String buttonValue) {
+ checkFormStateWithButton(buttonName);
+ return getForm().getSubmitButton(buttonName, buttonValue);
+ }
public boolean hasSubmitButton(String buttonName) {
***************
*** 462,465 ****
--- 472,484 ----
}
+ public boolean hasSubmitButton(String buttonName, String buttonValue) {
+ try {
+ return getSubmitButton(buttonName, buttonValue) != null;
+ } catch (UnableToSetFormException e) {
+ return false;
+ }
+
+ }
+
/**
* Return the HttpUnit Button with a given id.
***************
*** 651,654 ****
--- 670,693 ----
/**
+ * Submit the current form with the specifed submit button (by name and value).
See
+ * [EMAIL PROTECTED] #getForm}for an explanation of how the current form is
+ * established.
+ *
+ * @author Dragos Manolescu
+ * @param buttonName
+ * name of the button to use for submission.
+ * @param buttonValue
+ * value/label of the button to use for submission
+ */
+ public void submit(String buttonName, String buttonValue) {
+ try {
+ getForm().getSubmitButton(buttonName, buttonValue).click();
+ resp = wc.getCurrentPage();
+ } catch (Exception e) {
+ throw new RuntimeException(ExceptionUtility.stackTraceToString(e));
+ }
+ }
+
+ /**
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an explanation of
how
* the current form is established.
Index: WebTestCase.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTestCase.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** WebTestCase.java 16 Sep 2004 16:41:38 -0000 1.48
--- WebTestCase.java 20 Sep 2004 15:18:50 -0000 1.49
***************
*** 236,241 ****
}
! public void assertSubmitButtonValue(String buttonName, String expectedValue) {
! tester.assertSubmitButtonValue(buttonName, expectedValue);
}
--- 236,241 ----
}
! public void assertSubmitButtonPresent(String buttonName, String expectedValue) {
! tester.assertSubmitButtonPresent(buttonName, expectedValue);
}
***************
*** 378,381 ****
--- 378,385 ----
tester.submit(buttonName);
}
+
+ public void submit(String buttonName, String buttonValue) {
+ tester.submit(buttonName, buttonValue);
+ }
public void reset() {
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jwebunit-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development