{
ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));
ClientResponse response = request.head();
Assert.assertEquals(200, response.getStatus());
Link sender = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
System.out.println("pull: " + consumers);
response = consumers.request().formParameter("autoAck", "false").post();
Link consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("resource acknowledge-next: " + consumeNext);
ClientResponse res = sender.request().body("text/plain", Integer.toString(1)).post();
Assert.assertEquals(201, res.getStatus());
res = consumeNext.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("1", res.getEntity(String.class));
Link session = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
Link ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "acknowledgement");
System.out.println("ack: " + ack);
res = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(204, res.getStatus());
res = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(204, res.getStatus());
res = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(204, res.getStatus());
consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "acknowledge-next");
System.out.println("session 1st acknowledge-next: " + consumeNext);
res = sender.request().body("text/plain", Integer.toString(2)).post();
Assert.assertEquals(201, res.getStatus());
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "acknowledgement");
System.out.println("ack: " + ack);
res = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(204, res.getStatus());
Assert.assertEquals(204, session.request().delete().getStatus());