axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/test/utils/cache TestJavaClass.java
Date Mon, 04 Jun 2001 18:56:57 GMT
rubys       01/06/04 11:56:57

  Modified:    java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/utils/cache JavaMethod.java
               java/test/RPCDispatch Service.java TestRPC.java
               java/test/utils/cache TestJavaClass.java
  Log:
  Fix regression introduced into cache/JavaMethod, add additional tests
  to ensure that this does not reoccur.  Add a test for new function where
  messageContext can optionally be passed to the target method by RPCProvider.
  Eliminate string concatenation from two calls to debug.
  
  Revision  Changes    Path
  1.3       +22 -13    xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RPCProvider.java	2001/06/02 16:02:20	1.2
  +++ RPCProvider.java	2001/06/04 18:56:52	1.3
  @@ -132,13 +132,29 @@
                                           "Service name=" + methodName,
                                       null, null );  // should they??
               
  -            Debug.Print( 2, "mName: " + mName );
  -            Debug.Print( 2, "MethodName: " + methodName );
  +            Debug.Print( 2, "mName: ", mName );
  +            Debug.Print( 2, "MethodName: ", methodName );
               Method       method = jc.getMethod(mName, args.size());
   
  -            if ( method == null ) {
  -              // If method wasn't found using the args that were passed 
  -              // in then try again, this time with MessageContext frist
  +            // if the method wasn't found, try with one more parameter...
  +            if ( method == null ) method = jc.getMethod(mName, args.size()+1);
  +
  +
  +            if ( method == null )
  +                throw new AxisFault( "AxisServer.error",
  +                                    "Method not found\n" +
  +                                        "Method name=" + methodName + "\n" +
  +                                        "Service name=" + msgContext.getTargetService(),
  +                                    null, null );
  +            
  +            // If method has an additional parameter of the right parameter
  +            // type, add MessageContext as the first parameter
  +            Class params[] = method.getParameterTypes();
  +            System.out.println("params:" + params.length);
  +            System.out.println("args:" + args.size());
  +            if (params.length > args.size() 
  +              && params[0].equals(msgContext.getClass())) 
  +            {
                 args.add( 0, msgContext );
                 method = jc.getMethod(mName, args.size());
                 if ( method != null ) {
  @@ -150,15 +166,8 @@
                 }
               }
   
  -            if ( method == null )
  -                throw new AxisFault( "AxisServer.error",
  -                                    "Method not found\n" +
  -                                        "Method name=" + methodName + "\n" +
  -                                        "Service name=" + msgContext.getTargetService(),
  -                                    null, null );
  -            
               Object objRes = method.invoke( obj, argValues );
  -            
  +
               /* Now put the result in the result SOAPEnvelope */
               /*************************************************/
               RPCElement resBody = new RPCElement(mName + "Response");
  
  
  
  1.4       +2 -3      xml-axis/java/src/org/apache/axis/utils/cache/JavaMethod.java
  
  Index: JavaMethod.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/cache/JavaMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JavaMethod.java	2001/06/02 16:02:21	1.3
  +++ JavaMethod.java	2001/06/04 18:56:53	1.4
  @@ -109,7 +109,7 @@
        * will be picked randomly.  If the name is unique, it is simply
        * returned without checking as attempts to invoke a method based
        * on this will undoubtably fail anyway.
  -     * @param numargs number of arguments
  +     * @param numargs number of arguments.  Use -1 to indicate "don't care".
        * @return closest match
        */
       public Method getMethod(int numargs) {
  @@ -120,8 +120,7 @@
                   }
               }
           } 
  -        if ( unique.getParameterTypes().length != numargs )
  -          return null ;
  +
           return unique;
       }
   };
  
  
  
  1.3       +9 -0      xml-axis/java/test/RPCDispatch/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/Service.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Service.java	2001/05/22 00:07:49	1.2
  +++ Service.java	2001/06/04 18:56:54	1.3
  @@ -1,5 +1,7 @@
   package test.RPCDispatch;
   
  +import org.apache.axis.MessageContext;
  +
   /**
    * Test WebService
    */
  @@ -23,5 +25,12 @@
          result.setField2(reverseString(input.getField2()));
          result.setField3(input.getField1());
          return result;
  +    }
  +
  +    /**
  +     * Return the target service (should be this!)
  +     */
  +    public String targetService(MessageContext mc) throws Exception {
  +       return mc.getTargetService();
       }
   }
  
  
  
  1.6       +14 -0     xml-axis/java/test/RPCDispatch/TestRPC.java
  
  Index: TestRPC.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestRPC.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestRPC.java	2001/05/31 05:14:51	1.5
  +++ TestRPC.java	2001/06/04 18:56:55	1.6
  @@ -132,4 +132,18 @@
           Data expected = new Data(3, "cba", 5);
           assertEquals(expected, rpc("reverseData", new Object[] {input}));
       }
  +
  +    /**
  +     * Test a simple method that returns a field from the message context
  +     */
  +    public void testMessageContext() throws Exception {
  +        // Register the reverseString service
  +        SOAPService reverse = new SOAPService(RPCDispatcher, "RPCDispatcher");
  +        reverse.addOption("className", "test.RPCDispatch.Service");
  +        reverse.addOption("methodName", "targetService");
  +        sr.add(SOAPAction, reverse);
  +
  +        // invoke the service and verify the result
  +        assertEquals(SOAPAction, rpc("targetService", new Object[] {}));
  +    }
   }
  
  
  
  1.3       +22 -0     xml-axis/java/test/utils/cache/TestJavaClass.java
  
  Index: TestJavaClass.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/utils/cache/TestJavaClass.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestJavaClass.java	2001/06/03 00:04:16	1.2
  +++ TestJavaClass.java	2001/06/04 18:56:56	1.3
  @@ -45,4 +45,26 @@
           assertEquals("boolean", add1.getReturnType().getName());
           assertEquals("void", add2.getReturnType().getName());
       }
  +
  +    public void testNoSuchMethod()
  +    {
  +        Class v = new java.util.Vector().getClass(); 
  +        JavaClass jcVec = new JavaClass(v);
  +
  +        Method add7 = jcVec.getMethod("add", 7);
  +        assertNull(add7);
  +    }
  +
  +    public void testUnknownNumberOfArgs()
  +    {
  +        Class v = new java.util.Vector().getClass(); 
  +        JavaClass jcVec = new JavaClass(v);
  +
  +        Method add7 = jcVec.getMethod("add", -1);
  +        assertNull(add7);
  +
  +        Method insertElementAt = jcVec.getMethod("insertElementAt", -1);
  +        assertEquals(2, insertElementAt.getParameterTypes().length);
  +        assertEquals("void", insertElementAt.getReturnType().getName());
  +    }
   }
  
  
  

Mime
View raw message