Log Message:
-----------
Fixed broken attributes tests that had been failing due to ClassCastException when a proxy element was returned instead of the concrete class.
Modified Files:
--------------
/cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html:
AttributesTest.java
/cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html:
HtmlTextArea.java
HtmlElement.java
Revision Data
-------------
Index: AttributesTest.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/AttributesTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- AttributesTest.java 10 Jun 2003 19:58:52 -0000 1.1
+++ AttributesTest.java 28 Jun 2003 16:42:54 -0000 1.2
@@ -43,6 +43,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URL;
@@ -254,8 +255,22 @@
else {
final Constructor constructor = classUnderTest_.getDeclaredConstructor(
new Class[]{ HtmlPage.class, Element.class } );
- newInstance = constructor.newInstance(
- new Object[]{page_, proxyElement});
+ try {
+ newInstance = constructor.newInstance(
+ new Object[]{page_, proxyElement});
+ }
+ catch( final InvocationTargetException e ) {
+ final Throwable targetException = e.getTargetException();
+ if( targetException instanceof Exception ) {
+ throw (Exception)targetException;
+ }
+ else if( targetException instanceof Error ) {
+ throw (Error)targetException;
+ }
+ else {
+ throw e;
+ }
+ }
}
return newInstance;
Index: HtmlTextArea.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- HtmlTextArea.java 23 Jun 2003 14:27:34 -0000 1.11
+++ HtmlTextArea.java 28 Jun 2003 16:42:54 -0000 1.12
@@ -85,8 +85,7 @@
* @return The text
*/
public final String getText() {
- HTMLTextAreaElementImpl textElement = (HTMLTextAreaElementImpl) getElement();
- return textElement.getTextContent();
+ return asText();
}
Index: HtmlElement.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- HtmlElement.java 10 Jun 2003 11:56:57 -0000 1.24
+++ HtmlElement.java 28 Jun 2003 16:42:54 -0000 1.25
@@ -368,6 +368,9 @@
final StringBuffer buffer = new StringBuffer();
final NodeList nodeList = getElement().getChildNodes();
+ if( nodeList == null ) {
+ return "";
+ }
final int nodeCount = nodeList.getLength();
final HtmlPage page = getPage();
|