use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.
the class DiscoveryTest method addServiceListener.
protected void addServiceListener(TestServiceListener serviceListener) {
discoveryLocator.addServiceListener(serviceListener);
addListenerRegisterAndWait(serviceListener, serviceInfo);
discoveryLocator.removeServiceListener(serviceListener);
IContainerEvent[] event = serviceListener.getEvent();
assertNotNull("Test listener didn't receive any discovery event", event);
assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
IServiceInfo serviceInfo2 = ((IServiceEvent) event[eventsToExpect - 1]).getServiceInfo();
assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but was \n\t" + serviceInfo2, comparator.compare(serviceInfo2, serviceInfo) == 0);
}
use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.
the class DiscoveryTest method testAddServiceListenerIServiceTypeIDIServiceListener.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceListener(org.eclipse.ecf.discovery.identity.IServiceTypeID, org.eclipse.ecf.discovery.IServiceListener)}.
* @throws ContainerConnectException
*/
public void testAddServiceListenerIServiceTypeIDIServiceListener() throws ContainerConnectException {
IServiceInfo[] services = discoveryLocator.getServices();
assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);
final TestServiceListener tsl = new TestServiceListener(eventsToExpect, discoveryLocator, getName(), getTestId());
discoveryLocator.addServiceListener(serviceInfo.getServiceID().getServiceTypeID(), tsl);
addListenerRegisterAndWait(tsl, serviceInfo);
discoveryLocator.removeServiceListener(serviceInfo.getServiceID().getServiceTypeID(), tsl);
IContainerEvent[] event = tsl.getEvent();
assertNotNull("Test listener didn't receive discovery", event);
assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
IServiceInfo serviceInfo2 = ((IServiceEvent) event[eventsToExpect - 1]).getServiceInfo();
assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but:\n\t" + serviceInfo2, comparator.compare(serviceInfo2, serviceInfo) == 0);
}
use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.
the class DiscoveryTest method testAddServiceTypeListener.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceTypeListener(org.eclipse.ecf.discovery.IServiceTypeListener)}.
* @throws ContainerConnectException
*/
public void testAddServiceTypeListener() throws ContainerConnectException {
IServiceInfo[] services = discoveryLocator.getServices();
assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);
final TestServiceTypeListener testTypeListener = new TestServiceTypeListener(eventsToExpect);
discoveryLocator.addServiceTypeListener(testTypeListener);
synchronized (testTypeListener) {
// register a service which we expect the test listener to get notified of
registerService();
try {
testTypeListener.wait(waitTimeForProvider);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
fail("Some discovery unrelated threading issues?");
}
}
discoveryLocator.removeServiceTypeListener(testTypeListener);
IContainerEvent[] event = testTypeListener.getEvent();
assertNotNull("Test listener didn't receive discovery", event);
assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
}
use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.
the class MSNConnectWizard method performFinish.
public boolean performFinish() {
final String connectID = page.getEmail();
final String password = page.getPassword();
// Save combo text even if we don't successfully login
page.saveComboText();
connectContext = ConnectContextFactory.createPasswordConnectContext(password);
try {
targetID = container.getConnectNamespace().createInstance(new Object[] { connectID });
} catch (final IDCreateException e) {
new IDCreateErrorDialog(null, connectID, e).open();
return false;
}
page.saveComboItems();
final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
container.addListener(new IContainerListener() {
public void handleEvent(IContainerEvent event) {
if (event instanceof IContainerConnectedEvent) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
openView();
}
});
}
}
});
final IChatManager icm = adapter.getChatManager();
icms = icm.getChatMessageSender();
itms = icm.getTypingMessageSender();
icm.addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent e) {
if (e instanceof IChatMessageEvent) {
displayMessage((IChatMessageEvent) e);
} else if (e instanceof ITypingMessageEvent) {
displayTypingNotification((ITypingMessageEvent) e);
}
}
});
new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {
public void run() {
cachePassword(connectID, password);
}
}).run();
return true;
}
use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.
the class ClientContainerConnectTest method createServerAndClients.
/*
* (non-Javadoc)
*
* @see org.eclipse.ecf.tests.connect.ContainerConnectTestCase#createServerAndClients()
*/
protected void createServerAndClients() throws Exception {
clientCount = 5;
super.createServerAndClients();
getServer().addListener(new IContainerListener() {
public void handleEvent(IContainerEvent event) {
if (event instanceof IContainerConnectedEvent)
serverConnectEvents.add(event);
if (event instanceof IContainerDisconnectedEvent)
serverDisconnectEvents.add(event);
}
});
}
Aggregations