Java Code Examples for org.jboss.resteasy.client.ClientResponse#releaseConnection()
The following examples show how to use
org.jboss.resteasy.client.ClientResponse#releaseConnection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedRestActiveMQJMSTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void shouldReturnPublishedEntity() throws Exception { TransformTest.Order order = createTestOrder("1", "$5.00"); publish("exampleQueue", order, null); ClientResponse<?> res = consumeNext.request().header("Accept-Wait", "2").accept("application/xml").post(String.class); TransformTest.Order order2 = res.getEntity(TransformTest.Order.class); assertEquals(order, order2); res.releaseConnection(); }
Example 2
Source File: EmbeddedRestActiveMQJMSTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void shouldReturnLink() throws Exception { TransformTest.Order order = createTestOrder("1", "$5.00"); publish("exampleQueue", order, null); ClientResponse<?> res = consumeNext.request().header("Accept-Wait", "2").accept("application/xml").post(String.class); consumeNext = res.getLinkHeader().getLinkByTitle("consume-next"); res.releaseConnection(); assertNotNull(consumeNext); }
Example 3
Source File: RoundtripTimeTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testSuccessFirst() throws Exception { QueueDeployment deployment = new QueueDeployment(); deployment.setDuplicatesAllowed(true); deployment.setDurableSend(false); deployment.setName("testQueue"); manager.getQueueManager().deploy(deployment); ClientRequest request = new ClientRequest(generateURL("/queues/testQueue")); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, true); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("consume-next: " + consumeNext); long start = System.currentTimeMillis(); int num = 100; for (int i = 0; i < num; i++) { response = sender.request().body("text/plain", Integer.toString(i + 1)).post(); response.releaseConnection(); } long end = System.currentTimeMillis() - start; log.debug(num + " iterations took " + end + "ms"); for (int i = 0; i < num; i++) { response = consumeNext.request().post(String.class); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); Assert.assertEquals(200, response.getStatus()); Assert.assertEquals(Integer.toString(i + 1), response.getEntity(String.class)); response.releaseConnection(); } }
Example 4
Source File: AutoAckTopicTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void run() { try { ClientRequest req = new ClientRequest(url); req.header("Accept-Wait", acceptWaitTime); ClientResponse<?> response = req.post(); response.releaseConnection(); isFinished = true; } catch (Exception e) { failed = true; } }
Example 5
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testRestartOnNonDurableNamedSubscriber() 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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("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()); 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").post(); response.releaseConnection(); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("resource consume-next: " + consumeNext); response = consumeNext.request().header("Accept-Wait", "2").post(String.class); response.releaseConnection(); Assert.assertEquals(503, response.getStatus()); Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer"); response = session.request().delete(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); }
Example 6
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testRestartOnNonDurableNamedSubscriber() 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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("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()); 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").post(); response.releaseConnection(); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("resource consume-next: " + consumeNext); response = consumeNext.request().header("Accept-Wait", "2").post(String.class); response.releaseConnection(); Assert.assertEquals(503, response.getStatus()); Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer"); response = session.request().delete(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); }
Example 7
Source File: RepostingQueueTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testPostOnOldAcknowledgeNextAndAck() throws Exception { ClientRequest request = new ClientRequest(generateURL("/queues/testQueue")); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link sender = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create"); log.debug("create: " + sender); Link consumers = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, false); Link consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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, "3").post(String.class); Assert.assertEquals(200, response.getStatus()); Assert.assertEquals("1", response.getEntity(String.class)); response.releaseConnection(); Link session = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer"); log.debug("session: " + session); Link ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); Link oldAck = ack; log.debug("ack: " + ack); response = ack.request().formParameter("acknowledge", "true").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("session 1st acknowledge-next: " + 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 = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); log.debug("ack: " + ack); response = oldAck.request().formParameter("acknowledge", "true").post(); Assert.assertEquals(412, response.getStatus()); log.debug(response.getEntity(String.class)); response.releaseConnection(); response = ack.request().formParameter("acknowledge", "true").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); consumeNext = MessageTestBase.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()); }
Example 8
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testPostOnSameConsumeNextWithTimeout() 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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, true); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("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"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("session 1st consumeNext: " + consumeNext); // test timeout here response = consumeNext.request().post(String.class); response.releaseConnection(); Assert.assertEquals(503, response.getStatus()); session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("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()); }
Example 9
Source File: JMSTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testJmsConsumer() throws Exception { String queueName = "testQueue2"; String prefixedQueueName = ActiveMQDestination.createQueueAddressFromName(queueName).toString(); log.debug("Queue name: " + prefixedQueueName); QueueDeployment deployment = new QueueDeployment(); deployment.setDuplicatesAllowed(true); deployment.setDurableSend(false); deployment.setName(queueName); manager.getQueueManager().deploy(deployment); Connection conn = connectionFactory.createConnection(); try { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = createDestination(prefixedQueueName); MessageConsumer consumer = session.createConsumer(destination); consumer.setMessageListener(new Listener()); conn.start(); ClientRequest request = new ClientRequest(generateURL(Util.getUrlPath(queueName))); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create"); log.debug("create: " + sender); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("consume-next: " + consumeNext); // test that Accept header is used to set content-type { Order order = new Order(); order.setName("1"); order.setAmount("$5.00"); response = sender.request().body("application/xml", order).post(); response.releaseConnection(); Assert.assertEquals(201, response.getStatus()); Listener.latch.await(1, TimeUnit.SECONDS); Assert.assertNotNull(Listener.order); Assert.assertEquals(order, Listener.order); Assert.assertNotNull(Listener.messageID); } } finally { conn.close(); } }
Example 10
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, false); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("session: " + session); Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); log.debug("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()); log.debug(response.getEntity(String.class)); response.releaseConnection(); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("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()); }
Example 11
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testPostOnSameAcknowledgeNextAndAck() 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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, false); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("session: " + session); Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); log.debug("ack: " + ack); response = ack.request().formParameter("acknowledge", "true").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); response = ack.request().formParameter("acknowledge", "true").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); response = ack.request().formParameter("acknowledge", "true").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("session 1st acknowledge-next: " + 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(); ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); log.debug("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()); }
Example 12
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testPostOnSameConsumeNextWithTimeout() 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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, true); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("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"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("session 1st consumeNext: " + consumeNext); // test timeout here response = consumeNext.request().post(String.class); response.releaseConnection(); Assert.assertEquals(503, response.getStatus()); session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("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()); }
Example 13
Source File: ClientAckTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testPull() throws Exception { ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/testQueue")); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create"); log.debug("create: " + sender); Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions"); response = subscriptions.request().formParameter("autoAck", "false").formParameter("durable", "true").post(); response.releaseConnection(); Assert.assertEquals(201, response.getStatus()); Link sub1 = response.getLocationLink(); Assert.assertNotNull(sub1); Link consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("poller: " + consumeNext); ClientResponse<String> res = consumeNext.request().post(String.class); res.releaseConnection(); Assert.assertEquals(503, res.getStatus()); consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next"); log.debug(consumeNext); res = sender.request().body("text/plain", Integer.toString(1)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = consumeNext.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(Integer.toString(1), res.getEntity()); res.releaseConnection(); Link ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement"); log.debug("ack: " + ack); ClientResponse ackRes = ack.request().formParameter("acknowledge", "true").post(); ackRes.releaseConnection(); Assert.assertEquals(204, ackRes.getStatus()); res = consumeNext.request().post(); res.releaseConnection(); Assert.assertEquals(503, res.getStatus()); res = sender.request().body("text/plain", Integer.toString(2)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = sender.request().body("text/plain", Integer.toString(3)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = consumeNext.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(Integer.toString(2), res.getEntity()); res.releaseConnection(); ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement"); log.debug("ack: " + ack); ackRes = ack.request().formParameter("acknowledge", "true").post(); ackRes.releaseConnection(); Assert.assertEquals(204, ackRes.getStatus()); res = consumeNext.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(Integer.toString(3), res.getEntity()); res.releaseConnection(); ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement"); log.debug("ack: " + ack); ackRes = ack.request().formParameter("acknowledge", "true").post(); ackRes.releaseConnection(); Assert.assertEquals(204, ackRes.getStatus()); res = consumeNext.request().post(); res.releaseConnection(); Assert.assertEquals(503, res.getStatus()); log.debug(sub1); res = sub1.request().delete(); res.releaseConnection(); Assert.assertEquals(204, res.getStatus()); }
Example 14
Source File: DupQueueTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testDup() throws Exception { String testName = "testDup"; QueueDeployment deployment = new QueueDeployment(); deployment.setDuplicatesAllowed(false); deployment.setDurableSend(false); deployment.setName(testName); manager.getQueueManager().deploy(deployment); ClientRequest request = new ClientRequest(generateURL("/queues/" + testName)); ClientResponse<?> response = request.head(); Assert.assertEquals(200, response.getStatus()); Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, true); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("poller: " + consumeNext); ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post(); Assert.assertEquals(307, res.getStatus()); sender = res.getLocationLink(); res.releaseConnection(); log.debug("create-next: " + sender); Assert.assertNotNull(sender); res = sender.request().body("text/plain", Integer.toString(1)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = sender.request().body("text/plain", Integer.toString(1)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "create-next"); res = sender.request().body("text/plain", Integer.toString(2)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = consumeNext.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals("1", res.getEntity(String.class)); res.releaseConnection(); Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next"); log.debug("consumeNext: " + consumeNext); res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class); Assert.assertEquals(200, res.getStatus()); res.releaseConnection(); session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next"); log.debug("consumeNext: " + consumeNext); res = consumeNext.request().post(String.class); res.releaseConnection(); res = session.request().delete(); res.releaseConnection(); Assert.assertEquals(204, res.getStatus()); }
Example 15
Source File: SelectorTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testPull() throws Exception { ClientRequest request = new ClientRequest(generateURL("/topics/" + topicName)); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = consumers.request().formParameter("autoAck", "true").formParameter("selector", "MyTag = '1'").post(); response.releaseConnection(); Link consumeOne = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("consumeOne: " + consumeOne); response = consumers.request().formParameter("autoAck", "true").formParameter("selector", "MyTag = '2'").post(); response.releaseConnection(); Link consumeTwo = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next"); log.debug("consumeTwo: " + consumeTwo); // test that Accept header is used to set content-type { Order order = new Order(); order.setName("1"); order.setAmount("$5.00"); publish(prefixedTopicName, order, null, "1"); order.setName("2"); publish(prefixedTopicName, order, null, "2"); order.setName("3"); publish(prefixedTopicName, order, null, "2"); order.setName("4"); publish(prefixedTopicName, order, null, "1"); order.setName("5"); publish(prefixedTopicName, order, null, "1"); order.setName("6"); publish(prefixedTopicName, order, null, "1"); { order.setName("1"); consumeOne = consumeOrder(order, consumeOne); order.setName("2"); consumeTwo = consumeOrder(order, consumeTwo); order.setName("3"); consumeTwo = consumeOrder(order, consumeTwo); order.setName("4"); consumeOne = consumeOrder(order, consumeOne); order.setName("5"); consumeOne = consumeOrder(order, consumeOne); order.setName("6"); consumeOne = consumeOrder(order, consumeOne); } } }
Example 16
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, false); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("session: " + session); Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); Link oldAck = ack; log.debug("ack: " + ack); response = ack.request().formParameter("acknowledge", "true").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("ack: " + ack); response = oldAck.request().formParameter("acknowledge", "true").post(); Assert.assertEquals(412, response.getStatus()); log.debug(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()); }
Example 17
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testRepostSuccessfulUnacknowledge() 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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, false); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("session: " + session); Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); log.debug("ack: " + ack); response = ack.request().formParameter("acknowledge", "false").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); response = ack.request().formParameter("acknowledge", "false").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); response = ack.request().formParameter("acknowledge", "false").post(); response.releaseConnection(); Assert.assertEquals(204, response.getStatus()); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("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()); }
Example 18
Source File: ClientAckTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testSuccessFirst() throws Exception { ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/testQueue")); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create"); log.debug("create: " + sender); Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions"); response = subscriptions.request().formParameter("autoAck", "false").formParameter("durable", "true").post(); response.releaseConnection(); Assert.assertEquals(201, response.getStatus()); Link sub1 = response.getLocationLink(); Assert.assertNotNull(sub1); Link consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("poller: " + consumeNext); ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); log.debug("call ack next"); res = consumeNext.request().post(String.class); res.releaseConnection(); Assert.assertEquals(200, res.getStatus()); Link ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement"); log.debug("ack: " + ack); Assert.assertNotNull(ack); Link session = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consumer"); log.debug("session: " + session); consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next"); log.debug("consumeNext: " + consumeNext); ClientResponse ackRes = ack.request().formParameter("acknowledge", "true").post(); ackRes.releaseConnection(); Assert.assertEquals(204, ackRes.getStatus()); consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), ackRes, "acknowledge-next"); log.debug("sending next..."); res = sender.request().body("text/plain", Integer.toString(2)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); log.debug(consumeNext); res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class); res.releaseConnection(); Assert.assertEquals(200, res.getStatus()); ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement"); log.debug("ack: " + ack); Assert.assertNotNull(ack); getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next"); log.debug("consumeNext: " + consumeNext); ackRes = ack.request().formParameter("acknowledge", "true").post(); ackRes.releaseConnection(); Assert.assertEquals(204, ackRes.getStatus()); Assert.assertEquals(204, sub1.request().delete().getStatus()); }
Example 19
Source File: CreateDestinationTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testCreateTopic() throws Exception { String queueConfig = "<topic name=\"testTopic\"></topic>"; ClientRequest create = new ClientRequest(TestPortProvider.generateURL("/topics")); ClientResponse cRes = create.body("application/activemq.jms.topic+xml", queueConfig).post(); cRes.releaseConnection(); Assert.assertEquals(201, cRes.getStatus()); ClientRequest request = cRes.getLocationLink().request(); ClientResponse<?> response = request.head(); response.releaseConnection(); Assert.assertEquals(200, response.getStatus()); Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create"); Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions"); ClientResponse<?> res = subscriptions.request().post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); Link sub1 = res.getLocationLink(); Assert.assertNotNull(sub1); Link consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next"); Assert.assertNotNull(consumeNext1); log.debug("consumeNext1: " + consumeNext1); res = subscriptions.request().post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); Link sub2 = res.getLocationLink(); Assert.assertNotNull(sub2); Link consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next"); Assert.assertNotNull(consumeNext1); res = sender.request().body("text/plain", Integer.toString(1)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = sender.request().body("text/plain", Integer.toString(2)).post(); res.releaseConnection(); Assert.assertEquals(201, res.getStatus()); res = consumeNext1.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals("1", res.getEntity(String.class)); res.releaseConnection(); consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next"); res = consumeNext1.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals("2", res.getEntity(String.class)); res.releaseConnection(); consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next"); res = consumeNext2.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals("1", res.getEntity(String.class)); res.releaseConnection(); consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next"); res = consumeNext2.request().post(String.class); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals("2", res.getEntity(String.class)); res.releaseConnection(); consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next"); res = sub1.request().delete(); res.releaseConnection(); Assert.assertEquals(204, res.getStatus()); res = sub2.request().delete(); res.releaseConnection(); Assert.assertEquals(204, res.getStatus()); }
Example 20
Source File: RepostingTopicTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@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"); log.debug("create: " + sender); Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions"); log.debug("pull: " + consumers); response = Util.setAutoAck(consumers, false); Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("session: " + session); Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement"); log.debug("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()); log.debug(response.getEntity(String.class)); response.releaseConnection(); consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next"); log.debug("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"); log.debug("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()); }