stevel 2003/01/13 22:41:12
Modified: java/test/faults TestAxisFault.java
Log:
test for changed method to clear the existing faultDetails on a null array
Revision Changes Path
1.2 +38 -0 xml-axis/java/test/faults/TestAxisFault.java
Index: TestAxisFault.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/faults/TestAxisFault.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestAxisFault.java 31 Dec 2002 04:54:12 -0000 1.1
+++ TestAxisFault.java 14 Jan 2003 06:41:12 -0000 1.2
@@ -63,8 +63,11 @@
import org.apache.axis.NoEndPointException;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.Text;
import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
/**
* unit tests for the ubiquitous AxisFault
@@ -139,6 +142,41 @@
af.addFaultDetailString("alles geht gut");
Element match=af.lookupFaultDetail(new QName(null,"string"));
assertNotNull(match);
+ }
+
+ public void testArrayAddWorks() {
+ AxisFault af = new AxisFault();
+ af.addFaultDetailString("alles geht gut");
+ Element array[]=new Element[2];
+ array[0] = createElement("ein","un");
+ array[1] = createElement("zwei", "deux");
+ af.setFaultDetail(array);
+ Element match = af.lookupFaultDetail(new QName(null, "zwei"));
+ assertNotNull(match);
+ Element old = af.lookupFaultDetail(new QName(null, "string"));
+ assertNull(old);
+ }
+
+ public void testEmptyArrayAddWorks() {
+ AxisFault af = new AxisFault();
+ af.addFaultDetailString("alles geht gut");
+ Element array[] = new Element[0];
+ af.setFaultDetail(array);
+ Element old = af.lookupFaultDetail(new QName(null, "string"));
+ assertNull(old);
+ }
+
+ public Element createElement(String tag,String child) {
+ Document doc = null;
+ try {
+ doc = XMLUtils.newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException("xml trouble");
+ }
+ Element element = doc.createElement(tag);
+ Text text = doc.createTextNode(child);
+ element.appendChild(text);
+ return element;
}
/**