SessionRequestMessage extends RexProMessage { public void metaSetKillSession(Boolean val) { Meta.put(KILL_SESSION_META_KEY, val); }  void metaSetKillSession(Boolean val); Boolean metaGetKillSession(); void metaSetGraphName(String val); String metaGetGraphName(); void metaSetGraphObjName(String val); String metaGetGraphObjName(); public String Username; public String Password; }
@Test public void testMetaValidation() { SessionRequestMessage msg = new SessionRequestMessage(); msg.setRequestAsUUID(UUID.randomUUID()); msg.setSessionAsUUID(UUID.randomUUID()); msg.metaSetKillSession(true); msg.Username = "mr test"; msg.Password = "password"; try { msg.validateMetaData(); } catch (RexProException ex) { Assert.fail(); } try { msg.Meta.put(SessionRequestMessage.KILL_SESSION_META_KEY, 5); msg.validateMetaData(); Assert.fail(); } catch (RexProException ex) { } }
@Test public void testSerialization() { MessagePack msgpack = new MessagePack(); msgpack.register(RexProMessageMeta.class, MetaTemplate.getInstance()); msgpack.register(RexProBindings.class, RexProBindings.SerializationTemplate.getInstance()); msgpack.register(RexProScriptResult.class, ResultsTemplate.getInstance()); SessionRequestMessage outMsg = new SessionRequestMessage(); outMsg.setRequestAsUUID(UUID.randomUUID()); outMsg.setSessionAsUUID(UUID.randomUUID()); outMsg.metaSetKillSession(true); outMsg.Username = "mr test"; outMsg.Password = "password"; final ByteArrayOutputStream outStream = new ByteArrayOutputStream(); final Packer packer = msgpack.createPacker(outStream); try { packer.write(outMsg); packer.close(); } catch (IOException ex) { Assert.fail(); } byte[] bytes = outStream.toByteArray(); final ByteArrayInputStream in = new ByteArrayInputStream(bytes); final Unpacker unpacker = msgpack.createUnpacker(in); SessionRequestMessage inMsg; try { inMsg = unpacker.read(SessionRequestMessage.class); Assert.assertEquals(outMsg.Meta, inMsg.Meta); Assert.assertEquals(UUID.nameUUIDFromBytes(outMsg.Request), UUID.nameUUIDFromBytes(inMsg.Request)); Assert.assertEquals(UUID.nameUUIDFromBytes(outMsg.Session), UUID.nameUUIDFromBytes(inMsg.Session)); Assert.assertEquals(outMsg.Username, inMsg.Username); Assert.assertEquals(outMsg.Password, inMsg.Password); } catch (IOException ex) { Assert.fail(); } }