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();
}
Aggregations