Search in sources :

Example 31 with URI

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());
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) SynapseException(org.apache.synapse.SynapseException) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) URI(java.net.URI)

Example 32 with URI

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());
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) SynapseException(org.apache.synapse.SynapseException) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) URI(java.net.URI)

Example 33 with URI

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());
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) SynapseException(org.apache.synapse.SynapseException) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 34 with URI

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));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) URI(java.net.URI)

Example 35 with URI

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"));
}
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)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)16 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)15 OMElement (org.apache.axiom.om.OMElement)13 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)13 Parameter (org.apache.axis2.description.Parameter)11 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)10 URI (java.net.URI)9 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)9 Test (org.junit.Test)9 EndpointReference (org.apache.axis2.addressing.EndpointReference)8 URI (org.apache.axis2.databinding.types.URI)7 IOException (java.io.IOException)5 SynapseException (org.apache.synapse.SynapseException)5 MalformedURLException (java.net.MalformedURLException)4 Calendar (java.util.Calendar)4 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)4 InputStream (java.io.InputStream)3 URISyntaxException (java.net.URISyntaxException)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3