1 package org.opensrf.test;
3 import org.opensrf.util.*;
4 import org.opensrf.net.xmpp.*;
5 import java.io.PrintStream;
10 public class TestClient {
11 public static void main(String args[]) throws Exception {
13 PrintStream out = System.out;
17 /** setup the config parser */
18 String configFile = args[0];
19 Config config = new Config("/config/opensrf");
20 config.parse(configFile);
21 Config.setConfig(config);
23 /** Connect to jabber */
24 String username = Config.getString("/username");
25 String passwd = Config.getString("/passwd");
26 String host = (String) Config.getFirst("/domains/domain");
27 int port = Config.getInt("/port");
28 XMPPSession xses = new XMPPSession(host, port);
29 xses.connect(username, passwd, "test-java-client");
30 XMPPSession.setGlobalSession(xses);
32 /** build the client session and send the request */
33 ClientSession session = new ClientSession("opensrf.settings");
34 Request request = session.request(
35 "opensrf.settings.host_config.get",
36 new String[] {args[1]}
39 Result result = request.recv(10000);
41 out.println("no result");
45 out.println("status = " + result.getStatus());
46 out.println("status code = " + result.getStatusCode());
48 out.println("setting config memcache server(s) = " +
50 Utils.findPath( (Map) result.getContent(),
51 "/cache/global/servers/server")
55 } catch(ArrayIndexOutOfBoundsException e) {
56 out.println("usage: org.opensrf.test.TestClient <osrfConfigFile> <domain>");