use of org.jboss.resteasy.spi.Link in project activemq-artemis by apache.
the class RepostingTopicTest method testRepostAckAfterUnacknowledge.
@Test
public void testRepostAckAfterUnacknowledge() throws Exception {
ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, false);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("resource acknowledge-next: " + consumeNext);
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
System.out.println("session: " + session);
Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
System.out.println("ack: " + ack);
response = ack.request().formParameter("acknowledge", "false").post();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
response = ack.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(412, response.getStatus());
System.out.println(response.getEntity(String.class));
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("session 1st acknowledge-next: " + consumeNext);
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
System.out.println("ack: " + ack);
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
use of org.jboss.resteasy.spi.Link in project activemq-artemis by apache.
the class RepostingTopicTest method testReconnectOnNamedSubscriber.
@Test
public void testReconnectOnNamedSubscriber() throws Exception {
ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
System.out.println("pull: " + consumers);
response = consumers.request().formParameter("name", "bill").post();
response.releaseConnection();
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
// recreate subscription a second time as named. Should pick up old one.
response = consumers.request().formParameter("name", "bill").post();
response.releaseConnection();
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("resource consume-next: " + consumeNext);
response = consumeNext.request().post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
response = consumeNext.request().header("Accept-Wait", "2").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
use of org.jboss.resteasy.spi.Link in project activemq-artemis by apache.
the class RepostingTopicTest method testRestartOnDurableNamedSubscriber.
@Test
public void testRestartOnDurableNamedSubscriber() throws Exception {
ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
System.out.println("pull: " + consumers);
response = consumers.request().formParameter("name", "bill").formParameter("durable", "true").post();
response.releaseConnection();
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
manager.getTopicManager().getDestination().findTopic("testTopic").getSubscriptions().stop();
// recreate subscription a second time as named. Should pick up old one.
response = consumers.request().formParameter("name", "bill").formParameter("durable", "true").post();
response.releaseConnection();
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("resource consume-next: " + consumeNext);
response = consumeNext.request().header("Accept-Wait", "2").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
response = consumeNext.request().header("Accept-Wait", "2").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
use of org.jboss.resteasy.spi.Link in project activemq-artemis by apache.
the class RepostingTopicTest method testPostOnSameConsumeNext.
@Test
public void testPostOnSameConsumeNext() throws Exception {
ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, true);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("resource consume-next: " + consumeNext);
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("session 1st consumeNext: " + consumeNext);
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("session 2nd consumeNext: " + consumeNext);
response = sender.request().body("text/plain", Integer.toString(3)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("3", response.getEntity(String.class));
response.releaseConnection();
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
use of org.jboss.resteasy.spi.Link in project activemq-artemis by apache.
the class RepostingTopicTest method testPostOnOldAcknowledgeNextAndAck.
@Test
public void testPostOnOldAcknowledgeNextAndAck() throws Exception {
ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, false);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("resource acknowledge-next: " + consumeNext);
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().header(Constants.WAIT_HEADER, "1").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("1", response.getEntity(String.class));
response.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
System.out.println("session: " + session);
Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Link oldAck = ack;
System.out.println("ack: " + ack);
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("session 1st acknowledge-next: " + consumeNext);
Link firstConsumeNext = consumeNext;
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
System.out.println("ack: " + ack);
response = oldAck.request().formParameter("acknowledge", "true").post();
Assert.assertEquals(412, response.getStatus());
System.out.println(response.getEntity(String.class));
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
response = consumeNext.request().post(String.class);
response.releaseConnection();
Assert.assertEquals(503, response.getStatus());
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
Aggregations