use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class DecoupledClientServerTest method testDecoupled.
@Test
public void testDecoupled() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus("/org/apache/cxf/systest/ws/rm/decoupled.xml");
BusFactory.setDefaultBus(bus);
LoggingInInterceptor in = new LoggingInInterceptor();
bus.getInInterceptors().add(in);
bus.getInFaultInterceptors().add(in);
LoggingOutInterceptor out = new LoggingOutInterceptor();
bus.getOutInterceptors().add(out);
bus.getOutFaultInterceptors().add(out);
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, true);
class TwowayThread extends Thread {
String response;
@Override
public void run() {
response = greeter.greetMe("twoway");
}
}
TwowayThread t = new TwowayThread();
t.start();
// allow for partial response to twoway request to arrive
long wait = 3000;
while (wait > 0) {
long start = System.currentTimeMillis();
try {
Thread.sleep(wait);
} catch (InterruptedException ex) {
// ignore
}
wait -= System.currentTimeMillis() - start;
}
greeter.greetMeOneWay("oneway");
t.join();
assertEquals("Unexpected response to twoway request", "oneway", t.response);
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class ManagedEndpointsTest method testSuspendAndResumeSourceSequence.
@Test
public void testSuspendAndResumeSourceSequence() throws Exception {
prepareClient();
RMManager clientManager = clientBus.getExtension(RMManager.class);
InstrumentationManager serverIM = serverBus.getExtension(InstrumentationManager.class);
MBeanServer mbs = serverIM.getMBeanServer();
assertNotNull("MBeanServer must be available.", mbs);
Object o;
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, ManagedEndpointsTest.PORT);
LOG.fine("Created greeter client.");
org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(greeter).getEndpoint();
ObjectName clientEndpointName = RMUtils.getManagedObjectName(clientManager, ep);
// sent
greeter.greetMeOneWay("one");
o = mbs.invoke(clientEndpointName, "getCurrentSourceSequenceId", null, null);
assertTrue(o instanceof String);
String sseqId = (String) o;
o = mbs.invoke(clientEndpointName, "getUnAcknowledgedMessageIdentifiers", new Object[] { sseqId }, ONESTRING_SIGNATURE);
assertTrue("No unacknowledged message", o instanceof Long[] && 0 == ((Long[]) o).length);
// sent but suspended
greeter.greetMeOneWay("two");
// sent but suspended
greeter.greetMeOneWay("three");
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
assertTrue("One queued message", o instanceof Integer && 1 == ((Integer) o).intValue());
mbs.invoke(clientEndpointName, "suspendSourceQueue", new Object[] { sseqId }, ONESTRING_SIGNATURE);
LOG.info("suspended the source queue: " + sseqId);
// 3 sec retry interval + 1 sec
LOG.info("waiting for 4 secs for the retry (suspended)...");
Thread.sleep(4000);
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
assertTrue("One queued message", o instanceof Integer && 1 == ((Integer) o).intValue());
mbs.invoke(clientEndpointName, "resumeSourceQueue", new Object[] { sseqId }, ONESTRING_SIGNATURE);
LOG.info("resumed the source queue: " + sseqId);
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
int count = 0;
assertTrue(o instanceof Integer);
while (((Integer) o).intValue() > 0) {
Thread.sleep(200);
count++;
if (count > 100) {
// up to 20 seconds to do the resend, should be within 3 or 4
fail("Failed to empty the resend queue");
}
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
assertTrue(o instanceof Integer);
}
assertTrue("No queued messages", o instanceof Integer && 0 == ((Integer) o).intValue());
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class MessageCallbackOnewayTest method initProxy.
private void initProxy(Executor executor) {
GreeterService gs = new GreeterService();
if (null != executor) {
gs.setExecutor(executor);
}
greeter = gs.getGreeterPort();
try {
updateAddressPort(greeter, PORT);
} catch (Exception e) {
// ignore
}
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, false);
callback = new RecordingMessageCallback();
((BindingProvider) greeter).getRequestContext().put(RMMessageConstants.RM_CLIENT_CALLBACK, callback);
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class RetransmissionGZIPTest method testDecoupleFaultHandling.
@Test
public void testDecoupleFaultHandling() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus("/org/apache/cxf/systest/ws/rm/gzip-enabled.xml");
BusFactory.setDefaultBus(bus);
LoggingInInterceptor in = new LoggingInInterceptor();
bus.getInInterceptors().add(in);
bus.getInFaultInterceptors().add(in);
LoggingOutInterceptor out = new LoggingOutInterceptor();
bus.getOutInterceptors().add(out);
bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(4000));
// an interceptor to simulate a transmission error
MessageLossSimulator loser = new MessageLossSimulator();
bus.getOutInterceptors().add(loser);
bus.getOutFaultInterceptors().add(out);
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, true);
loser.setMode(-1);
loser.setThrowsException(true);
try {
greeter.greetMeOneWay("oneway");
} catch (Exception e) {
fail("fault thrown after queued for retransmission");
}
Thread.sleep(2000);
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertFalse("RetransmissionQueue is empty", empty);
loser.setMode(1);
Thread.sleep(6000);
empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue not cleared", empty);
}
use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.
the class RetransmissionQueueTest method testOnewayFaultHandlingWithoutRetry.
@Test
public void testOnewayFaultHandlingWithoutRetry() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml");
BusFactory.setDefaultBus(bus);
LoggingInInterceptor in = new LoggingInInterceptor();
bus.getInInterceptors().add(in);
bus.getInFaultInterceptors().add(in);
LoggingOutInterceptor out = new LoggingOutInterceptor();
bus.getOutInterceptors().add(out);
bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(4000));
SourcePolicyType sourcePolicy = new SourcePolicyType();
RetryPolicyType retryP = new RetryPolicyType();
retryP.setMaxRetries(0);
sourcePolicy.setRetryPolicy(retryP);
bus.getExtension(RMManager.class).setSourcePolicy(sourcePolicy);
// an interceptor to simulate a transmission error
MessageLossSimulator loser = new MessageLossSimulator();
bus.getOutInterceptors().add(loser);
bus.getOutFaultInterceptors().add(out);
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, true);
loser.setMode(-1);
loser.setThrowsException(true);
try {
greeter.greetMeOneWay("oneway");
fail("no retransmission so catch an Exception");
} catch (Exception e) {
assertEquals("simulated transmission exception", e.getMessage());
}
Thread.sleep(6000);
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertFalse("RetransmissionQueue is empty", empty);
}
Aggregations