Search in sources :

Example 1 with SimpleInMemoryRegistry

use of org.apache.synapse.registry.SimpleInMemoryRegistry 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"));
}
Also used : OMNode(org.apache.axiom.om.OMNode) HashMap(java.util.HashMap) SimpleInMemoryRegistry(org.apache.synapse.registry.SimpleInMemoryRegistry) OMElement(org.apache.axiom.om.OMElement) Registry(org.apache.synapse.registry.Registry) SimpleInMemoryRegistry(org.apache.synapse.registry.SimpleInMemoryRegistry) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 2 with SimpleInMemoryRegistry

use of org.apache.synapse.registry.SimpleInMemoryRegistry in project wso2-synapse by wso2.

the class MultiXMLConfigurationSerializerTest method testSerialize3.

/**
 * Test serialize method with registry set for SynapseConfiguration and assert synapse.xml is created.
 */
@Test
public void testSerialize3() {
    MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
    SynapseConfiguration configuration = 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);
    configuration.setRegistry(registry);
    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 : OMNode(org.apache.axiom.om.OMNode) HashMap(java.util.HashMap) SimpleInMemoryRegistry(org.apache.synapse.registry.SimpleInMemoryRegistry) Registry(org.apache.synapse.registry.Registry) SimpleInMemoryRegistry(org.apache.synapse.registry.SimpleInMemoryRegistry) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 OMNode (org.apache.axiom.om.OMNode)2 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)2 Registry (org.apache.synapse.registry.Registry)2 SimpleInMemoryRegistry (org.apache.synapse.registry.SimpleInMemoryRegistry)2 Test (org.junit.Test)2 File (java.io.File)1 OMElement (org.apache.axiom.om.OMElement)1