Search in sources :

Example 16 with Link

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());
}
Also used : ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 17 with Link

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());
}
Also used : ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 18 with Link

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());
}
Also used : ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 19 with Link

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());
}
Also used : ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 20 with Link

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());
}
Also used : ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Aggregations

Link (org.jboss.resteasy.spi.Link)86 ClientRequest (org.jboss.resteasy.client.ClientRequest)81 Test (org.junit.Test)68 ClientResponse (org.jboss.resteasy.client.ClientResponse)25 XmlLink (org.apache.activemq.artemis.rest.queue.push.xml.XmlLink)20 QueueDeployment (org.apache.activemq.artemis.rest.queue.QueueDeployment)11 PushTopicRegistration (org.apache.activemq.artemis.rest.topic.PushTopicRegistration)8 TopicDeployment (org.apache.activemq.artemis.rest.topic.TopicDeployment)7 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 PushRegistration (org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration)4 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)2 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)2 ActiveMQPushStrategy (org.apache.activemq.artemis.rest.queue.push.ActiveMQPushStrategy)2 Connection (javax.jms.Connection)1 Destination (javax.jms.Destination)1 MessageConsumer (javax.jms.MessageConsumer)1 MessageListener (javax.jms.MessageListener)1 Session (javax.jms.Session)1 SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)1 ActiveMQDestination (org.apache.activemq.artemis.jms.client.ActiveMQDestination)1