Update of /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5552/src/net/sourceforge/jwebunit
Modified Files:
Tag: JACOBIE
HttpUnitDialog.java WebTester.java
CompositeJWebUnitDialog.java IJWebUnitDialog.java
Log Message:
more changes
Index: WebTester.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.47.4.1
retrieving revision 1.47.4.2
diff -C2 -d -r1.47.4.1 -r1.47.4.2
*** WebTester.java 2 Dec 2004 20:17:41 -0000 1.47.4.1
--- WebTester.java 11 Feb 2005 21:27:12 -0000 1.47.4.2
***************
*** 24,30 ****
*/
public class WebTester {
! private IJWebUnitDialog dialog;
! private TestContext context = new TestContext();
public WebTester() {
--- 24,30 ----
*/
public class WebTester {
! private IJWebUnitDialog dialog = null;
! private TestContext context = null;
public WebTester() {
***************
*** 64,69 ****
--- 64,85 ----
*/
public TestContext getTestContext() {
+ if(context == null) {
+ //defaulting to the original implementation.
+ context = new TestContext();
+ }
return context;
}
+
+ /**
+ * Allows setting an external test context class that might be extended
from TestContext.
+ * Example: setTestContext(new CompanyATestContext());
+ *
+ * CompanyATestContext extends TestContext.
+ *
+ * @param aTestContext
+ */
+ public void setTestContext(TestContext aTestContext) {
+ context = aTestContext;
+ }
/**
***************
*** 428,432 ****
public void assertCheckboxSelected(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! Assert.assertEquals("on",
getDialog().getFormParameterValue(checkBoxName));
}
--- 444,450 ----
public void assertCheckboxSelected(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! if (!getDialog().isCheckboxSelected(checkBoxName)) {
! Assert.fail("Checkbox with name [" + checkBoxName + "] was not
found selected.");
! }
}
***************
*** 438,442 ****
public void assertCheckboxNotSelected(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! Assert.assertNull(getDialog().getFormParameterValue(checkBoxName));
}
--- 456,462 ----
public void assertCheckboxNotSelected(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! if (!getDialog().isCheckboxNotSelected(checkBoxName)) {
! Assert.fail("Checkbox with name [" + checkBoxName + "] was found
selected.");
! }
}
***************
*** 449,454 ****
public void assertRadioOptionPresent(String name, String radioOption) {
assertFormElementPresent(name);
! if (!getDialog().hasRadioOption(name, radioOption))
! Assert.fail("Unable to find option " + radioOption + " in radio
group " + name);
}
--- 469,475 ----
public void assertRadioOptionPresent(String name, String radioOption) {
assertFormElementPresent(name);
! if (!getDialog().hasRadioOption(name, radioOption)) {
! Assert.fail("Unable to find option [" + radioOption + "] in radio
group [" + name + "]");
! }
}
***************
*** 462,466 ****
assertFormElementPresent(name);
if (getDialog().hasRadioOption(name, radioOption))
! Assert.fail("Found option " + radioOption + " in radio group " +
name);
}
--- 483,487 ----
assertFormElementPresent(name);
if (getDialog().hasRadioOption(name, radioOption))
! Assert.fail("Found option [" + radioOption + "] in radio group ["
+ name + "]");
}
***************
*** 918,937 ****
/**
! * Select a specified checkbox.
! *
* @param checkBoxName name of checkbox to be deselected.
*/
public void checkCheckbox(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! getDialog().setFormParameter(checkBoxName, "on");
}
public void checkCheckbox(String checkBoxName, String value) {
assertFormElementPresent(checkBoxName);
! getDialog().updateFormParameter(checkBoxName, value);
}
/**
! * Deselect a specified checkbox.
*
* @param checkBoxName name of checkbox to be deselected.
--- 939,959 ----
/**
! * Select a specified checkbox. If the checkbox is already checked then
the checkbox
! * will stay checked.
* @param checkBoxName name of checkbox to be deselected.
*/
public void checkCheckbox(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! getDialog().checkCheckbox(checkBoxName);
}
public void checkCheckbox(String checkBoxName, String value) {
assertFormElementPresent(checkBoxName);
! getDialog().checkCheckbox(checkBoxName, value);
}
/**
! * Deselect a specified checkbox. If the checkbox is already unchecked
then the checkbox
! * will stay unchecked.
*
* @param checkBoxName name of checkbox to be deselected.
***************
*** 939,948 ****
public void uncheckCheckbox(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! getDialog().removeFormParameter(checkBoxName);
}
public void uncheckCheckbox(String checkBoxName, String value) {
assertFormElementPresent(checkBoxName);
! getDialog().removeFormParameterWithValue(checkBoxName, value);
}
--- 961,970 ----
public void uncheckCheckbox(String checkBoxName) {
assertFormElementPresent(checkBoxName);
! getDialog().uncheckCheckbox(checkBoxName);
}
public void uncheckCheckbox(String checkBoxName, String value) {
assertFormElementPresent(checkBoxName);
! getDialog().uncheckCheckbox(checkBoxName, value);
}
Index: CompositeJWebUnitDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/Attic/CompositeJWebUnitDialog.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** CompositeJWebUnitDialog.java 2 Dec 2004 20:17:41 -0000 1.1.2.1
--- CompositeJWebUnitDialog.java 11 Feb 2005 21:27:15 -0000 1.1.2.2
***************
*** 386,389 ****
--- 386,424 ----
}
+ public boolean isCheckboxSelected(String checkBoxName) {
+ throw new UnsupportedOperationException("isCheckboxSelected");
+ }
+
+ public boolean isCheckboxNotSelected(String checkBoxName) {
+ throw new UnsupportedOperationException("isCheckboxNotSelected");
+ }
+
+ /**
+ * Select a specified checkbox. If the checkbox is already checked then
the checkbox
+ * will stay checked.
+ * @param checkBoxName name of checkbox to be deselected.
+ */
+ public void checkCheckbox(String checkBoxName) {
+ throw new UnsupportedOperationException("checkCheckbox");
+ }
+
+ public void checkCheckbox(String checkBoxName, String value) {
+ throw new UnsupportedOperationException("checkCheckbox2Params");
+ }
+
+ /**
+ * Deselect a specified checkbox. If the checkbox is already unchecked
then the checkbox
+ * will stay unchecked.
+ *
+ * @param checkBoxName name of checkbox to be deselected.
+ */
+ public void uncheckCheckbox(String checkBoxName) {
+ throw new UnsupportedOperationException("uncheckCheckbox");
+ }
+
+ public void uncheckCheckbox(String checkBoxName, String value) {
+ throw new UnsupportedOperationException("uncheckCheckbox2Params");
+ }
+
/*
* (non-Javadoc)
Index: HttpUnitDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/HttpUnitDialog.java,v
retrieving revision 1.40.4.1
retrieving revision 1.40.4.2
diff -C2 -d -r1.40.4.1 -r1.40.4.2
*** HttpUnitDialog.java 2 Dec 2004 20:17:41 -0000 1.40.4.1
--- HttpUnitDialog.java 11 Feb 2005 21:27:09 -0000 1.40.4.2
***************
*** 610,613 ****
--- 610,630 ----
}
+
+ public boolean isCheckboxSelected(String checkBoxName) {
+ boolean bReturn = false;
+ if(getFormParameterValue(checkBoxName).equals("on")) {
+ bReturn = true;
+ }
+ return bReturn;
+ }
+
+ public boolean isCheckboxNotSelected(String checkBoxName) {
+ boolean bReturn = false;
+ if(getFormParameterValue(checkBoxName) == null) {
+ bReturn = true;
+ }
+ return bReturn;
+ }
+
/**
* Return true if a link is present in the current response containing
the specified text (note that HttpUnit uses
***************
*** 654,657 ****
--- 671,676 ----
}
}
+
+
/**
***************
*** 669,672 ****
--- 688,694 ----
}
+
+
+
/**
* Navigate by submitting a request based on a link containing the
specified text. A RuntimeException is thrown if
***************
*** 767,770 ****
--- 789,819 ----
}
+ /**
+ * Select a specified checkbox. If the checkbox is already checked then
the checkbox
+ * will stay checked.
+ * @param checkBoxName name of checkbox to be deselected.
+ */
+ public void checkCheckbox(String checkBoxName) {
+ setFormParameter(checkBoxName, "on");
+ }
+
+ public void checkCheckbox(String checkBoxName, String value) {
+ updateFormParameter(checkBoxName, value);
+ }
+
+ /**
+ * Deselect a specified checkbox. If the checkbox is already unchecked
then the checkbox
+ * will stay unchecked.
+ *
+ * @param checkBoxName name of checkbox to be deselected.
+ */
+ public void uncheckCheckbox(String checkBoxName) {
+ removeFormParameter(checkBoxName);
+ }
+
+ public void uncheckCheckbox(String checkBoxName, String value) {
+ removeFormParameterWithValue(checkBoxName, value);
+ }
+
/**
* Navigate by submitting a request based on a link with a given ID. A
RuntimeException is thrown if no such link
Index: IJWebUnitDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/Attic/IJWebUnitDialog.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** IJWebUnitDialog.java 2 Dec 2004 20:17:42 -0000 1.1.2.1
--- IJWebUnitDialog.java 11 Feb 2005 21:27:16 -0000 1.1.2.2
***************
*** 31,36 ****
import org.w3c.dom.Element;
- import com.meterware.httpunit.Button;
- import com.meterware.httpunit.SubmitButton;
import com.meterware.httpunit.WebClient;
import com.meterware.httpunit.WebResponse;
--- 31,34 ----
***************
*** 171,193 ****
public abstract String getFormElementNameForLabel(String
formElementLabel);
- /**
- * Return the HttpUnit SubmitButton with a given name.
- *
- * @param buttonName
- * name of button.
- */
- public abstract SubmitButton getSubmitButton(String buttonName);
-
public abstract String getSubmitButtonValue(String buttonName);
public abstract boolean hasSubmitButton(String buttonName);
- /**
- * Return the HttpUnit Button with a given id.
- *
- * @param buttonId
- */
- public abstract Button getButton(String buttonId);
-
public abstract boolean hasButton(String buttonId);
--- 169,176 ----
***************
*** 314,317 ****
--- 297,330 ----
/**
+ * Determines if the checkbox is selected.
+ * @param checkBoxName
+ */
+ public abstract boolean isCheckboxSelected(String checkBoxName);
+
+ /**
+ * Determines if the checkbox is not selected.
+ * @param checkBoxName
+ */
+ public abstract boolean isCheckboxNotSelected(String checkBoxName);
+
+ /**
+ * Select a specified checkbox. If the checkbox is already checked then
the checkbox
+ * will stay checked.
+ * @param checkBoxName name of checkbox to be deselected.
+ */
+ public abstract void checkCheckbox(String checkBoxName);
+
+ public abstract void checkCheckbox(String checkBoxName, String value);
+
+ /**
+ * Deselect a specified checkbox. If the checkbox is already unchecked
then the checkbox
+ * will stay unchecked.
+ * @param checkBoxName name of checkbox to be deselected.
+ */
+ public abstract void uncheckCheckbox(String checkBoxName);
+
+ public abstract void uncheckCheckbox(String checkBoxName, String value);
+
+ /**
* Navigate by submitting a request based on a link containing the
specified text. A RuntimeException is thrown if
* no such link can be found.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development