Search in sources :

Example 1 with StartUpController

use of org.apache.synapse.startup.quartz.StartUpController in project wso2-synapse by wso2.

the class SynapseObserverTest method testSimpleObserver.

public void testSimpleObserver() {
    SynapseConfiguration synapseConfig = new SynapseConfiguration();
    synapseConfig.setAxisConfiguration(new AxisConfiguration());
    synapseConfig.registerObserver(observer);
    Endpoint epr = new AddressEndpoint();
    epr.setName("endpoint1");
    synapseConfig.addEndpoint(epr.getName(), epr);
    assertItemAdded(epr.getName(), ENDPOINT);
    synapseConfig.removeEndpoint(epr.getName());
    assertItemRemoved(epr.getName(), ENDPOINT);
    SequenceMediator seq = new SequenceMediator();
    seq.setName("sequence1");
    synapseConfig.addSequence(seq.getName(), seq);
    assertItemAdded(seq.getName(), SEQUENCE);
    synapseConfig.removeSequence(seq.getName());
    assertItemRemoved(seq.getName(), SEQUENCE);
    TemplateMediator template = new TemplateMediator();
    template.setName("template1");
    synapseConfig.addSequenceTemplate(template.getName(), template);
    assertItemAdded(template.getName(), SEQUENCE_TEMPLATE);
    synapseConfig.removeSequenceTemplate(template.getName());
    assertItemRemoved(template.getName(), SEQUENCE_TEMPLATE);
    Entry entry = new Entry();
    entry.setKey("entry1");
    synapseConfig.addEntry(entry.getKey(), entry);
    assertItemAdded(entry.getKey(), ENTRY);
    synapseConfig.removeEntry(entry.getKey());
    assertItemRemoved(entry.getKey(), ENTRY);
    ProxyService proxy = new ProxyService("proxy1");
    synapseConfig.addProxyService(proxy.getName(), proxy);
    assertItemAdded(proxy.getName(), PROXY);
    synapseConfig.removeProxyService(proxy.getName());
    assertItemRemoved(proxy.getName(), PROXY);
    Startup startup = new StartUpController();
    startup.setName("startup1");
    synapseConfig.addStartup(startup);
    assertItemAdded(startup.getName(), STARTUP);
    synapseConfig.removeStartup(startup.getName());
    assertItemRemoved(startup.getName(), STARTUP);
    SynapseEventSource eventSrc = new SynapseEventSource("eventSrc1");
    synapseConfig.addEventSource(eventSrc.getName(), eventSrc);
    assertItemAdded(eventSrc.getName(), EVENT_SRC);
    synapseConfig.removeEventSource(eventSrc.getName());
    assertItemRemoved(eventSrc.getName(), EVENT_SRC);
    PriorityExecutor exec = new PriorityExecutor();
    exec.setName("exec1");
    synapseConfig.addPriorityExecutor(exec.getName(), exec);
    assertItemAdded(exec.getName(), EXECUTOR);
    synapseConfig.removeExecutor(exec.getName());
    assertItemRemoved(exec.getName(), EXECUTOR);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) StartUpController(org.apache.synapse.startup.quartz.StartUpController) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) SynapseEventSource(org.apache.synapse.eventing.SynapseEventSource) ProxyService(org.apache.synapse.core.axis2.ProxyService) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) Startup(org.apache.synapse.Startup)

Example 2 with StartUpController

use of org.apache.synapse.startup.quartz.StartUpController in project wso2-synapse by wso2.

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration8.

/**
 * Test serializeConfigurationMethod with startUp added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration8() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    StartUpController startup = new StartUpController();
    startup.setName("testStartup");
    TaskDescription taskDescription = new TaskDescription();
    taskDescription.setName("testTask");
    startup.setTaskDescription(taskDescription);
    synapseConfiguration.addStartup(startup);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("StartUp added is not serialized.", element.getChildren().next().toString().contains("name=\"testTask\""));
}
Also used : StartUpController(org.apache.synapse.startup.quartz.StartUpController) TaskDescription(org.apache.synapse.task.TaskDescription) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Aggregations

StartUpController (org.apache.synapse.startup.quartz.StartUpController)2 OMElement (org.apache.axiom.om.OMElement)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1 Startup (org.apache.synapse.Startup)1 PriorityExecutor (org.apache.synapse.commons.executors.PriorityExecutor)1 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)1 ProxyService (org.apache.synapse.core.axis2.ProxyService)1 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)1 Endpoint (org.apache.synapse.endpoints.Endpoint)1 SynapseEventSource (org.apache.synapse.eventing.SynapseEventSource)1 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)1 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)1 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)1 TaskDescription (org.apache.synapse.task.TaskDescription)1 Test (org.junit.Test)1