本文整理汇总了Java中org.jboss.resteasy.client.ClientResponse.getLocationLink方法的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse.getLocationLink方法的具体用法?Java ClientResponse.getLocationLink怎么用?Java ClientResponse.getLocationLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.resteasy.client.ClientResponse
的用法示例。
在下文中一共展示了ClientResponse.getLocationLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPushRegistration
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
private Link createPushRegistration(String queueToPushTo,
Link pushSubscriptions,
PushRegistrationType pushRegistrationType,
int sessionCount) throws Exception {
PushRegistration reg = new PushRegistration();
reg.setDurable(false);
XmlLink target = new XmlLink();
if (pushRegistrationType == PushRegistrationType.CLASS) {
target.setHref(generateURL(Util.getUrlPath(queueToPushTo)));
target.setClassName(ActiveMQPushStrategy.class.getName());
} else if (pushRegistrationType == PushRegistrationType.BRIDGE) {
target.setHref(generateURL(Util.getUrlPath(queueToPushTo)));
target.setRelationship("destination");
} else if (pushRegistrationType == PushRegistrationType.TEMPLATE) {
target.setHref(queueToPushTo);
target.setRelationship("template");
} else if (pushRegistrationType == PushRegistrationType.URI) {
target.setMethod("put");
target.setHref(queueToPushTo);
}
reg.setTarget(target);
reg.setSessionCount(sessionCount);
ClientResponse pushRegistrationResponse = pushSubscriptions.request().body("application/xml", reg).post();
pushRegistrationResponse.releaseConnection();
Assert.assertEquals(201, pushRegistrationResponse.getStatus());
Link pushSubscription = pushRegistrationResponse.getLocationLink();
return pushSubscription;
}
示例2: testFindTopic
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testFindTopic() throws Exception {
server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString("testTopic"), RoutingType.MULTICAST));
server.getActiveMQServer().createQueue(new SimpleString("testTopic"), RoutingType.MULTICAST, new SimpleString("testTopic"), null, false, false);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/testTopic"));
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();
Assert.assertEquals(201, res.getStatus());
Link sub1 = res.getLocationLink();
res.releaseConnection();
Assert.assertNotNull(sub1);
Link consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
Assert.assertNotNull(consumeNext1);
System.out.println("consumeNext1: " + consumeNext1);
res = subscriptions.request().post();
Assert.assertEquals(201, res.getStatus());
Link sub2 = res.getLocationLink();
res.releaseConnection();
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();
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();
res = sub1.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
res = sub2.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
}
示例3: testFailure
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testFailure() throws Exception {
try {
startup();
String testName = "testFailure";
QueueDeployment deployment = new QueueDeployment();
deployment.setDuplicatesAllowed(true);
deployment.setDurableSend(false);
deployment.setName(testName);
manager.getQueueManager().deploy(deployment);
ClientRequest request = new ClientRequest(generateURL("/queues/" + testName));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link pushSubscriptions = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-consumers");
System.out.println("push subscriptions: " + pushSubscriptions);
PushRegistration reg = new PushRegistration();
reg.setDurable(true);
XmlLink target = new XmlLink();
target.setHref("http://localhost:3333/error");
target.setRelationship("uri");
reg.setTarget(target);
reg.setDisableOnFailure(true);
reg.setMaxRetries(3);
reg.setRetryWaitMillis(10);
response = pushSubscriptions.request().body("application/xml", reg).post();
Assert.assertEquals(201, response.getStatus());
Link pushSubscription = response.getLocationLink();
response.releaseConnection();
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
Thread.sleep(5000);
response = pushSubscription.request().get();
PushRegistration reg2 = response.getEntity(PushRegistration.class);
Assert.assertEquals(reg.isDurable(), reg2.isDurable());
Assert.assertEquals(reg.getTarget().getHref(), reg2.getTarget().getHref());
Assert.assertFalse(reg2.isEnabled()); // make sure the failure disables the PushRegistration
response.releaseConnection();
manager.getQueueManager().getPushStore().removeAll();
} finally {
shutdown();
}
}
示例4: testRestartFromAutoAckSession
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testRestartFromAutoAckSession() throws Exception {
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");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, true);
Link session = response.getLocationLink();
response = session.request().head();
response.releaseConnection();
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("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();
response = session.request().get();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = session.request().head();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
response = sender.request().body("text/plain", Integer.toString(3)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().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());
}
示例5: testTopicRestartFromAutoAckSession
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testTopicRestartFromAutoAckSession() 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 session = response.getLocationLink();
response = session.request().head();
response.releaseConnection();
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("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();
response = session.request().get();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = session.request().head();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
response = sender.request().body("text/plain", Integer.toString(3)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
response = consumeNext.request().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());
}
示例6: testRestartFromAckSession
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testRestartFromAckSession() throws Exception {
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");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, false);
Link session = response.getLocationLink();
response = session.request().head();
response.releaseConnection();
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("consume-next: " + consumeNext);
Link ack = null;
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
// consume
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();
response = session.request().get();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNotNull(ack);
// acknowledge
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
response = session.request().head();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNotNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNull(ack);
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
// consume
response = consumeNext.request().header(Constants.WAIT_HEADER, "1").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = session.request().get();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNotNull(ack);
// acknowledge
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
response = session.request().head();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNotNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNull(ack);
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
示例7: testTopicRestartFromAckSession
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testTopicRestartFromAckSession() 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 session = response.getLocationLink();
response = session.request().head();
response.releaseConnection();
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("consume-next: " + consumeNext);
Link ack = null;
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
// consume
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();
response = session.request().get();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNotNull(ack);
// acknowledge
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
response = session.request().head();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNotNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNull(ack);
response = sender.request().body("text/plain", Integer.toString(2)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
// consume
response = consumeNext.request().header(Constants.WAIT_HEADER, "1").post(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("2", response.getEntity(String.class));
response.releaseConnection();
response = session.request().get();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNotNull(ack);
// acknowledge
response = ack.request().formParameter("acknowledge", "true").post();
response.releaseConnection();
response = session.request().head();
response.releaseConnection();
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
Assert.assertNotNull(consumeNext);
ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
Assert.assertNull(ack);
response = session.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
示例8: testSuccessFirst
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@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");
System.out.println("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");
System.out.println("poller: " + consumeNext);
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
System.out.println("call ack next");
res = consumeNext.request().post(String.class);
res.releaseConnection();
Assert.assertEquals(200, res.getStatus());
Link ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement");
System.out.println("ack: " + ack);
Assert.assertNotNull(ack);
Link session = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next");
System.out.println("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");
System.out.println("sending next...");
res = sender.request().body("text/plain", Integer.toString(2)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
System.out.println(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");
System.out.println("ack: " + ack);
Assert.assertNotNull(ack);
getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next");
System.out.println("consumeNext: " + consumeNext);
ackRes = ack.request().formParameter("acknowledge", "true").post();
ackRes.releaseConnection();
Assert.assertEquals(204, ackRes.getStatus());
Assert.assertEquals(204, sub1.request().delete().getStatus());
}
示例9: testSuccessFirstNonDurable
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testSuccessFirstNonDurable() 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");
System.out.println("create: " + sender);
Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions");
response = subscriptions.request().formParameter("autoAck", "false").formParameter("durable", "false").post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
Link sub1 = response.getLocationLink();
Assert.assertNotNull(sub1);
Link consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "acknowledge-next");
System.out.println("poller: " + consumeNext);
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
System.out.println("call ack next");
res = consumeNext.request().post(String.class);
res.releaseConnection();
Assert.assertEquals(200, res.getStatus());
Link ack = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledgement");
System.out.println("ack: " + ack);
Assert.assertNotNull(ack);
Link session = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next");
System.out.println("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");
System.out.println("sending next...");
res = sender.request().body("text/plain", Integer.toString(2)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
System.out.println(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");
System.out.println("ack: " + ack);
Assert.assertNotNull(ack);
getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "acknowledge-next");
System.out.println("consumeNext: " + consumeNext);
ackRes = ack.request().formParameter("acknowledge", "true").post();
ackRes.releaseConnection();
Assert.assertEquals(204, ackRes.getStatus());
Assert.assertEquals(204, sub1.request().delete().getStatus());
}
示例10: testPull
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@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");
System.out.println("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");
System.out.println("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");
System.out.println(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");
System.out.println("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");
System.out.println("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");
System.out.println("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());
System.out.println(sub1);
res = sub1.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
}
示例11: testSuccessFirst
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@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());
}
示例12: testNewSubNotBlockedByTimeoutTask
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@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();
}
示例13: testUri
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testUri() throws Exception {
TopicDeployment deployment = new TopicDeployment();
deployment.setDuplicatesAllowed(true);
deployment.setDurableSend(false);
deployment.setName("testUri");
manager.getTopicManager().deploy(deployment);
ClientRequest request = new ClientRequest(generateURL("/topics/testUri"));
server.getJaxrsServer().getDeployment().getRegistry().addPerRequestResource(MyResource.class);
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 pushSubscriptions = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-subscriptions");
System.out.println("push subscriptions: " + pushSubscriptions);
PushTopicRegistration reg = new PushTopicRegistration();
reg.setDurable(false);
XmlLink target = new XmlLink();
target.setMethod("put");
target.setHref(generateURL("/my"));
reg.setTarget(target);
response = pushSubscriptions.request().body("application/xml", reg).post();
Assert.assertEquals(201, response.getStatus());
Link pushSubscription = response.getLocationLink();
response.releaseConnection();
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
Thread.sleep(100);
Assert.assertEquals("1", MyResource.gotit);
response = pushSubscription.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
示例14: testUriWithMultipleSessions
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Test
public void testUriWithMultipleSessions() throws Exception {
final int CONCURRENT = 10;
TopicDeployment deployment = new TopicDeployment();
deployment.setDuplicatesAllowed(true);
deployment.setDurableSend(false);
deployment.setName("testUriWithMultipleSessions");
manager.getTopicManager().deploy(deployment);
ClientRequest request = new ClientRequest(generateURL("/topics/testUriWithMultipleSessions"));
server.getJaxrsServer().getDeployment().getRegistry().addPerRequestResource(MyConcurrentResource.class);
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 pushSubscriptions = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-subscriptions");
System.out.println("push subscriptions: " + pushSubscriptions);
PushTopicRegistration reg = new PushTopicRegistration();
reg.setDurable(false);
XmlLink target = new XmlLink();
target.setMethod("put");
target.setHref(generateURL("/myConcurrent"));
reg.setTarget(target);
reg.setSessionCount(CONCURRENT);
response = pushSubscriptions.request().body("application/xml", reg).post();
Assert.assertEquals(201, response.getStatus());
Link pushSubscription = response.getLocationLink();
response.releaseConnection();
for (int i = 0; i < CONCURRENT; i++) {
response = sender.request().body("text/plain", Integer.toString(1)).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
}
// wait until all the invocations have completed
while (MyConcurrentResource.concurrentInvocations.get() > 0) {
Thread.sleep(100);
}
Assert.assertEquals(CONCURRENT, MyConcurrentResource.maxConcurrentInvocations.get());
response = pushSubscription.request().delete();
response.releaseConnection();
Assert.assertEquals(204, response.getStatus());
}
示例15: testDup
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@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");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, true);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("poller: " + consumeNext);
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
Assert.assertEquals(307, res.getStatus());
sender = res.getLocationLink();
res.releaseConnection();
System.out.println("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");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
System.out.println("consumeNext: " + consumeNext);
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res.releaseConnection();
session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
System.out.println("consumeNext: " + consumeNext);
res = consumeNext.request().post(String.class);
res.releaseConnection();
Assert.assertEquals(503, res.getStatus());
res = session.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
}