1 package org.opensrf.test;
3 import org.opensrf.util.*;
7 import java.util.ArrayList;
8 import java.io.PrintStream;
11 public class TestClient {
12 public static void main(String args[]) throws Exception {
14 PrintStream out = System.out;
19 Sys.bootstrapClient(args[0], "/config/opensrf");
22 } catch(ArrayIndexOutOfBoundsException e) {
23 out.println( "usage: org.opensrf.test.TestClient "+
24 "<osrfConfigFile> <service> <method> [<JSONparam1>, <JSONparam2>]");
28 /** build the client session and send the request */
29 ClientSession session = new ClientSession(service);
30 List<Object> params = new ArrayList<Object>();
33 for(int i = 3; i < args.length; i++) /* add the params */
34 params.add(new JSONReader(args[i]).read());
36 Request request = session.request(method, params);
39 long start = new Date().getTime();
40 while( (result = request.recv(60000)) != null ) {
41 out.println("status = " + result.getStatus());
42 out.println("status code = " + result.getStatusCode());
43 out.println("result JSON: " + new JSONWriter(result.getContent()).write());
45 out.println("Request took: " + (new Date().getTime() - start));