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