Search in sources :

Example 6 with Customer

use of com.example.customerservice.Customer in project camel by apache.

the class CustomerServiceImpl method getCustomersByName.

/**
     * If the request.name is "none" a NoSuchCustomerException is thrown in any
     * other case a dummy customer is returned that has the same name as the
     * request
     */
public GetCustomersByNameResponse getCustomersByName(GetCustomersByName request) throws NoSuchCustomerException {
    if ("none".equals(request.getName())) {
        NoSuchCustomer noSuchCustomer = new NoSuchCustomer();
        noSuchCustomer.setCustomerId(request.getName());
        throw new NoSuchCustomerException("Customer not found", noSuchCustomer);
    }
    GetCustomersByNameResponse response = new GetCustomersByNameResponse();
    Customer customer = new Customer();
    customer.setName(request.getName());
    customer.setRevenue(100000);
    response.getReturn().add(customer);
    return response;
}
Also used : GetCustomersByNameResponse(com.example.customerservice.GetCustomersByNameResponse) Customer(com.example.customerservice.Customer) NoSuchCustomer(com.example.customerservice.NoSuchCustomer) SaveCustomer(com.example.customerservice.SaveCustomer) NoSuchCustomer(com.example.customerservice.NoSuchCustomer) NoSuchCustomerException(com.example.customerservice.NoSuchCustomerException)

Example 7 with Customer

use of com.example.customerservice.Customer in project camel by apache.

the class CustomerServiceImpl method getAllAmericanCustomers.

/**
     * This method is to test a call without input parameter
     */
public GetAllAmericanCustomersResponse getAllAmericanCustomers() {
    GetAllAmericanCustomersResponse response = new GetAllAmericanCustomersResponse();
    Customer customer = new Customer();
    customer.setName("Schmitz");
    customer.setRevenue(100000);
    response.getReturn().add(customer);
    return response;
}
Also used : Customer(com.example.customerservice.Customer) NoSuchCustomer(com.example.customerservice.NoSuchCustomer) SaveCustomer(com.example.customerservice.SaveCustomer) GetAllAmericanCustomersResponse(com.example.customerservice.GetAllAmericanCustomersResponse)

Example 8 with Customer

use of com.example.customerservice.Customer in project camel by apache.

the class SoapCxfClientTest method testRoundTripSaveCustomer.

@Test
public void testRoundTripSaveCustomer() throws Exception {
    Customer testCustomer = new Customer();
    testCustomer.setName("testName");
    SaveCustomer request = new SaveCustomer();
    request.setCustomer(testCustomer);
    customerService.saveCustomer(request);
    Customer customer2 = serverBean.getLastSavedCustomer();
    Assert.assertEquals("testName", customer2.getName());
}
Also used : Customer(com.example.customerservice.Customer) NoSuchCustomer(com.example.customerservice.NoSuchCustomer) SaveCustomer(com.example.customerservice.SaveCustomer) SaveCustomer(com.example.customerservice.SaveCustomer) Test(org.junit.Test)

Example 9 with Customer

use of com.example.customerservice.Customer in project camel by apache.

the class SoapCxfClientTest method testSuccess.

@Test
public void testSuccess() throws NoSuchCustomerException {
    GetCustomersByName request = new GetCustomersByName();
    request.setName("test");
    GetCustomersByNameResponse response = customerService.getCustomersByName(request);
    Assert.assertNotNull(response);
    List<Customer> customers = response.getReturn();
    Assert.assertEquals(1, customers.size());
    Assert.assertEquals("test", customers.get(0).getName());
}
Also used : GetCustomersByNameResponse(com.example.customerservice.GetCustomersByNameResponse) Customer(com.example.customerservice.Customer) NoSuchCustomer(com.example.customerservice.NoSuchCustomer) SaveCustomer(com.example.customerservice.SaveCustomer) GetCustomersByName(com.example.customerservice.GetCustomersByName) Test(org.junit.Test)

Example 10 with Customer

use of com.example.customerservice.Customer in project cxf by apache.

the class CustomerServiceTester method testCustomerService.

public void testCustomerService() throws NoSuchCustomerException {
    List<Customer> customers = null;
    // First we test the positive case where customers are found and we retreive
    // a list of customers
    System.out.println("Sending request for customers named Smith");
    customers = customerService.getCustomersByName("Smith");
    System.out.println("Response received");
    Assert.assertEquals(2, customers.size());
    Assert.assertEquals("Smith", customers.get(0).getName());
    // Then we test for an unknown Customer name and expect the NoSuchCustomerException
    try {
        customers = customerService.getCustomersByName("None");
        Assert.fail("We should get a NoSuchCustomerException here");
    } catch (NoSuchCustomerException e) {
        System.out.println(e.getMessage());
        Assert.assertNotNull("FaultInfo must not be null", e.getFaultInfo());
        Assert.assertEquals("None", e.getFaultInfo().getCustomerName());
        System.out.println("NoSuchCustomer exception was received as expected");
    }
    // The implementation of updateCustomer is set to sleep for some seconds.
    // Still this method should return instantly as the method is declared
    // as a one way method in the WSDL
    Customer customer = new Customer();
    customer.setName("Smith");
    customerService.updateCustomer(customer);
    System.out.println("All calls were successful");
}
Also used : Customer(com.example.customerservice.Customer) NoSuchCustomerException(com.example.customerservice.NoSuchCustomerException)

Aggregations

Customer (com.example.customerservice.Customer)10 NoSuchCustomer (com.example.customerservice.NoSuchCustomer)8 SaveCustomer (com.example.customerservice.SaveCustomer)6 Test (org.junit.Test)5 GetCustomersByNameResponse (com.example.customerservice.GetCustomersByNameResponse)4 GetCustomersByName (com.example.customerservice.GetCustomersByName)3 NoSuchCustomerException (com.example.customerservice.NoSuchCustomerException)3 GetAllCustomersResponse (com.example.customerservice.GetAllCustomersResponse)2 GetAllAmericanCustomersResponse (com.example.customerservice.GetAllAmericanCustomersResponse)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1