Search in sources :

Example 1 with MinimalAlternativeSelector

use of org.apache.cxf.ws.policy.selector.MinimalAlternativeSelector 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)

Aggregations

Closeable (java.io.Closeable)1 Endpoint (javax.xml.ws.Endpoint)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 BasicGreeterService (org.apache.cxf.greeter_control.BasicGreeterService)1 Greeter (org.apache.cxf.greeter_control.Greeter)1 PingMeFault (org.apache.cxf.greeter_control.PingMeFault)1 MessageFlow (org.apache.cxf.systest.ws.util.MessageFlow)1 InMessageRecorder (org.apache.cxf.testutil.recorders.InMessageRecorder)1 OutMessageRecorder (org.apache.cxf.testutil.recorders.OutMessageRecorder)1 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)1 MinimalAlternativeSelector (org.apache.cxf.ws.policy.selector.MinimalAlternativeSelector)1 Test (org.junit.Test)1