use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class SequenceTest method testTerminateOnShutdown.
@Test
public void testTerminateOnShutdown() throws Exception {
init("org/apache/cxf/systest/ws/rm/terminate-on-shutdown.xml", true);
RMManager manager = greeterBus.getExtension(RMManager.class);
// this test also verify the DB is correctly being updated during the shutdown
RMMemoryStore store = new RMMemoryStore();
manager.setStore(store);
greeter.greetMeOneWay("neutrophil");
greeter.greetMeOneWay("basophil");
greeter.greetMeOneWay("eosinophil");
stopGreeterButNotCloseConduit();
awaitMessages(6, 2);
MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
mf.verifyMessages(6, true);
String[] expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION, RM10Constants.CLOSE_SEQUENCE_ACTION, RM10Constants.TERMINATE_SEQUENCE_ACTION };
mf.verifyActions(expectedActions, true);
mf.verifyMessageNumbers(new String[] { null, "1", "2", "3", "4", null }, true);
// inbound: CreateSequenceResponse, out-of-band SequenceAcknowledgement
// plus 6 partial responses
mf.verifyMessages(2, false);
mf.verifyMessageNumbers(new String[2], false);
expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION };
mf.verifyActions(expectedActions, false);
mf.verifyAcknowledgements(new boolean[] { false, true }, false);
// additional check to verify the operations performed on DB
assertEquals("sequences not released from DB", 0, store.ssmap.size());
assertEquals("messages not released from DB", 0, store.ommap.size());
assertEquals("sequence not closed in DB", 1, store.ssclosed.size());
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class SequenceTest method testCreateSequenceRefused.
@Test
public void testCreateSequenceRefused() throws Exception {
init("org/apache/cxf/systest/ws/rm/limit-seqs.xml");
RMManager manager = greeterBus.getExtension(RMManager.class);
assertEquals("Unexpected maximum sequence count.", 1, manager.getDestinationPolicy().getMaxSequences());
greeter.greetMe("one");
// hold onto the greeter to keep the sequence open
Closeable oldGreeter = (Closeable) greeter;
// force greeter to be re-initialized so that a new sequence is created
initProxy(false, null);
try {
greeter.greetMe("two");
fail("Expected fault.");
} catch (WebServiceException ex) {
// sequence creation refused
}
// the third inbound message has a SequenceFault header
MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
mf.verifySequenceFault(RM10Constants.CREATE_SEQUENCE_REFUSED_FAULT_QNAME, false, 2);
String[] expectedActions = new String[3];
expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, RM10_GENERIC_FAULT_ACTION };
mf.verifyActions(expectedActions, false);
// now close the old greeter to cleanup the sequence
oldGreeter.close();
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class SequenceTest method testTwowayMessageLoss.
private void testTwowayMessageLoss(Executor executor) throws Exception {
init("org/apache/cxf/systest/ws/rm/message-loss.xml", true, executor);
greeterBus.getOutInterceptors().add(new MessageLossSimulator());
RMManager manager = greeterBus.getExtension(RMManager.class);
manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
greeter.greetMe("one");
greeter.greetMe("two");
greeter.greetMe("three");
greeter.greetMe("four");
awaitMessages(7, 5, 10000);
MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
// Expected outbound:
// CreateSequence
// + 4 greetMe messages
// + 2 resends
String[] expectedActions = new String[7];
expectedActions[0] = RM10Constants.CREATE_SEQUENCE_ACTION;
for (int i = 1; i < expectedActions.length; i++) {
expectedActions[i] = GREETME_ACTION;
}
mf.verifyActions(expectedActions, true);
mf.verifyMessageNumbers(new String[] { null, "1", "2", "2", "3", "4", "4" }, true);
mf.verifyLastMessage(new boolean[7], true);
boolean[] expectedAcks = new boolean[7];
for (int i = 2; i < expectedAcks.length; i++) {
expectedAcks[i] = true;
}
mf.verifyAcknowledgements(expectedAcks, true);
// Expected inbound:
// createSequenceResponse
// + 4 greetMeResponse actions (to original or resent)
// + 5 partial responses (to CSR & each of the initial greetMe messages)
// + at least 2 further partial response (for each of the resends)
expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, GREETME_RESPONSE_ACTION };
mf.verifyActions(expectedActions, false);
mf.verifyMessageNumbers(new String[] { null, "1", "2", "3", "4" }, false);
mf.verifyAcknowledgements(new boolean[] { false, true, true, true, true }, false);
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class WSRMWithWSSecurityPolicyTest method testWithSecurityInPolicy.
@Test
public void testWithSecurityInPolicy() throws Exception {
LOG.fine("Creating greeter client");
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/apache/cxf/systest/ws/rm/sec/client-policy.xml")) {
Bus bus = (Bus) context.getBean("bus");
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
Greeter greeter = (Greeter) context.getBean("GreeterCombinedClient");
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue is not empty", empty);
LOG.fine("Invoking greeter");
greeter.greetMeOneWay("one");
Thread.sleep(3000);
empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue not empty", empty);
}
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class WSRMWithWSSecurityPolicyTest method testContextProperty.
@Test
public void testContextProperty() throws Exception {
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/apache/cxf/systest/ws/rm/sec/client-policy.xml")) {
Bus bus = (Bus) context.getBean("bus");
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
Greeter greeter = (Greeter) context.getBean("GreeterCombinedClientNoProperty");
Client client = ClientProxy.getClient(greeter);
QName operationQName = new QName("http://cxf.apache.org/greeter_control", "greetMe");
BindingOperationInfo boi = client.getEndpoint().getBinding().getBindingInfo().getOperation(operationQName);
Map<String, Object> invocationContext = new HashMap<>();
Map<String, Object> requestContext = new HashMap<>();
Map<String, Object> responseContext = new HashMap<>();
invocationContext.put(Client.REQUEST_CONTEXT, requestContext);
invocationContext.put(Client.RESPONSE_CONTEXT, responseContext);
requestContext.put(SecurityConstants.USERNAME, "Alice");
requestContext.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.ws.rm.sec.UTPasswordCallback");
requestContext.put(SecurityConstants.ENCRYPT_PROPERTIES, "bob.properties");
requestContext.put(SecurityConstants.ENCRYPT_USERNAME, "bob");
requestContext.put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
requestContext.put(SecurityConstants.SIGNATURE_USERNAME, "alice");
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue is not empty", empty);
GreetMe param = new GreetMe();
param.setRequestType("testContextProperty");
Object[] answer = client.invoke(boi, new Object[] { param }, invocationContext);
Assert.assertEquals("TESTCONTEXTPROPERTY", answer[0].toString());
Thread.sleep(5000);
empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue not empty", empty);
}
}
Aggregations