use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class DebugManagerTest method testDebugManagerProcessCommandClearSkipProxyOutSequence.
public void testDebugManagerProcessCommandClearSkipProxyOutSequence() throws Exception {
ProxyService ps = new ProxyService("test_proxy_8");
TestMediator in1 = new TestMediator();
TestMediator in2 = new TestMediator();
TestMediator in3 = new TestMediator();
SequenceMediator inSeq = new SequenceMediator();
inSeq.addChild(in1);
inSeq.addChild(in2);
inSeq.addChild(in3);
TestMediator out1 = new TestMediator();
TestMediator out2 = new TestMediator();
TestMediator out3 = new TestMediator();
SequenceMediator outSeq = new SequenceMediator();
outSeq.addChild(out1);
outSeq.addChild(out2);
outSeq.addChild(out3);
ps.setTargetInLineInSequence(inSeq);
ps.setTargetInLineOutSequence(inSeq);
synConfig.addProxyService(ps.getName(), ps);
String debug_command = "{\"command\":\"set\",\"command-argument\":\"skip\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_8\",\"sequence-type\":\"proxy_outseq\"," + "\"mediator-position\":\"0\"}}}";
dm.processDebugCommand(debug_command);
debug_command = "{\"command\":\"clear\",\"command-argument\":\"skip\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_8\",\"sequence-type\":\"proxy_outseq\"," + "\"mediator-position\":\"0\"}}}";
dm.processDebugCommand(debug_command);
assertTrue(!((AbstractMediator) ps.getTargetInLineOutSequence().getChild(0)).isSkipEnabled());
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class DebugManagerTest method testDebugManagerProcessCommandSetSkipProxyInSequence.
public void testDebugManagerProcessCommandSetSkipProxyInSequence() throws Exception {
ProxyService ps = new ProxyService("test_proxy_5");
TestMediator in1 = new TestMediator();
TestMediator in2 = new TestMediator();
TestMediator in3 = new TestMediator();
SequenceMediator inSeq = new SequenceMediator();
inSeq.addChild(in1);
inSeq.addChild(in2);
inSeq.addChild(in3);
TestMediator out1 = new TestMediator();
TestMediator out2 = new TestMediator();
TestMediator out3 = new TestMediator();
SequenceMediator outSeq = new SequenceMediator();
outSeq.addChild(out1);
outSeq.addChild(out2);
outSeq.addChild(out3);
ps.setTargetInLineInSequence(inSeq);
ps.setTargetInLineOutSequence(inSeq);
synConfig.addProxyService(ps.getName(), ps);
String debug_command = "{\"command\":\"set\",\"command-argument\":\"skip\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_5\",\"sequence-type\":\"proxy_inseq\"," + "\"mediator-position\":\"0\"}}}";
dm.processDebugCommand(debug_command);
assertTrue(((AbstractMediator) ps.getTargetInLineInSequence().getChild(0)).isSkipEnabled());
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class ForEachMediatorTest method setUp.
protected void setUp() throws Exception {
super.setUp();
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration config = new AxisConfiguration();
testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg));
((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config));
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
testCtx.setEnvelope(envelope);
testCtx.setSoapAction("urn:test");
SequenceMediator seqMed = new SequenceMediator();
helperMediator = new ForEachHelperMediator();
helperMediator.init(testCtx.getEnvironment());
seqMed.addChild(helperMediator);
SequenceMediator seqMedInvalid = new SequenceMediator();
SendMediator sendMediator = new SendMediator();
sendMediator.init(testCtx.getEnvironment());
seqMedInvalid.addChild(sendMediator);
testCtx.getConfiguration().addSequence("seqRef", seqMed);
testCtx.getConfiguration().addSequence("seqRefInvalid", seqMedInvalid);
testCtx.getConfiguration().addSequence("main", new SequenceMediator());
testCtx.getConfiguration().addSequence("fault", new SequenceMediator());
testCtx.setEnvelope(envelope);
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class AbstractSplitMediatorTestCase method setUp.
protected void setUp() throws Exception {
super.setUp();
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration config = new AxisConfiguration();
testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg));
((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config));
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
envelope.getBody().addChild(createOMElement("<original>test-split-context</original>"));
testCtx.setEnvelope(envelope);
testCtx.setSoapAction("urn:test");
SequenceMediator seqMed = new SequenceMediator();
helperMediator = new SplitTestHelperMediator();
helperMediator.init(testCtx.getEnvironment());
seqMed.addChild(helperMediator);
testCtx.getConfiguration().addSequence("seqRef", seqMed);
testCtx.getConfiguration().addSequence("main", new SequenceMediator());
testCtx.getConfiguration().addSequence("fault", new SequenceMediator());
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class FilterMediatorTest method testFilterConditionWithThenElseKey.
public void testFilterConditionWithThenElseKey() throws Exception {
setFilterConditionPassed(false);
// create a new filter mediator
FilterMediator filter = new FilterMediator();
// set source xpath condition to //symbol
SynapseXPath source = new SynapseXPath("//wsx:symbol");
source.addNamespace("wsx", "http://www.webserviceX.NET/");
filter.setSource(source);
// set regex to MSFT
Pattern regex = Pattern.compile("MSFT");
filter.setRegex(regex);
MessageContext msgCtx = TestUtils.getTestContext(REQ);
SequenceMediator seq = new SequenceMediator();
seq.setName("refSeq");
seq.addChild(testMediator);
msgCtx.getConfiguration().addSequence("refSeq", testMediator);
filter.setElseKey("refSeq");
// test validate mediator, with static enveope
filter.mediate(msgCtx);
assertTrue(filterConditionPassed);
}
Aggregations