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