Search in sources :

Example 11 with Endpoint

use of org.talend.esb.servicelocator.client.Endpoint in project tesb-rt-se by Talend.

the class RegisterEndpointProviderTest method unregister.

@Ignore
@Test
public void unregister() throws Exception {
    Endpoint endpoint = create(SERVICE_QNAME_1, ENDPOINT_1, BindingType.JAXRS, TransportType.HTTP);
    Capture<Long> lastTimeStoppedCapture = new Capture<Long>();
    endpointExists(ENDPOINT_PATH_11);
    getData(ENDPOINT_PATH_11, OLD_DATA);
    data2Ep(SERVICE_QNAME_1, OLD_DATA);
    deleteEndpointStatus(ENDPOINT_PATH_11);
    ep2Data(endpoint, LAST_TIME_STARTED, lastTimeStoppedCapture, NEW_DATA);
    setData(ENDPOINT_PATH_11, NEW_DATA);
    replayAll();
    ServiceLocatorImpl slc = createServiceLocatorSuccess();
    slc.setEndpointTransformer(trans);
    long beforeUnregister = System.currentTimeMillis();
    slc.unregister(endpoint);
    long afterUnregister = System.currentTimeMillis();
    verifyAll();
    long lastTimeStopped = lastTimeStoppedCapture.getValue();
    assertTrue(beforeUnregister <= lastTimeStopped && lastTimeStopped <= afterUnregister);
}
Also used : Endpoint(org.talend.esb.servicelocator.client.Endpoint) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) EasyMock.anyLong(org.easymock.EasyMock.anyLong) Capture(org.easymock.Capture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with Endpoint

use of org.talend.esb.servicelocator.client.Endpoint in project tesb-rt-se by Talend.

the class RegisterEndpointProviderTest method unregisterEndpointDeleteFails.

@Ignore
@Test
public void unregisterEndpointDeleteFails() throws Exception {
    endpointExists(ENDPOINT_PATH_11);
    getData(ENDPOINT_PATH_11, OLD_DATA);
    data2Ep(SERVICE_QNAME_1, OLD_DATA);
    delete(ENDPOINT_STATUS_PATH_11, new KeeperException.RuntimeInconsistencyException());
    Endpoint eprProvider = create(SERVICE_QNAME_1, ENDPOINT_1);
    replayAll();
    ServiceLocatorImpl slc = createServiceLocatorSuccess();
    slc.setEndpointTransformer(trans);
    try {
        slc.unregister(eprProvider);
        fail("A ServiceLocatorException should have been thrown.");
    } catch (ServiceLocatorException e) {
        ignore("Expected exception");
    }
    verifyAll();
}
Also used : Endpoint(org.talend.esb.servicelocator.client.Endpoint) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) KeeperException(org.apache.zookeeper.KeeperException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with Endpoint

use of org.talend.esb.servicelocator.client.Endpoint in project tesb-rt-se by Talend.

the class EndpointStubFactory method create.

public static Endpoint create(QName serviceName, String endpoint, BindingType bindingType, TransportType transportType) throws Exception {
    Endpoint eprProvider = createNiceMock(Endpoint.class);
    expect(eprProvider.getServiceName()).andStubReturn(serviceName);
    expect(eprProvider.getAddress()).andStubReturn(endpoint);
    expect(eprProvider.getBinding()).andStubReturn(bindingType);
    expect(eprProvider.getTransport()).andStubReturn(transportType);
    eprProvider.writeEndpointReferenceTo(anyDOMResult(), (Endpoint.PropertiesTransformer) EasyMock.anyObject());
    expectLastCall().asStub();
    replay(eprProvider);
    return eprProvider;
}
Also used : Endpoint(org.talend.esb.servicelocator.client.Endpoint)

Example 14 with Endpoint

use of org.talend.esb.servicelocator.client.Endpoint in project tesb-rt-se by Talend.

the class EndpointTransformerImplTest method fromEndpoint.

@Test
public void fromEndpoint() throws Exception {
    Endpoint endpoint = EndpointStubFactory.create(SERVICE_QNAME_1, ENDPOINT_1, BindingType.JAXRS, TransportType.HTTP);
    EndpointTransformerImpl trans = new EndpointTransformerImpl();
    byte[] content = trans.fromEndpoint(endpoint, LAST_TIME_STARTED, LAST_TIME_STOPPED);
    Document contentAsXML = DomMother.parse(content);
    assertThat(contentAsXML, hasXPath("/sl:EndpointData", WSA_SL_NS_CONTEXT));
    assertThat(contentAsXML, hasXPath("/sl:EndpointData/sl:LastTimeStarted/text()", WSA_SL_NS_CONTEXT, equalTo(Long.toString(LAST_TIME_STARTED))));
    assertThat(contentAsXML, hasXPath("/sl:EndpointData/sl:LastTimeStopped/text()", WSA_SL_NS_CONTEXT, equalTo(Long.toString(LAST_TIME_STOPPED))));
    assertThat(contentAsXML, hasXPath("/sl:EndpointData/sl:Binding/text()", WSA_SL_NS_CONTEXT, equalTo(BindingType.JAXRS.getValue())));
    assertThat(contentAsXML, hasXPath("/sl:EndpointData/sl:Transport/text()", WSA_SL_NS_CONTEXT, equalTo(TransportType.HTTP.getValue())));
    assertThat(contentAsXML, hasXPath("/sl:EndpointData/wsa:EndpointReference", WSA_SL_NS_CONTEXT));
}
Also used : Endpoint(org.talend.esb.servicelocator.client.Endpoint) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

Endpoint (org.talend.esb.servicelocator.client.Endpoint)14 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)12 Test (org.junit.Test)11 Ignore (org.junit.Ignore)10 ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 QName (javax.xml.namespace.QName)2 Capture (org.easymock.Capture)2 EasyMock.anyLong (org.easymock.EasyMock.anyLong)2 SimpleEndpoint (org.talend.esb.servicelocator.client.SimpleEndpoint)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 KeeperException (org.apache.zookeeper.KeeperException)1 BindingType (org.talend.esb.servicelocator.client.BindingType)1 SLPropertiesImpl (org.talend.esb.servicelocator.client.SLPropertiesImpl)1 SLPropertiesMatcher (org.talend.esb.servicelocator.client.SLPropertiesMatcher)1 TransportType (org.talend.esb.servicelocator.client.TransportType)1 EndpointReferenceList (org.talend.schemas.esb.locator.rest._2011._11.EndpointReferenceList)1 EntryType (org.talend.schemas.esb.locator.rest._2011._11.EntryType)1 Document (org.w3c.dom.Document)1