Search in sources :

Example 11 with Book

use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.

the class JAXRSJmsTest method testGetBookFromSubresourceProxyClient.

@Test
public void testGetBookFromSubresourceProxyClient() 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";
    JMSBookStore client = JAXRSClientFactory.create(endpointAddressUrlEncoded, JMSBookStore.class);
    Book bookProxy = client.getBookSubResource("123");
    Book book = bookProxy.retrieveState();
    assertEquals("Get a wrong response code.", 200, WebClient.client(bookProxy).getResponse().getStatus());
    assertEquals("Get a wrong book id.", 123, book.getId());
}
Also used : JMSBookStore(org.apache.cxf.systest.jaxrs.JMSBookStore) Book(org.apache.cxf.systest.jaxrs.Book) Test(org.junit.Test)

Example 12 with Book

use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.

the class JAXRSJmsTest method testGetBookFromWebClientWithTextJMSMessage.

@Test
public void testGetBookFromWebClientWithTextJMSMessage() throws Exception {
    // setup the the client
    String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text" + "?replyToName=dynamicQueues/test.jmstransport.response" + "&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&jndiURL=tcp://localhost:" + JMS_PORT + "&messageType=text";
    WebClient client = WebClient.create(endpointAddressUrlEncoded);
    WebClient.getConfig(client).getInInterceptors().add(new LoggingInInterceptor());
    WebClient.getConfig(client).getRequestContext().put(org.apache.cxf.message.Message.REQUEST_URI, "/bookstore/books/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());
}
Also used : Book(org.apache.cxf.systest.jaxrs.Book) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 13 with Book

use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.

the class JAXRSJmsTest method testGetBookFromProxyClient.

@Test
public void testGetBookFromProxyClient() 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";
    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());
}
Also used : JMSBookStore(org.apache.cxf.systest.jaxrs.JMSBookStore) Book(org.apache.cxf.systest.jaxrs.Book) Test(org.junit.Test)

Example 14 with Book

use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.

the class JAXRSCompletionStageTest method testGetBookAsyncStageAsyncResponse.

@Test
public void testGetBookAsyncStageAsyncResponse() throws Exception {
    String address = "http://localhost:" + PORT + "/completable/booksAsync";
    WebClient wc = createWebClient(address);
    CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
    Book book = stage.toCompletableFuture().join();
    assertEquals(123L, book.getId());
}
Also used : Book(org.apache.cxf.systest.jaxrs.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 15 with Book

use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.

the class JAXRSCompletionStageTest method testGetBookAsyncStage.

@Test
public void testGetBookAsyncStage() throws Exception {
    String address = "http://localhost:" + PORT + "/completable/books";
    WebClient wc = createWebClient(address);
    CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
    Book book = stage.toCompletableFuture().join();
    assertEquals(123L, book.getId());
}
Also used : Book(org.apache.cxf.systest.jaxrs.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Aggregations

Book (org.apache.cxf.systest.jaxrs.Book)46 Test (org.junit.Test)31 WebClient (org.apache.cxf.jaxrs.client.WebClient)22 BookStore (org.apache.cxf.systest.jaxrs.BookStore)8 JMSBookStore (org.apache.cxf.systest.jaxrs.JMSBookStore)6 SequentialStrategy (org.apache.cxf.clustering.SequentialStrategy)5 Response (javax.ws.rs.core.Response)4 ArrayList (java.util.ArrayList)3 BytesMessage (javax.jms.BytesMessage)3 JAXBContext (javax.xml.bind.JAXBContext)3 InputStream (java.io.InputStream)2 ExecutionException (java.util.concurrent.ExecutionException)2 MessageProducer (javax.jms.MessageProducer)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)2 NotFoundException (javax.ws.rs.NotFoundException)2 ProcessingException (javax.ws.rs.ProcessingException)2 Client (javax.ws.rs.client.Client)2 ClientBuilder (javax.ws.rs.client.ClientBuilder)2 WebTarget (javax.ws.rs.client.WebTarget)2 Form (javax.ws.rs.core.Form)2