01: /*
02: Licensed to the Apache Software Foundation (ASF) under one
03: or more contributor license agreements. See the NOTICE file
04: distributed with this work for additional information
05: regarding copyright ownership. The ASF licenses this file
06: to you under the Apache License, Version 2.0 (the
07: "License"); you may not use this file except in compliance
08: with the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing,
13: software distributed under the License is distributed on an
14: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: KIND, either express or implied. See the License for the
16: specific language governing permissions and limitations
17: under the License.
18: */
19:
20: package org.ofbiz.webapp.test;
21:
22: import org.ofbiz.entity.GenericDelegator;
23: import org.ofbiz.service.GenericDispatcher;
24: import org.ofbiz.service.ModelService;
25: import org.ofbiz.service.LocalDispatcher;
26: import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
27: import org.apache.xmlrpc.client.XmlRpcClient;
28:
29: import java.util.Map;
30: import java.net.URL;
31:
32: import junit.framework.TestCase;
33:
34: /**
35: * XmlRpcTests
36: */
37: public class XmlRpcTests extends TestCase {
38:
39: public static final String module = XmlRpcTests.class.getName();
40: protected LocalDispatcher dispatcher = null;
41:
42: public XmlRpcTests(String name) {
43: super (name);
44: }
45:
46: protected void setUp() throws Exception {
47: GenericDelegator delegator = GenericDelegator
48: .getGenericDelegator("test");
49: dispatcher = GenericDispatcher.getLocalDispatcher(
50: "test-dispatcher", delegator);
51: }
52:
53: protected void tearDown() throws Exception {
54: }
55:
56: public void testXmlRpcRequest() throws Exception {
57: XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
58: config.setServerURL(new URL(
59: "http://localhost:8080/webtools/control/xmlrpc"));
60: config.setBasicUserName("admin");
61: config.setBasicPassword("ofbiz");
62:
63: XmlRpcClient client = new XmlRpcClient();
64: client.setConfig(config);
65:
66: Object[] params = new Object[] { new Double(55.00),
67: "message from xml-rpc client" };
68: Map result = (Map) client.execute("testScv", params);
69: assertEquals("XML-RPC Service result success",
70: ModelService.RESPOND_SUCCESS, result
71: .get(ModelService.RESPONSE_MESSAGE));
72: }
73: }
|