Search in sources :

Example 1 with QuartzTaskManager

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

the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML2.

/**
 * Test serializeSynapseXML method with taskManager set for SynapseConfiguration and assert synapse.xml is created.
 */
@Test
public void testSerializeSynapseXML2() throws Exception {
    MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
    SynapseConfiguration configuration = new SynapseConfiguration();
    configuration.setTaskManager(new QuartzTaskManager());
    serializer.serializeSynapseXML(configuration);
    Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
    removeTestFolder(TEST_DIRECTORY_NAME);
}
Also used : QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Example 2 with QuartzTaskManager

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

the class TaskManagerFactoryTest method testCreateTaskManager.

/**
 * test createTaskManager
 *
 * @throws XMLStreamException - XMLStreamException.
 */
@Test
public void testCreateTaskManager() throws XMLStreamException {
    String inputXML = "<taskManager provider=\"org.apache.synapse.startup.quartz.QuartzTaskManager\"/>";
    OMElement element = AXIOMUtil.stringToOM(inputXML);
    TaskManager taskManager = TaskManagerFactory.createTaskManager(element, null);
    Assert.assertTrue("TaskManager is not created.", taskManager instanceof QuartzTaskManager);
}
Also used : QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) TaskManager(org.apache.synapse.task.TaskManager) QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) OMElement(org.apache.axiom.om.OMElement) Test(org.junit.Test)

Example 3 with QuartzTaskManager

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

the class MultiXMLConfigurationSerializerTest method testSerialize4.

/**
 * Test serialize method with taskManager set for SynapseConfiguration and assert synapse.xml is created.
 */
@Test
public void testSerialize4() {
    MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
    SynapseConfiguration configuration = new SynapseConfiguration();
    configuration.setTaskManager(new QuartzTaskManager());
    serializer.serialize(configuration);
    Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
    removeTestFolder(TEST_DIRECTORY_NAME);
}
Also used : QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Example 4 with QuartzTaskManager

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

the class TaskManagerSerializerTest method testCase.

/**
 * Test serializetaskManager method by asserting resulting OMElement.
 *
 * @throws XMLStreamException
 */
@Test
public void testCase() throws XMLStreamException {
    String input = "<template xmlns=\"http://ws.apache.org/ns/synapse\" name=\"HelloWordLogger\">\n" + "   <sequence>\n" + "      <log level=\"full\">\n" + "         <property xmlns:ns2=\"http://org.apache.synapse/xsd\" name=\"message\" " + "expression=\"$func:message\"></property>\n" + "      </log>\n" + "   </sequence>\n" + "</template>";
    OMElement element = AXIOMUtil.stringToOM(input);
    TaskManager taskManager = new QuartzTaskManager();
    Properties properties = new Properties();
    properties.setProperty("name", "testName");
    taskManager.setConfigurationProperties(properties);
    OMElement omElement = TaskManagerSerializer.serializetaskManager(element, taskManager);
    Assert.assertEquals("asserting localName inserted by the method", "taskManager", omElement.getLocalName());
    Iterator iter = omElement.getChildElements();
    while (iter.hasNext()) {
        OMElementImpl impl = (OMElementImpl) iter.next();
        Assert.assertEquals("asserting localName inserted by the method", "parameter", impl.getLocalName());
    }
}
Also used : QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) TaskManager(org.apache.synapse.task.TaskManager) OMElementImpl(org.apache.axiom.om.impl.llom.OMElementImpl) Iterator(java.util.Iterator) QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) OMElement(org.apache.axiom.om.OMElement) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with QuartzTaskManager

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

the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML3.

/**
 * Test serializeSynapseXML method with proxyServices added for SynapseConfiguration and
 * assert synapse.xml is created.
 */
@Test
public void testSerializeSynapseXML3() throws Exception {
    MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
    SynapseConfiguration configuration = new SynapseConfiguration();
    configuration.setTaskManager(new QuartzTaskManager());
    ProxyService proxyService = new ProxyService("testProxyService");
    configuration.addProxyService(proxyService.getName(), proxyService);
    serializer.serializeSynapseXML(configuration);
    Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
    removeTestFolder(TEST_DIRECTORY_NAME);
}
Also used : ProxyService(org.apache.synapse.core.axis2.ProxyService) QuartzTaskManager(org.apache.synapse.startup.quartz.QuartzTaskManager) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Aggregations

QuartzTaskManager (org.apache.synapse.startup.quartz.QuartzTaskManager)7 Test (org.junit.Test)7 OMElement (org.apache.axiom.om.OMElement)4 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)4 File (java.io.File)3 TaskManager (org.apache.synapse.task.TaskManager)3 Iterator (java.util.Iterator)1 Properties (java.util.Properties)1 OMElementImpl (org.apache.axiom.om.impl.llom.OMElementImpl)1 ProxyService (org.apache.synapse.core.axis2.ProxyService)1