use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class WSRM12ServerCycleTest method runTest.
public void runTest(String cfg, boolean faultOnRestart) throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus();
BusFactory.setDefaultBus(bus);
ControlService cs = new ControlService();
Control control = cs.getControlPort();
ConnectionHelper.setKeepAliveConnection(control, false, true);
updateAddressPort(control, PORT);
Assert.assertTrue("Failed to start greeter", control.startGreeter(cfg));
System.setProperty("db.name", getPrefix() + "-recovery");
Bus greeterBus = new SpringBusFactory().createBus();
System.clearProperty("db.name");
BusFactory.setDefaultBus(greeterBus);
// avoid early client resends
greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterPort(new LoggingFeature(), new AddressingFeature(), wsrm());
updateAddressPort(greeter, PORT);
greeter.greetMe("one");
greeter.greetMe("two");
greeter.greetMe("three");
control.stopGreeter(cfg);
// make sure greeter is down
Thread.sleep(1000);
control.startGreeter(cfg);
// CXF-7392
if (faultOnRestart) {
try {
greeter.greetMe("four");
} catch (SOAPFaultException ex) {
assertTrue(ex.getMessage().contains("wsrm:Identifier"));
// expected, sequence identifier doesn't exist on other side
}
} else {
// this should work as the sequence should be recovered on the server side
greeter.greetMe("four");
}
((Closeable) greeter).close();
greeterBus.shutdown(true);
control.stopGreeter(cfg);
bus.shutdown(true);
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class ClientServerSessionTest method doSessionsTest.
private void doSessionsTest(String url) {
GreeterService service = new GreeterService();
assertNotNull(service);
Greeter greeter = service.getGreeterPort();
Greeter greeter2 = service.getGreeterPort();
BindingProvider bp = (BindingProvider) greeter;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
bp = (BindingProvider) greeter2;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
String result = greeter.greetMe("World");
assertEquals("Hello World", result);
assertEquals("Bonjour World", greeter.sayHi());
result = greeter2.greetMe("Universe");
assertEquals("Hello Universe", result);
assertEquals("Bonjour Universe", greeter2.sayHi());
// make sure session 1 was maintained
assertEquals("Bonjour World", greeter.sayHi());
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class ClientServerSessionTest method testInvocationWithSpringBeanAnnotation.
@Test
public void testInvocationWithSpringBeanAnnotation() throws Exception {
GreeterService service = new GreeterService();
assertNotNull(service);
Greeter greeter = service.getGreeterPort();
BindingProvider bp = (BindingProvider) greeter;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/SpringBean");
bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
String result = greeter.greetMe("World");
assertEquals("Hello World", result);
assertEquals("Bonjour World", greeter.sayHi());
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class ClientServerSessionTest method testInvocationWithoutSession.
@Test
public void testInvocationWithoutSession() 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);
greeting = greeter.greetMe("Hello");
assertNotNull("no response received from service", greeting);
assertEquals("Hello Hello", greeting);
greeting = greeter.greetMe("NiHao");
assertNotNull("no response received from service", greeting);
assertEquals("Hello NiHao", greeting);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class StaxTransformFeatureTest method testTransformWithLogging.
@Test
public void testTransformWithLogging() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
Bus bus = bf.createBus();
BusFactory.setDefaultBus(bus);
TestLoggingEventSender logIn = new TestLoggingEventSender();
bus.getInInterceptors().add(new LoggingInInterceptor(logIn));
bus.getInFaultInterceptors().add(new LoggingInInterceptor(logIn));
TestLoggingEventSender logOut = new TestLoggingEventSender();
bus.getOutInterceptors().add(new LoggingOutInterceptor(logOut));
bus.getOutFaultInterceptors().add(new LoggingOutInterceptor(logOut));
TransformInInterceptor transIn = new TransformInInterceptor();
Map<String, String> inElements = new HashMap<>();
inElements.put("{http://cxf.apache.org/greeter_control/types}noFaultDetail", "{http://cxf.apache.org/greeter_control/types}faultDetail");
bus.getInInterceptors().add(transIn);
TransformOutInterceptor transOut = new TransformOutInterceptor();
Map<String, String> outElements = new HashMap<>();
outElements.put("{http://cxf.apache.org/greeter_control/types}pingMe", "{http://cxf.apache.org/greeter_control/types}dontPingMe");
transOut.setOutTransformElements(outElements);
bus.getOutInterceptors().add(transOut);
bus.getOutFaultInterceptors().add(transOut);
GreeterService gs = new GreeterService();
greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
// ping 1: request-response transformation
greeter.pingMe();
verifyPayload(logOut.getMessage(), "dontPingMe");
verifyPayload(logIn.getMessage(), "pingMeResponse");
verifyPayload(serverlogIn.getMessage(), "dontPingMe");
verifyPayload(serverlogOut.getMessage(), "pingMeResponse");
serverlogOut.cleaerMessage();
serverlogIn.cleaerMessage();
logOut.cleaerMessage();
logIn.cleaerMessage();
// ping 2: request-fault transformation
try {
greeter.pingMe();
fail("Ping should have failed");
} catch (Exception e) {
assertEquals("Pings succeed only every other time.", e.getMessage());
}
verifyPayload(logOut.getMessage(), "dontPingMe");
verifyPayload(logIn.getMessage(), "noFaultDetail");
verifyPayload(serverlogIn.getMessage(), "dontPingMe");
verifyPayload(serverlogOut.getMessage(), "noFaultDetail");
// ping 3: idle
greeter.pingMe();
serverlogOut.cleaerMessage();
serverlogIn.cleaerMessage();
logOut.cleaerMessage();
logIn.cleaerMessage();
// ping 4: request-fault transformation with skipOnFault
transOut.setSkipOnFault(true);
servertransOut.setSkipOnFault(true);
try {
greeter.pingMe();
fail("Ping should have failed");
} catch (Exception e) {
assertEquals("Pings succeed only every other time.", e.getMessage());
}
verifyPayload(logOut.getMessage(), "dontPingMe");
verifyPayload(logIn.getMessage(), "faultDetail");
verifyPayload(serverlogIn.getMessage(), "dontPingMe");
verifyPayload(serverlogOut.getMessage(), "faultDetail");
bus.shutdown(true);
}
Aggregations