JBIContainer container = new JBIContainer();
container.init();
container.start();
ReceiverComponent receiver = new ReceiverComponent() {
protected void init() throws JBIException {
ServiceEndpoint ep = new ExternalEndpoint(getService(), getEndpoint());
getContext().registerExternalEndpoint(ep);
setService(null);
setEndpoint(null);
}
public ServiceEndpoint resolveEndpointReference(DocumentFragment fragment) {
try {
SourceTransformer st = new SourceTransformer();
String xml = st.toString(fragment);
return (ServiceEndpoint) new XStream(new DomDriver()).fromXML(xml);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
container.activateComponent(new ActivationSpec("receiver", receiver));
ServiceMixClient client = new DefaultServiceMixClient(container);
ServiceEndpoint[] endpoints = client.getContext().getExternalEndpoints(null);
assertNotNull(endpoints);
assertEquals(1, endpoints.length);
assertNull(client.getContext().getEndpointDescriptor(endpoints[0]));
ServiceEndpoint se = client.getContext().resolveEndpointReference(endpoints[0].getAsReference(null));
assertNull(client.getContext().getEndpointDescriptor(se));
InOnly me = client.createInOnlyExchange();
me.setEndpoint(se);
client.send(me);
receiver.getMessageList().assertMessagesReceived(1);