Search in sources :

Example 36 with SynapseConfiguration

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

the class MessageStoreDeployerTest method testDeploy.

/**
 * Testing the deployment of an message store
 *
 * @throws Exception
 */
@Test
public void testDeploy() throws Exception {
    String inputXML = "<messageStore name=\"JMSMS\" class=\"org.apache.synapse.message.store.impl.jms.JmsStore\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "   <parameter name=\"java.naming.factory.initial\">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>" + "   <parameter name=\"java.naming.provider.url\">repository/conf/jndi.properties</parameter>" + "   <parameter name=\"store.jms.destination\">ordersQueue</parameter>" + "   <parameter name=\"store.jms.connection.factory\">QueueConnectionFactory</parameter>" + "   <parameter name=\"store.jms.JMSSpecVersion\">1.1</parameter>" + "</messageStore>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    MessageStoreDeployer messageStoreDeployer = new MessageStoreDeployer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
    cfgCtx.setAxisConfiguration(axisConfiguration);
    messageStoreDeployer.init(cfgCtx);
    String response = messageStoreDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertEquals("Message store not deployed!", "JMSMS", response);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 37 with SynapseConfiguration

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

the class MessageStoreDeployerTest method testUpdate.

/**
 * Test updating a message store
 *
 * @throws Exception
 */
@Test
public void testUpdate() throws Exception {
    String inputXML = "<messageStore name=\"JMSMS\" class=\"org.apache.synapse.message.store.impl.jms.JmsStore\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "   <parameter name=\"java.naming.factory.initial\">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>" + "   <parameter name=\"java.naming.provider.url\">repository/conf/jndi.properties</parameter>" + "   <parameter name=\"store.jms.destination\">ordersQueue</parameter>" + "   <parameter name=\"store.jms.connection.factory\">QueueConnectionFactory</parameter>" + "   <parameter name=\"store.jms.JMSSpecVersion\">1.1</parameter>" + "</messageStore>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    MessageStoreDeployer messageStoreDeployer = new MessageStoreDeployer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
    cfgCtx.setAxisConfiguration(axisConfiguration);
    messageStoreDeployer.init(cfgCtx);
    messageStoreDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdatedXML = "<messageStore name=\"JMSMSnew\" class=\"org.apache.synapse.message.store.impl.jms.JmsStore\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "   <parameter name=\"java.naming.factory.initial\">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>" + "   <parameter name=\"java.naming.provider.url\">repository/conf/jndi.properties</parameter>" + "   <parameter name=\"store.jms.destination\">ordersQueue</parameter>" + "   <parameter name=\"store.jms.connection.factory\">QueueConnectionFactory</parameter>" + "   <parameter name=\"store.jms.JMSSpecVersion\">1.1</parameter>" + "</messageStore>";
    OMElement inputUpdatedElement = AXIOMUtil.stringToOM(inputUpdatedXML);
    String response = messageStoreDeployer.updateSynapseArtifact(inputUpdatedElement, "sampleUpdatedFile", "JMSMS", null);
    Assert.assertEquals("Message Store not updated!", "JMSMSnew", response);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 38 with SynapseConfiguration

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

the class PriorityExecutorDeployerTest method testDeploy.

/**
 * Testing the deployment of an endpoint
 *
 * @throws Exception
 */
@Test
public void testDeploy() throws Exception {
    String inputXML = "<priority-executor name=\"TestExec\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "         <queues>" + "            <queue size=\"100\" priority=\"1\"/>" + "            <queue size=\"100\" priority=\"10\"/>" + "         </queues>" + "        </priority-executor>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    PriorityExecutorDeployer priorityExecutorDeployer = new PriorityExecutorDeployer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
    cfgCtx.setAxisConfiguration(axisConfiguration);
    priorityExecutorDeployer.init(cfgCtx);
    String response = priorityExecutorDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertEquals("Priority executor not deployed!", "TestExec", response);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 39 with SynapseConfiguration

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

the class ProxyServiceDeployerTest method testUndeploy.

/**
 * Test undeploying a proxy service
 *
 * @throws Exception
 */
@Test
public void testUndeploy() throws Exception {
    String inputXML = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"TestProxy\">" + "        <target>" + "            <endpoint>" + "                <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>" + "            </endpoint>" + "            <outSequence>" + "                <send/>" + "            </outSequence>" + "        </target>" + "    </proxy>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    ProxyServiceDeployer proxyServiceDeployer = new ProxyServiceDeployer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
    cfgCtx.setAxisConfiguration(axisConfiguration);
    proxyServiceDeployer.init(cfgCtx);
    proxyServiceDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertNotNull("Proxy not deployed!", synapseConfiguration.getProxyService("TestProxy"));
    proxyServiceDeployer.undeploySynapseArtifact("TestProxy");
    Assert.assertNull("Proxy service cannot be undeployed", synapseConfiguration.getProxyService("TestProxy"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 40 with SynapseConfiguration

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

the class ProxyServiceDeployerTest method testUpdate.

/**
 * Test updating a proxy service
 *
 * @throws Exception
 */
@Test
public void testUpdate() throws Exception {
    String inputXML = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"TestProxy\">" + "        <target>" + "            <endpoint>" + "                <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>" + "            </endpoint>" + "            <outSequence>" + "                <send/>" + "            </outSequence>" + "        </target>" + "    </proxy>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    ProxyServiceDeployer proxyServiceDeployer = new ProxyServiceDeployer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
    axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
    cfgCtx.setAxisConfiguration(axisConfiguration);
    proxyServiceDeployer.init(cfgCtx);
    proxyServiceDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdateXML = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"TestProxyUpdated\">" + "        <target>" + "            <endpoint>" + "                <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>" + "            </endpoint>" + "            <outSequence>" + "                <send/>" + "            </outSequence>" + "        </target>" + "    </proxy>";
    OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
    String response = proxyServiceDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "TestProxy", null);
    Assert.assertEquals("Proxy not updated!", "TestProxyUpdated", response);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) 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