use of org.apache.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.
the class SynapseEventSource method getEndpointFromURL.
/**
* Create a Endpoint for a given URL
*
* @param endpointUrl URL
* @param se synapse environment
* @return AddressEndpoint address endpoint
*/
private Endpoint getEndpointFromURL(String endpointUrl, SynapseEnvironment se) {
AddressEndpoint endpoint = new AddressEndpoint();
EndpointDefinition def = new EndpointDefinition();
def.setAddress(endpointUrl.trim());
endpoint.setDefinition(def);
endpoint.init(se);
return endpoint;
}
use of org.apache.synapse.endpoints.EndpointDefinition 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.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.
the class WeightedRRLCAlgorithmTest method createEndpoints.
private List<Endpoint> createEndpoints() {
List<Endpoint> endpoints = new ArrayList<Endpoint>();
for (int i = 0; i < hosts.length; i++) {
AddressEndpoint addressEndpoint = new AddressEndpoint();
EndpointDefinition definition = new EndpointDefinition();
definition.setAddress("http://" + hosts[i] + "/");
addressEndpoint.setDefinition(definition);
MediatorProperty property = new MediatorProperty();
property.setName(WeightedRRLCAlgorithm.LB_WEIGHTED_RRLC_WEIGHT);
property.setValue(weights[i]);
addressEndpoint.addProperty(property);
endpoints.add(addressEndpoint);
}
return endpoints;
}
use of org.apache.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.
the class DynamicEndpointTest method testContextProperties.
public void testContextProperties() throws Exception {
SynapseXPath xpath = new SynapseXPath("$ctx:timeout");
AbstractEndpoint endpoint = new AddressEndpoint();
EndpointDefinition definition = new EndpointDefinition();
endpoint.setDefinition(definition);
definition.setDynamicTimeoutExpression(xpath);
MessageContext synCtx = new TestMessageContext();
synCtx.setProperty("timeout", "90000");
assertEquals(Long.valueOf((String) xpath.evaluate(synCtx)).longValue(), endpoint.getDefinition().evaluateDynamicEndpointTimeout(synCtx));
}
Aggregations