@Test
public void testSubscribeListUnsubsribeTopic() {
ICNSTopicPersistence topicHandler = new CNSTopicCassandraPersistence();
ICNSAttributesPersistence attributeHandler = PersistenceFactory.getCNSAttributePersistence();
String topicArn = null;
try {
String topicName = "T" + rand.nextLong();
String userId1 = user1.getUserId();
String userId2 = user2.getUserId();
CNSTopic t = topicHandler.createTopic(topicName, topicName, userId2);
topicArn = t.getArn();
try {
topicHandler.deleteTopic(topicArn); //delete any pre-existing state
} catch (Exception e) { }
t = topicHandler.createTopic(topicName, topicName, userId2);
topicArn = t.getArn();
ICNSSubscriptionPersistence subscriptionHandler = new CNSSubscriptionCassandraPersistence();
long beforeSubscribeCount = subscriptionHandler.getCountSubscription(t.getArn(), "subscriptionPending");
CNSSubscription s = subscriptionHandler.subscribe(CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/1234", CnsSubscriptionProtocol.http, t.getArn(), userId1);
long afterSubscribeCount = subscriptionHandler.getCountSubscription(t.getArn(), "subscriptionPending");
// check default delivery policy on topic1
CNSSubscriptionAttributes attributes = attributeHandler.getSubscriptionAttributes(s.getArn());
assertTrue("Expected 3 retries in healthy policy, instead found " + attributes.getEffectiveDeliveryPolicy().getHealthyRetryPolicy().getNumRetries(), attributes.getEffectiveDeliveryPolicy().getHealthyRetryPolicy().getNumRetries() == 3);
List<CNSSubscription> l = subscriptionHandler.listSubscriptions(null, null, userId1);