use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJmsTest method readBook.
private Book readBook(InputStream is) throws Exception {
JAXBContext c = JAXBContext.newInstance(new Class[] { Book.class });
Unmarshaller u = c.createUnmarshaller();
return (Book) u.unmarshal(is);
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJmsTest method testGetBookFromWebClientWithPath.
@Test
public void testGetBookFromWebClientWithPath() 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";
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 testGetBookFromProxyClientWithQuery.
@Test
public void testGetBookFromProxyClientWithQuery() 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.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 JAXRSJmsTest method checkBookInResponse.
private void checkBookInResponse(Session session, Destination replyToDestination, long bookId, String bookName) throws Exception {
MessageConsumer consumer = session.createConsumer(replyToDestination);
BytesMessage jmsMessage = (BytesMessage) consumer.receive(5000);
if (jmsMessage == null) {
throw new RuntimeException("No response recieved on " + replyToDestination);
}
byte[] bytes = new byte[(int) jmsMessage.getBodyLength()];
jmsMessage.readBytes(bytes);
InputStream is = new ByteArrayInputStream(bytes);
Book b = readBook(is);
assertEquals(bookId, b.getId());
assertEquals(bookName, b.getName());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJmsTest method testGetBookFromSubresourceProxyClientWithTextJMSMessage.
@Test
public void testGetBookFromSubresourceProxyClientWithTextJMSMessage() 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 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());
}
Aggregations