You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by js...@apache.org on 2004/11/29 19:40:08 UTC

svn commit: r106937 - /incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java

Author: jsong
Date: Mon Nov 29 10:40:07 2004
New Revision: 106937

URL: http://svn.apache.org/viewcvs?view=rev&rev=106937
Log:
Adding a missed file for milton.

Added:
   incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java   (contents, props changed)

Added: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java?view=auto&rev=106937
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java	Mon Nov 29 10:40:07 2004
@@ -0,0 +1,67 @@
+package org.apache.beehive.test.tools.milton.junit;
+
+import org.apache.beehive.test.tools.milton.junit.ReportTestCase;
+import org.apache.beehive.test.tools.milton.junit.AbortTestException;
+import org.apache.beehive.test.tools.milton.junit.FailTestError;
+import org.apache.beehive.test.tools.milton.common.Report;
+
+import org.apache.axis.client.Call;
+import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.encoding.ser.BeanSerializerFactory;
+import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+
+import javax.xml.namespace.QName;
+
+public abstract class SOAPReportTestCase extends ReportTestCase
+{
+    public SOAPReportTestCase(String name)
+    {
+        super(name);
+    }
+
+    private Call createCall(String p_uri, String p_method) throws java.net.MalformedURLException {
+        Call l_call = new Call(p_uri);
+        QName l_qname = new QName("http://common.milton.tools.test.beehive.apache.org", "Report");
+
+        l_call.setOperationName(new javax.xml.namespace.QName(p_method));
+        l_call.setReturnType(l_qname, Report.class);
+        l_call.registerTypeMapping(Report.class, l_qname, 
+                                   new BeanSerializerFactory(Report.class, l_qname),
+                                   new BeanDeserializerFactory(Report.class, l_qname), true);
+        return l_call;
+    }
+
+    protected void assertReport(String p_uri, String p_method) throws Exception
+    {
+        if (null == p_uri || null == p_method)
+            throw new IllegalArgumentException("URI and Method cannot be Null");
+     
+        Object l_resp = createCall(p_uri, p_method).invoke(new Object[] {});
+    
+        if (l_resp instanceof java.rmi.RemoteException)
+            throw (java.rmi.RemoteException)l_resp;
+
+        Report l_report = (Report)l_resp;
+
+        String l_status = l_report.getStatus();
+        String l_message = l_report.getMessage();
+        String l_exceptionStack = l_report.getExceptionStack();
+
+        if (Report.ABORT.equals(l_status))
+            throw new AbortTestException("Abort Status Dectected: \n" + 
+                                         l_report.toString());
+        else if (Report.FAIL.equals(l_status))
+            throw new junit.framework.AssertionFailedError("FAILURE: \n" + 
+                                                           l_report.toString());
+        
+        else if (! Report.PASS.equals(l_status))
+            throw new AbortTestException("Unknown Status Detected: \n" +
+                                         l_report.toString());
+
+        if (null != l_message && ! "".equals(l_message))
+            System.out.println("\n[MESSAGES]\n\t" + l_message);
+        
+        if (null != l_exceptionStack && ! "".equals(l_exceptionStack))
+            System.out.println("\n[EXCEPTION]\n\t" + l_exceptionStack);
+    }
+}