Revision: 814
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=814&view=rev
Author: jevonwright
Date: 2009-11-30 06:23:59 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
moving logic behind private assertLabeleldFieldEquals to a new protected
getLabeledFieldValue method, allowing for easier subclassing
Modified Paths:
--------------
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
---
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
2009-09-03 12:56:30 UTC (rev 813)
+++
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
2009-11-30 06:23:59 UTC (rev 814)
@@ -2727,15 +2727,30 @@
return fields;
}
+
/**
- * Private method to test the value of a field connected to a particular
IElement label.
+ * Private method - test the value of a field connected to a particular
IElement label.
*
- * @param label
- * @param fieldText
+ * @param identifier the HTML ID for the given labelled field
+ * @param label the label found for the given HTML field
+ * @param fieldText the value to check is equal
*/
private void assertLabeledFieldEquals(String identifier, IElement label,
String fieldText) {
+ String value = getLabeledFieldValue(identifier, label);
+ Assert.assertEquals("value of field for label [" + identifier + "]
should be [" + fieldText + "]", fieldText, value == null ? "" : value);
+ }
+
+ /**
+ * Get the current value of a given labelled field.
+ *
+ * @param identifier the HTML ID for the given labelled field
+ * @param label the label found for the given HTML ID
+ * @return the value found in a field for the given label/ID, or
+ * <code>null</code> if none was found
+ */
+ protected String getLabeledFieldValue(String identifier, IElement label) {
List<IElement> fields = getFieldsForLabel(label);
-
+
Assert.assertFalse("No field found for label [" + identifier + "]",
fields.isEmpty());
String value = null;
// cycle through all fields trying to find value
@@ -2778,15 +2793,17 @@
}
}
- Assert.assertEquals("value of field for label [" + identifier + "]
should be [" + fieldText + "]", fieldText, value == null ? "" : value);
+ return value;
}
/**
- * Assert that a labeled field exists (for the given id) and the
+ * Assert that a labeled field exists (for the given ID) and the
* field that it labels equals the given text
*
- * @param id
- * @param fieldText
+ * @param id the HTML ID for the given labelled field
+ * @param fieldText the text that the field's value should equal
+ * @see #getLabeledFieldValue(String, IElement, String)
+ * @see #getLabel(String)
*/
public void assertLabeledFieldEquals(String id, String fieldText) {
IElement label = getLabel(id);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development