use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class SequenceMediatorFactory method createAnonymousSequence.
public SequenceMediator createAnonymousSequence(OMElement elem, Properties properties) {
SequenceMediator seqMediator = new SequenceMediator();
OMAttribute e = elem.getAttribute(ATT_ONERROR);
if (e != null) {
seqMediator.setErrorHandler(e.getAttributeValue());
}
processAuditStatus(seqMediator, elem);
OMElement descElem = elem.getFirstChildWithName(DESCRIPTION_Q);
if (descElem != null) {
seqMediator.setDescription(descElem.getText());
}
addChildren(elem, seqMediator, properties);
seqMediator.setSequenceType(SequenceType.ANON);
return seqMediator;
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class SequenceMediatorSerializer method serializeSpecificMediator.
public OMElement serializeSpecificMediator(Mediator m) {
if (!(m instanceof SequenceMediator)) {
handleException("Unsupported mediator passed in for serialization : " + m.getType());
}
SequenceMediator mediator = (SequenceMediator) m;
OMElement sequence = fac.createOMElement("sequence", synNS);
// except make sure that we refer back to the registry key used when we loaded ourself
if (mediator.isDynamic()) {
sequence.addAttribute(fac.createOMAttribute("name", nullNS, mediator.getName()));
sequence.addAttribute(fac.createOMAttribute("key", nullNS, mediator.getRegistryKey()));
} else {
if (mediator.getKey() != null) {
// Serialize Value using ValueSerializer
ValueSerializer keySerializer = new ValueSerializer();
keySerializer.serializeValue(mediator.getKey(), XMLConfigConstants.KEY, sequence);
} else if (mediator.getName() != null) {
sequence.addAttribute(fac.createOMAttribute("name", nullNS, mediator.getName()));
if (mediator.getErrorHandler() != null) {
sequence.addAttribute(fac.createOMAttribute("onError", nullNS, mediator.getErrorHandler()));
}
saveTracingState(sequence, mediator);
serializeChildren(sequence, mediator.getList());
}
}
return sequence;
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class StatisticSynapseConfigurationObserverTest method testSequenceAdded.
/**
* Test sequenceAdded method by hash generation.
*/
@Test
public void testSequenceAdded() {
SequenceMediator mediator = new SequenceMediator();
observer.sequenceAdded(mediator);
Assert.assertNotNull("New hash must be set by the method", mediator.getAspectConfiguration().getHashCode());
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class MultiXMLConfigurationBuilderTest method testConfigurationBuilder.
public void testConfigurationBuilder() throws Exception {
URL u = this.getClass().getClassLoader().getResource("synapse-config");
String root = new File(u.toURI()).getAbsolutePath();
System.out.println("Using SYNAPSE_CONFIG_HOME=" + root);
SynapseConfiguration synapseConfig = MultiXMLConfigurationBuilder.getConfiguration(root, new Properties());
assertNotNull(synapseConfig.getDefinedSequences().get("main"));
assertNotNull(synapseConfig.getDefinedSequences().get("fault"));
SequenceMediator foo = synapseConfig.getDefinedSequences().get("foo");
SequenceMediator seq1 = synapseConfig.getDefinedSequences().get("synapse_xml_seq1");
assertNotNull(foo);
assertNotNull(seq1);
assertEquals("foo.xml", foo.getFileName());
assertNull(seq1.getFileName());
assertNull(synapseConfig.getDefinedSequences().get("bar"));
assertNotNull(synapseConfig.getDefinedEndpoints().get("epr1"));
assertNotNull(synapseConfig.getDefinedEndpoints().get("synapse_xml_epr1"));
assertNotNull(synapseConfig.getProxyService("proxy1"));
assertNotNull(synapseConfig.getStartup("task1"));
assertNotNull(synapseConfig.getRegistry());
assertTrue(JavaUtils.isTrueExplicitly(synapseConfig.getProperty(MultiXMLConfigurationBuilder.SEPARATE_REGISTRY_DEFINITION)));
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML4.
/**
* Test serializeSynapseXML method with SequenceMediator added for SynapseConfiguration and
* assert synapse.xml is created.
*/
@Test
public void testSerializeSynapseXML4() throws Exception {
MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
SynapseConfiguration configuration = new SynapseConfiguration();
org.apache.synapse.mediators.TestMediator t1 = new org.apache.synapse.mediators.TestMediator();
org.apache.synapse.mediators.TestMediator t2 = new org.apache.synapse.mediators.TestMediator();
org.apache.synapse.mediators.TestMediator t3 = new org.apache.synapse.mediators.TestMediator();
SequenceMediator seq = new SequenceMediator();
seq.addChild(t1);
seq.addChild(t2);
seq.addChild(t3);
configuration.addSequence("testSequence", seq);
serializer.serializeSynapseXML(configuration);
Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
removeTestFolder(TEST_DIRECTORY_NAME);
}
Aggregations