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;
}
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"));
}
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"));
}
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);
}
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);
}
Aggregations