axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r227182 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis2/engine/ core/src/org/apache/axis2/receivers/ core/src/org/apache/axis2/transport/ core/src/org/apache/axis2/transport/http/ samples/test/org/apache/axis2/engine/
Date Wed, 03 Aug 2005 08:28:23 GMT
Author: ruchithf
Date: Wed Aug  3 01:27:50 2005
New Revision: 227182

URL: http://svn.apache.org/viewcvs?rev=227182&view=rev
Log:
Character encoding support completed and committing the test case

Added:
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/CharctersetEncodingTest.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/TransportUtils.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java Wed
Aug  3 01:27:50 2005
@@ -138,12 +138,6 @@
             invokePhases(operationSpecificPhases, msgContext);
         }
         
-        /**
-         * Promote the operation specific paramters in the message context to
-         * the operation context
-         */
-        promoteMessageContextProperties(msgContext);
-        
         if (msgContext.isServerSide() && !msgContext.isPaused()) {
             // invoke the Message Receivers
             MessageReceiver receiver =
@@ -497,18 +491,7 @@
         return context.getStorage().clean();
     }
     
-    /**
-     * This is used to promote operation/service specific properties that are 
-     * in the message context to the relevant context 
-     * @param msgContext The message context
-     */
-    private void promoteMessageContextProperties(MessageContext msgContext) {
-    	//Character set encoding
-    	String charSetEncoding = (String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
-		if(charSetEncoding != null){
-    		msgContext.getOperationContext().setProperty(MessageContext.CHARACTER_SET_ENCODING,charSetEncoding,true);
-    	}
-    }
+
 
     private String getSenderFaultCode(String soapNamespace) {
         return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
Wed Aug  3 01:27:50 2005
@@ -15,8 +15,12 @@
  */
 package org.apache.axis2.receivers;
 
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.MessageInformationHeaders;
+import org.apache.axis2.addressing.miheaders.RelatesTo;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.AxisFault;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -27,10 +31,11 @@
 public abstract class AbstractInOutAsyncMessageReceiver extends AbstractMessageReceiver {
     protected Log log = LogFactory.getLog(getClass());
 
-    public abstract void invokeBusinessLogic(MessageContext inMessage, ServerCallback callback)
+    public abstract void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage,
ServerCallback callback)
         throws AxisFault;
 
     public final void recieve(final MessageContext messgeCtx) throws AxisFault {
+    	
         final ServerCallback callback = new ServerCallback() {
             public void handleResult(MessageContext result) throws AxisFault {
                 AxisEngine engine =
@@ -49,7 +54,43 @@
         Runnable theadedTask = new Runnable() {
             public void run() {
                 try {
-                    invokeBusinessLogic(messgeCtx, callback);
+                	
+                    MessageContext newmsgCtx =
+                        new MessageContext(messgeCtx.getSystemContext(),
+                                messgeCtx.getSessionContext(),
+                                messgeCtx.getTransportIn(),
+                                messgeCtx.getTransportOut());
+                    
+                    newmsgCtx.setMessageInformationHeaders(
+                            new MessageInformationHeaders());
+                    MessageInformationHeaders oldMessageInfoHeaders =
+                            messgeCtx.getMessageInformationHeaders();
+                    MessageInformationHeaders messageInformationHeaders =
+                            new MessageInformationHeaders();
+                    messageInformationHeaders.setTo(oldMessageInfoHeaders.getReplyTo());
+                    messageInformationHeaders.setFaultTo(
+                            oldMessageInfoHeaders.getFaultTo());
+                    messageInformationHeaders.setFrom(oldMessageInfoHeaders.getTo());
+                    messageInformationHeaders.setRelatesTo(
+                            new RelatesTo(oldMessageInfoHeaders.getMessageId(),
+                                    AddressingConstants.Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE));
+                    newmsgCtx.setMessageInformationHeaders(messageInformationHeaders);
+                    newmsgCtx.setOperationContext(messgeCtx.getOperationContext());
+                    newmsgCtx.setServiceContext(messgeCtx.getServiceContext());
+                    newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,
+                            messgeCtx.getProperty(MessageContext.TRANSPORT_OUT));
+                    newmsgCtx.setProperty(HTTPConstants.HTTPOutTransportInfo,
+                            messgeCtx.getProperty(HTTPConstants.HTTPOutTransportInfo));
+                    
+                    //Setting the charater set encoding
+                    newmsgCtx.setProperty(MessageContext.CHARACTER_SET_ENCODING, messgeCtx
+            				.getProperty(MessageContext.CHARACTER_SET_ENCODING));
+                    
+                    newmsgCtx.setDoingREST(messgeCtx.isDoingREST());
+                    newmsgCtx.setDoingMTOM(messgeCtx.isDoingMTOM());
+                    newmsgCtx.setServerSide(messgeCtx.isServerSide());
+                	
+                    invokeBusinessLogic(messgeCtx, newmsgCtx, callback);
                 } catch (AxisFault e) {
                     log.error(e);
                 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
Wed Aug  3 01:27:50 2005
@@ -59,6 +59,11 @@
                 messgeCtx.getProperty(MessageContext.TRANSPORT_OUT));
         newmsgCtx.setProperty(HTTPConstants.HTTPOutTransportInfo,
                 messgeCtx.getProperty(HTTPConstants.HTTPOutTransportInfo));
+        
+        //Setting the charater set encoding
+        newmsgCtx.setProperty(MessageContext.CHARACTER_SET_ENCODING, messgeCtx
+				.getProperty(MessageContext.CHARACTER_SET_ENCODING));
+        
         newmsgCtx.setDoingREST(messgeCtx.isDoingREST());
         newmsgCtx.setDoingMTOM(messgeCtx.isDoingMTOM());
         newmsgCtx.setServerSide(messgeCtx.isServerSide());

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
Wed Aug  3 01:27:50 2005
@@ -79,7 +79,7 @@
                         "paramIsNotSpecified",
                         "SERVICE_CLASS"));
             }
-
+            
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
         }
@@ -135,4 +135,6 @@
     public SOAPFactory getSOAPFactory() {
         return fac;
     }
+    
+
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/TransportUtils.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/TransportUtils.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/TransportUtils.java
Wed Aug  3 01:27:50 2005
@@ -15,6 +15,12 @@
  */
 package org.apache.axis2.transport;
 
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.i18n.Messages;
@@ -26,13 +32,6 @@
 import org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPTransportUtils;
-import org.apache.axis2.AxisFault;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
 
 public class TransportUtils {
    public static SOAPEnvelope createSOAPMessage(MessageContext msgContext, String soapNamespaceURI)
throws AxisFault {
@@ -65,7 +64,12 @@
             StAXBuilder builder = null;
             SOAPEnvelope envelope = null;
 
-            if (contentType != null) {
+            String charSetEnc = (String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+            if(charSetEnc == null) {
+            	charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+            }
+            
+			if (contentType != null) {
                 msgContext.setDoingMTOM(true);
                 builder =
                         HTTPTransportUtils.selectBuilderForMIME(msgContext,
@@ -73,20 +77,18 @@
                                 (String) contentType);
                 envelope = (SOAPEnvelope) builder.getDocumentElement();
             } else if (msgContext.isDoingREST()) {
-                Reader reader = new InputStreamReader(inStream);
                 XMLStreamReader xmlreader =
                         XMLInputFactory.newInstance().createXMLStreamReader(
-                                reader);
+                                inStream,charSetEnc);
                 SOAPFactory soapFactory = new SOAP11Factory();
                 builder = new StAXOMBuilder(xmlreader);
                 builder.setOmbuilderFactory(soapFactory);
                 envelope = soapFactory.getDefaultEnvelope();
                 envelope.getBody().addChild(builder.getDocumentElement());
             } else {
-                Reader reader = new InputStreamReader(inStream);
                 XMLStreamReader xmlreader =
                         XMLInputFactory.newInstance().createXMLStreamReader(
-                                reader);
+                        		inStream,charSetEnc);
                 builder = new StAXSOAPModelBuilder(xmlreader, soapNamespaceURI);
                 envelope = (SOAPEnvelope) builder.getDocumentElement();
             }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Wed Aug  3 01:27:50 2005
@@ -16,8 +16,20 @@
 
 package org.apache.axis2.transport.http;
 
-import org.apache.axis2.Constants;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
@@ -30,27 +42,18 @@
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.transport.TransportSender;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HeaderElement;
 import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
 import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HeaderElement;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.methods.GetMethod;
-
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
 
 public class CommonsHTTPTransportSender
     extends AbstractHandler
@@ -77,6 +80,13 @@
                     MessageContext.CHARACTER_SET_ENCODING);
             if (charSetEnc != null) {
                 omOutput.setCharSetEncoding(charSetEnc);
+            } else {
+            	OperationContext opctx = msgContext.getOperationContext();
+            	if(opctx != null) {
+            		charSetEnc = (String)opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+            	} else {
+            		charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+            	}
             }
             msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
             omOutput.setSoap11(msgContext.isSOAP11());
@@ -397,27 +407,10 @@
         }
 
         this.httpClient.executeMethod(hostConfig, postMethod);
+        
         if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
-            Header header =
-                postMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
-            if (header != null) {
-                HeaderElement[] headers = header.getElements();
-                for (int i = 0; i < headers.length; i++) {
-                    if (headers[i]
-                        .getName()
-                        .equals(
-                            HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
-                        OperationContext opContext =
-                            msgContext.getOperationContext();
-                        if (opContext != null) {
-                            opContext.setProperty(
-                                HTTPConstants.MTOM_RECIVED_CONTENT_TYPE,
-                                header.getValue());
-                        }
-                    }
-                }
-            }
-            InputStream in = postMethod.getResponseBodyAsStream();
+        	obatainHTTPHeaderInformation(postMethod, msgContext);
+        	InputStream in = postMethod.getResponseBodyAsStream();
             if (in == null) {
                 throw new AxisFault(
                     Messages.getMessage("canNotBeNull", "InputStream"));
@@ -459,8 +452,11 @@
             this.getHostConfiguration(msgContext, url);
 
         this.httpClient.executeMethod(hostConfig, getMethod);
+        
         if (getMethod.getStatusCode() == HttpStatus.SC_OK) {
-
+        	
+        	obatainHTTPHeaderInformation(getMethod, msgContext);
+        	
             InputStream in = getMethod.getResponseBodyAsStream();
             if (in == null) {
                 throw new AxisFault(
@@ -480,4 +476,40 @@
         }
     }
 
+    /**
+     * Collect the HTTP header information and set them in the message context
+     * @param method
+     * @param msgContext
+     */
+    private void obatainHTTPHeaderInformation(HttpMethodBase method,MessageContext msgContext)
{
+        Header header =
+        	method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
+        if (header != null) {
+            HeaderElement[] headers = header.getElements();
+            for (int i = 0; i < headers.length; i++) {
+                NameValuePair charsetEnc = headers[i]
+											.getParameterByName(HTTPConstants.CHAR_SET_ENCODING);
+				if (headers[i]
+                    .getName()
+                    .equals(
+                        HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
+                    OperationContext opContext =
+                        msgContext.getOperationContext();
+                    if (opContext != null) {
+                        opContext.setProperty(
+								HTTPConstants.MTOM_RECIVED_CONTENT_TYPE,
+								header.getValue());
+					}
+				} else if (charsetEnc != null) {
+
+					msgContext
+							.setProperty(
+									MessageContext.CHARACTER_SET_ENCODING,
+									charsetEnc);
+				}
+			}
+        }
+	
+    }
+    
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=227182&r1=227181&r2=227182&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
Wed Aug  3 01:27:50 2005
@@ -22,6 +22,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -196,7 +197,8 @@
             throw new AxisFault(e);
         } catch (FactoryConfigurationError e) {
             throw new AxisFault(e);
-
+        } catch (UnsupportedEncodingException e) {
+        	throw new AxisFault(e);
         } finally {
             if (msgContext.getEnvelope() == null && !soap11) {
                 msgContext.setEnvelope(
@@ -299,7 +301,9 @@
         MessageContext msgContext,
         InputStream inStream,
         String contentTypeString)
-        throws OMException, XMLStreamException, FactoryConfigurationError {
+        throws OMException,
+			XMLStreamException, FactoryConfigurationError,
+			UnsupportedEncodingException {
         StAXBuilder builder = null;
 
         boolean fileCacheForAttachments =
@@ -321,15 +325,17 @@
                 contentTypeString,
                 fileCacheForAttachments,
                 attachmentRepoDir);
-        XMLStreamReader reader =
-            XMLInputFactory.newInstance().createXMLStreamReader(
-                new BufferedReader(
-                    new InputStreamReader(
-                        mimeHelper.getSOAPPartInputStream())));
+        
+        String charSetEnc = getCharSetEncoing(contentTypeString);
+        
+        XMLStreamReader reader = XMLInputFactory.newInstance()
+				.createXMLStreamReader(
+						new BufferedReader(new InputStreamReader(mimeHelper
+								.getSOAPPartInputStream(), charSetEnc)));
 
         /*
-         * put a reference to Attachments in to the message context
-         */
+		 * put a reference to Attachments in to the message context
+		 */
         msgContext.setProperty(MIMEHelper.ATTACHMENTS, mimeHelper);
         if (mimeHelper.getAttachmentSpecType().equals(MIMEHelper.MTOM_TYPE)) {
             /*

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/CharctersetEncodingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/CharctersetEncodingTest.java?rev=227182&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/CharctersetEncodingTest.java
(added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/CharctersetEncodingTest.java
Wed Aug  3 01:27:50 2005
@@ -0,0 +1,169 @@
+package org.apache.axis2.engine;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class CharctersetEncodingTest extends TestCase {
+	
+    private EndpointReference targetEPR = new EndpointReference(
+			"http://127.0.0.1:" + (UtilServer.TESTING_PORT)
+					+ "/axis/services/EchoXMLService/echoOMElement");
+    
+    private EndpointReference targetEPR1 = new EndpointReference(
+			"http://127.0.0.1:5556/axis/services/EchoXMLService/echoOMElement");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	private QName serviceName = new QName("EchoXMLService");
+
+	private QName operationName = new QName("echoOMElement");
+
+	private QName transportName = new QName("http://localhost/my",
+			"NullTransport");
+
+	private AxisConfiguration engineRegistry;
+
+	private MessageContext mc;
+
+	private ServiceContext serviceContext;
+
+	private ServiceDescription service;
+
+	private boolean finish = false;
+	
+	public CharctersetEncodingTest(String arg0) {
+		super(arg0);
+	}
+
+    protected void setUp() throws Exception {
+        UtilServer.start(Constants.TESTING_PATH + "chuncked-enabledRepository");
+        
+        service =
+                Utils.createSimpleService(serviceName,
+                        Echo.class.getName(),
+                        operationName);
+        UtilServer.deployService(service);
+        serviceContext =
+                UtilServer.getConfigurationContext().createServiceContext(
+                        service.getName());
+
+
+    }
+    
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.stop();
+    }
+    
+    
+    private void runTest(String value, String expected) {
+    	
+    	try {
+			OMFactory fac = OMAbstractFactory.getOMFactory();
+			OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+			OMElement payload = fac.createOMElement("echoOMElement", omNs);
+			OMElement text = fac.createOMElement("Text", omNs);
+			text.addChild(fac.createText(text, value));
+			payload.addChild(text);
+
+			org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(
+					Constants.TESTING_PATH + "chuncked-enabledRepository");
+
+			call.setTo(targetEPR);
+			call.setTransportInfo(Constants.TRANSPORT_HTTP,
+					Constants.TRANSPORT_HTTP, false);
+
+
+			OMElement resultElem = (OMElement) call.invokeBlocking(operationName
+					.getLocalPart(), payload);
+
+
+
+			assertNotNull("Result is null", resultElem);
+			String result = ((OMElement) resultElem.getFirstChild()).getText();
+
+			assertNotNull("Result value is null", result);
+
+			assertEquals("Expected result not received.", expected, result);
+			
+			call.close();
+
+		} catch (AxisFault e) {
+			e.printStackTrace();
+			assertFalse("Faliure in processing", true);
+		}
+	}
+
+	
+    private void runtest(String value) throws Exception {
+        runTest(value, value);
+    }
+    
+    public void testSimpleString() throws Exception {
+        runtest("a simple string");
+    }
+    
+    public void testStringWithApostrophes() throws Exception {
+        runtest("this isn't a simple string");
+    }
+    
+    public void testStringWithEntities() throws Exception {
+        runTest("&amp;&lt;&gt;&apos;&quot;", "&amp;&lt;&gt;&apos;&quot;");
+    }
+    
+    public void testStringWithRawEntities() throws Exception {
+        runTest("&<>'\"", "&<>'\"");
+    }
+    public void testStringWithLeadingAndTrailingSpaces() throws Exception {
+        runtest("          centered          ");
+    }
+    
+    public void testWhitespace() throws Exception {
+        runtest(" \n \t "); // note: \r fails
+    }
+    
+    public void testFrenchAccents() throws Exception {
+        runtest("\u00e0\u00e2\u00e4\u00e7\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u00f6\u00f9\u00fb\u00fc");
+    }
+    
+    public void testGermanUmlauts() throws Exception {
+        runtest(" Some text \u00df with \u00fc special \u00f6 chars \u00e4.");
+    }
+    
+    public void testWelcomeUnicode() throws Exception {
+        // welcome in several languages
+        runtest(
+          "Chinese (trad.) : \u6b61\u8fce  ");
+    }
+
+    public void testWelcomeUnicode2() throws Exception {
+        // welcome in several languages
+        runtest(
+          "Greek : \u03ba\u03b1\u03bb\u03ce\u03c2 \u03bf\u03c1\u03af\u03c3\u03b1\u03c4\u03b5");
+    }
+
+    public void testWelcomeUnicode3() throws Exception {
+        // welcome in several languages
+        runtest(
+          "Japanese : \u3088\u3046\u3053\u305d");
+    }    
+    
+}



Mime
View raw message