assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
Watcherinfo watcherinfo = getWatcherinfo(notify);
assertEquals(0, watcherinfo.getVersion().intValue());
assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
assertEquals(1, watcherinfo.getWatcherListArray().length);
WatcherList watcherList = watcherinfo.getWatcherListArray(0);
assertEquals(getBobUri(), watcherList.getResource());
assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
assertEquals(0, watcherList.getWatcherArray().length);
SubscribeSession presenceSession = new SubscribeSession(getAlicePhone(), "presence");
subscribe = presenceSession.newInitialSubscribe(100, getBobUri()); // 5
presenceSession.sendRequest(subscribe, Response.OK); // 6
tx = winfoSession.waitForNotify(); // 7
notify = tx.getRequest();
//System.out.println(notify);
winfoSession.sendResponse(Response.OK, tx); // 8
watcherinfo = getWatcherinfo(notify);
assertEquals(1, watcherinfo.getVersion().intValue());
watcherList = watcherinfo.getWatcherListArray(0);
assertEquals(1, watcherList.sizeOfWatcherArray());
Watcher watcher = watcherList.getWatcherArray(0);
assertEquals(Event.SUBSCRIBE, watcher.getEvent());
assertEquals(getAliceUri(), watcher.getStringValue());
assertEquals(Status.ACTIVE, watcher.getStatus());
tx = presenceSession.waitForNotify(); // 9
presenceSession.sendResponse(Response.OK, tx); // 10
subscribe = presenceSession.newSubsequentSubscribe(0); // 11
presenceSession.sendRequest(subscribe, Response.OK); // 12
tx = winfoSession.waitForNotify(); // 13
notify = tx.getRequest();
// System.out.println(notify);
winfoSession.sendResponse(Response.OK, tx); // 14
watcherinfo = getWatcherinfo(notify);
assertEquals(2, watcherinfo.getVersion().intValue());
watcherList = watcherinfo.getWatcherListArray(0);
assertEquals(1, watcherList.sizeOfWatcherArray());
watcher = watcherList.getWatcherArray(0);
assertEquals(Event.TIMEOUT, watcher.getEvent());
assertEquals(getAliceUri(), watcher.getStringValue());
assertEquals(Status.TERMINATED, watcher.getStatus());
tx = presenceSession.waitForNotify(); // 15
presenceSession.sendResponse(Response.OK, tx); // 16
subscribe = winfoSession.newSubsequentSubscribe(0); // 17
winfoSession.sendRequest(subscribe, Response.OK); //18
tx = winfoSession.waitForNotify(); // 19
notify = tx.getRequest();
// System.out.println(notify);
winfoSession.sendResponse(Response.OK, tx); // 20
watcherinfo = getWatcherinfo(notify);
assertEquals(3, watcherinfo.getVersion().intValue());
watcherList = watcherinfo.getWatcherListArray(0);
assertEquals(0, watcherList.sizeOfWatcherArray());
}