use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class ProxyServiceTest method testBuildAxisServiceWithMalformedWsdlUri.
/**
* Tests building a proxy service with a malformed URI specified as the published wsdl url.
*
* @throws Exception if an error occurs due to the malformed url
*/
public void testBuildAxisServiceWithMalformedWsdlUri() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("testBuildAxisServiceWithInvalidWsdlUriProxy");
// note incorrect protocol, 'files'
URI wsdlUri = new URI("files:/home/sasikala/Documents/ei/git/wso2-synapse/modules/core/target/test-classes" + "/org/apache/synapse/core/axis2/SimpleStockService.wsdl");
proxyService.setWsdlURI(wsdlUri);
try {
proxyService.buildAxisService(synCfg, axisCfg);
Assert.fail("Axis service should not be built with malformed publish wsdl URI: " + wsdlUri.toString());
} catch (SynapseException e) {
Assert.assertEquals("Unexpected exception thrown: " + e, "Malformed URI for wsdl", e.getMessage());
}
}
use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class ProxyServiceTest method testBuildAxisServiceWithUnreachableWsdlUriWithPublishWSDLSafeModeDisabled.
/**
* Tests building a proxy service with an unreachable URI 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 testBuildAxisServiceWithUnreachableWsdlUriWithPublishWSDLSafeModeDisabled() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("unreachableWsdlUriWithPublishWSDLSafeModeDisabledProxy");
proxyService.addParameter("enablePublishWSDLSafeMode", false);
URI wsdlUri = new URI("http://localhost/SimpleStockService.wsdl");
proxyService.setWsdlURI(wsdlUri);
try {
proxyService.buildAxisService(synCfg, axisCfg);
Assert.fail("Axis service should not be built with malformed publish wsdl URI: " + wsdlUri);
} catch (SynapseException e) {
Assert.assertEquals("Unexpected exception thrown: " + e, "Error reading from wsdl URI", e.getMessage());
}
}
use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class ProxyServiceTest method testBuildAxisServiceWithFaultyPublishWsdlEndpoint.
/**
* Tests building a proxy service with a faulty wsdl endpoint specified as the wsdl endpoint.
*
* @throws Exception if an error occurs when converting the URI string to a URI
*/
public void testBuildAxisServiceWithFaultyPublishWsdlEndpoint() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxy");
proxyService.setPublishWSDLEndpoint("wsdlEndPoint");
try {
proxyService.buildAxisService(synCfg, axisCfg);
Assert.fail("Axis service built with null wsdl endpoint should throw fault");
} catch (SynapseException e) {
Assert.assertEquals("Unexpected exception thrown: " + e, "Unable to resolve WSDL url. wsdlEndPoint is null", e.getMessage());
}
AddressEndpoint wsdlEndpoint = new AddressEndpoint();
EndpointDefinition endpointDefinition = new EndpointDefinition();
endpointDefinition.setAddress(getClass().getResource("SimpleStockService.wsdl").toURI().toString());
wsdlEndpoint.setDefinition(endpointDefinition);
synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint);
try {
proxyService.buildAxisService(synCfg, axisCfg);
Assert.fail("Axis service built with faulty wsdl endpoint should be null");
} catch (SynapseException e) {
Assert.assertEquals("Unexpected exception thrown: " + e, "Error building service from WSDL", e.getMessage());
}
}
use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class ProxyServiceTest method testBuildAxisServiceWithUnreachableWsdlUriWithPublishWSDLSafeModeEnabled.
/**
* Tests building a proxy service with an unreachable URI specified as the published wsdl url with the
* 'enablePublishWSDLSafeMode' set to true.
*
* @throws URISyntaxException if an error occurs when converting the URI string to a URI
*/
public void testBuildAxisServiceWithUnreachableWsdlUriWithPublishWSDLSafeModeEnabled() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("unreachableWsdlUriWithPublishWSDLSafeModeEnabledProxy");
proxyService.addParameter("enablePublishWSDLSafeMode", true);
URI wsdlUri = new URI("http://localhost/SimpleStockService.wsdl");
proxyService.setWsdlURI(wsdlUri);
Assert.assertNull("Axis service returned should be null", proxyService.buildAxisService(synCfg, axisCfg));
}
use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class EndpointDeployerTest method testUndeploy.
/**
* Test undeploying an endpoint
*
* @throws Exception
*/
@Test
public void testUndeploy() throws Exception {
String inputXML = "<endpoint name = \"sampleEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
EndpointDeployer endpointDeployer = new EndpointDeployer();
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);
endpointDeployer.init(cfgCtx);
endpointDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
Assert.assertNotNull("Endpoint not deployed!", synapseConfiguration.getEndpoint("sampleEP"));
endpointDeployer.undeploySynapseArtifact("sampleEP");
Assert.assertNull("Endpoint cannot be undeployed", synapseConfiguration.getEndpoint("sampleEP"));
}
Aggregations