Search in sources :

Example 51 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration5.

/**
 * Test serializeConfigurationMethod with TemplateMediator added for SynapseConfiguration
 * and assert OMElement returned
 */
@Test
public void testSerializeConfiguration5() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = 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);
    synapseConfiguration.addSequence("testSequence", templateMediator);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("Template added is not serialized.", element.getChildren().next().toString().contains("template"));
}
Also used : TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 52 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration11.

/**
 * Test serializeConfigurationMethod with API added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration11() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    API api = new API("testAPI", "/");
    synapseConfiguration.addAPI(api.getName(), api);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("testAPI added is not serialized.", element.getChildren().next().toString().contains("name=\"testAPI\""));
}
Also used : API(org.apache.synapse.rest.API) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 53 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration6.

/**
 * Test serializeConfigurationMethod with Endpoint added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration6() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AddressEndpoint endpoint = new AddressEndpoint();
    EndpointDefinition definition = new EndpointDefinition();
    definition.setAddress("testUrl");
    endpoint.setName("testEndpoint");
    endpoint.setDefinition(definition);
    synapseConfiguration.addEndpoint(endpoint.getName(), endpoint);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("Endpoint added is not serialized.", element.getChildren().next().toString().contains("name=\"testEndpoint\""));
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 54 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration7.

/**
 * Test serializeConfigurationMethod with Entry added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration7() throws MalformedURLException {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    Entry entry = PowerMockito.mock(Entry.class);
    entry.setType(Entry.URL_SRC);
    doReturn(new URL("https://test")).when(entry).getSrc();
    doReturn("testKey").when(entry).getKey();
    synapseConfiguration.addEntry("root_wsdl", entry);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("Entry added is not serialized.", element.getChildren().next().toString().contains("key=\"testKey\""));
}
Also used : Entry(org.apache.synapse.config.Entry) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) URL(java.net.URL) Test(org.junit.Test)

Example 55 with SynapseConfiguration

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration9.

/**
 * Test serializeConfigurationMethod with messageStore added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration9() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    MessageStore messageStore = new JmsStore();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
    parameters.put("java.naming.provider.url", "tcp://127.0.0.1:61616");
    messageStore.setName("testMessageStore");
    messageStore.setParameters(parameters);
    synapseConfiguration.addMessageStore(messageStore.getName(), messageStore);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("MessageStore added is not serialized.", element.getChildren().next().toString().contains("name=\"testMessageStore\""));
}
Also used : MessageStore(org.apache.synapse.message.store.MessageStore) JmsStore(org.apache.synapse.message.store.impl.jms.JmsStore) HashMap(java.util.HashMap) 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