/** * 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); }
proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration()); if (log.isDebugEnabled()) {
AxisService proxyService = proxy.buildAxisService(synapseConfiguration, configurationContext.getAxisConfiguration()); if (proxyService != null) {
AxisService proxyService = proxy.buildAxisService(synapseConfiguration, configurationContext.getAxisConfiguration()); if (proxyService != null) {
log.info("ProxyService named " + existingArtifactName + " has been Undeployed"); proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration()); if (log.isDebugEnabled()) {
log.info("ProxyService named " + existingArtifactName + " has been Undeployed"); AxisService axisService = proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration()); getSynapseConfiguration().addProxyService(proxy.getName(), proxy);
/** * 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()))); }
AxisService axisService = proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration());
/** * 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()); } }
/** * 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://invalid-host/SimpleStockService.wsdl"); proxyService.setWsdlURI(wsdlUri); Assert.assertNull("Axis service returned should be null", proxyService.buildAxisService(synCfg, axisCfg)); }
AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg); Assert.assertNull("Axis service built with incorrect pinned servers should be null", axisService); .getServerConfigurationInformation().getServerName()).thenReturn(pinnedServer); Assert.assertNotNull("Axis service should be built with correct pinned servers", proxyService.buildAxisService(synCfg, axisCfg));
/** * 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()); } }
/** * 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://invalid-host/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()); } }
/** * 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")); } }
resourceMap.addResource("imported.xsd", "imported_xsd"); proxyService.setResourceMap(resourceMap); AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg);
/** * 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)); }