Search in sources :

Example 66 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration 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", new Properties());
    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) Properties(java.util.Properties) Test(org.junit.Test)

Example 67 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration 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", new Properties());
    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) Properties(java.util.Properties) Test(org.junit.Test)

Example 68 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration 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 69 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration 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 70 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.

the class EndpointViewTest method createEndPointView.

/**
 * Creates a basic EndpointView with a given number of children added to the endpoint.
 *
 * @param numberOfChildren the child endpoints inside the endpoint attached to the end point view. If
 *                         specified as 0, the children list will be null
 * @return the created end point view
 */
private EndpointView createEndPointView(int numberOfChildren) {
    AbstractEndpoint endpoint = new AddressEndpoint();
    MessageContext synCtx = new TestMessageContext();
    synCtx.setConfiguration(new SynapseConfiguration());
    SynapseEnvironment environment = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), synCtx.getConfiguration());
    if (numberOfChildren > 0) {
        List<Endpoint> children = new ArrayList<>(numberOfChildren);
        for (int i = 0; i < numberOfChildren; i++) {
            AbstractEndpoint child = new AddressEndpoint();
            child.init(environment);
            child.setEnableMBeanStats(true);
            child.setName("endpoint" + i);
            children.add(child);
        }
        endpoint.setChildren(children);
    }
    endpoint.init(environment);
    return new EndpointView("endpoint", endpoint);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) ArrayList(java.util.ArrayList) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestMessageContext(org.apache.synapse.TestMessageContext) TestMessageContext(org.apache.synapse.TestMessageContext) MessageContext(org.apache.synapse.MessageContext)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)211 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)122 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)95 Test (org.junit.Test)68 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)65 Parameter (org.apache.axis2.description.Parameter)62 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)62 OMElement (org.apache.axiom.om.OMElement)40 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 AxisService (org.apache.axis2.description.AxisService)33 DeploymentEngine (org.apache.axis2.deployment.DeploymentEngine)32 MessageContext (org.apache.synapse.MessageContext)32 AxisFault (org.apache.axis2.AxisFault)31 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)28 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)21 DeploymentException (org.apache.axis2.deployment.DeploymentException)20 SynapseException (org.apache.synapse.SynapseException)20 IOException (java.io.IOException)19 XMLStreamException (javax.xml.stream.XMLStreamException)16 File (java.io.File)15