From: Bill Erickson Date: Wed, 29 Feb 2012 14:35:40 +0000 (-0500) Subject: more java gateway X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=67568785c2ce474b5e01975b6f251065a1f8d0e3;p=working%2FEvergreen.git more java gateway Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/java/org/open_ils/test/TestGateway.java b/Open-ILS/src/java/org/open_ils/test/TestGateway.java index 3d3a1ef49b..19d2bf7d42 100644 --- a/Open-ILS/src/java/org/open_ils/test/TestGateway.java +++ b/Open-ILS/src/java/org/open_ils/test/TestGateway.java @@ -8,52 +8,43 @@ import org.open_ils.idl.*; import java.util.Map; import java.util.HashMap; +import java.util.List; import java.net.URL; import java.net.HttpURLConnection; import java.io.InputStream; import java.io.BufferedInputStream; -/* -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.IOException; -import java.net.URI; -import java.lang.StringBuffer; -import java.util.List; -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; -import java.math.BigInteger; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -*/ - public class TestGateway { private static final String idlUrl = "http://dev198.esilibrary.com/reports/fm_IDL.xml"; private static IDLParser idlParser = null; - public static void main(String[] args) { + public static void main(String[] args) throws java.net.MalformedURLException { + System.out.println("Loading IDL..."); loadIDL(); + System.out.println("Done loading IDL."); - GatewayConnection conn = new GatewayConnection("http", "dev198.esilibrary.com"); + // configure the connection + HttpConnection conn = new HttpConnection("http://dev198.esilibrary.com/osrf-gateway-v1"); - Method method = new Method("opensrf.system.echo"); - Map pmap = new HashMap(); - pmap.put("foo", "bar"); - pmap.put("baz", "São Paulo"); - method.addParam("hello, yall j;lkj a;sldkfj as;ldfkja sd;flkajs df;alsdjfk as;l"); - method.addParam(pmap); + // create a stub biblio.record_entry + OSRFObject bre = new OSRFObject("bre"); + bre.put("id", new Integer(123)); + bre.put("marc", ""); + Method method = new Method("opensrf.system.echo"); + method.addParam(bre); - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 50; i++) { final int ii = i; - GatewayRequest req = conn.request("open-ils.auth", method); + HttpRequest req = new GatewayRequest(conn, "open-ils.auth", method); req.sendAsync( - new GatewayRequestHandler() { - public void onComplete(Object payload) { - System.out.println("response " + ii + " : " + payload.toString()); + new HttpRequestHandler() { + public void onResponse(HttpRequest req, Object resp) { + List respList = (List) resp; + OSRFObject bre = (OSRFObject) respList.get(0); + System.out.println("response " + ii + " : bre echoed with ID " + bre.get("id") + " and marc " + bre.get("marc")); System.out.flush(); } } @@ -74,14 +65,6 @@ public class TestGateway { } catch (Exception ex) { ex.printStackTrace(); } - - /* - OSRFObject bre = new OSRFObject("bre"); - bre.put("id", new Integer(1)); - bre.put("tcn_value", "FooBoo"); - bre.put("marc", ""); - System.out.println(new JSONWriter(bre).write()); - */ } }