use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.
the class DynamicLoadBalanceEndpointTest method getMockedSynapseEnvironment.
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
private Axis2SynapseEnvironment getMockedSynapseEnvironment() throws AxisFault {
Axis2SynapseEnvironment synapseEnvironment = PowerMockito.mock(Axis2SynapseEnvironment.class);
ConfigurationContext axis2ConfigurationContext = new ConfigurationContext(new AxisConfiguration());
axis2ConfigurationContext.getAxisConfiguration().addParameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment);
Mockito.when(synapseEnvironment.getAxis2ConfigurationContext()).thenReturn(axis2ConfigurationContext);
return synapseEnvironment;
}
use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.
the class ProxyServiceTest method testWSDLWithoutPublishWSDL.
/**
* Test that a proxy service without publishWSDL will produce a meaningful WSDL.
* This is a regression test for SYNAPSE-366.
*/
public void testWSDLWithoutPublishWSDL() throws Exception {
// Build the proxy service
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("Test");
AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg);
// Serialize the WSDL
ByteArrayOutputStream baos = new ByteArrayOutputStream();
axisService.printWSDL(baos);
// Check that the produced WSDL can be read by WSDL4J
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.readWSDL(null, new InputSource(new ByteArrayInputStream(baos.toByteArray())));
}
use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.
the class ProxyServiceTest method testRecursiveImports2.
/**
* Test a proxy service with recursive imports and without a {@link ResourceMap}.
* Regression test for SYNAPSE-442.
*/
public void testRecursiveImports2() throws Exception {
ProxyService testService = new ProxyService("mytest");
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
testService.setWsdlURI(getClass().getResource("SimpleStockService.wsdl").toURI());
testService.buildAxisService(synCfg, axisCfg);
}
use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.
the class ProxyServiceTest method testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeEnabled.
/**
* Tests building a proxy service with an unreachable endpoint specified as the published wsdl url with the
* 'enablePublishWSDLSafeMode' set to false.
*
* @throws Exception if an error occurs when converting the URI string to a URI
*/
public void testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeEnabled() throws Exception {
MessageContext synCtx = new TestMessageContext();
SynapseConfiguration synCfg = new SynapseConfiguration();
synCtx.setConfiguration(synCfg);
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxyWithPublishWSDLSafeModeEnabled");
proxyService.setPublishWSDLEndpoint("wsdlEndPoint");
AddressEndpoint wsdlEndpoint = new AddressEndpoint();
EndpointDefinition endpointDefinition = new EndpointDefinition();
endpointDefinition.setAddress((new URI("http://invalid-host/SimpleStockService.wsdl")).toString());
wsdlEndpoint.setDefinition(endpointDefinition);
proxyService.addParameter("enablePublishWSDLSafeMode", true);
synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint);
Assert.assertNull("Axis service built with an unreachable wsdl endpoint be null", proxyService.buildAxisService(synCfg, axisCfg));
}
use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.
the class ProxyServiceTest method testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeDisabled.
/**
* Tests building a proxy service with an unreachable endpoint specified as the published wsdl url with the
* 'enablePublishWSDLSafeMode' set to true.
*
* @throws Exception if an error occurs when converting the URI string to a URI
*/
public void testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeDisabled() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxyWithPublishWSDLSafeModeDisabled");
proxyService.setPublishWSDLEndpoint("wsdlEndPoint");
AddressEndpoint wsdlEndpoint = new AddressEndpoint();
EndpointDefinition endpointDefinition = new EndpointDefinition();
endpointDefinition.setAddress((new URI("http://invalid-host/SimpleStockService.wsdl")).toString());
wsdlEndpoint.setDefinition(endpointDefinition);
proxyService.addParameter("enablePublishWSDLSafeMode", false);
synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint);
try {
proxyService.buildAxisService(synCfg, axisCfg);
Assert.fail("Axis service built with an unreachable wsdl endpoint should throw fault");
} catch (SynapseException e) {
Assert.assertTrue("Unexpected exception thrown: " + e, e.getMessage().contains("Error reading from wsdl URI"));
}
}
Aggregations