Search in sources :

Example 1 with GetCustomersByName

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

the class Soap12UnMarshalTest method testUnMarshalSoap.

@Test
public void testUnMarshalSoap() throws IOException, InterruptedException {
    resultEndpoint.expectedMessageCount(1);
    InputStream in = this.getClass().getResourceAsStream("request.xml");
    producer.sendBody(in);
    resultEndpoint.assertIsSatisfied();
    Exchange exchange = resultEndpoint.getExchanges().get(0);
    Object body = exchange.getIn().getBody();
    assertEquals(GetCustomersByName.class, body.getClass());
    GetCustomersByName request = (GetCustomersByName) body;
    assertEquals("Smith", request.getName());
}
Also used : Exchange(org.apache.camel.Exchange) InputStream(java.io.InputStream) GetCustomersByName(com.example.customerservice.GetCustomersByName) Test(org.junit.Test)

Example 2 with GetCustomersByName

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

the class SoapClientTest method testRoundTripGetCustomersByName.

@Test
public void testRoundTripGetCustomersByName() throws Exception {
    GetCustomersByNameResponse response = customerService.getCustomersByName(new GetCustomersByName());
    assertEquals(1, response.getReturn().size());
    Customer firstCustomer = response.getReturn().get(0);
    assertEquals(100000.0, firstCustomer.getRevenue(), 0.0D);
}
Also used : GetCustomersByNameResponse(com.example.customerservice.GetCustomersByNameResponse) Customer(com.example.customerservice.Customer) GetCustomersByName(com.example.customerservice.GetCustomersByName) Test(org.junit.Test)

Example 3 with GetCustomersByName

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

the class SoapCxfClientTest method testFault.

@Test
public void testFault() {
    GetCustomersByName request = new GetCustomersByName();
    request.setName("none");
    try {
        customerService.getCustomersByName(request);
        Assert.fail("NoSuchCustomerException expected");
    } catch (NoSuchCustomerException e) {
        NoSuchCustomer info = e.getFaultInfo();
        Assert.assertEquals("none", info.getCustomerId());
    }
}
Also used : GetCustomersByName(com.example.customerservice.GetCustomersByName) NoSuchCustomer(com.example.customerservice.NoSuchCustomer) NoSuchCustomerException(com.example.customerservice.NoSuchCustomerException) Test(org.junit.Test)

Example 4 with GetCustomersByName

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

the class SoapCxfServerTest method testSuccess.

@Test
public void testSuccess() throws NoSuchCustomerException {
    GetCustomersByName request = new GetCustomersByName();
    request.setName("test");
    GetCustomersByNameResponse response = customerServiceProxy.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) GetCustomersByName(com.example.customerservice.GetCustomersByName) Test(org.junit.Test)

Example 5 with GetCustomersByName

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

the class SoapRoundtripTest method testRoundTrip.

@Test
public void testRoundTrip() throws IOException, InterruptedException {
    resultEndpoint.expectedMessageCount(1);
    GetCustomersByName request = new GetCustomersByName();
    request.setName("Mueller");
    producer.sendBody(request);
    resultEndpoint.assertIsSatisfied();
    Exchange exchange = resultEndpoint.getExchanges().get(0);
    GetCustomersByName received = exchange.getIn().getBody(GetCustomersByName.class);
    assertNotNull(received);
    assertEquals("Mueller", received.getName());
}
Also used : Exchange(org.apache.camel.Exchange) GetCustomersByName(com.example.customerservice.GetCustomersByName) Test(org.junit.Test)

Aggregations

GetCustomersByName (com.example.customerservice.GetCustomersByName)12 Test (org.junit.Test)12 Exchange (org.apache.camel.Exchange)5 NoSuchCustomer (com.example.customerservice.NoSuchCustomer)4 InputStream (java.io.InputStream)4 Customer (com.example.customerservice.Customer)3 GetCustomersByNameResponse (com.example.customerservice.GetCustomersByNameResponse)3 NoSuchCustomerException (com.example.customerservice.NoSuchCustomerException)2 SaveCustomer (com.example.customerservice.SaveCustomer)1