use of org.apache.synapse.mediators.eventing.EventPublisherMediator in project wso2-synapse by wso2.
the class EventPublisherMediatorFactory method createSpecificMediator.
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
EventPublisherMediator eventPublisherMediator = new EventPublisherMediator();
processAuditStatus(eventPublisherMediator, elem);
OMAttribute attEventSource = elem.getAttribute(PROP_NAME);
if (attEventSource != null) {
eventPublisherMediator.setEventSourceName(attEventSource.getAttributeValue());
} else {
handleException("The 'eventSourceName' attribute is required for the EventPublisher mediator");
}
addAllCommentChildrenToList(elem, eventPublisherMediator.getCommentsList());
return eventPublisherMediator;
}
use of org.apache.synapse.mediators.eventing.EventPublisherMediator in project wso2-synapse by wso2.
the class EventPublisherMediatorSerializer method serializeSpecificMediator.
public OMElement serializeSpecificMediator(Mediator m) {
if (!(m instanceof EventPublisherMediator)) {
handleException("Unsupported mediator passed in for serialization : " + m.getType());
}
EventPublisherMediator mediator = (EventPublisherMediator) m;
OMElement elmEventPublisher = fac.createOMElement("eventPublisher", synNS);
if (mediator.getEventSourceName() != null) {
elmEventPublisher.addAttribute(fac.createOMAttribute("eventSourceName", nullNS, mediator.getEventSourceName()));
} else {
handleException("Invalid EventPublisher mediator. Event Source Name required");
}
saveTracingState(elmEventPublisher, mediator);
serializeComments(elmEventPublisher, mediator.getCommentsList());
return elmEventPublisher;
}
use of org.apache.synapse.mediators.eventing.EventPublisherMediator in project wso2-synapse by wso2.
the class EventPublisherMediatorSerializerTest method testCreateEventSource1.
/**
* Mediator with no event source name.
*/
@Test(expected = SynapseException.class)
public void testCreateEventSource1() {
EventPublisherMediatorSerializer mediatorSerializer = new EventPublisherMediatorSerializer();
EventPublisherMediator mediator = new EventPublisherMediator();
mediatorSerializer.serializeSpecificMediator(mediator);
}
use of org.apache.synapse.mediators.eventing.EventPublisherMediator in project wso2-synapse by wso2.
the class EventPublisherMediatorSerializerTest method testCreateEventSource2.
/**
* Test serializeSpecificMediator and asserting Name of OMElement.
*/
@Test
public void testCreateEventSource2() {
EventPublisherMediatorSerializer mediatorSerializer = new EventPublisherMediatorSerializer();
EventPublisherMediator mediator = new EventPublisherMediator();
mediator.setEventSourceName("Test");
OMElement element = mediatorSerializer.serializeSpecificMediator(mediator);
Assert.assertEquals("Name should be eventPublisher", "eventPublisher", element.getLocalName());
}
Aggregations