Search in sources :

Example 26 with Axis2SynapseEnvironment

use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment 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);
}
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 27 with Axis2SynapseEnvironment

use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment 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"));
}
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 28 with Axis2SynapseEnvironment

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

the class TemplateDeployerTest method testUpdateForSequence.

/**
 * Test updating an endpoint
 *
 * @throws Exception
 */
@Test
public void testUpdateForSequence() throws Exception {
    String inputXML = "<template name = \"TestTemplate\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "              <sequence name=\"TestSequenceUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "                  <log/>" + "              </sequence>" + "          </template>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    TemplateDeployer templateDeployer = new TemplateDeployer();
    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);
    templateDeployer.init(cfgCtx);
    templateDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdateXML = "<template name = \"TestTemplateUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "              <sequence name=\"TestSequenceUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "                  <log/>" + "              </sequence>" + "          </template>";
    OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
    String response = templateDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "TestTemplate", null);
    Assert.assertEquals("Sequence template not updated!", "TestTemplateUpdated", 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 29 with Axis2SynapseEnvironment

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

the class TemplateDeployerTest method testUpdateForEndpoint.

/**
 * Test updating an endpoint
 *
 * @throws Exception
 */
@Test
public void testUpdateForEndpoint() throws Exception {
    String inputXML = "<template name = \"TestTemplate\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "              <endpoint name = \"sampleEP\" >" + "                  <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "              </endpoint>" + "          </template>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    TemplateDeployer templateDeployer = new TemplateDeployer();
    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);
    templateDeployer.init(cfgCtx);
    templateDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdateXML = "<template name = \"TestTemplateUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "              <endpoint name = \"sampleEP\" >" + "                  <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "              </endpoint>" + "          </template>";
    OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
    String response = templateDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "TestTemplate", null);
    Assert.assertEquals("Endpoint template not updated!", "TestTemplateUpdated", 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 30 with Axis2SynapseEnvironment

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

the class TemplateDeployerTest method testDeployForEndpoint.

/**
 * Testing the deployment of an endpoint template
 *
 * @throws Exception
 */
@Test
public void testDeployForEndpoint() throws Exception {
    String inputXML = "<template name = \"TestTemplate\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "              <endpoint name = \"sampleEP\" >" + "                  <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "              </endpoint>" + "          </template>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    TemplateDeployer templateDeployer = new TemplateDeployer();
    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);
    templateDeployer.init(cfgCtx);
    String response = templateDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertEquals("Endpoint template not deployed!", "TestTemplate", 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

Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)81 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)64 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)57 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)49 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)43 Test (org.junit.Test)38 OMElement (org.apache.axiom.om.OMElement)30 Parameter (org.apache.axis2.description.Parameter)26 MessageContext (org.apache.synapse.MessageContext)23 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)21 Properties (java.util.Properties)14 TestMessageContext (org.apache.synapse.TestMessageContext)13 Mediator (org.apache.synapse.Mediator)12 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)10 ArrayList (java.util.ArrayList)8 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)7 Endpoint (org.apache.synapse.endpoints.Endpoint)7 HashMap (java.util.HashMap)5 OMDocument (org.apache.axiom.om.OMDocument)4 EndpointReference (org.apache.axis2.addressing.EndpointReference)4