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);
}
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();
}
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;
}
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));
}
Aggregations