use of org.apache.synapse.core.SynapseEnvironment 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);
}
use of org.apache.synapse.core.SynapseEnvironment 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"));
}
use of org.apache.synapse.core.SynapseEnvironment 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);
}
use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.
the class ProxyServiceDeployerTest method testDeploy.
/**
* Testing the deployment of a proxy service
*
* @throws Exception
*/
@Test
public void testDeploy() 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);
String response = proxyServiceDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
Assert.assertEquals("Proxy service not deployed!", "TestProxy", response);
}
use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.
the class SequenceDeployerTest method testUndeploy.
/**
* Test undeploying a sequence
*
* @throws Exception
*/
@Test
public void testUndeploy() 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);
Assert.assertNotNull("Sequence not deployed!", synapseConfiguration.getSequence("TestSequence"));
sequenceDeployer.undeploySynapseArtifact("TestSequence");
Assert.assertNull("Sequence cannot be undeployed", synapseConfiguration.getSequence("TestSequence"));
}
Aggregations