OldRpcMessageWriter implements RpcMessageWriter { public void write(RpcRequest request) throws RpcException { try { writer.write(buildPar1(request)); } catch (IOException e) { throw new RpcException("unable to write request message", e); } } OldRpcMessageWriter(Writer w); void writeStartConnection(String hostname, String address, int localPort); void writeStopConnection(); void write(RpcRequest request); void flush(); static String buildApi(String n, String p, long f); static String buildHdr(String wkid, String winh, String prch, String wish); static String strPack(String n, int p); static String varPack(String n); static final String PREFIX; }
@Test public void testWriteRequestWithNoParameters() throws IOException { RpcRequest r = new RpcRequest("FOO BAR"); try { w.write(r); } catch (RpcException e) { e.printStackTrace(); } assertEquals("{XWB}00037|\u0001000029007XWB;;;;000140FOO BAR^00000", s.toString()); }
@Test public void testWriteRequestWithLiteralParameter() throws IOException { List<RpcParam> params = new ArrayList<RpcParam>(); params.add(new RpcParam("baz")); RpcRequest r = new RpcRequest("FOO BAR", params); try { w.write(r); } catch (RpcException e) { e.printStackTrace(); } assertEquals("{XWB}00044|\u0001000036007XWB;;;;000210FOO BAR^000070040baz", s.toString()); }
@Test public void testWriteRequestWithListParameter() throws IOException { List<RpcParam> params = new ArrayList<RpcParam>(); Mult mult = new Mult(); mult.put("baz", "spaz"); params.add(new RpcParam(mult)); RpcRequest r = new RpcRequest("FOO BAR", params); try { w.write(r); } catch (RpcException e) { e.printStackTrace(); } assertEquals("{XWB}00043|\u0001000035007XWB;;;;000201FOO BAR^000060032.x003baz004spaz000", s.toString()); }