Search in sources :

Example 56 with SynapseEnvironment

use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.

the class SynapseEventSourceTest method createMessageContext.

private MessageContext createMessageContext(String payload, String action) {
    try {
        SynapseConfiguration synapseConfig = new SynapseConfiguration();
        AxisConfiguration axisConfig = new AxisConfiguration();
        synapseConfig.setAxisConfiguration(axisConfig);
        ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
        SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, synapseConfig);
        axisConfig.addParameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfig);
        axisConfig.addParameter(SynapseConstants.SYNAPSE_ENV, env);
        MessageContext msgCtx = TestUtils.getAxis2MessageContext(payload, null).getAxis2MessageContext();
        msgCtx.setConfigurationContext(cfgCtx);
        msgCtx.setTo(new EndpointReference(SUB_MAN_URL));
        msgCtx.setWSAAction(action);
        return msgCtx;
    } catch (Exception e) {
        fail();
    }
    return null;
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) MessageContext(org.apache.axis2.context.MessageContext) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) EventException(org.wso2.eventing.exceptions.EventException) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 57 with SynapseEnvironment

use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.

the class MessageStoreDeployerTest method testUndeploy.

/**
 * Test undeploying a message store
 *
 * @throws Exception
 */
@Test
public void testUndeploy() 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);
    Assert.assertNotNull("Message Store not deployed!", synapseConfiguration.getMessageStore("JMSMS"));
    messageStoreDeployer.undeploySynapseArtifact("JMSMS");
    Assert.assertNull("Message Store cannot be undeployed!", synapseConfiguration.getMessageStore("JMSMS"));
}
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 58 with SynapseEnvironment

use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.

the class PriorityExecutorDeployerTest method testUndeploy.

/**
 * Test undeploying a priority executor
 *
 * @throws Exception
 */
@Test
public void testUndeploy() 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);
    priorityExecutorDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertNotNull("Priority executor not deployed!", synapseConfiguration.getPriorityExecutors().get("TestExec"));
    priorityExecutorDeployer.undeploySynapseArtifact("TestExec");
    Assert.assertNull("Priority executor cannot be undeployed", synapseConfiguration.getPriorityExecutors().get("TestExec"));
}
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 59 with SynapseEnvironment

use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.

the class PriorityExecutorDeployerTest method testUpdate.

/**
 * Test updating a priority executor
 *
 * @throws Exception
 */
@Test
public void testUpdate() 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);
    priorityExecutorDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdateXML = "<priority-executor name=\"TestExecUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "         <queues>" + "            <queue size=\"100\" priority=\"1\"/>" + "            <queue size=\"100\" priority=\"10\"/>" + "         </queues>" + "        </priority-executor>";
    OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
    String response = priorityExecutorDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "TestExec", null);
    Assert.assertEquals("Priority executor not updated!", "TestExecUpdated", 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 60 with SynapseEnvironment

use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.

the class SequenceDeployerTest method testUpdate.

/**
 * Test updating a sequence
 *
 * @throws Exception
 */
@Test
public void testUpdate() throws Exception {
    String inputXML = "<sequence name=\"TestSequence\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "             <log/>" + "         </sequence>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    SequenceDeployer sequenceDeployer = new SequenceDeployer();
    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);
    sequenceDeployer.init(cfgCtx);
    sequenceDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdateXML = "<sequence name=\"TestSequenceUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "                  <log/>" + "              </sequence>";
    OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
    String response = sequenceDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "TestSequence", null);
    Assert.assertEquals("Sequence not updated!", "TestSequenceUpdated", 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

SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)67 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)50 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)49 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)44 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)43 Test (org.junit.Test)40 OMElement (org.apache.axiom.om.OMElement)35 Parameter (org.apache.axis2.description.Parameter)29 MessageContext (org.apache.synapse.MessageContext)18 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)18 ArrayList (java.util.ArrayList)8 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)8 Endpoint (org.apache.synapse.endpoints.Endpoint)8 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)6 HashMap (java.util.HashMap)5 OMDocument (org.apache.axiom.om.OMDocument)4 SynapseException (org.apache.synapse.SynapseException)4 TestMessageContext (org.apache.synapse.TestMessageContext)4 IOException (java.io.IOException)3 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)3