use of org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl in project tesb-rt-se by Talend.
the class LocatorRestServiceTest method lookUpEndpointWithReturnProps.
@Test
public void lookUpEndpointWithReturnProps() throws ServiceLocatorException, InterruptedException {
names.clear();
names.add(ENDPOINTURL);
SLPropertiesImpl slPropertiesImpl = new SLPropertiesImpl();
List<String> list = new ArrayList<String>();
slPropertiesImpl.addProperty("test", list);
expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(endpoint);
expect(endpoint.getProperties()).andStubReturn(slPropertiesImpl);
replayAll();
W3CEndpointReference endpointRef, expectedRef;
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(SERVICE_NAME);
builder.address(ENDPOINTURL);
EndpointTransformerImpl transformer = new EndpointTransformerImpl();
DOMResult result = new DOMResult();
transformer.writePropertiesTo(slPropertiesImpl, result);
Document docResult = (Document) result.getNode();
builder.metadata(docResult.getDocumentElement());
expectedRef = builder.build();
endpointRef = lps.lookupEndpoint(SERVICE_NAME.toString(), new ArrayList<String>());
assertTrue(endpointRef.toString().equals(expectedRef.toString()));
}
use of org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl in project tesb-rt-se by Talend.
the class LocatorSoapServiceImpl method buildEndpoint.
/**
* Build Endpoint Reference for giving service name and address
*
* @param serviceName
* @param adress
* @return
*/
private W3CEndpointReference buildEndpoint(QName serviceName, String adress) throws ServiceLocatorFault, InterruptedExceptionFault {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(serviceName);
builder.address(adress);
SLEndpoint endpoint = null;
try {
endpoint = locatorClient.getEndpoint(serviceName, adress);
} catch (ServiceLocatorException e) {
ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
serviceFaultDetail.setLocatorFaultDetail(serviceName.toString() + "throws ServiceLocatorFault");
throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
} catch (InterruptedException e) {
InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
interruptionFaultDetail.setInterruptionDetail(serviceName.toString() + "throws InterruptionFault");
throw new InterruptedExceptionFault(e.getMessage(), interruptionFaultDetail);
}
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.internal.EndpointTransformerImpl in project tesb-rt-se by Talend.
the class SimpleEndpointlEmptyContentTest method setUp.
@Before
public void setUp() throws Exception {
transf = new EndpointTransformerImpl();
endpoint = transf.toSLEndpoint(SERVICE_QNAME_1, EMPTY_CONTENT, true);
}
use of org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl 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.internal.EndpointTransformerImpl in project tesb-rt-se by Talend.
the class LocatorSoapServiceTest method lookUpEndpointWithReturnProps.
@Test
public void lookUpEndpointWithReturnProps() throws InterruptedExceptionFault, ServiceLocatorFault, ServiceLocatorException, InterruptedException {
names.clear();
names.add(ENDPOINTURL);
SLPropertiesImpl slPropertiesImpl = new SLPropertiesImpl();
List<String> list = new ArrayList<String>();
slPropertiesImpl.addProperty("test", list);
expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(endpoint);
expect(endpoint.getProperties()).andStubReturn(slPropertiesImpl);
replayAll();
W3CEndpointReference endpointRef, expectedRef;
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(SERVICE_NAME);
builder.address(ENDPOINTURL);
EndpointTransformerImpl transformer = new EndpointTransformerImpl();
DOMResult result = new DOMResult();
transformer.writePropertiesTo(slPropertiesImpl, result);
Document docResult = (Document) result.getNode();
builder.metadata(docResult.getDocumentElement());
expectedRef = builder.build();
endpointRef = lps.lookupEndpoint(SERVICE_NAME, null);
assertTrue(endpointRef.toString().equals(expectedRef.toString()));
}
Aggregations