Search in sources :

Example 41 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class LocalEntryDeployerTest method testUpdate.

/**
 * Test updating a local entry
 *
 * @throws Exception
 */
@Test
public void testUpdate() throws Exception {
    String inputXML = "<localEntry key=\"TestEntry\" xmlns=\"http://ws.apache.org/ns/synapse\">0.1</localEntry>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    LocalEntryDeployer localEntryDeployer = new LocalEntryDeployer();
    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);
    localEntryDeployer.init(cfgCtx);
    localEntryDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    String inputUpdateXML = "<localEntry key=\"TestEntryUpdated\" xmlns=\"http://ws.apache.org/ns/synapse\">0.1</localEntry>";
    OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
    String response = localEntryDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "TestEntry", null);
    Assert.assertEquals("Local Entry not updated!", "TestEntryUpdated", 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 42 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class LocalEntryDeployerTest method testUndeploy.

/**
 * Test undeploying a local entry
 *
 * @throws Exception
 */
@Test
public void testUndeploy() throws Exception {
    String inputXML = "<localEntry key=\"TestEntry\" xmlns=\"http://ws.apache.org/ns/synapse\">0.1</localEntry>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    LocalEntryDeployer localEntryDeployer = new LocalEntryDeployer();
    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);
    localEntryDeployer.init(cfgCtx);
    localEntryDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertNotNull("Local Entry not deployed!", synapseConfiguration.getEntry("TestEntry"));
    localEntryDeployer.undeploySynapseArtifact("TestEntry");
    Assert.assertNull("Local Entry cannot be undeployed", synapseConfiguration.getEntry("TestEntry"));
}
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 43 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class LocalEntryDeployerTest method testDeploy.

/**
 * Testing the deployment of a local entry
 *
 * @throws Exception
 */
@Test
public void testDeploy() throws Exception {
    String inputXML = "<localEntry key=\"TestEntry\" xmlns=\"http://ws.apache.org/ns/synapse\">0.1</localEntry>";
    OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
    LocalEntryDeployer localEntryDeployer = new LocalEntryDeployer();
    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);
    localEntryDeployer.init(cfgCtx);
    String response = localEntryDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
    Assert.assertEquals("Local Entry not deployed!", "TestEntry", 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 44 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext 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);
}
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 45 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext 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)

Aggregations

ConfigurationContext (org.apache.axis2.context.ConfigurationContext)184 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)119 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)70 Test (org.junit.Test)64 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)62 Parameter (org.apache.axis2.description.Parameter)56 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)48 OMElement (org.apache.axiom.om.OMElement)43 AxisFault (org.apache.axis2.AxisFault)34 MessageContext (org.apache.synapse.MessageContext)34 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)30 AxisService (org.apache.axis2.description.AxisService)26 EndpointReference (org.apache.axis2.addressing.EndpointReference)24 MessageContext (org.apache.axis2.context.MessageContext)23 Options (org.apache.axis2.client.Options)22 HashMap (java.util.HashMap)20 ServiceContext (org.apache.axis2.context.ServiceContext)19 Map (java.util.Map)18 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)16