use of org.apache.camel.example.cxf.jaxrs.resources.Book in project camel by apache.
the class Client method invoke.
void invoke() throws BookNotFoundFault {
// JAXWSClient invocation
JAXWSClient jaxwsClient = new JAXWSClient();
BookStore bookStore = jaxwsClient.getBookStore();
bookStore.addBook(new Book("Camel User Guide", 123L));
Book book = bookStore.getBook(123L);
System.out.println("Get the book with id 123. " + book);
try {
book = bookStore.getBook(124L);
System.out.println("Get the book with id 124. " + book);
} catch (Exception exception) {
System.out.println("Expected exception received: " + exception);
}
// JAXRSClient invocation
JAXRSClient jaxrsClient = new JAXRSClient();
bookStore = jaxrsClient.getBookStore();
bookStore.addBook(new Book("Karaf User Guide", 124L));
book = bookStore.getBook(124L);
System.out.println("Get the book with id 124. " + book);
try {
book = bookStore.getBook(126L);
System.out.println("Get the book with id 126. " + book);
} catch (Exception exception) {
System.out.println("Expected exception received: " + exception);
}
}
use of org.apache.camel.example.cxf.jaxrs.resources.Book in project camel by apache.
the class JAXRSClientServerTest method testJAXWSClient.
@Test
public void testJAXWSClient() throws BookNotFoundFault {
JAXWSClient jaxwsClient = new JAXWSClient();
BookStore bookStore = jaxwsClient.getBookStore();
bookStore.addBook(new Book("Camel User Guide", 123L));
Book book = bookStore.getBook(123L);
assertNotNull("We should find the book here", book);
try {
book = bookStore.getBook(124L);
fail("We should not have this book");
} catch (Exception exception) {
assertTrue("The exception should be BookNotFoundFault", exception instanceof BookNotFoundFault);
}
}
use of org.apache.camel.example.cxf.jaxrs.resources.Book in project camel by apache.
the class JAXRSClientServerTest method testJAXRSClient.
@Test
public void testJAXRSClient() throws BookNotFoundFault {
// JAXRSClient invocation
JAXRSClient jaxrsClient = new JAXRSClient();
BookStore bookStore = jaxrsClient.getBookStore();
bookStore.addBook(new Book("Camel User Guide", 124L));
Book book = bookStore.getBook(124L);
assertNotNull("We should find the book here", book);
try {
book = bookStore.getBook(126L);
fail("We should not have this book");
} catch (Exception exception) {
assertTrue("The exception should be BookNotFoundFault", exception instanceof BookNotFoundFault);
}
}
use of org.apache.camel.example.cxf.jaxrs.resources.Book in project camel by apache.
the class CamelRouterBuilder method main.
/**
* Allow this route to be run as an application
*/
public static void main(String[] args) throws Exception {
System.setProperty("soapEndpointPort", "9006");
System.setProperty("restEndpointPort", "9002");
CamelContext context = new DefaultCamelContext();
PropertiesComponent pc = new PropertiesComponent();
context.addComponent("properties", pc);
context.start();
context.addRoutes(new CamelRouterBuilder());
Thread.sleep(1000);
// JAXWSClient invocation
JAXWSClient jaxwsClient = new JAXWSClient();
BookStore bookStore = jaxwsClient.getBookStore();
bookStore.addBook(new Book("Camel User Guide", 123L));
Book book = bookStore.getBook(123L);
System.out.println("Get the book with id 123. " + book);
try {
book = bookStore.getBook(124L);
System.out.println("Get the book with id 124. " + book);
} catch (Exception exception) {
System.out.println("Expected exception received: " + exception);
}
// JAXRSClient invocation
JAXRSClient jaxrsClient = new JAXRSClient();
bookStore = jaxrsClient.getBookStore();
bookStore.addBook(new Book("Karaf User Guide", 124L));
book = bookStore.getBook(124L);
System.out.println("Get the book with id 124. " + book);
try {
book = bookStore.getBook(126L);
System.out.println("Get the book with id 126. " + book);
} catch (Exception exception) {
System.out.println("Expected exception received: " + exception);
}
Thread.sleep(1000);
context.stop();
System.exit(0);
}
Aggregations