use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.
the class ServiceLocatorImplTest method connectFailing.
@Test
public void connectFailing() throws Exception {
expect(backend.connect()).andThrow(new ServiceLocatorException());
replayAll();
ServiceLocatorImpl slc = new ServiceLocatorImpl();
slc.setBackend(backend);
try {
slc.connect();
fail("A ServiceLocatorException should have been thrown.");
} catch (ServiceLocatorException e) {
ignore("Expected exception");
}
verifyAll();
}
use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.
the class CXFEndpointProvider method writeEndpointReferenceTo.
/* (non-Javadoc)
* @see org.talend.esb.servicelocator.client.Endpoint#writeEndpointReferenceTo(javax.xml.transform.Result, org.talend.esb.servicelocator.client.Endpoint.PropertiesTransformer)
*/
@Override
public void writeEndpointReferenceTo(Result result, PropertiesTransformer transformer) throws ServiceLocatorException {
try {
JAXBElement<EndpointReferenceType> ep = WSA_OBJECT_FACTORY.createEndpointReference(epr);
createMarshaller().marshal(ep, result);
} catch (JAXBException e) {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE, "Failed to serialize endpoint data", e);
}
throw new ServiceLocatorException("Failed to serialize endpoint data", e);
}
}
use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.
the class LocatorRestServiceImpl method lookupEndpoint.
/**
* For the given service return endpoint reference randomly selected from
* list of endpoints currently registered at the service locator server.
*
* @param input
* String encoded name of service
* @param input
* List of encoded additional parameters separated by comma
*
* @return endpoint references or <code>null</code>
*/
@Override
public W3CEndpointReference lookupEndpoint(String arg0, List<String> arg1) {
QName serviceName = null;
try {
serviceName = QName.valueOf(URLDecoder.decode(arg0, "UTF-8"));
} catch (UnsupportedEncodingException e1) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity("Error during decoding serviceName").build());
}
List<String> names = null;
String adress = null;
SLPropertiesMatcher matcher = null;
try {
matcher = createMatcher(arg1);
} catch (UnsupportedEncodingException e1) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity("Error during decoding serviceName").build());
}
try {
initLocator();
if (matcher == null) {
names = locatorClient.lookup(serviceName);
} else {
names = locatorClient.lookup(serviceName, matcher);
}
} catch (ServiceLocatorException e) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build());
} catch (InterruptedException e) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build());
}
if (names != null && !names.isEmpty()) {
names = getRotatedList(names);
adress = names.get(0);
} else {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "lookup Endpoint for " + serviceName + " failed, service is not known.");
}
throw new WebApplicationException(Response.status(Status.NOT_FOUND).entity("lookup Endpoint for " + serviceName + " failed, service is not known.").build());
}
return buildEndpoint(serviceName, adress);
}
use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.
the class LocatorRestServiceImpl method buildEndpoint.
/**
* Build Endpoint Reference for giving service name and address
*
* @param serviceName
* @param adress
* @return
*/
private W3CEndpointReference buildEndpoint(QName serviceName, String adress) {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(serviceName);
builder.address(adress);
SLEndpoint endpoint = null;
try {
endpoint = locatorClient.getEndpoint(serviceName, adress);
} catch (ServiceLocatorException e) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build());
} catch (InterruptedException e) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build());
}
if (endpoint != null) {
SLProperties properties = endpoint.getProperties();
if (properties != null && !properties.getPropertyNames().isEmpty()) {
EndpointTransformerImpl transformer = new EndpointTransformerImpl();
DOMResult result = new DOMResult();
transformer.writePropertiesTo(properties, result);
Document docResult = (Document) result.getNode();
builder.metadata(docResult.getDocumentElement());
}
}
return builder.build();
}
use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.
the class LocatorRestServiceTest method lookUpEndpointsExpectedLocatorException.
@Test(expected = WebApplicationException.class)
public void lookUpEndpointsExpectedLocatorException() throws ServiceLocatorException, InterruptedException {
names.clear();
names.add(ENDPOINTURL);
expect(sl.lookup(SERVICE_NAME)).andStubThrow(new ServiceLocatorException("test"));
replayAll();
lps.lookupEndpoints(SERVICE_NAME.toString(), new ArrayList<String>());
}
Aggregations