axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r377777 - in /webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine: FaultHandlingTest.java util/FaultHandler.java util/TestConstants.java
Date Tue, 14 Feb 2006 17:29:30 GMT
Author: chinthaka
Date: Tue Feb 14 09:29:26 2006
New Revision: 377777

URL: http://svn.apache.org/viewcvs?rev=377777&view=rev
Log:
Finishing Fault handling with the completed test case.

Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/FaultHandler.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java?rev=377777&r1=377776&r2=377777&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java
Tue Feb 14 09:29:26 2006
@@ -29,7 +29,6 @@
 import org.apache.axis2.engine.util.TestConstants;
 import org.apache.axis2.integration.TestingUtils;
 import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.ws.commons.om.OMAbstractFactory;
 import org.apache.ws.commons.om.OMElement;
 import org.apache.ws.commons.soap.SOAP11Constants;
@@ -57,24 +56,37 @@
         Phase phaseOne = (Phase) inPhasesUptoAndIncludingPostDispatch.get(0);
         phaseOne.addHandler(new FaultHandler());
 
+        ConfigurationContext configContext =
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
+        ServiceClient sender = new ServiceClient(configContext, null);
 
         OMElement payload = TestingUtils.createDummyOMElement();
+
+        // test with SOAP 1.2
         Options options = new Options();
         options.setTo(targetEPR);
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
         options.setExceptionToBeThrownOnSOAPFault(false);
-        options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(60000 *20));
-        options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(60000 *20));
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
-        ServiceClient sender = new ServiceClient(configContext, null);
+        options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
         sender.setOptions(options);
 
-        OMElement result = sender.sendReceive(payload);
+        String result = sender.sendReceive(payload).toString();
+
+        assertTrue(result.indexOf(FaultHandler.DETAIL_MORE_INFO) > -1);
+        assertTrue(result.indexOf(FaultHandler.FAULT_REASON) > -1);
+
+        // test with SOAP 1.1
+        options = new Options();
+        options.setTo(targetEPR);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+        options.setExceptionToBeThrownOnSOAPFault(false);
+        options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        sender.setOptions(options);
 
-        System.out.println("result = " + result);
+        result = sender.sendReceive(payload).toString();
 
+        assertTrue(result.indexOf(FaultHandler.DETAIL_MORE_INFO) > -1);
+        assertTrue(result.indexOf(FaultHandler.FAULT_REASON) > -1);
 
     }
 

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/FaultHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/FaultHandler.java?rev=377777&r1=377776&r2=377777&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/FaultHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/FaultHandler.java
Tue Feb 14 09:29:26 2006
@@ -29,22 +29,24 @@
  */
 
 public class FaultHandler extends AbstractHandler {
+    public static final String FAULT_REASON = "This is a test fault message which happened
suddenly";
+    public static final String DETAIL_MORE_INFO = "This error is a result due to a fake problem
in Axis2 engine. Do not worry ;)";
 
     public void invoke(MessageContext msgContext) throws AxisFault {
         // this handler will be used to check the fault handling of Axis2.
         // this will create some dummy faults and send
 
-        SOAPFactory soapFac = msgContext.isSOAP11() ? OMAbstractFactory.getSOAP11Factory()
: OMAbstractFactory.getSOAP11Factory();
+        SOAPFactory soapFac = msgContext.isSOAP11() ? OMAbstractFactory.getSOAP11Factory()
: OMAbstractFactory.getSOAP12Factory();
 
         // I have a sudden fake error ;)
         SOAPFaultText soapFaultText = soapFac.createSOAPFaultText();
         soapFaultText.setLang("en");
-        soapFaultText.setText("This is a test fault message which happened suddenly");
+        soapFaultText.setText(FAULT_REASON);
         SOAPFaultReason soapFaultReason = soapFac.createSOAPFaultReason();
         soapFaultReason.setSOAPText(soapFaultText);
 
         OMElement detailEntry = soapFac.createOMElement("MoreInfo", null);
-        detailEntry.setText("This error is a result due to a fake problem in Axis2 engine.
Do not worry ;)");
+        detailEntry.setText(DETAIL_MORE_INFO);
         SOAPFaultDetail faultDetail = soapFac.createSOAPFaultDetail();
         faultDetail.addDetailEntry(detailEntry);
 

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java?rev=377777&r1=377776&r2=377777&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
Tue Feb 14 09:29:26 2006
@@ -26,7 +26,6 @@
  */
 public interface TestConstants {
     public static final EndpointReference targetEPR = new EndpointReference(
-//            "http://127.0.0.1:" + 5556
             "http://127.0.0.1:" + (UtilServer.TESTING_PORT)
                     + "/axis2/services/EchoXMLService/echoOMElement");
 



Mime
View raw message