Search in sources :

Example 6 with TopicDeployment

use of org.apache.activemq.artemis.rest.topic.TopicDeployment in project activemq-artemis by apache.

the class RepostingTopicTest method setup.

@BeforeClass
public static void setup() throws Exception {
    TopicDeployment deployment1 = new TopicDeployment("testTopic", true);
    manager.getTopicManager().deploy(deployment1);
}
Also used : TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) BeforeClass(org.junit.BeforeClass)

Example 7 with TopicDeployment

use of org.apache.activemq.artemis.rest.topic.TopicDeployment in project activemq-artemis by apache.

the class SelectorTest method setup.

@BeforeClass
public static void setup() throws Exception {
    connectionFactory = new ActiveMQJMSConnectionFactory(manager.getQueueManager().getServerLocator());
    System.out.println("Queue name: " + prefixedTopicName);
    TopicDeployment deployment = new TopicDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName(topicName);
    manager.getTopicManager().deploy(deployment);
}
Also used : TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) ActiveMQJMSConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory) BeforeClass(org.junit.BeforeClass)

Example 8 with TopicDeployment

use of org.apache.activemq.artemis.rest.topic.TopicDeployment in project activemq-artemis by apache.

the class AutoAckTopicTest method testSuccessFirst.

@Test
public void testSuccessFirst() throws Exception {
    String testName = "AutoAckTopicTest.testSuccessFirst";
    TopicDeployment deployment = new TopicDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName(testName);
    manager.getTopicManager().deploy(deployment);
    ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/" + testName));
    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);
    System.out.println("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(consumeNext2);
    System.out.println("consumeNext2: " + consumeNext2);
    res = sender.request().body("text/plain", "1").post();
    res.releaseConnection();
    Assert.assertEquals(201, res.getStatus());
    res = sender.request().body("text/plain", "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");
    Assert.assertEquals(204, sub1.request().delete().getStatus());
    Assert.assertEquals(204, sub2.request().delete().getStatus());
}
Also used : TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 9 with TopicDeployment

use of org.apache.activemq.artemis.rest.topic.TopicDeployment in project activemq-artemis by apache.

the class AutoAckTopicTest method testNewSubNotBlockedByTimeoutTask.

@Test
public void testNewSubNotBlockedByTimeoutTask() throws Exception {
    // Default config is 1s interval, 300s timeout.
    // Create a topic
    String testName = "AutoAckTopicTest.testNewSubNotBlockedByTimeoutTask";
    TopicDeployment deployment = new TopicDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName(testName);
    manager.getTopicManager().deploy(deployment);
    // Create a consumer
    ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/" + testName));
    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");
    // Create the pull-subscription itself.
    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);
    // Pull on the topic for 8s (long enoguh to guarantee the rest of the test
    // will pass/fail due to the timeouttask + test operations)
    AcceptWaitListener awlistener = new AcceptWaitListener(consumeNext1.getHref());
    Thread t = new Thread(awlistener);
    t.start();
    // Wait 2 seconds to ensure a new TimeoutTask is running concurrently.
    Thread.sleep(2000);
    // Attempt to create a new pull-subscription. Validate that it takes no longer than 2 seconds
    // (it should take like 20ms, but give it a relatively huge amount of leeway)
    NewPullSubscriber nps = new NewPullSubscriber(subscriptions.getHref());
    Thread npsThread = new Thread(nps);
    npsThread.start();
    Thread.sleep(2000);
    Assert.assertTrue("NewPullSubscriber did not finish in 2 seconds!", nps.isFinished());
    Assert.assertFalse("AcceptWaitListener failed to open connection!", awlistener.isFailed());
    Assert.assertFalse("NewPullSubscriber failed to open new subscription!", nps.isFailed());
    npsThread.interrupt();
    t.interrupt();
}
Also used : TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 10 with TopicDeployment

use of org.apache.activemq.artemis.rest.topic.TopicDeployment in project activemq-artemis by apache.

the class ClientAckTopicTest method setup.

@BeforeClass
public static void setup() throws Exception {
    TopicDeployment deployment1 = new TopicDeployment("testQueue", true);
    manager.getTopicManager().deploy(deployment1);
}
Also used : TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) BeforeClass(org.junit.BeforeClass)

Aggregations

TopicDeployment (org.apache.activemq.artemis.rest.topic.TopicDeployment)13 Test (org.junit.Test)8 ClientRequest (org.jboss.resteasy.client.ClientRequest)7 Link (org.jboss.resteasy.spi.Link)7 XmlLink (org.apache.activemq.artemis.rest.queue.push.xml.XmlLink)5 PushTopicRegistration (org.apache.activemq.artemis.rest.topic.PushTopicRegistration)5 QueueDeployment (org.apache.activemq.artemis.rest.queue.QueueDeployment)4 BeforeClass (org.junit.BeforeClass)4 ActiveMQJMSConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory)1 ActiveMQPushStrategy (org.apache.activemq.artemis.rest.queue.push.ActiveMQPushStrategy)1 CustomHeaderLinkStrategy (org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy)1 LinkHeaderLinkStrategy (org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy)1