{
ClientRequest request = new ClientRequest(generateURL("/queues/testQueue"));
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-consumers");
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("poller: " + consumeNext);
String data = Integer.toString(start);
System.out.println("Sending: " + data);
ClientResponse res = sender.request().body("text/plain", data).post();
Assert.assertEquals(201, res.getStatus());
System.out.println("call ack next");
res = consumeNext.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals(Integer.toString(start++), res.getEntity());
Link ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "acknowledgement");
System.out.println("ack: " + ack);
Assert.assertNotNull(ack);
Link session = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "acknowledge-next");
System.out.println("consumeNext: " + consumeNext);
ClientResponse ackRes = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(204, ackRes.getStatus());
consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), ackRes, "acknowledge-next");
System.out.println("sending next...");
String data2 = Integer.toString(start);
System.out.println("Sending: " + data2);
res = sender.request().body("text/plain", data2).post();
Assert.assertEquals(201, res.getStatus());
System.out.println(consumeNext);
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals(Integer.toString(start++), res.getEntity());
ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "acknowledgement");
System.out.println("ack: " + ack);
Assert.assertNotNull(ack);
session = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
ackRes = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(204, ackRes.getStatus());
consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), ackRes, "acknowledge-next");
System.out.println("consumeNext: " + consumeNext);
res = consumeNext.request().post(String.class);
System.out.println(res.getStatus());
Assert.assertEquals(204, session.request().delete().getStatus());
}