use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration2.
/**
* Test serializeConfigurationMethod with registry set for SynapseConfiguration and assert OMElement returned
*/
@Test
public void testSerializeConfiguration2() {
SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
Map<String, OMNode> data = new HashMap<>();
data.put(KEY_DYNAMIC_ENDPOINT_1, TestUtils.createOMElement(DYNAMIC_ENDPOINT_1));
data.put(KEY_DYNAMIC_SEQUENCE_1, TestUtils.createOMElement(DYNAMIC_SEQUENCE_1));
Registry registry = new SimpleInMemoryRegistry(data, 8000L);
synapseConfiguration.setRegistry(registry);
OMElement element = serializer.serializeConfiguration(synapseConfiguration);
Assert.assertNotNull("OMElement is not returned", element);
Assert.assertEquals("definitions", element.getLocalName());
Assert.assertTrue("Registry added is not serialized.", element.getChildren().next().toString().contains("registry"));
}
use of org.apache.synapse.config.SynapseConfiguration 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);
}
use of org.apache.synapse.config.SynapseConfiguration 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);
}
use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class ThrottleMediatorTest method testMediate.
public void testMediate() throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(POLICY.getBytes());
StAXOMBuilder builde = new StAXOMBuilder(in);
ThrottleTestMediator throttleMediator = new ThrottleTestMediator();
throttleMediator.setPolicyKey("throttlepolicy");
MessageContext synCtx = createLightweightSynapseMessageContext("<empty/>");
synCtx.setProperty(REMOTE_ADDR, "192.168.8.212");
SynapseConfiguration synCfg = new SynapseConfiguration();
Entry prop = new Entry();
prop.setKey("throttlepolicy");
prop.setType(Entry.INLINE_XML);
prop.setValue(builde.getDocumentElement());
synCfg.addEntry("throttlepolicy", prop);
synCtx.setConfiguration(synCfg);
for (int i = 0; i < 6; i++) {
try {
throttleMediator.mediate(synCtx);
Thread.sleep(1000);
} catch (Exception e) {
if (i == 3) {
assertTrue(e.getMessage().lastIndexOf("IP_BASE") > 0);
}
if (i == 4) {
assertTrue(e.getMessage().lastIndexOf("IP_BASE") > 0);
}
if (i == 5) {
assertTrue(e.getMessage().lastIndexOf("IP_BASE") > 0);
}
}
}
}
use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class HessianMessageBuilderTest method testProcessDocumentWithSynEnv.
public void testProcessDocumentWithSynEnv() throws IOException {
SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), new SynapseConfiguration());
testProcessDocument(synEnv);
}
Aggregations