Search in sources :

Example 86 with SynapseConfiguration

use of org.apache.synapse.config.SynapseConfiguration 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);
}
Also used : SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Example 87 with SynapseConfiguration

use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.

the class MultiXMLConfigurationSerializerTest method testSerialize.

/**
 * Test serialize method and assert synapse.xml is created.
 */
@Test
public void testSerialize() {
    MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
    SynapseConfiguration configuration = new SynapseConfiguration();
    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 : SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Example 88 with SynapseConfiguration

use of org.apache.synapse.config.SynapseConfiguration 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)

Example 89 with SynapseConfiguration

use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.

the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML5.

/**
 * Test serializeSynapseXML method with TemplateMediator added for SynapseConfiguration and
 * assert synapse.xml is created.
 */
@Test
public void testSerializeSynapseXML5() 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();
    TemplateMediator templateMediator = new TemplateMediator();
    templateMediator.addChild(t1);
    templateMediator.addChild(t2);
    templateMediator.addChild(t3);
    configuration.addSequence("testSequence", templateMediator);
    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 : TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Example 90 with SynapseConfiguration

use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.

the class MultiXMLConfigurationSerializerTest method testSerialize2.

/**
 * Test serialize method with root directory already existing and assert synapse.xml is created.
 *
 * @throws IOException - IOException in file creation.
 */
@Test
public void testSerialize2() throws IOException {
    File file = new File(TEST_DIRECTORY_NAME);
    File xmlFile = new File(TEST_DIRECTORY_NAME + File.separator + "test.xml");
    if (!file.exists()) {
        file.mkdir();
        if (!xmlFile.exists()) {
            xmlFile.createNewFile();
        }
    }
    Long startTime = System.currentTimeMillis();
    do {
        try {
            Thread.sleep(500);
        } catch (InterruptedException ignored) {
        }
    } while (!xmlFile.exists() && (System.currentTimeMillis() - startTime) < 5000);
    if (xmlFile.exists()) {
        MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
        SynapseConfiguration configuration = new SynapseConfiguration();
        serializer.serialize(configuration);
        Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
    } else {
        Assert.fail("Failed to create XML file.");
    }
    removeTestFolder(TEST_DIRECTORY_NAME);
}
Also used : SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Aggregations

SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)145 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)64 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)59 MessageContext (org.apache.synapse.MessageContext)56 Test (org.junit.Test)56 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)50 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)49 OMElement (org.apache.axiom.om.OMElement)41 Parameter (org.apache.axis2.description.Parameter)29 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)27 TestMessageContext (org.apache.synapse.TestMessageContext)16 Properties (java.util.Properties)15 SynapseException (org.apache.synapse.SynapseException)13 Mediator (org.apache.synapse.Mediator)12 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)11 File (java.io.File)10 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)7 Endpoint (org.apache.synapse.endpoints.Endpoint)7