Package org.apache.camel.component.cxf.jaxrs.testbean

Examples of org.apache.camel.component.cxf.jaxrs.testbean.Customer


                inMessage.setBody(null);               
            }
        });
    
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
        assertEquals("Get a wrong customer name", response.getName(), "John");
    }
View Full Code Here


                            assertEquals("Get a wrong http method", "GET", httpMethod);
                            String path = inMessage.getHeader(Exchange.HTTP_PATH, String.class);
                            // The parameter of the invocation is stored in the body of in message
                            String id = (String) inMessage.getBody(String.class);
                            if ("/customerservice/customers/126".equals(path)) {                           
                                Customer customer = new Customer();
                                customer.setId(Long.parseLong(id));
                                customer.setName("Willem");
                                // We just put the response Object into the out message body
                                exchange.getOut().setBody(customer);
                            } else {
                                if ("/customerservice/customers/456".equals(path)) {
                                    Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
                                    throw new WebApplicationException(r);
                                } else {
                                    throw new RuntimeCamelException("Can't found the customer with uri " + path);
                                }
                            }
                        }
                        if ("updateCustomer".equals(operationName)) {
                            assertEquals("Get a wrong customer message header", "header1;header2", inMessage.getHeader("test"));
                            String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
                            assertEquals("Get a wrong http method", "PUT", httpMethod);
                            Customer customer = inMessage.getBody(Customer.class);
                            assertNotNull("The customer should not be null.", customer);
                            // Now you can do what you want on the customer object
                            assertEquals("Get a wrong customer name.", "Mary", customer.getName());
                            // set the response back
                            exchange.getOut().setBody(Response.ok().build());
                        }
                    }
                   
View Full Code Here

            }
           
        });
    
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
        assertEquals("Get a wrong customer name", response.getName(), "John");
        // END SNIPPET: ProxyExample    
    }
View Full Code Here

            }
           
        });
    
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
        assertEquals("Get a wrong customer name", response.getName(), "John");
        // END SNIPPET: HttpExample
    }
View Full Code Here

                            assertEquals("Get a wrong http method", "GET", httpMethod);
                            String path = inMessage.getHeader(Exchange.HTTP_PATH, String.class);
                            // The parameter of the invocation is stored in the body of in message
                            String id = (String) inMessage.getBody(String.class);
                            if ("/customerservice/customers/126".equals(path)) {                           
                                Customer customer = new Customer();
                                customer.setId(Long.parseLong(id));
                                customer.setName("Willem");
                                // We just put the response Object into the out message body
                                exchange.getOut().setBody(customer);
                            } else {
                                Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
                                throw new WebApplicationException(r);
                            }
                        }
                        if ("updateCustomer".equals(operationName)) {
                            String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
                            assertEquals("Get a wrong http method", "PUT", httpMethod);
                            Customer customer = inMessage.getBody(Customer.class);
                            assertNotNull("The customer should not be null.", customer);
                            // Now you can do what you want on the customer object
                            assertEquals("Get a wrong customer name.", "Mary", customer.getName());
                            // set the response back
                            exchange.getOut().setBody(Response.ok().build());
                        }
                    }
                   
View Full Code Here

            }
           
        });
    
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
        assertEquals("Get a wrong customer name", response.getName(), "John");
        // END SNIPPET: ProxyExample    
    }
View Full Code Here

            }
           
        });
    
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
        assertEquals("Get a wrong customer name", response.getName(), "John");
        // END SNIPPET: HttpExample
    }
View Full Code Here

            }
           
        });
    
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
        assertEquals("Get a wrong customer name", response.getName(), "John");
       
    }
View Full Code Here

                // set the relative path
                inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customersUniqueResponseCode");               
                // put the response's entity into out message body
                inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
                // create a new customer object
                Customer customer = new Customer();
                customer.setId(8888);
                customer.setName("Willem");
                inMessage.setBody(customer);               
            }
           
        });
       
        // get the response message
        Customer response = (Customer) exchange.getOut().getBody();
       
        assertNotNull("The response should not be null ", response);
        assertTrue("Get a wrong customer id ", response.getId() != 8888);
        assertEquals("Get a wrong customer name", response.getName(), "Willem");
    }
View Full Code Here

                            assertEquals("Get a wrong http method", "GET", httpMethod);
                            String path = inMessage.getHeader(Exchange.HTTP_PATH, String.class);
                            // The parameter of the invocation is stored in the body of in message
                            String id = (String) inMessage.getBody(String.class);
                            if ("/customerservice/customers/126".equals(path)) {                           
                                Customer customer = new Customer();
                                customer.setId(Long.parseLong(id));
                                customer.setName("Willem");
                                // We just put the response Object into the out message body
                                exchange.getOut().setBody(customer);
                            } else {
                                if ("/customerservice/customers/400".equals(path)) {
                                    // We return the remote client IP address this time
                                    org.apache.cxf.message.Message cxfMessage = inMessage.getHeader(CxfConstants.CAMEL_CXF_MESSAGE, org.apache.cxf.message.Message.class);
                                    ServletRequest request = (ServletRequest) cxfMessage.get("HTTP.REQUEST");
                                    String remoteAddress = request.getRemoteAddr();
                                    Response r = Response.status(200).entity("The remoteAddress is " + remoteAddress).build();
                                    exchange.getOut().setBody(r);
                                    return;
                                }
                                if ("/customerservice/customers/123".equals(path)) {
                                    // send a customer response back
                                    Response r = Response.status(200).entity("customer response back!").build();
                                    exchange.getOut().setBody(r);
                                    return;
                                }
                                if ("/customerservice/customers/456".equals(path)) {
                                    Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
                                    throw new WebApplicationException(r);
                                } else {
                                    throw new RuntimeCamelException("Can't found the customer with uri " + path);
                                }
                            }
                        }
                        if ("updateCustomer".equals(operationName)) {
                            assertEquals("Get a wrong customer message header", "header1;header2", inMessage.getHeader("test"));
                            String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
                            assertEquals("Get a wrong http method", "PUT", httpMethod);
                            Customer customer = inMessage.getBody(Customer.class);
                            assertNotNull("The customer should not be null.", customer);
                            // Now you can do what you want on the customer object
                            assertEquals("Get a wrong customer name.", "Mary", customer.getName());
                            // set the response back
                            exchange.getOut().setBody(Response.ok().build());
                        }
                       
                    }
View Full Code Here

TOP

Related Classes of org.apache.camel.component.cxf.jaxrs.testbean.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.