presenceSession.sendRequest(subscribe, Response.OK); // 4
ServerTransaction tx = presenceSession.waitForNotify(); // 5
System.out.println("5:\n" + tx.getRequest());
presenceSession.sendResponse(Response.OK, tx); // 6
Presence presence = getPresence(tx.getRequest());
assertEquals(Basic.CLOSED, presence.getTupleArray()[0].getStatus().getBasic());
SubscribeSession winfoSession = new SubscribeSession(getAlicePhone(), "presence.winfo"); // 7
subscribe = winfoSession.newInitialSubscribe(60, getAliceUri());
winfoSession.sendRequest(subscribe, Response.OK); // 8
tx = winfoSession.waitForNotify(); // 9
Request notify = tx.getRequest();
System.out.println("9:\n" +notify);
winfoSession.sendResponse(Response.OK, tx); // 10
SubscriptionStateHeader subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
assertEquals(SubscriptionStateHeader.ACTIVE.toLowerCase(), subState.getState().toLowerCase());
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(getAliceUri(), watcherList.getResource());
assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
assertEquals(1, watcherList.getWatcherArray().length);
Watcher watcher = watcherList.getWatcherArray(0);
assertEquals(Event.TIMEOUT, watcher.getEvent());
assertEquals(getBobUri(), watcher.getStringValue());
assertEquals(Status.WAITING, watcher.getStatus());
HttpClient httpClient = new HttpClient();
PutMethod put = new PutMethod(getHttpXcapUri() + ALICE_PRES_RULES_URI); // 11
InputStream is = WatcherInfoTest.class.getResourceAsStream("/xcap-root/pres-rules/users/put/elementCondAliceBob.xml");
RequestEntity entity = new InputStreamRequestEntity(is, "application/xcap-el+xml");
put.setRequestEntity(entity);
int result = httpClient.executeMethod(put);
assertEquals(200, result); // 12
put.releaseConnection();
presenceSession = new SubscribeSession(getBobPhone(), "presence");
subscribe = presenceSession.newInitialSubscribe(0, getAliceUri()); // 13
presenceSession.sendRequest(subscribe, Response.OK); // 14
tx = presenceSession.waitForNotify(); // 15
System.out.println("15:\n" + tx.getRequest());
presenceSession.sendResponse(Response.OK, tx); // 16
presence = getPresence(tx.getRequest());
assertEquals(Basic.OPEN, presence.getTupleArray()[0].getStatus().getBasic());
publish = publishSession.newUnpublish(); // 25
publishSession.sendRequest(publish, Response.OK); // 26
}