use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class ClientServerGreeterBaseNoWsdlTest method testInvocation.
@Test
public void testInvocation() throws Exception {
GreeterService service = new GreeterService();
assertNotNull(service);
try {
Greeter greeter = service.getGreeterPort();
updateAddressPort(greeter, PORT);
String greeting = greeter.greetMe("Bonjour");
assertNotNull("no response received from service", greeting);
assertEquals("Hello Bonjour", greeting);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class ClientServerGreeterNoWsdlTest method testInvocation.
@Test
public void testInvocation() throws Exception {
GreeterService service = new GreeterService();
assertNotNull(service);
try {
Greeter greeter = service.getGreeterPort();
updateAddressPort(greeter, PORT);
String greeting = greeter.greetMe("Bonjour");
assertNotNull("no response received from service", greeting);
assertEquals("Hello Bonjour", greeting);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class InterceptorFaultTest method setupGreeter.
private void setupGreeter(String cfgResource, boolean useDecoupledEndpoint) throws NumberFormatException, MalformedURLException {
SpringBusFactory bf = new SpringBusFactory();
controlBus = bf.createBus();
BusFactory.setDefaultBus(controlBus);
ControlService cs = new ControlService();
control = cs.getControlPort();
updateAddressPort(control, PORT);
assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
greeterBus = bf.createBus(cfgResource);
BusFactory.setDefaultBus(greeterBus);
LOG.fine("Initialised greeter bus with configuration: " + cfgResource);
if (null == comparator) {
comparator = new PhaseComparator();
}
if (null == inPhases) {
inPhases = new ArrayList<>();
inPhases.addAll(greeterBus.getExtension(PhaseManager.class).getInPhases());
Collections.sort(inPhases, comparator);
}
if (null == postUnMarshalPhase) {
postUnMarshalPhase = getPhase(Phase.POST_UNMARSHAL);
}
GreeterService gs = new GreeterService();
greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
if (!useDecoupledEndpoint) {
return;
}
// programatically configure decoupled endpoint that is guaranteed to
// be unique across all test cases
decoupledEndpointPort++;
decoupledEndpoint = "http://localhost:" + allocatePort("decoupled-" + decoupledEndpointPort) + "/decoupled_endpoint";
Client c = ClientProxy.getClient(greeter);
HTTPConduit hc = (HTTPConduit) (c.getConduit());
HTTPClientPolicy cp = hc.getClient();
cp.setDecoupledEndpoint(decoupledEndpoint);
LOG.fine("Using decoupled endpoint: " + cp.getDecoupledEndpoint());
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class AbstractClientPersistenceTest method startClient.
void startClient() throws Exception {
LOG.fine("Creating greeter client");
System.setProperty("db.name", getPrefix() + "-client");
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus("/org/apache/cxf/systest/ws/rm/persistent.xml");
BusFactory.setDefaultBus(bus);
System.clearProperty("db.name");
GreeterService gs = new GreeterService();
greeter = gs.getGreeterPort();
updateAddressPort(greeter, getPort());
((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
out = new OutMessageRecorder();
in = new InMessageRecorder();
bus.getOutInterceptors().add(out);
bus.getInInterceptors().add(in);
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class AbstractServerPersistenceTest method testRecovery.
@Test
public void testRecovery() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus();
BusFactory.setDefaultBus(bus);
LOG.fine("Created bus " + bus + " with default cfg");
ControlService cs = new ControlService();
Control control = cs.getControlPort();
ConnectionHelper.setKeepAliveConnection(control, false, true);
updateAddressPort(control, getPort());
assertTrue("Failed to start greeter", control.startGreeter(SERVER_LOSS_CFG));
LOG.fine("Started greeter server.");
System.setProperty("db.name", getPrefix() + "-recovery");
greeterBus = new SpringBusFactory().createBus(CFG);
System.clearProperty("db.name");
LOG.fine("Created bus " + greeterBus + " with cfg : " + CFG);
BusFactory.setDefaultBus(greeterBus);
// avoid early client resends
greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, getPort());
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, false, true);
Client c = ClientProxy.getClient(greeter);
HTTPConduit hc = (HTTPConduit) (c.getConduit());
HTTPClientPolicy cp = hc.getClient();
cp.setDecoupledEndpoint("http://localhost:" + getDecoupledPort() + "/decoupled_endpoint");
out = new OutMessageRecorder();
in = new InMessageRecorder();
greeterBus.getOutInterceptors().add(out);
greeterBus.getInInterceptors().add(in);
LOG.fine("Configured greeter client.");
Response<GreetMeResponse>[] responses = cast(new Response[4]);
responses[0] = greeter.greetMeAsync("one");
responses[1] = greeter.greetMeAsync("two");
responses[2] = greeter.greetMeAsync("three");
verifyMissingResponse(responses);
control.stopGreeter(SERVER_LOSS_CFG);
LOG.fine("Stopped greeter server");
out.getOutboundMessages().clear();
in.getInboundMessages().clear();
control.startGreeter(CFG);
String nl = System.getProperty("line.separator");
LOG.fine("Restarted greeter server" + nl + nl);
verifyServerRecovery(responses);
responses[3] = greeter.greetMeAsync("four");
verifyRetransmissionQueue();
verifyAcknowledgementRange(1, 4);
out.getOutboundMessages().clear();
in.getInboundMessages().clear();
greeterBus.shutdown(true);
control.stopGreeter(CFG);
bus.shutdown(true);
}
Aggregations