axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/providers/java RPCProvider.java
Date Mon, 24 Nov 2003 12:57:14 GMT
dims        2003/11/24 04:57:14

  Modified:    java/src/org/apache/axis/description ParameterDesc.java
               java/src/org/apache/axis/providers/java RPCProvider.java
  Added:       java/test/outparams2 build.xml PackageTests.java
                        TestOutParams.java
  Log:
  Fix and test case for Bug 22772 - OUT params incorrectly handled in RPCProvider
  from gawor@mcs.anl.gov
  
  Revision  Changes    Path
  1.1                  ws-axis/java/test/outparams2/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" ?>
  <!DOCTYPE project [
          <!ENTITY properties SYSTEM "file:../../xmls/properties.xml">
          <!ENTITY paths  SYSTEM "file:../../xmls/path_refs.xml">
          <!ENTITY taskdefs SYSTEM "file:../../xmls/taskdefs.xml">
          <!ENTITY taskdefs_post_compile SYSTEM "file:../../xmls/taskdefs_post_compile.xml">
          <!ENTITY targets SYSTEM "file:../../xmls/targets.xml">
  ]>
  
  <!-- ===================================================================
  <description>
     Test/Sample Component file for Axis
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
  
  Build Instructions:
     To compile
          ant compile
     To execute
          ant run
  
  Author:
    Matt Seibert mseibert@us.ibm.com
  
  Copyright:
    Copyright (c) 2002-2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  
          <property name="axis.home" location="../../" />
  	<property name="componentName" value="test/outparams2"/>
  
          &properties;
          &paths;
          &taskdefs;
          &taskdefs_post_compile;
  	&targets;
  
  
  <target name="clean">
      <echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}"
/>
      <delete dir="${build.dir}/classes/${componentName}"/>
      <delete dir="${build.dir}/work/${componentName}"/>
  </target>
  
  <target name="copy" depends="setenv"/>
  
  <target name="compile" depends="copy">
    <echo message="Compiling test.${componentName}"/>
    <javac srcdir="${axis.home}" destdir="${build.dest}" debug="${debug}" fork="${javac.fork}">
      <classpath>
          <path refid="classpath"/>
      </classpath>
      <include name="${componentName}/*.java"/>
    </javac>
  </target>
  
  <target name="run">
  	<antcall target="execute-Component" />
  </target>
  
  </project>
  
  
  
  1.1                  ws-axis/java/test/outparams2/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  package test.outparams2;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Session tests
   */
  public class PackageTests extends TestCase {
  
      public PackageTests(String name) {
          super(name);
      }
  
      public static Test suite() throws Exception {
          TestSuite suite = new TestSuite();
  
          suite.addTestSuite(TestOutParams.class);
  
          return suite;
      }
  }
  
  
  
  1.1                  ws-axis/java/test/outparams2/TestOutParams.java
  
  Index: TestOutParams.java
  ===================================================================
  package test.outparams2;
  
  import junit.framework.TestCase;
  
  import org.apache.axis.EngineConfiguration;
  import org.apache.axis.Message;
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.axis.description.ServiceDesc;
  import org.apache.axis.description.OperationDesc;
  import org.apache.axis.description.ParameterDesc;
  import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
  import org.apache.axis.configuration.SimpleProvider;
  import org.apache.axis.handlers.soap.SOAPService;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.providers.java.RPCProvider;
  import org.apache.axis.server.AxisServer;
  import org.apache.axis.transport.local.LocalTransport;
  
  import javax.xml.rpc.holders.StringHolder;
  import javax.xml.namespace.QName;
  
  public class TestOutParams extends TestCase { 
  
        /** A fixed message, with no parameters */
      private final String message =
  	"<?xml version=\"1.0\"?>\n" +
  	"<soapenv:Envelope " +
  	"xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
  	"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
  	"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
  	"<soapenv:Body>\n" +
  	"<ns1:serviceMethod soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"
" +
  	"xmlns:ns1=\"outParamsTest\"> </ns1:serviceMethod>\n" +
  	"</soapenv:Body></soapenv:Envelope>\n";
  
      private Service s_service = null ;
      private Call    client    = null ;
      private SimpleProvider provider = new SimpleProvider();
      private AxisServer server = new AxisServer(provider);
  
      private static boolean called = false;
  
      public TestOutParams(String name) {
          super(name);
          server.init();
      }
  
      public TestOutParams() {
  	super("Test Out Params");
      }
  
      public void testOutputParams() throws Exception {
          // Register the service
          s_service = new Service();
          client  = (Call) s_service.createCall();
  
  	SOAPService service = new SOAPService(null, 
                                                new RPCProvider(),
                                                null);
  	service.setName("TestOutParamsService");
          service.setOption("className", "test.outparams2.TestOutParams");
          service.setOption("allowedMethods", "serviceMethod");
  
          EngineConfiguration defaultConfig =
              (new DefaultEngineConfigurationFactory()).getServerEngineConfig();
          SimpleProvider config = new SimpleProvider(defaultConfig);
          config.deployService("outParamsTest", service);
          provider.deployService("outParamsTest", service);
  
          // Make sure the local transport uses the server we just configured
          client.setTransport(new LocalTransport(server));
  
  	Message msg = new Message(message, false);
  	SOAPEnvelope env = msg.getSOAPEnvelope();
  
  	// test invocation. test Holder parameter defaults to INOUT type
  	client.invoke(env);
  	
  	// method was succesfully invoked
  	assertTrue(called);
  	
  	ServiceDesc description = null;
  	OperationDesc operation = null;
  	ParameterDesc parameter = null;
  
  	description = service.getServiceDescription();
  	operation = description.getOperationByName("serviceMethod");
  	parameter = operation.getParamByQName(new QName("", "out1"));
  	    
  	assertEquals(ParameterDesc.INOUT, parameter.getMode());
  
  	// Changing output parameter to OUT type.
  	parameter.setMode(ParameterDesc.OUT);
  
  	// rest called
  	called = false;
  
  	// invoke again
  	client.invoke(env);
  	assertTrue(this.called);
      }
      
      public void serviceMethod(String in1, StringHolder out1) {
  	called = true;
      }
  
      public static void main(String args[])
      {
  	try {
  	    TestOutParams tester = new TestOutParams("OutParams Test");
  	    tester.testOutputParams();
  	} catch (Exception e) {
  	    e.printStackTrace();
  	}
      }
  }
  
  
  
  1.29      +2 -2      ws-axis/java/src/org/apache/axis/description/ParameterDesc.java
  
  Index: ParameterDesc.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/description/ParameterDesc.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ParameterDesc.java	13 Oct 2003 19:15:39 -0000	1.28
  +++ ParameterDesc.java	24 Nov 2003 12:57:13 -0000	1.29
  @@ -175,8 +175,8 @@
           text+=indent + "typeEntry:  " + typeEntry + "\n";
           text+=indent + "mode:       " + (mode == IN ? 
                                            "IN" : mode == INOUT ? 
  -                                         "INOUT" : "OUT:  " 
  -                                         + "position:" + order) + "\n";
  +                                         "INOUT" : "OUT") + "\n"; 
  +        text+=indent + "position:   " + order + "\n";
           text+=indent + "isReturn:   " + isReturn + "\n";
           text+=indent + "typeQName:  " + typeQName + "\n";
           text+=indent + "javaType:   " + javaType + "\n";
  
  
  
  1.108     +9 -14     ws-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- RPCProvider.java	2 May 2003 04:28:16 -0000	1.107
  +++ RPCProvider.java	24 Nov 2003 12:57:13 -0000	1.108
  @@ -273,21 +273,16 @@
               if (holderClass != null &&
                       Holder.class.isAssignableFrom(holderClass)) {
                   int index = count;
  -                if (param.getMode()==ParameterDesc.OUT) {
  -                    // OUT params don't have param order, just stick them at the end. 
  +                // Use the parameter order if specified or just stick them to the end.
 
  +                if (param.getOrder() != -1) {
  +                    index = param.getOrder();
  +                } else {
                       count++;
  -                } else if (param.getMode()==ParameterDesc.INOUT) {
  -                    // Use the parameter order if specified or just stick them to the end.
 
  -                    if(param.getOrder() != -1) {
  -                        index = param.getOrder();
  -                    } else {
  -                        count++;
  -                    }
  -                    // If it's already filled, don't muck with it
  -                    if(argValues[index] != null) {
  -                        continue;
  -                    }
  -                }                    
  +                }
  +                // If it's already filled, don't muck with it
  +                if (argValues[index] != null) {
  +                    continue;
  +                }
                   argValues[index] = holderClass.newInstance();
                   // Store an RPCParam in the outs collection so we
                   // have an easy and consistent way to write these
  
  
  

Mime
View raw message