axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <dava...@gmail.com>
Subject [Axis2] Cleanup (Re: svn commit: r327093 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/rpc/receivers/ codegen/src/org/apache/axis2/util/ integration/test/org/apache/axis2/rpc/)
Date Fri, 21 Oct 2005 12:16:17 GMT
Deepal,

#1) please remove printStackTrace()
#2) copyright goes right on top. Please see other files (even before
the package statement)
#3) please remove the author tag as well with date and time.

thanks,
dims

On 10/21/05, deepal@apache.org <deepal@apache.org> wrote:
> Author: deepal
> Date: Thu Oct 20 21:06:53 2005
> New Revision: 327093
>
> URL: http://svn.apache.org/viewcvs?rev=327093&view=rev
> Log:
> Improved RPCMessageReciver to support multiref , I added a testcase too , still one thing
missing as far as multiref is concern , if the service class take OMElement as argument it
will fail. I have to improve that.
>
> Added:
>     webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/MultirefHelper.java
>     webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
> Modified:
>     webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
>     webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
>     webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
>
> Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java?rev=327093&r1=327092&r2=327093&view=diff
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
(original)
> +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
Thu Oct 20 21:06:53 2005
> @@ -106,6 +106,7 @@
>              outMessage.setEnvelope(envelope);
>
>
>
>          } catch (Exception e) {
>
> +            e.printStackTrace();
>
>              throw AxisFault.makeFault(e);
>
>          }
>
>      }
>
>
> Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java?rev=327093&r1=327092&r2=327093&view=diff
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
(original)
> +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
Thu Oct 20 21:06:53 2005
> @@ -4,6 +4,7 @@
>  import org.apache.axis2.rpc.receivers.SimpleTypeMapper;
>
>  import org.apache.axis2.databinding.utils.ADBPullParser;
>
>  import org.apache.axis2.om.OMElement;
>
> +import org.apache.axis2.om.OMAttribute;
>
>  import org.apache.axis2.AxisFault;
>
>
>
>  import javax.xml.namespace.QName;
>
> @@ -37,7 +38,6 @@
>
>
>  public class BeanSerializerUtil {
>
>
>
> -
>
>      /**
>
>       * To Serilize Bean object this method is used, this will create an object array
using given
>
>       * bean object
>
> @@ -123,6 +123,57 @@
>          return beanObj;
>
>      }
>
>
>
> +    public static Object deserialize(Class beanClass, OMElement beanElement, MultirefHelper
helper) throws AxisFault{
>
> +        Object beanObj ;
>
> +        try {
>
> +            HashMap properties = new HashMap() ;
>
> +            BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
>
> +            PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
>
> +            for (int i = 0; i < propDescs.length; i++) {
>
> +                PropertyDescriptor proprty = propDescs[i];
>
> +                properties.put(proprty.getName(), proprty);
>
> +            }
>
> +
>
> +            beanObj = beanClass.newInstance();
>
> +            Iterator elements = beanElement.getChildren();
>
> +            while (elements.hasNext()) {
>
> +                OMElement parts = (OMElement) elements.next();
>
> +                String partsLocalName = parts.getLocalName();
>
> +                PropertyDescriptor prty =(PropertyDescriptor)properties.get(partsLocalName.toLowerCase());
>
> +                if(prty !=null){
>
> +                    Class parameters = prty.getPropertyType();
>
> +                    if (prty.equals("class"))
>
> +                        continue;
>
> +                    Object partObj;
>
> +                    OMAttribute attr = MultirefHelper.processRefAtt(parts);
>
> +                    if(attr != null){
>
> +                        String refId = MultirefHelper.getAttvalue(attr);
>
> +                        partObj =  helper.getObject(refId);
>
> +                        if(partObj == null){
>
> +                           partObj = helper.processRef(parameters,refId);
>
> +                        }
>
> +                    } else {
>
> +                        partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
>
> +                        if (partObj == null) {
>
> +                            partObj = deserialize(parameters, parts);
>
> +                        }
>
> +                    }
>
> +                    Object [] parms = new Object[]{partObj};
>
> +                    prty.getWriteMethod().invoke(beanObj,parms);
>
> +                }
>
> +            }
>
> +        } catch (InstantiationException e) {
>
> +            throw new AxisFault("InstantiationException : " + e);
>
> +        } catch (IllegalAccessException e) {
>
> +            throw new AxisFault("IllegalAccessException : " + e);
>
> +        } catch (InvocationTargetException e) {
>
> +            throw new AxisFault("InvocationTargetException : " + e);
>
> +        } catch (IntrospectionException e) {
>
> +            throw new AxisFault("IntrospectionException : " + e);
>
> +        }
>
> +        return beanObj;
>
> +    }
>
> +
>
>
>
>      /**
>
>       * To get JavaObjects from XML elemnt , the element most of the time contains only
one element
>
> @@ -135,7 +186,7 @@
>       * @throws AxisFault
>
>       */
>
>      public static Object [] deserialize(OMElement response , Object [] returnTypes )
throws AxisFault {
>
> -         /**
>
> +        /**
>
>           * Take the number of paramters in the method and , only take that much of child
elements
>
>           * from the OMElement , other are ignore , as an example
>
>           * if the method is , foo(String a , int b)
>
> @@ -150,20 +201,66 @@
>          int length = returnTypes.length;
>
>          int count =0;
>
>          Object [] retObjs = new Object[length];
>
> +
>
> +        /**
>
> +         * If the body first child contains , then there can not be any other element
withot
>
> +         * refs , so I can assume if the first child of the body first element has ref
then
>
> +         * the messge has to handle as mutiref message.
>
> +         * as an exmple if the body is like below
>
> +         * <foo>
>
> +         *  <arg0 href="#0"/>
>
> +         * </foo>
>
> +         *
>
> +         * then there can not be any element without refs , meaning following we are
not handling
>
> +         * <foo>
>
> +         *  <arg0 href="#0"/>
>
> +         *  <arg1>absbsbs</arg1>
>
> +         * </foo>
>
> +         */
>
>          Iterator parts = response.getChildren();
>
> +        //to handle multirefs
>
> +        //have to check the instnceof
>
> +        MultirefHelper helper = new MultirefHelper((OMElement)response.getParent());
>
> +        boolean hasRef = false;
>
>          while (parts.hasNext() && count < length) {
>
>              OMElement omElement = (OMElement) parts.next();
>
>              Class classType = (Class)returnTypes[count];
>
> +            //handling refs
>
> +            OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
>
> +            String ref=null;
>
> +            if(omatribute !=null) {
>
> +                hasRef = true;
>
> +                ref = MultirefHelper.getAttvalue(omatribute);
>
> +            }
>
> +
>
>              if(OMElement.class.isAssignableFrom(classType)){
>
> -                retObjs[count] =omElement;
>
> -            }  else if(SimpleTypeMapper.isSimpleType(classType)){
>
> -                retObjs[count]  = SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
>
> +                if(hasRef){
>
> +                    throw new AxisFault("The method take OMElenent as argument , and
the body contains" +
>
> +                            "refs , encounter processing error ");
>
> +                } else
>
> +                    retObjs[count] =omElement;
>
>              } else {
>
> -                retObjs[count] = BeanSerializerUtil.deserialize(classType, omElement);
>
> +                if(hasRef){
>
> +                    if(helper.getObject(ref) !=null) {
>
> +                        retObjs[count] =  helper.getObject(ref);
>
> +                    } else {
>
> +                        retObjs[count]  = helper.processRef(classType,ref) ;
>
> +                    }
>
> +                } else{
>
> +                    if(SimpleTypeMapper.isSimpleType(classType)){
>
> +                        retObjs[count]  = SimpleTypeMapper.getSimpleTypeObject(classType,
omElement);
>
> +                    } else {
>
> +                        retObjs[count] = BeanSerializerUtil.deserialize(classType, omElement);
>
> +                    }
>
> +                }
>
>              }
>
> +            hasRef = false;
>
>              count ++;
>
>          }
>
> +        helper.clean();
>
>          return  retObjs;
>
>      }
>
> +
>
> +
>
>
>
>  }
>
>
> Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/MultirefHelper.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/MultirefHelper.java?rev=327093&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/MultirefHelper.java
(added)
> +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/MultirefHelper.java
Thu Oct 20 21:06:53 2005
> @@ -0,0 +1,120 @@
> +package org.apache.axis2.util;
>
> +
>
> +import org.apache.axis2.om.OMElement;
>
> +import org.apache.axis2.om.OMAttribute;
>
> +import org.apache.axis2.AxisFault;
>
> +import org.apache.axis2.rpc.receivers.SimpleTypeMapper;
>
> +
>
> +import javax.xml.namespace.QName;
>
> +import java.util.HashMap;
>
> +import java.util.Iterator;
>
> +/*
>
> +* Copyright 2004,2005 The Apache Software Foundation.
>
> +*
>
> +* Licensed under the Apache License, Version 2.0 (the "License");
>
> +* you may not use this file except in compliance with the License.
>
> +* You may obtain a copy of the License at
>
> +*
>
> +*      http://www.apache.org/licenses/LICENSE-2.0
>
> +*
>
> +* Unless required by applicable law or agreed to in writing, software
>
> +* distributed under the License is distributed on an "AS IS" BASIS,
>
> +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>
> +* See the License for the specific language governing permissions and
>
> +* limitations under the License.
>
> +*
>
> +*
>
> +*/
>
> +
>
> +/**
>
> + * Author: Deepal Jayasinghe
>
> + * Date: Oct 20, 2005
>
> + * Time: 12:45:21 PM
>
> + */
>
> +public class MultirefHelper {
>
> +
>
> +    public static final String SOAP12_REF_ATTR = "ref";
>
> +    public static final String SOAP11_REF_ATTR = "href";
>
> +
>
> +    private boolean filledTable;
>
> +
>
> +    private OMElement parent ;
>
> +
>
> +    private HashMap objectmap = new HashMap();
>
> +    private HashMap elementMap = new HashMap();
>
> +
>
> +    public MultirefHelper(OMElement parent) {
>
> +        this.parent = parent;
>
> +    }
>
> +
>
> +    public Object getObject(String id){
>
> +        return objectmap.get(id);
>
> +    }
>
> +
>
> +    public Object processRef(Class javatype, String id) throws AxisFault {
>
> +        if(!filledTable){
>
> +            readallChildElements();
>
> +        }
>
> +        OMElement val = (OMElement)elementMap.get(id);
>
> +        if(val == null){
>
> +            throw new AxisFault("Invalid reference :" + id);
>
> +        } else {
>
> +            if(SimpleTypeMapper.isSimpleType(javatype)){
>
> +                /**
>
> +                 * in this case OM element can not contains more child, that is no way
to get
>
> +                 * the value as an exp ,
>
> +                 * <refernce id="12">
>
> +                 *   <value>foo</value>
>
> +                 * </refernce>
>
> +                 * the above one is not valid , that should always be like below
>
> +                 * <refernce id="12">foo</refernce>
>
> +                 */
>
> +                Object valObj =  SimpleTypeMapper.getSimpleTypeObject(javatype,val);
>
> +                objectmap.put(id,valObj);
>
> +                return  valObj;
>
> +            } else {
>
> +                Object obj = BeanSerializerUtil.deserialize(javatype,val,this);
>
> +                objectmap.put(id,obj);
>
> +                return obj;
>
> +            }
>
> +        }
>
> +    }
>
> +
>
> +    private void readallChildElements(){
>
> +        Iterator childs =  parent.getChildElements();
>
> +        while (childs.hasNext()) {
>
> +            OMElement omElement = (OMElement) childs.next();
>
> +            OMAttribute id =  omElement.getAttribute(new QName("id"));
>
> +            if(id !=null){
>
> +                omElement.build();
>
> +                elementMap.put(id.getAttributeValue(),omElement);
>
> +            }
>
> +        }
>
> +        filledTable =true;
>
> +    }
>
> +
>
> +    public static String getAttvalue(OMAttribute omatribute) {
>
> +        String ref;
>
> +        ref = omatribute.getAttributeValue();
>
> +        if (ref != null) {
>
> +            if (ref.charAt(0) == '#') {
>
> +                ref = ref.substring(1);
>
> +            }
>
> +        }
>
> +        return ref;
>
> +    }
>
> +
>
> +    public static OMAttribute processRefAtt(OMElement omElement) {
>
> +        OMAttribute omatribute =  omElement.getAttribute(new QName(SOAP11_REF_ATTR));
>
> +        if(omatribute == null){
>
> +            omatribute =  omElement.getAttribute(new QName(SOAP12_REF_ATTR));
>
> +        }
>
> +        return omatribute;
>
> +    }
>
> +
>
> +    public void clean(){
>
> +        elementMap.clear();
>
> +        objectmap.clear();
>
> +    }
>
> +
>
> +}
>
>
> Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java?rev=327093&view=auto
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
(added)
> +++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
Thu Oct 20 21:06:53 2005
> @@ -0,0 +1,291 @@
> +package org.apache.axis2.rpc;
>
> +
>
> +import org.apache.axis2.addressing.EndpointReference;
>
> +import org.apache.axis2.integration.UtilServer;
>
> +import org.apache.axis2.engine.AxisConfiguration;
>
> +import org.apache.axis2.context.MessageContext;
>
> +import org.apache.axis2.context.ServiceContext;
>
> +import org.apache.axis2.description.ServiceDescription;
>
> +import org.apache.axis2.description.ParameterImpl;
>
> +import org.apache.axis2.description.OperationDescription;
>
> +import org.apache.axis2.description.InOutOperationDescrition;
>
> +import org.apache.axis2.AxisFault;
>
> +import org.apache.axis2.Constants;
>
> +import org.apache.axis2.util.BeanSerializerUtil;
>
> +import org.apache.axis2.soap.SOAPFactory;
>
> +import org.apache.axis2.soap.SOAPEnvelope;
>
> +import org.apache.axis2.om.OMFactory;
>
> +import org.apache.axis2.om.OMAbstractFactory;
>
> +import org.apache.axis2.om.OMNamespace;
>
> +import org.apache.axis2.om.OMElement;
>
> +import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
>
> +import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
>
> +import org.apache.axis2.rpc.client.RPCCall;
>
> +import org.apache.axis2.receivers.AbstractMessageReceiver;
>
> +import org.apache.commons.logging.Log;
>
> +import org.apache.commons.logging.LogFactory;
>
> +import org.apache.wsdl.WSDLService;
>
> +
>
> +import javax.xml.namespace.QName;
>
> +import javax.xml.stream.XMLStreamReader;
>
> +import javax.xml.stream.XMLInputFactory;
>
> +import javax.xml.stream.XMLStreamException;
>
> +import javax.xml.stream.FactoryConfigurationError;
>
> +import java.text.SimpleDateFormat;
>
> +import java.io.ByteArrayInputStream;
>
> +
>
> +import junit.framework.TestCase;
>
> +/*
>
> +* Copyright 2004,2005 The Apache Software Foundation.
>
> +*
>
> +* Licensed under the Apache License, Version 2.0 (the "License");
>
> +* you may not use this file except in compliance with the License.
>
> +* You may obtain a copy of the License at
>
> +*
>
> +*      http://www.apache.org/licenses/LICENSE-2.0
>
> +*
>
> +* Unless required by applicable law or agreed to in writing, software
>
> +* distributed under the License is distributed on an "AS IS" BASIS,
>
> +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>
> +* See the License for the specific language governing permissions and
>
> +* limitations under the License.
>
> +*
>
> +*
>
> +*/
>
> +
>
> +/**
>
> + * Author: Deepal Jayasinghe
>
> + * Date: Oct 20, 2005
>
> + * Time: 9:54:32 PM
>
> + */
>
> +public class MultirefTest extends TestCase {
>
> +
>
> +    private SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
>
> +    //  0123456789 0 123456789
>
> +
>
> +
>
> +    protected EndpointReference targetEPR =
>
> +            new EndpointReference("http://127.0.0.1:"
>
> +                    + (UtilServer.TESTING_PORT)
>
> +                    + "/axis/services/EchoXMLService/concat");
>
> +    protected Log log = LogFactory.getLog(getClass());
>
> +    protected QName serviceName = new QName("EchoXMLService");
>
> +    protected QName operationName = new QName("http://localhost/my", "concat");
>
> +    protected QName transportName = new QName("http://localhost/my",
>
> +            "NullTransport");
>
> +
>
> +    protected AxisConfiguration engineRegistry;
>
> +    protected MessageContext mc;
>
> +    protected ServiceContext serviceContext;
>
> +    protected ServiceDescription service;
>
> +
>
> +    protected boolean finish = false;
>
> +
>
> +    protected void setUp() throws Exception {
>
> +        UtilServer.start();
>
> +    }
>
> +
>
> +    protected void tearDown() throws Exception {
>
> +        UtilServer.unDeployService(serviceName);
>
> +        UtilServer.stop();
>
> +        UtilServer.unDeployClientService();
>
> +    }
>
> +    private void configureSystem(String opName) throws AxisFault {
>
> +        targetEPR =
>
> +                new EndpointReference("http://127.0.0.1:"
>
> +//                        + (5000)
>
> +                        + (UtilServer.TESTING_PORT)
>
> +                        + "/axis/services/EchoXMLService/" + opName);
>
> +        String className = "org.apache.axis2.rpc.RPCServiceClass";
>
> +        operationName = new QName("http://localhost/my", opName, "req");
>
> +        ServiceDescription service = new ServiceDescription(serviceName);
>
> +        service.setClassLoader(Thread.currentThread().getContextClassLoader());
>
> +        service.addParameter(new ParameterImpl(AbstractMessageReceiver.SERVICE_CLASS,
>
> +                className));
>
> +        OperationDescription axisOp = new InOutOperationDescrition(operationName);
>
> +        axisOp.setMessageReceiver(new RPCMessageReceiver());
>
> +        axisOp.setStyle(WSDLService.STYLE_RPC);
>
> +        service.addOperation(axisOp);
>
> +        UtilServer.deployService(service);
>
> +    }
>
> +
>
> +    public void testMulitref1() throws AxisFault {
>
> +        configureSystem("echoString");
>
> +        OMFactory fac = OMAbstractFactory.getOMFactory();
>
> +
>
> +        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
>
> +        OMElement method = fac.createOMElement("echoString", omNs);
>
> +        OMElement value = fac.createOMElement("arg0", null);
>
> +        value.addAttribute(fac.createOMAttribute("href",null,"#1"));
>
> +        method.addChild(value);
>
> +        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
>
> +        SOAPEnvelope envelope = factory.getDefaultEnvelope();
>
> +        envelope.getBody().addChild(method);
>
> +
>
> +        OMElement ref = fac.createOMElement("reference", null);
>
> +        ref.addAttribute(fac.createOMAttribute("id",null,"1"));
>
> +        ref.setText("hello Axis2");
>
> +        envelope.getBody().addChild(ref);
>
> +        RPCCall call =
>
> +                new RPCCall("target/test-resources/intregrationRepo");
>
> +
>
> +        call.setTo(targetEPR);
>
> +        call.setTransportInfo(Constants.TRANSPORT_HTTP,
>
> +                Constants.TRANSPORT_HTTP,
>
> +                false);
>
> +        SOAPEnvelope env = call.invokeBlocking("echoString",envelope);
>
> +        assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "hello
Axis2");
>
> +    }
>
> +
>
> +    public void testadd() throws AxisFault {
>
> +        configureSystem("add");
>
> +        OMFactory fac = OMAbstractFactory.getOMFactory();
>
> +
>
> +        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
>
> +        OMElement method = fac.createOMElement("add", omNs);
>
> +        OMElement value = fac.createOMElement("arg0", null);
>
> +        value.addAttribute(fac.createOMAttribute("href",null,"#1"));
>
> +        method.addChild(value);
>
> +
>
> +        OMElement value2 = fac.createOMElement("arg1", null);
>
> +        value2.addAttribute(fac.createOMAttribute("href",null,"#2"));
>
> +        method.addChild(value2);
>
> +
>
> +        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
>
> +        SOAPEnvelope envelope = factory.getDefaultEnvelope();
>
> +        envelope.getBody().addChild(method);
>
> +
>
> +        OMElement ref = fac.createOMElement("reference", null);
>
> +        ref.addAttribute(fac.createOMAttribute("id",null,"1"));
>
> +        ref.setText("10");
>
> +        envelope.getBody().addChild(ref);
>
> +
>
> +        OMElement ref2 = fac.createOMElement("reference", null);
>
> +        ref2.addAttribute(fac.createOMAttribute("id",null,"2"));
>
> +        ref2.setText("10");
>
> +        envelope.getBody().addChild(ref2);
>
> +
>
> +
>
> +        RPCCall call =
>
> +                new RPCCall("target/test-resources/intregrationRepo");
>
> +
>
> +        call.setTo(targetEPR);
>
> +        call.setTransportInfo(Constants.TRANSPORT_HTTP,
>
> +                Constants.TRANSPORT_HTTP,
>
> +                false);
>
> +        SOAPEnvelope env = call.invokeBlocking("add",envelope);
>
> +        assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "20");
>
> +    }
>
> +
>
> +    public void testaddError() {
>
> +        try {
>
> +            configureSystem("add");
>
> +            OMFactory fac = OMAbstractFactory.getOMFactory();
>
> +
>
> +            OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
>
> +            OMElement method = fac.createOMElement("add", omNs);
>
> +            OMElement value = fac.createOMElement("arg0", null);
>
> +            value.addAttribute(fac.createOMAttribute("href",null,"#1"));
>
> +            method.addChild(value);
>
> +
>
> +            OMElement value2 = fac.createOMElement("arg1", null);
>
> +            value2.addAttribute(fac.createOMAttribute("href",null,"#2"));
>
> +            method.addChild(value2);
>
> +
>
> +            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
>
> +            SOAPEnvelope envelope = factory.getDefaultEnvelope();
>
> +            envelope.getBody().addChild(method);
>
> +
>
> +            OMElement ref = fac.createOMElement("reference", null);
>
> +            ref.addAttribute(fac.createOMAttribute("id",null,"1"));
>
> +            ref.setText("10");
>
> +            envelope.getBody().addChild(ref);
>
> +
>
> +            OMElement ref2 = fac.createOMElement("reference", null);
>
> +            ref2.addAttribute(fac.createOMAttribute("id",null,"3"));
>
> +            ref2.setText("10");
>
> +            envelope.getBody().addChild(ref2);
>
> +
>
> +
>
> +            RPCCall call =
>
> +                    new RPCCall("target/test-resources/intregrationRepo");
>
> +
>
> +            call.setTo(targetEPR);
>
> +            call.setTransportInfo(Constants.TRANSPORT_HTTP,
>
> +                    Constants.TRANSPORT_HTTP,
>
> +                    false);
>
> +            call.invokeBlocking("add",envelope);
>
> +            fail("This should fail with : " + "org.apache.axis2.AxisFault: Invalid reference
:2");
>
> +        } catch (AxisFault axisFault) {
>
> +            String val = axisFault.getMessage();
>
> +            int index =  val.indexOf("org.apache.axis2.AxisFault: Invalid reference
:2") ;
>
> +            if(index <0){
>
> +                fail("This should fail with : " + "org.apache.axis2.AxisFault: Invalid
reference :2");
>
> +            }
>
> +        }
>
> +    }
>
> +
>
> +
>
> +    public void testMulitrefBean() throws AxisFault {
>
> +        configureSystem("editBean");
>
> +        OMFactory fac = OMAbstractFactory.getOMFactory();
>
> +
>
> +        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
>
> +        OMElement method = fac.createOMElement("editBean", omNs);
>
> +        OMElement value = fac.createOMElement("arg0", null);
>
> +        value.addAttribute(fac.createOMAttribute("href",null,"#1"));
>
> +        method.addChild(value);
>
> +        OMElement value2 = fac.createOMElement("arg1", null);
>
> +        value2.setText("159");
>
> +        method.addChild(value2);
>
> +
>
> +
>
> +        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
>
> +        SOAPEnvelope envelope = factory.getDefaultEnvelope();
>
> +        envelope.getBody().addChild(method);
>
> +
>
> +
>
> +        String ref1 ="<reference id=\"1\"><name>Deepal</name><value
href=\"#2\"/><address href=\"#3\"/></reference>";
>
> +        OMElement om1 = getOMelemnt(ref1,fac);
>
> +        envelope.getBody().addChild(om1);
>
> +        String ref2 = "<reference id=\"2\">false</reference>";
>
> +        OMElement om2 = getOMelemnt(ref2,fac);
>
> +        envelope.getBody().addChild(om2);
>
> +        String ref3 = "<reference id=\"3\"><town href=\"#4\"/><number>1010</number></reference>";
>
> +        OMElement om3 = getOMelemnt(ref3,fac);
>
> +        envelope.getBody().addChild(om3);
>
> +        String ref4 = "<reference id=\"4\">Colombo3</reference>";
>
> +        OMElement om4 = getOMelemnt(ref4,fac);
>
> +        envelope.getBody().addChild(om4);
>
> +
>
> +        RPCCall call =
>
> +                new RPCCall("target/test-resources/intregrationRepo");
>
> +
>
> +        call.setTo(targetEPR);
>
> +        call.setTransportInfo(Constants.TRANSPORT_HTTP,
>
> +                Constants.TRANSPORT_HTTP,
>
> +                false);
>
> +        SOAPEnvelope env = call.invokeBlocking("editBean",envelope);
>
> +        OMElement response = env.getBody().getFirstElement();
>
> +        MyBean resBean = (MyBean) BeanSerializerUtil.deserialize(MyBean.class, response.getFirstElement());
>
> +        assertNotNull(resBean);
>
> +        assertEquals(resBean.getAge(), 159);
>
> +        call.close();
>
> +    }
>
> +
>
> +    private OMElement getOMelemnt(String str,OMFactory fac) throws AxisFault {
>
> +        StAXOMBuilder staxOMBuilder;
>
> +        try {
>
> +            XMLStreamReader xmlReader=  XMLInputFactory.newInstance().createXMLStreamReader(new
>
> +                    ByteArrayInputStream(str.getBytes()));
>
> +            staxOMBuilder = new
>
> +                    StAXOMBuilder(fac,xmlReader);
>
> +        } catch (XMLStreamException e) {
>
> +            throw new AxisFault(e);
>
> +        } catch (FactoryConfigurationError factoryConfigurationError) {
>
> +            throw new AxisFault(factoryConfigurationError);
>
> +        }
>
> +        return staxOMBuilder.getDocumentElement();
>
> +    }
>
> +
>
> +}
>
>
> Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
> URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?rev=327093&r1=327092&r2=327093&view=diff
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
(original)
> +++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
Thu Oct 20 21:06:53 2005
> @@ -125,6 +125,7 @@
>      private void configureSystem(String opName) throws AxisFault {
>
>          targetEPR =
>
>                  new EndpointReference("http://127.0.0.1:"
>
> +//                        + (5000)
>
>                          + (UtilServer.TESTING_PORT)
>
>                          + "/axis/services/EchoXMLService/" + opName);
>
>          String className = "org.apache.axis2.rpc.RPCServiceClass";
>
>
>
>


--
Davanum Srinivas : http://wso2.com/blogs/

Mime
View raw message