FmqMsg { public FmqMsg (int id) { this.id = id; } FmqMsg(int id); void destroy(); void putNumber8(long value); long getNumber8(); void putString(String value); String getString(); static FmqMsg recv(Socket input); boolean send(Socket socket); static void sendOhai(
        Socket output); static void sendOrly(
        Socket output,
        Collection <String> mechanisms,
        ZFrame challenge); static void sendYarly(
        Socket output,
        String mechanism,
        ZFrame response); static void sendOhai_Ok(
        Socket output); static void sendIcanhaz(
        Socket output,
        String path,
        Map <String, String> options,
        Map <String, String> cache); static void sendIcanhaz_Ok(
        Socket output); static void sendNom(
        Socket output,
        long credit,
        long sequence); static void sendCheezburger(
        Socket output,
        long sequence,
        int operation,
        String filename,
        long offset,
        int eof,
        Map <String, String> headers,
        ZFrame chunk); static void sendHugz(
        Socket output); static void sendHugz_Ok(
        Socket output); static void sendKthxbai(
        Socket output); static void sendSrsly(
        Socket output,
        String reason); static void sendRtfm(
        Socket output,
        String reason); FmqMsg dup(FmqMsg self); static void optionsDump(Map.Entry <String, String> entry, FmqMsg self); static void cacheDump(Map.Entry <String, String> entry, FmqMsg self); static void headersDump(Map.Entry <String, String> entry, FmqMsg self); void dump(); ZFrame address(); void setAddress(ZFrame address); int id(); void setId(int id); List <String> mechanisms(); void appendMechanisms(String format, Object ... args); void setMechanisms(Collection <String> value); ZFrame challenge(); void setChallenge(ZFrame frame); String mechanism(); void setMechanism(String format, Object ... args); ZFrame response(); void setResponse(ZFrame frame); String path(); void setPath(String format, Object ... args); Map <String, String> options(); String optionsString(String key, String defaultValue); long optionsNumber(String key, long defaultValue); void insertOptions(String key, String format, Object ... args); void setOptions(Map <String, String> value); Map <String, String> cache(); String cacheString(String key, String defaultValue); long cacheNumber(String key, long defaultValue); void insertCache(String key, String format, Object ... args); void setCache(Map <String, String> value); long credit(); void setCredit(long credit); long sequence(); void setSequence(long sequence); int operation(); void setOperation(int operation); String filename(); void setFilename(String format, Object ... args); long offset(); void setOffset(long offset); int eof(); void setEof(int eof); Map <String, String> headers(); String headersString(String key, String defaultValue); long headersNumber(String key, long defaultValue); void insertHeaders(String key, String format, Object ... args); void setHeaders(Map <String, String> value); ZFrame chunk(); void setChunk(ZFrame frame); String reason(); void setReason(String format, Object ... args); static final int FMQ_MSG_VERSION; static final int FMQ_MSG_FILE_CREATE; static final int FMQ_MSG_FILE_DELETE; static final int OHAI; static final int ORLY; static final int YARLY; static final int OHAI_OK; static final int ICANHAZ; static final int ICANHAZ_OK; static final int NOM; static final int CHEEZBURGER; static final int HUGZ; static final int HUGZ_OK; static final int KTHXBAI; static final int SRSLY; static final int RTFM; }
@Test public void testFmqMsg () { System.out.printf (" * fmq_msg: "); FmqMsg self = new FmqMsg (0); assert (self != null); self.destroy (); ZContext ctx = new ZContext (); assert (ctx != null); Socket output = ctx.createSocket (ZMQ.DEALER); assert (output != null); output.bind ("inproc: Socket input = ctx.createSocket (ZMQ.ROUTER); assert (input != null); input.connect ("inproc: self = new FmqMsg (FmqMsg.OHAI); self.send (output); self = FmqMsg.recv (input); assert (self != null); self.destroy (); self = new FmqMsg (FmqMsg.ORLY); self.appendMechanisms ("Name: %s", "Brutus"); self.appendMechanisms ("Age: %d", 43); self.setChallenge (new ZFrame ("Captcha Diem")); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.mechanisms ().size (), 2); assertEquals (self.mechanisms ().get (0), "Name: Brutus"); assertEquals (self.mechanisms ().get (1), "Age: 43"); assertTrue (self.challenge ().streq ("Captcha Diem")); self.destroy (); self = new FmqMsg (FmqMsg.YARLY); self.setMechanism ("Life is short but Now lasts for ever"); self.setResponse (new ZFrame ("Captcha Diem")); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.mechanism (), "Life is short but Now lasts for ever"); assertTrue (self.response ().streq ("Captcha Diem")); self.destroy (); self = new FmqMsg (FmqMsg.OHAI_OK); self.send (output); self = FmqMsg.recv (input); assert (self != null); self.destroy (); self = new FmqMsg (FmqMsg.ICANHAZ); self.setPath ("Life is short but Now lasts for ever"); self.insertOptions ("Name", "Brutus"); self.insertOptions ("Age", "%d", 43); self.insertCache ("Name", "Brutus"); self.insertCache ("Age", "%d", 43); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.path (), "Life is short but Now lasts for ever"); assertEquals (self.options ().size (), 2); assertEquals (self.optionsString ("Name", "?"), "Brutus"); assertEquals (self.optionsNumber ("Age", 0), 43); assertEquals (self.cache ().size (), 2); assertEquals (self.cacheString ("Name", "?"), "Brutus"); assertEquals (self.cacheNumber ("Age", 0), 43); self.destroy (); self = new FmqMsg (FmqMsg.ICANHAZ_OK); self.send (output); self = FmqMsg.recv (input); assert (self != null); self.destroy (); self = new FmqMsg (FmqMsg.NOM); self.setCredit ((byte) 123); self.setSequence ((byte) 123); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.credit (), 123); assertEquals (self.sequence (), 123); self.destroy (); self = new FmqMsg (FmqMsg.CHEEZBURGER); self.setSequence ((byte) 123); self.setOperation ((byte) 123); self.setFilename ("Life is short but Now lasts for ever"); self.setOffset ((byte) 123); self.setEof ((byte) 123); self.insertHeaders ("Name", "Brutus"); self.insertHeaders ("Age", "%d", 43); self.setChunk (new ZFrame ("Captcha Diem")); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.sequence (), 123); assertEquals (self.operation (), 123); assertEquals (self.filename (), "Life is short but Now lasts for ever"); assertEquals (self.offset (), 123); assertEquals (self.eof (), 123); assertEquals (self.headers ().size (), 2); assertEquals (self.headersString ("Name", "?"), "Brutus"); assertEquals (self.headersNumber ("Age", 0), 43); assertTrue (self.chunk ().streq ("Captcha Diem")); self.destroy (); self = new FmqMsg (FmqMsg.HUGZ); self.send (output); self = FmqMsg.recv (input); assert (self != null); self.destroy (); self = new FmqMsg (FmqMsg.HUGZ_OK); self.send (output); self = FmqMsg.recv (input); assert (self != null); self.destroy (); self = new FmqMsg (FmqMsg.KTHXBAI); self.send (output); self = FmqMsg.recv (input); assert (self != null); self.destroy (); self = new FmqMsg (FmqMsg.SRSLY); self.setReason ("Life is short but Now lasts for ever"); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.reason (), "Life is short but Now lasts for ever"); self.destroy (); self = new FmqMsg (FmqMsg.RTFM); self.setReason ("Life is short but Now lasts for ever"); self.send (output); self = FmqMsg.recv (input); assert (self != null); assertEquals (self.reason (), "Life is short but Now lasts for ever"); self.destroy (); ctx.destroy (); System.out.printf ("OK\n"); }