use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJmsTest method testGetBookFromWebClientWithPathWithTextJMSMessage.
@Test
public void testGetBookFromWebClientWithPathWithTextJMSMessage() throws Exception {
// setup the the client
String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response" + "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory" + "&messageType=text";
WebClient client = WebClient.create(endpointAddressUrlEncoded);
client.path("bookstore").path("books").path("123");
Book book = client.get(Book.class);
assertEquals("Get a wrong response code.", 200, client.getResponse().getStatus());
assertEquals("Get a wrong book id.", 123, book.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJmsTest method testGetBookFromProxyClientWithTextJMSMessage.
@Test
public void testGetBookFromProxyClientWithTextJMSMessage() throws Exception {
// setup the the client
String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response" + "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory" + "&messageType=text";
JMSBookStore client = JAXRSClientFactory.create(endpointAddressUrlEncoded, JMSBookStore.class);
Book book = client.getBook("123");
assertEquals("Get a wrong response code.", 200, WebClient.client(client).getResponse().getStatus());
assertEquals("Get a wrong book id.", 123, book.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJmsTest method testGetBookFromProxyClientWithQueryWithTextJMSMessage.
@Test
public void testGetBookFromProxyClientWithQueryWithTextJMSMessage() throws Exception {
// setup the the client
String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response" + "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory" + "&messageType=text";
JMSBookStore client = JAXRSClientFactory.create(endpointAddressUrlEncoded, JMSBookStore.class);
Book book = client.getBookByURLQuery(new String[] { "1", "2", "3" });
assertEquals("Get a wrong response code.", 200, WebClient.client(client).getResponse().getStatus());
assertEquals("Get a wrong book id.", 123, book.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSCompletionStageTest method testGetBookAsyncStageThenAcceptAsync.
@Test
public void testGetBookAsyncStageThenAcceptAsync() throws Exception {
String address = "http://localhost:" + PORT + "/completable/books";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
Holder<Book> holder = new Holder<Book>();
stage.thenApply(v -> {
v.setId(v.getId() * 2);
return v;
}).thenAcceptAsync(v -> {
holder.value = v;
});
Thread.sleep(3000);
assertEquals(246L, holder.value.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSCompletionStageTest method testGetBookAsyncStage404.
@Test
public void testGetBookAsyncStage404() throws Exception {
String address = "http://localhost:" + PORT + "/completable/books";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("124").rx().get(Book.class);
try {
stage.toCompletableFuture().get();
fail("Exception expected");
} catch (ExecutionException ex) {
assertTrue(ex.getCause() instanceof NotFoundException);
}
}
Aggregations