use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class AbstractClientPersistenceTest method verifyStorePopulation.
void verifyStorePopulation() {
RMManager manager = bus.getExtension(RMManager.class);
assertNotNull(manager);
RMStore store = manager.getStore();
assertNotNull(store);
Client client = ClientProxy.getClient(greeter);
String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
Collection<DestinationSequence> dss = store.getDestinationSequences(id);
assertEquals(1, dss.size());
Collection<SourceSequence> sss = store.getSourceSequences(id);
assertEquals(1, sss.size());
Collection<RMMessage> msgs = store.getMessages(sss.iterator().next().getIdentifier(), true);
assertEquals(2, msgs.size());
msgs = store.getMessages(sss.iterator().next().getIdentifier(), false);
assertEquals(0, msgs.size());
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class CachedOutMessageTest method testCachedOutMessage.
@Test
public void testCachedOutMessage() 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);
// an interceptor to simulate a message loss
MessageLossSimulator mls = new MessageLossSimulator();
bus.getOutInterceptors().add(mls);
RMManager manager = bus.getExtension(RMManager.class);
manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
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);
greeter.greetMeOneWay("one");
greeter.greetMeOneWay("two");
greeter.greetMeOneWay("three");
long wait = 4000;
while (wait > 0) {
long start = System.currentTimeMillis();
try {
Thread.sleep(wait);
} catch (InterruptedException ex) {
// ignore
}
wait -= System.currentTimeMillis() - start;
}
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("Some messages are not acknowledged", empty);
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class DeliveryAssuranceOnewayTest method testOnewayAtMostOnce.
private void testOnewayAtMostOnce(Executor executor) throws Exception {
init("org/apache/cxf/systest/ws/rm/atmostonce.xml", executor);
greeterBus.getOutInterceptors().add(new MessageLossSimulator());
RMManager manager = greeterBus.getExtension(RMManager.class);
manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
String[] callArgs = new String[] { "one", "two", "three", "four" };
for (int i = 0; i < callArgs.length; i++) {
greeter.greetMeOneWay(callArgs[i]);
}
awaitMessages(callArgs.length, 1000, 60000);
List<String> actualArgs = GreeterProvider.CALL_ARGS;
assertTrue("Too many messages", callArgs.length >= actualArgs.size());
for (int i = 0; i < actualArgs.size() - 1; i++) {
for (int j = i + 1; j < actualArgs.size(); j++) {
if (actualArgs.get(j).equals(actualArgs.get(i))) {
fail("Message received more than once " + callArgs[i]);
}
}
}
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class DeliveryAssuranceOnewayTest method testOnewayAtLeastOnce.
private void testOnewayAtLeastOnce(Executor executor) throws Exception {
init("org/apache/cxf/systest/ws/rm/atleastonce.xml", executor);
greeterBus.getOutInterceptors().add(new MessageLossSimulator());
RMManager manager = greeterBus.getExtension(RMManager.class);
manager.getConfiguration().setBaseRetransmissionInterval(new Long(1000));
String[] callArgs = new String[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
for (int i = 0; i < callArgs.length; i++) {
greeter.greetMeOneWay(callArgs[i]);
}
awaitMessages(callArgs.length, 1, 3000);
List<String> actualArgs = GreeterProvider.CALL_ARGS;
int checkCount = 0;
for (int i = 0; i < callArgs.length; i++) {
boolean match = false;
for (int j = 0; j < actualArgs.size(); j++) {
if (actualArgs.get(j).equals(callArgs[i])) {
match = true;
break;
}
}
if (!match) {
if (checkCount > 20) {
fail("No match for request " + callArgs[i]);
}
checkCount++;
awaitMessages(callArgs.length, 1, 250);
i--;
}
}
assertTrue("Too few messages " + actualArgs.size(), callArgs.length <= actualArgs.size());
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class DeliveryAssuranceOnewayTest method testOnewayInOrder.
private void testOnewayInOrder(Executor executor) throws Exception {
init("org/apache/cxf/systest/ws/rm/inorder.xml", executor);
greeterBus.getOutInterceptors().add(new MessageLossSimulator());
RMManager manager = greeterBus.getExtension(RMManager.class);
manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
String[] callArgs = new String[] { "one", "two", "three", "four" };
for (int i = 0; i < callArgs.length; i++) {
greeter.greetMeOneWay(callArgs[i]);
}
awaitMessages(callArgs.length - 2, 1000, 60000);
List<String> actualArgs = GreeterProvider.CALL_ARGS;
int argNum = 0;
for (String actual : actualArgs) {
while (argNum < callArgs.length && !actual.equals(callArgs[argNum])) {
argNum++;
}
assertTrue("Message out of order", argNum < callArgs.length);
}
}
Aggregations