use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.
the class APIDeployerTest method testUpdate.
/**
* Test updating an API
*
* @throws Exception
*/
@Test
public void testUpdate() throws Exception {
String inputXML = "<api name=\"TestAPI\" context=\"/order\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<resource url-mapping=\"/list\" inSequence=\"seq1\" outSequence=\"seq2\" xmlns=\"http://ws.apache.org/ns/synapse\"/>" + "</api>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
APIDeployer apiDeployer = new APIDeployer();
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);
apiDeployer.init(cfgCtx);
apiDeployer.deploySynapseArtifact(inputElement, "sampleFile", new Properties());
String inputUpdatedXML = "<api name=\"TestAPIUpdated\" context=\"/orderUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<resource url-mapping=\"/list\" inSequence=\"seq1\" outSequence=\"seq2\" xmlns=\"http://ws.apache.org/ns/synapse\"/>" + "</api>";
OMElement inputUpdatedElement = AXIOMUtil.stringToOM(inputUpdatedXML);
String response = apiDeployer.updateSynapseArtifact(inputUpdatedElement, "sampleUpdatedFile", "TestAPI", new Properties());
Assert.assertEquals("API not updated!", "TestAPIUpdated", response);
}
use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.
the class EndpointDeployerTest method testDeploy.
/**
* Testing the deployment of an endpoint
*
* @throws Exception
*/
@Test
public void testDeploy() throws Exception {
String inputXML = "<endpoint name = \"sampleEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
EndpointDeployer endpointDeployer = new EndpointDeployer();
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);
endpointDeployer.init(cfgCtx);
String response = endpointDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
Assert.assertEquals("Endpoint not deployed!", "sampleEP", response);
}
use of org.apache.axis2.context.ConfigurationContext 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);
}
use of org.apache.axis2.context.ConfigurationContext 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);
}
use of org.apache.axis2.context.ConfigurationContext 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", new Properties());
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", new Properties());
Assert.assertEquals("Proxy not updated!", "TestProxyUpdated", response);
}
Aggregations