Search in sources :

Example 91 with SynapseConfiguration

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

the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML.

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

Example 92 with SynapseConfiguration

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

Example 93 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration10.

/**
 * Test serializeConfigurationMethod with InboundEndpoint added for SynapseConfiguration
 * and assert OMElement returned
 */
@Test
public void testSerializeConfiguration10() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    InboundEndpoint inboundEndpoint = new InboundEndpoint();
    inboundEndpoint.setName("test_inbound_1");
    inboundEndpoint.setProtocol("http");
    synapseConfiguration.addInboundEndpoint(inboundEndpoint.getName(), inboundEndpoint);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("InboundEndpoint added is not serialized.", element.getChildren().next().toString().contains("name=\"test_inbound_1\""));
}
Also used : InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 94 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration.

/**
 * Test serializeConfigurationMethod and assert OMElement returned
 */
@Test
public void testSerializeConfiguration() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    synapseConfiguration.setDescription("testConfiguration");
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
}
Also used : OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 95 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration4.

/**
 * Test serializeConfigurationMethod with proxyServices added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration4() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    ProxyService proxyService = new ProxyService("testProxyService");
    synapseConfiguration.addProxyService(proxyService.getName(), proxyService);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("ProxyService added is not serialized.", element.getChildren().next().toString().contains("name=\"testProxyService\""));
}
Also used : ProxyService(org.apache.synapse.core.axis2.ProxyService) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) 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