MsgUnitRaw msg = new MsgUnitRaw(null, content, qos);
msgInfo.addMessage(msg);
byte[] raw = parser.createRawMsg(msgInfo);
System.out.println(parser.toLiteral(raw));
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
out.write(raw);
out.flush();
out.close();
MsgInfo msgInfoNew = parser.parse(in)[0];
byte[] rawNew = parser.createRawMsg(msgInfoNew);
System.out.println("Parsed and dumped again:" + parser.toLiteral(rawNew));
}
{
System.out.println("TEST1 SHOULD FORCE BASE64");
parser.init(glob, null, null);
MsgInfo msgInfo = new MsgInfo(glob, MsgInfo.INVOKE_BYTE, "12",
MethodName.PUBLISH, "secret", null);
byte[] content = "hello&bye]]>".getBytes();
//content[3] = 0;
MsgUnitRaw msg = new MsgUnitRaw("<key oid='hello'/>", content, "<qos></qos>");
msgInfo.addMessage(msg);
byte[] raw = parser.createRawMsg(msgInfo);
System.out.println("Initial creation:" + parser.toLiteral(raw));
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
out.write(raw);
out.flush();
out.close();
MsgInfo msgInfoNew = parser.parse(in)[0];
byte[] rawNew = parser.createRawMsg(msgInfoNew);
System.out.println("Parsed and dumped again:" + parser.toLiteral(rawNew));
}
{
System.out.println("TEST2 SHOULD KEEP LITERAL STRING");
parser.init(glob, null, null);
MsgInfo msgInfo = new MsgInfo(glob, MsgInfo.INVOKE_BYTE, "12",
MethodName.PUBLISH, "secret", null);
byte[] content = "Hello World!".getBytes();
MsgUnitRaw msg = new MsgUnitRaw("<key oid='hello'/>", content, "<qos></qos>");
msgInfo.addMessage(msg);
byte[] raw = parser.createRawMsg(msgInfo);
System.out.println("Initial creation:" + parser.toLiteral(raw));
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
out.write(raw);
out.flush();
out.close();
MsgInfo msgInfoNew = parser.parse(in)[0];