cns1.addPermission(new AddPermissionRequest(topicArn, "p1", Arrays.asList("*") , Arrays.asList("*")));
String endpoint = CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + rand.nextInt();
SubscribeRequest subscribeRequest = new SubscribeRequest();
subscribeRequest.setEndpoint(endpoint);
subscribeRequest.setProtocol("http");
subscribeRequest.setTopicArn(topicArn);
String subscriptionArn1 = cns2.subscribe(subscribeRequest).getSubscriptionArn();
String lastMessageUrl = endpoint.replace("recv", "info") + "?showLast=true";
if (subscriptionArn1.equals("pending confirmation")) {
String resp = CNSTestingUtils.sendHttpMessage(lastMessageUrl, "");
JSONObject o = new JSONObject(resp);
if (!o.has("SubscribeURL")) {
fail("Message is not a confirmation messsage");
}
String subscriptionUrl = o.getString("SubscribeURL");
resp = CNSTestingUtils.sendHttpMessage(subscriptionUrl, "");
logger.info(resp);
subscriptionArn1 = XmlUtil.getCurrentLevelTextValue(XmlUtil.getChildNodes(XmlUtil.buildDoc(resp)).get(0), "SubscriptionArn");
}
endpoint = CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + rand.nextInt();
subscribeRequest = new SubscribeRequest();
subscribeRequest.setEndpoint(endpoint);
subscribeRequest.setProtocol("http");
subscribeRequest.setTopicArn(topicArn);
String subscriptionArn2 = cns2.subscribe(subscribeRequest).getSubscriptionArn();
lastMessageUrl = endpoint.replace("recv", "info") + "?showLast=true";
if (subscriptionArn2.equals("pending confirmation")) {