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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations