Search in sources :

Example 1 with EndpointTransformerImpl

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()));
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ArrayList(java.util.ArrayList) SLPropertiesImpl(org.talend.esb.servicelocator.client.SLPropertiesImpl) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 2 with EndpointTransformerImpl

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();
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Document(org.w3c.dom.Document) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)

Example 3 with EndpointTransformerImpl

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);
}
Also used : EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) Before(org.junit.Before)

Example 4 with EndpointTransformerImpl

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();
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) WebApplicationException(javax.ws.rs.WebApplicationException) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Document(org.w3c.dom.Document)

Example 5 with EndpointTransformerImpl

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()));
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ArrayList(java.util.ArrayList) SLPropertiesImpl(org.talend.esb.servicelocator.client.SLPropertiesImpl) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

EndpointTransformerImpl (org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl)5 DOMResult (javax.xml.transform.dom.DOMResult)4 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)4 Document (org.w3c.dom.Document)4 ArrayList (java.util.ArrayList)2 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)2 Test (org.junit.Test)2 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)2 SLProperties (org.talend.esb.servicelocator.client.SLProperties)2 SLPropertiesImpl (org.talend.esb.servicelocator.client.SLPropertiesImpl)2 ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 Before (org.junit.Before)1 InterruptionFaultDetail (org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail)1 ServiceLocatorFaultDetail (org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)1 InterruptedExceptionFault (org.talend.services.esb.locator.v1.InterruptedExceptionFault)1 ServiceLocatorFault (org.talend.services.esb.locator.v1.ServiceLocatorFault)1