use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.
the class ProxyServiceTest method testRegisterFaultHandler.
/**
* Tests if the correct fault handler is set when a fault handler is not explicitly set, and when set by using
* targetFaultSequence and targetInlineFaultSequence properties of the proxy.
*/
public void testRegisterFaultHandler() {
ProxyService proxyService = new ProxyService("TestRegisterFaultHandlerProxy");
MessageContext messageContext = new TestMessageContext();
SynapseConfiguration synCfg = new SynapseConfiguration();
messageContext.setConfiguration(synCfg);
SequenceMediator faultMediator = new SequenceMediator();
synCfg.addSequence("fault", faultMediator);
// test if the default fault proxy set in the message context is returned when a fault sequence is not
// explicitly set
faultMediator.setName("defaultFault");
proxyService.registerFaultHandler(messageContext);
String faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()).getFaultMediator()).getName();
Assert.assertEquals("Incorrect fault handler set: " + faultMediatorName, "defaultFault", faultMediatorName);
// tests the functionality when the fault sequence is set in line in the target
faultMediator.setName("targetInLineFaultSequenceMediator");
proxyService.setTargetInLineFaultSequence(faultMediator);
proxyService.registerFaultHandler(messageContext);
faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()).getFaultMediator()).getName();
Assert.assertEquals("Incorrect fault handler set: " + faultMediatorName, "targetInLineFaultSequenceMediator", faultMediatorName);
// tests the functionality when the fault sequence is set separately in the target
AxisConfiguration axisCfg = new AxisConfiguration();
SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(axisCfg), synCfg);
messageContext.setEnvironment(synEnv);
proxyService.setTargetFaultSequence("targetFaultSequence");
// when the message context does not have the correct fault sequence specified as the target fault sequence
faultMediator.setName("defaultFaultMediator");
proxyService.registerFaultHandler(messageContext);
faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()).getFaultMediator()).getName();
Assert.assertEquals("Incorrect fault handler set: " + faultMediatorName, "defaultFaultMediator", faultMediatorName);
// when the message context has the correct fault sequence specified as the target fault sequence
faultMediator.setName("targetFaultSequenceMediator");
synCfg.addSequence("targetFaultSequence", faultMediator);
proxyService.registerFaultHandler(messageContext);
faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()).getFaultMediator()).getName();
Assert.assertEquals("Incorrect fault handler set: " + faultMediatorName, "targetFaultSequenceMediator", faultMediatorName);
}
use of org.apache.axis2.engine.AxisConfiguration 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);
}
use of org.apache.axis2.engine.AxisConfiguration 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"));
}
use of org.apache.axis2.engine.AxisConfiguration 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);
}
use of org.apache.axis2.engine.AxisConfiguration 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);
}
Aggregations