TEST_F(ClusterTest, testListenersWhenClusterDown) {
                HazelcastServer instance(*g_srvFactory);

                std::auto_ptr<ClientConfig> clientConfig(getConfig());
                clientConfig->setAttemptPeriod(1000 * 10).setConnectionAttemptLimit(100).setLogLevel(FINEST);
                HazelcastClient hazelcastClient(*clientConfig);

                util::CountDownLatch countDownLatch(1);
                DummyListenerClusterTest listener(countDownLatch);
                IMap<std::string, std::string> m = hazelcastClient.getMap<std::string, std::string>(
                        "testListenersWhenClusterDown");
                m.addEntryListener(listener, true);
                instance.shutdown();

                util::CountDownLatch lifecycleLatch(1);
                LclForClusterTest lifecycleListener(lifecycleLatch);
                hazelcastClient.addLifecycleListener(&lifecycleListener);

                HazelcastServer instance2(*g_srvFactory);
                ASSERT_TRUE(lifecycleLatch.await(120));
                // Let enough time for the client to re-register the failed listeners
                util::sleep(1);
                m.put("sample", "entry");
                ASSERT_TRUE(countDownLatch.await(60));
                ASSERT_TRUE(hazelcastClient.removeLifecycleListener(&lifecycleListener));
            }
            void ClientTxnMapTest::testKeySetAndValuesWithPredicates() {
                std::string name = "testKeysetAndValuesWithPredicates";
                IMap<Employee, Employee> map = client->getMap<Employee, Employee>(name);

                Employee emp1("abc-123-xvz", 34);
                Employee emp2("abc-123-xvz", 20);

                map.put(emp1, emp1);

                TransactionContext context = client->newTransactionContext();
                context.beginTransaction();

                TransactionalMap<Employee, Employee> txMap = context.getMap<Employee, Employee>(name);
                assertNull(txMap.put(emp2, emp2).get());

                assertEqual(2, (int)txMap.size());
                assertEqual(2, (int)txMap.keySet().size());
                query::SqlPredicate predicate("a = 10");
                assertEqual(0, (int)txMap.keySet(&predicate).size());
                assertEqual(0, (int)txMap.values(&predicate).size());
                predicate.setSql("a >= 10");
                assertEqual(2, (int)txMap.keySet(&predicate).size());
                assertEqual(2, (int)txMap.values(&predicate).size());

                context.commitTransaction();

                assertEqual(2, (int)map.size());
                assertEqual(2, (int)map.values().size());


            }
            void ClientTxnMapTest::testKeySetValues() {
                std::string name = "testKeySetValues";
                IMap<std::string, std::string> map = client->getMap<std::string, std::string>(name);
                map.put("key1", "value1");
                map.put("key2", "value2");

                TransactionContext context = client->newTransactionContext();
                context.beginTransaction();
                TransactionalMap<std::string, std::string> txMap = context.getMap<std::string, std::string>(name);
                assertNull(txMap.put("key3", "value3").get());


                assertEqual(3, (int)txMap.size());
                assertEqual(3, (int)txMap.keySet().size());
                assertEqual(3, (int)txMap.values().size());
                context.commitTransaction();

                assertEqual(3, (int)map.size());
                assertEqual(3, (int)map.keySet().size());
                assertEqual(3, (int)map.values().size());

            }
            void ClusterTest::testListenersWhenClusterDown() {
                HazelcastServer instance(hazelcastInstanceFactory);

                std::auto_ptr<ClientConfig> clientConfig(getConfig());
                clientConfig->setAttemptPeriod(1000 * 10).setConnectionAttemptLimit(100).setLogLevel(FINEST);
                HazelcastClient hazelcastClient(*clientConfig);

                util::CountDownLatch countDownLatch(1);
                DummyListenerClusterTest listener(countDownLatch);
                IMap<std::string, std::string> m = hazelcastClient.getMap<std::string, std::string>("testListenersWhenClusterDown");
                m.addEntryListener(listener, true);
                instance.shutdown();

                util::CountDownLatch lifecycleLatch(1);
                LclForClusterTest lifecycleListener(lifecycleLatch);
                hazelcastClient.addLifecycleListener(&lifecycleListener);

                HazelcastServer instance2(hazelcastInstanceFactory);
                assertTrue(lifecycleLatch.await(120), "Lifecycle latch await timed out!");
                m.put("sample", "entry");
                assertTrue(countDownLatch.await(60), "Await timed out !");
                assertTrue(hazelcastClient.removeLifecycleListener(&lifecycleListener), "Listener could not removed");
            }