Search in sources :

Example 56 with AxisConfiguration

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;
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration)

Example 57 with AxisConfiguration

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())));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) AxisService(org.apache.axis2.description.AxisService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 58 with AxisConfiguration

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

Example 59 with AxisConfiguration

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

Example 60 with AxisConfiguration

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"));
    }
}
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) URI(java.net.URI)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)205 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)121 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)95 Test (org.junit.Test)68 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)65 Parameter (org.apache.axis2.description.Parameter)62 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)62 OMElement (org.apache.axiom.om.OMElement)40 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 AxisService (org.apache.axis2.description.AxisService)33 DeploymentEngine (org.apache.axis2.deployment.DeploymentEngine)32 MessageContext (org.apache.synapse.MessageContext)32 AxisFault (org.apache.axis2.AxisFault)31 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)28 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)21 DeploymentException (org.apache.axis2.deployment.DeploymentException)20 SynapseException (org.apache.synapse.SynapseException)20 IOException (java.io.IOException)19 XMLStreamException (javax.xml.stream.XMLStreamException)16 File (java.io.File)15