Package org.springmodules.remoting.xmlrpc.support

Examples of org.springmodules.remoting.xmlrpc.support.XmlRpcRequest


   * service specified in the XML-RPC request.
   */
  public void testHandleRequest() throws Exception {
    this.setUpMockObjects();

    XmlRpcRequest xmlRpcRequest = new XmlRpcRequest();
    xmlRpcRequest.setServiceName(this.serviceName);

    // expectation: parse the XML-RPC request.
    this.xmlRpcRequestParser.parseRequest(this.request.getInputStream());
    this.xmlRpcRequestParserControl.setReturnValue(xmlRpcRequest);

View Full Code Here


   */
  public void testHandleRequestWhenServiceInvocationThrowsException()
      throws Exception {
    this.setUpMockObjects();

    XmlRpcRequest xmlRpcRequest = new XmlRpcRequest();
    xmlRpcRequest.setServiceName(this.serviceName);

    // expectation: parse the XML-RPC request.
    this.xmlRpcRequestParser.parseRequest(this.request.getInputStream());
    this.xmlRpcRequestParserControl.setReturnValue(xmlRpcRequest);

View Full Code Here

  public void testHandleRequestWhenServiceIsNotFound() {
    this.setUpMockObjects();

    String notExistingServiceName = "anotherService";

    XmlRpcRequest xmlRpcRequest = new XmlRpcRequest();
    xmlRpcRequest.setServiceName(notExistingServiceName);

    // expectation: parse the XML-RPC request.
    this.xmlRpcRequestParser.parseRequest(this.request.getInputStream());
    this.xmlRpcRequestParserControl.setReturnValue(xmlRpcRequest);
View Full Code Here

    Long customerId = new Long(542);

    String methodName = "getCustomerName";
    XmlRpcElement[] parameters = { new XmlRpcString(customerId.toString()) };

    XmlRpcRequest request = new XmlRpcRequest();
    request.setMethodName(methodName);
    request.setParameters(parameters);

    RemoteInvocation remoteInvocation = this.serviceExporter
        .findMatchingMethod(request);

    assertEquals("<Method name>", methodName, remoteInvocation.getMethodName());
View Full Code Here

   * throws a <code>{@link XmlRpcMethodNotFoundException}</code> if the method
   * name of the given XML-RPC request does not match any method name of the
   * service.
   */
  public void testFindMatchingMethodWithNotMatchingMethodName() {
    XmlRpcRequest request = new XmlRpcRequest();
    request.setMethodName("notExistingMethod");

    try {
      this.serviceExporter.findMatchingMethod(request);
      fail("A 'XmlRpcMethodNotFoundException' should have been thrown");

View Full Code Here

   * throws a <code>{@link XmlRpcMethodNotFoundException}</code> if the number
   * of parameters of the given XML-RPC request does not match the number of
   * parameters of the service method with matching name.
   */
  public void testFindMatchingMethodWithNotMatchingParameterCount() {
    XmlRpcRequest request = new XmlRpcRequest();
    request.setMethodName("getCustomerName");

    XmlRpcElement[] parameters = { new XmlRpcString("Luke"),
        new XmlRpcString("Anakin") };
    request.setParameters(parameters);

    try {
      this.serviceExporter.findMatchingMethod(request);
      fail("A 'XmlRpcMethodNotFoundException' should have been thrown");

View Full Code Here

   * throws a <code>{@link XmlRpcMethodNotFoundException}</code> if the type
   * of the parameters of the given XML-RPC request does not match the type of
   * the parameters of the service method with matching name.
   */
  public void testFindMatchingMethodWithNotMatchingParameterType() {
    XmlRpcRequest request = new XmlRpcRequest();
    request.setMethodName("getCustomerName");

    XmlRpcElement[] parameters = { new XmlRpcString("Luke") };
    request.setParameters(parameters);

    try {
      this.serviceExporter.findMatchingMethod(request);
      fail("A 'XmlRpcMethodNotFoundException' should have been thrown");

View Full Code Here

    String customerName = "Luke";

    String methodName = "getCustomerName";
    XmlRpcElement[] parameters = { new XmlRpcString(argument.toString()) };

    XmlRpcRequest request = new XmlRpcRequest();
    request.setMethodName(methodName);
    request.setParameters(parameters);
   
    RemoteInvocation invocation = new RemoteInvocation();
    invocation.setMethodName("getCustomerName");
    invocation.setParameterTypes(new Class[] { Long.class });
    invocation.setArguments(new Object[] { argument });
View Full Code Here

    xmlRpcArray.add(new XmlRpcString("Luke"));
    xmlRpcArray.add(new XmlRpcString("Leia"));

    XmlRpcElement[] parameters = { xmlRpcArray };

    XmlRpcRequest expected = new XmlRpcRequest(this.serviceName,
        this.methodName, parameters);

    StringBuffer builder = new StringBuffer();
    builder.append("<?xml version=\"1.0\"?>");
    builder.append("<methodCall><methodName>");
    builder.append(this.serviceAndMethodNames);
    builder.append("</methodName><params><param><value><array><data>");

    XmlRpcElement[] elements = xmlRpcArray.getElements();
    int memberCount = elements.length;
    for (int i = 0; i < memberCount; i++) {
      XmlRpcString element = (XmlRpcString) elements[i];

      builder.append("<value>");
      builder.append(element.getValue());
      builder.append("</value>");
    }

    builder.append("</data></array></value></param></params></methodCall>");

    String request = builder.toString();

    InputStream inputStream = new ByteArrayInputStream(request.getBytes());
    XmlRpcRequest actual = this.parser.parseRequest(inputStream);

    this.logger.info("XML-RPC request: " + request);
    this.logger.info(actual);
   
    assertEquals("<XML-RPC request>", expected, actual);
View Full Code Here

    byte[] encodedValue = Base64.encodeBase64(value);

    XmlRpcBase64 xmlRpcBase64 = new XmlRpcBase64(value);
    XmlRpcElement[] parameters = { xmlRpcBase64 };

    XmlRpcRequest expected = new XmlRpcRequest(this.serviceName,
        this.methodName, parameters);

    StringBuffer builder = new StringBuffer();
    builder.append("<?xml version=\"1.0\"?>");
    builder.append("<methodCall><methodName>");
    builder.append(this.serviceAndMethodNames);
    builder.append("</methodName><params><param><value><base64>");
    builder.append(new String(encodedValue, 0, encodedValue.length));
    builder.append("</base64></value></param></params></methodCall>");

    String request = builder.toString();

    InputStream inputStream = new ByteArrayInputStream(request.getBytes());
    XmlRpcRequest actual = this.parser.parseRequest(inputStream);

    this.logger.info("XML-RPC request: " + request);
    this.logger.info(actual);
   
    assertEquals("<XML-RPC request>", expected, actual);
View Full Code Here

TOP

Related Classes of org.springmodules.remoting.xmlrpc.support.XmlRpcRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.