// We shouldn't be able to route on a SOAPAction that is a duplicate.
MessageContext messageContext = new MessageContext();
AxisService as = new AxisService("Service1");
messageContext.setAxisService(as);
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
operation1.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation1");
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
operation2.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");
as.addOperation(operation1);
as.addOperation(operation2);
messageContext.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");
SOAPActionBasedDispatcher soapActionDispatcher = new SOAPActionBasedDispatcher();
soapActionDispatcher.invoke(messageContext);
assertEquals(operation2, messageContext.getAxisOperation());
// Now add a duplicate action, then validate we can't route on it anymore.
AxisOperation operation3 = new InOnlyAxisOperation(new QName("operation3"));
// Note that the SOAPAction is intentionally duplicated with operation 2 above.
operation3.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");
as.addOperation(operation3);
messageContext = new MessageContext();
messageContext.setAxisService(as);
messageContext.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");
soapActionDispatcher.invoke(messageContext);
assertNull(messageContext.getAxisOperation());
// Now verify that adding another operation with the duplicate SOAPAction
// doesn't somehow get it added back into the valid alias map
AxisOperation operation4 = new InOnlyAxisOperation(new QName("operation4"));
// Note that the SOAPAction is intentionally duplicated with operation 2 above.
operation4.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");
as.addOperation(operation4);
messageContext = new MessageContext();
messageContext.setAxisService(as);
messageContext.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");