assertEquals(text, 0, this.updateInterceptor.waitOnUpdate(sleep, msgOid, Constants.STATE_OK));
this.updateInterceptor.clear();
// Now reestablish the callback server ...
I_CallbackServer cbServer = null;
try {
updateMsgs = new MsgInterceptor(glob, log, null); // just used as message container
this.updateInterceptor.clear();
try {
// TODO change this since it can not work when using xmlrpc with singleChannel=true
cbServer = new XmlRpcCallbackServer();
CallbackAddress cbAddress = new CallbackAddress(glob);
cbServer.initialize(this.glob, name, cbAddress, new AbstractCallbackExtended(glob) {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) throws XmlBlasterException {
try {
String contentStr = new String(content);
String cont = (contentStr.length() > 10) ? (contentStr.substring(0,10)+"...") : contentStr;
log.info("Receiving update of a message oid=" + updateKey.getOid() +
" priority=" + updateQos.getPriority() +
" state=" + updateQos.getState() +
" content=" + cont);
if (!updateQos.isErased()) {
updateMsgs.add(new Msg(cbSessionId, updateKey, content, updateQos));
}
}
catch (Throwable e) {
log.severe("Error in update method: " + e.toString());
e.printStackTrace();
}
return "";
}
public I_ClientPlugin getSecurityPlugin() { return null; }
public void lostConnection(XmlBlasterException xmlBlasterException) {}
}); // Establish new callback server
}
catch (Throwable e) {
log.severe("Can't restart callback server: " + e.toString());
fail("Can't restart callback server: " + e.toString());
}
log.info("Waiting long enough that xmlBlaster reconnected to us and expecting the 6 queued messages ...");
try { Thread.sleep(3000L); } catch( InterruptedException i) {}
assertEquals(text, 0, this.updateInterceptor.getMsgs().length);
assertEquals(text, 6, updateMsgs.getMsgs(msgOid, Constants.STATE_OK).length);
Msg[] msgArr = updateMsgs.getMsgs();
assertEquals(text, 6, msgArr.length);
int lastNum = -1;
int lastPrio = PriorityEnum.MAX_PRIORITY.getInt() + 1;
for (int i=0; i<msgArr.length; i++) {
int currPrio = msgArr[i].getUpdateQos().getPriority().getInt();
int currNum = msgArr[i].getContentInt();
if (lastPrio < currPrio || lastPrio == currPrio && lastNum >= currNum)
fail(text + " Sequence is not ascending: last=" + lastNum + " curr=" + currNum);
lastNum = currNum;
lastPrio = currPrio;
}
assertEquals("", PriorityEnum.MAX_PRIORITY, msgArr[0].getUpdateQos().getPriority());
assertEquals("", 4, msgArr[5].getUpdateQos().getPriority().getInt());
updateMsgs.clear();
this.updateInterceptor.clear();
}
finally {
if (cbServer != null) {
try { cbServer.shutdown(); } catch (Exception e) { log.severe(e.toString()); };
}
}
log.info("Success in testPriorizedDispatchPluginConnectionState()");
}