@@ -406,4 +406,36 @@ public void testRemoveNamespacedGroup() throws InterruptedException, JSONExcepti
406406 assertJSONArrayHasNo (group , groups );
407407 assertEquals (channelNamespace , result .getString ("namespace" ));
408408 }
409+
410+ @ Test
411+ public void testPresence () throws InterruptedException , JSONException , PubnubException {
412+ String group = "jtest_group3" ;
413+ JSONObject result ;
414+
415+ final CountDownLatch latch1 = new CountDownLatch (1 );
416+ final CountDownLatch latch2 = new CountDownLatch (1 );
417+ final CountDownLatch latch3 = new CountDownLatch (1 );
418+ final TestHelper .SimpleCallback cb1 = new TestHelper .SimpleCallback (latch1 );
419+ final TestHelper .SimpleCallback cb2 = new TestHelper .SimpleCallback (latch2 ) {
420+ @ Override
421+ public void connectCallback (String channel , Object message ) {
422+ latch3 .countDown ();
423+ }
424+ };
425+
426+ pubnub .channelGroupAddChannel (group , "ch1" , cb1 );
427+ latch1 .await (10 , TimeUnit .SECONDS );
428+
429+ pubnub .channelGroupSubscribe (group + "-pnpres" , cb2 );
430+ latch3 .await (10 , TimeUnit .SECONDS );
431+
432+ pubnub .subscribe ("ch1" , new Callback () {
433+ });
434+
435+ latch2 .await (10 , TimeUnit .SECONDS );
436+
437+ result = (JSONObject ) cb2 .getResponse ();
438+
439+ assertEquals (pubnub .getUUID (), result .getString ("uuid" ));
440+ }
409441}
0 commit comments