NewRpcMessageWriter implements RpcMessageWriter { public static String SPack(String str) { int r = str.length(); if (r > 255) throw new IllegalArgumentException("In generation of message to server, send to SPack with string '" + str + "' of " + r + " chars which exceeds max of 255 chars'"); return ((char) r) + str; } NewRpcMessageWriter(Writer w); void writeStartConnection(String hostname, String address, int localPort); void writeStopConnection(); void write(RpcRequest request); void flush(); static String SPack(String str); static String LPack(String str, int nDigits); static final String PREFIX; }
@Test public void testSPack() { assertEquals("\u0003foo", NewRpcMessageWriter.SPack("foo")); assertEquals("\u0009foobarbaz", NewRpcMessageWriter.SPack("foobarbaz")); }