Search in sources :

Example 1 with AddNumbersImpl

use of org.apache.cxf.jaxws.service.AddNumbersImpl in project cxf by apache.

the class SEIWithJAXBAnnoTest method testXMLList.

@Test
public void testXMLList() throws Exception {
    AddNumbersImpl serviceImpl = new AddNumbersImpl();
    Endpoint.publish("local://localhost:9000/Hello", serviceImpl);
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(BusFactory.getDefaultBus());
    factory.setServiceClass(AddNumbers.class);
    factory.setAddress(address);
    AddNumbers proxy = (AddNumbers) factory.create();
    StringWriter strWriter = new StringWriter();
    LoggingOutInterceptor log = new LoggingOutInterceptor(new PrintWriter(strWriter));
    ClientProxy.getClient(proxy).getOutInterceptors().add(log);
    List<String> args = new ArrayList<>();
    args.add("str1");
    args.add("str2");
    args.add("str3");
    List<Integer> result = proxy.addNumbers(args);
    String expected = "<arg0>str1 str2 str3</arg0>";
    assertTrue("Client does not use the generated wrapper class to marshal request parameters", strWriter.toString().indexOf(expected) > -1);
    assertEquals("Get the wrong result", 100, (int) result.get(0));
}
Also used : StringWriter(java.io.StringWriter) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) AddNumbersImpl(org.apache.cxf.jaxws.service.AddNumbersImpl) AddNumbers(org.apache.cxf.jaxws.service.AddNumbers) ArrayList(java.util.ArrayList) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 AddNumbers (org.apache.cxf.jaxws.service.AddNumbers)1 AddNumbersImpl (org.apache.cxf.jaxws.service.AddNumbersImpl)1 Test (org.junit.Test)1