From: Bill Erickson Date: Mon, 27 Feb 2012 23:08:16 +0000 (-0500) Subject: osrf http gateway test; add more idl stuff X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4e75cfe300c6b3eb73ec207a7d799c319d20de9d;p=working%2FEvergreen.git osrf http gateway test; add more idl stuff 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 new file mode 100644 index 0000000000..3d3a1ef49b --- /dev/null +++ b/Open-ILS/src/java/org/open_ils/test/TestGateway.java @@ -0,0 +1,88 @@ +package org.open_ils.test; + +import org.opensrf.*; +import org.opensrf.util.*; +import org.opensrf.net.http.*; +import org.open_ils.*; +import org.open_ils.idl.*; + +import java.util.Map; +import java.util.HashMap; +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) { + + loadIDL(); + + GatewayConnection conn = new GatewayConnection("http", "dev198.esilibrary.com"); + + 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); + + + for (int i = 0; i < 100; i++) { + final int ii = i; + GatewayRequest req = conn.request("open-ils.auth", method); + req.sendAsync( + new GatewayRequestHandler() { + public void onComplete(Object payload) { + System.out.println("response " + ii + " : " + payload.toString()); + System.out.flush(); + } + } + ); + } + } + + private static void loadIDL() { + try { + System.out.println("Fetching IDL"); + URL url = new URL(idlUrl); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + InputStream netStream = new BufferedInputStream(urlConnection.getInputStream()); + idlParser = new IDLParser(netStream); + idlParser.parse(); + System.out.println("Done parsing IDL"); + + } 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()); + */ + } +} + +