Search in sources :

Example 6 with BasicGreeterService

use of org.apache.cxf.greeter_control.BasicGreeterService in project cxf by apache.

the class NestedAddressingPolicyTest method greetMe.

@Test
public void greetMe() throws Exception {
    // use a plain client
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    BasicGreeterService gs = new BasicGreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LoggingInInterceptor in = new LoggingInInterceptor();
    LoggingOutInterceptor out = new LoggingOutInterceptor();
    bus.getInInterceptors().add(in);
    bus.getOutInterceptors().add(out);
    try {
        greeter.greetMe("mytest");
        fail("SoapFault expected");
    } catch (Exception e) {
        assertTrue("Addressing Header Required message is expected", e.getMessage().contains("Addressing Property is not present"));
    }
    ((Closeable) greeter).close();
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.cxf.greeter_control.Greeter) Closeable(java.io.Closeable) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) BasicGreeterService(org.apache.cxf.greeter_control.BasicGreeterService) Test(org.junit.Test)

Example 7 with BasicGreeterService

use of org.apache.cxf.greeter_control.BasicGreeterService in project cxf by apache.

the class JaxwsExecutorTest method testUseCustomExecutorOnClient.

@Test
public void testUseCustomExecutorOnClient() throws Exception {
    BasicGreeterService service = new BasicGreeterService();
    class CustomExecutor implements Executor {

        private int count;

        public void execute(Runnable command) {
            count++;
            command.run();
        }

        public int getCount() {
            return count;
        }
    }
    CustomExecutor executor = new CustomExecutor();
    service.setExecutor(executor);
    assertSame(executor, service.getExecutor());
    Greeter proxy = service.getGreeterPort();
    updateAddressPort(proxy, PORT);
    assertEquals(0, executor.getCount());
    Response<GreetMeResponse> response = proxy.greetMeAsync("cxf");
    int waitCount = 0;
    while (!response.isDone() && waitCount < 15) {
        Thread.sleep(1000);
        waitCount++;
    }
    assertTrue("Response still not received.", response.isDone());
    assertEquals(1, executor.getCount());
}
Also used : Executor(java.util.concurrent.Executor) Greeter(org.apache.cxf.greeter_control.Greeter) BasicGreeterService(org.apache.cxf.greeter_control.BasicGreeterService) GreetMeResponse(org.apache.cxf.greeter_control.types.GreetMeResponse) Test(org.junit.Test)

Example 8 with BasicGreeterService

use of org.apache.cxf.greeter_control.BasicGreeterService in project cxf by apache.

the class AddressingInlinePolicyTest method testUsingAddressing.

@Test
public void testUsingAddressing() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy-old.xml");
    BusFactory.setDefaultBus(bus);
    BasicGreeterService gs = new BasicGreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, true);
    testInterceptors(bus);
    // oneway
    greeter.greetMeOneWay("CXF");
    // two-way
    assertEquals("CXF", greeter.greetMe("cxf"));
    try {
        greeter.pingMe();
    } catch (PingMeFault ex) {
        fail("First invocation should have succeeded.");
    }
    try {
        greeter.pingMe();
        fail("Expected PingMeFault not thrown.");
    } catch (PingMeFault ex) {
        assertEquals(2, ex.getFaultInfo().getMajor());
        assertEquals(1, ex.getFaultInfo().getMinor());
    }
    ((Closeable) greeter).close();
}
Also used : PingMeFault(org.apache.cxf.greeter_control.PingMeFault) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.cxf.greeter_control.Greeter) Closeable(java.io.Closeable) BasicGreeterService(org.apache.cxf.greeter_control.BasicGreeterService) Test(org.junit.Test)

Example 9 with BasicGreeterService

use of org.apache.cxf.greeter_control.BasicGreeterService in project cxf by apache.

the class AddressingOptionalPolicyTest method testNotUsingAddressing.

@Test
public void testNotUsingAddressing() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
    BusFactory.setDefaultBus(bus);
    InMessageRecorder in = new InMessageRecorder();
    bus.getInInterceptors().add(in);
    OutMessageRecorder out = new OutMessageRecorder();
    bus.getOutInterceptors().add(out);
    bus.getExtension(PolicyEngine.class).setAlternativeSelector(new MinimalAlternativeSelector());
    BasicGreeterService gs = new BasicGreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, true);
    // oneway
    greeter.greetMeOneWay("CXF");
    // two-way
    assertEquals("CXF", greeter.greetMe("cxf"));
    try {
        greeter.pingMe();
    } catch (PingMeFault ex) {
        fail("First invocation should have succeeded.");
    }
    try {
        greeter.pingMe();
        fail("Expected PingMeFault not thrown.");
    } catch (PingMeFault ex) {
        assertEquals(2, ex.getFaultInfo().getMajor());
        assertEquals(1, ex.getFaultInfo().getMinor());
    }
    MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages());
    for (int i = 0; i < 3; i++) {
        mf.verifyNoHeader(RMUtils.getAddressingConstants().getMessageIDQName(), true, i);
        mf.verifyNoHeader(RMUtils.getAddressingConstants().getMessageIDQName(), false, i);
    }
    ((Closeable) greeter).close();
}
Also used : InMessageRecorder(org.apache.cxf.testutil.recorders.InMessageRecorder) PingMeFault(org.apache.cxf.greeter_control.PingMeFault) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) OutMessageRecorder(org.apache.cxf.testutil.recorders.OutMessageRecorder) MinimalAlternativeSelector(org.apache.cxf.ws.policy.selector.MinimalAlternativeSelector) Greeter(org.apache.cxf.greeter_control.Greeter) Closeable(java.io.Closeable) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) BasicGreeterService(org.apache.cxf.greeter_control.BasicGreeterService) MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 10 with BasicGreeterService

use of org.apache.cxf.greeter_control.BasicGreeterService in project cxf by apache.

the class AddressingOptionalPolicyTest method testUsingAddressing.

@Test
public void testUsingAddressing() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
    BusFactory.setDefaultBus(bus);
    InMessageRecorder in = new InMessageRecorder();
    bus.getInInterceptors().add(in);
    OutMessageRecorder out = new OutMessageRecorder();
    bus.getOutInterceptors().add(out);
    BasicGreeterService gs = new BasicGreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, true);
    // oneway
    greeter.greetMeOneWay("CXF");
    // two-way
    assertEquals("CXF", greeter.greetMe("cxf"));
    try {
        greeter.pingMe();
    } catch (PingMeFault ex) {
        fail("First invocation should have succeeded.");
    }
    try {
        greeter.pingMe();
        fail("Expected PingMeFault not thrown.");
    } catch (PingMeFault ex) {
        assertEquals(2, ex.getFaultInfo().getMajor());
        assertEquals(1, ex.getFaultInfo().getMinor());
    }
    MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages());
    for (int i = 0; i < 3; i++) {
        mf.verifyHeader(RMUtils.getAddressingConstants().getMessageIDQName(), true, i);
        mf.verifyHeader(RMUtils.getAddressingConstants().getMessageIDQName(), false, i);
    }
    ((Closeable) greeter).close();
}
Also used : InMessageRecorder(org.apache.cxf.testutil.recorders.InMessageRecorder) PingMeFault(org.apache.cxf.greeter_control.PingMeFault) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) OutMessageRecorder(org.apache.cxf.testutil.recorders.OutMessageRecorder) Greeter(org.apache.cxf.greeter_control.Greeter) Closeable(java.io.Closeable) BasicGreeterService(org.apache.cxf.greeter_control.BasicGreeterService) MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Aggregations

BasicGreeterService (org.apache.cxf.greeter_control.BasicGreeterService)14 Greeter (org.apache.cxf.greeter_control.Greeter)14 Test (org.junit.Test)14 Closeable (java.io.Closeable)13 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)13 PingMeFault (org.apache.cxf.greeter_control.PingMeFault)9 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)8 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)8 MessageFlow (org.apache.cxf.systest.ws.util.MessageFlow)3 InMessageRecorder (org.apache.cxf.testutil.recorders.InMessageRecorder)3 OutMessageRecorder (org.apache.cxf.testutil.recorders.OutMessageRecorder)3 URL (java.net.URL)2 Endpoint (javax.xml.ws.Endpoint)2 WebServiceException (javax.xml.ws.WebServiceException)2 SocketTimeoutException (java.net.SocketTimeoutException)1 Executor (java.util.concurrent.Executor)1 Bus (org.apache.cxf.Bus)1 SoapFault (org.apache.cxf.binding.soap.SoapFault)1 GreetMeResponse (org.apache.cxf.greeter_control.types.GreetMeResponse)1 MessageRecorder (org.apache.cxf.testutil.recorders.MessageRecorder)1