Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] Small changes to AbstractRemoteServicesTest

Hello folks,

I'm working on OSCAR/ICQ provider for Eclipse Communication Framework
and implemented Remote Service API via OSCAR/ICQ.

I want suggest small changes to AbstractRemoteServicesTest:

1. add assertTrue(done); after waiting to method testServiceListener. If
do not check 'done' - test can be passed if even RemoteServiceListener
was not be invoked.

2. add protected method customizeProperties and invoked it for
customizing register services properties in other bundles. For example
in the org.eclipse.ecf.tests.provider.oscar I implemented this method:

protected Dictionary customizeProperties(Dictionary props) {
	Dictionary result = new Hashtable();
	// ...
	result.put(Constants.SERVICE_REGISTRATION_TARGETS,
getClient(1).getConnectedID());
	return result;
}

If we do not put Constants.SERVICE_REGISTRATION_TARGETS to properties,
test testServiceListener will not be passed because
adapters[0].registerRemoteService will not send message to
containers[1]. ICQ do not support predefined groups and do not send
broadcast messages.

I attach my patch to this message.

-- 
Pavel Samolisov

Meet me at:
Vkontakte.ru: http://vkontakte.ru/id3178981
Blog: http://samolisov.blogspot.com
Twitter: http://twitter.com/samolisov
XMPP/Jabber: samolisov@xxxxxxxxx
### Eclipse Workspace Patch 1.0
#P org.eclipse.ecf.tests.remoteservice
Index: src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java
===================================================================
RCS file: /cvsroot/rt/org.eclipse.ecf/tests/bundles/org.eclipse.ecf.tests.remoteservice/src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java,v
retrieving revision 1.15
diff -u -r1.15 AbstractRemoteServiceTest.java
--- src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java	4 Nov 2009 14:56:38 -0000	1.15
+++ src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java	16 Jan 2010 18:18:49 -0000
@@ -35,7 +35,7 @@
 import org.osgi.framework.InvalidSyntaxException;
 
 /**
- * 
+ *
  */
 public abstract class AbstractRemoteServiceTest extends
 		ContainerAbstractTestCase {
@@ -43,10 +43,10 @@
 	protected IRemoteServiceContainerAdapter[] adapters = null;
 
 	protected IRemoteServiceID[] ids;
-	
+
 	/*
 	 * (non-Javadoc)
-	 * 
+	 *
 	 * @see
 	 * org.eclipse.ecf.tests.ContainerAbstractTestCase#getClientContainerName()
 	 */
@@ -114,7 +114,7 @@
 	}
 
 	protected IRemoteService getRemoteService(
-			IRemoteServiceContainerAdapter adapter, ID target, String clazz, String filter) {
+			IRemoteServiceContainerAdapter adapter, ID target, String clazz, String filter, int sleepTime) {
 		final IRemoteServiceReference[] refs = getRemoteServiceReferences(
 				adapter, target, clazz, filter);
 		if (refs == null || refs.length == 0)
@@ -147,7 +147,7 @@
 		registerService(server, serviceName, createService(),
 				serviceProperties, sleepTime);
 		return getRemoteService(client, target, serviceName,
-				getFilterFromServiceProperties(serviceProperties));
+				getFilterFromServiceProperties(serviceProperties), sleepTime);
 	}
 
 	protected IRemoteCall createRemoteCall(final String method,
@@ -162,7 +162,7 @@
 			}
 
 			public long getTimeout() {
-				return 3000;
+				return 5000;
 			}
 		};
 	}
@@ -193,12 +193,12 @@
 			assertNotNull(namespace);
 		}
 	}
-	
+
 	public void testRegisterService() throws Exception {
 		final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
 		// adapter [0] is the service 'server'
 		final IRemoteServiceRegistration reg = registerService(adapters[0],
-				IConcatService.class.getName(), createService(), null, 1500);
+				IConcatService.class.getName(), createService(), customizeProperties(null), 0);
 		assertNotNull(reg);
 		IRemoteServiceID remoteServiceID = reg.getID();
 		assertNotNull(remoteServiceID);
@@ -209,18 +209,17 @@
 		final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
 		// adapter [0] is the service 'server'
 		final IRemoteServiceRegistration reg = registerService(adapters[0],
-				IConcatService.class.getName(), createService(), null, 1500);
+				IConcatService.class.getName(), createService(), customizeProperties(null), 0);
 		assertNotNull(reg);
 		assertNotNull(reg.getContainerID());
 
 		reg.unregister();
-
 	}
 
 	public void testGetServiceReferences() throws Exception {
 		final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
 		registerService(adapters[0], IConcatService.class.getName(),
-				createService(), null, 0);
+				createService(), customizeProperties(null), 0);
 
 		final IRemoteServiceReference[] refs = getRemoteServiceReferences(
 				adapters[1], getClient(0).getConnectedID(), IConcatService.class.getName(), null);
@@ -235,11 +234,11 @@
 		props.put("foo", "bar");
 		props.put("foo1", "bar");
 		registerService(adapters[0], IConcatService.class.getName(),
-				createService(), props, 0);
+				createService(), customizeProperties(props), 0);
 
 		final IRemoteServiceReference[] refs = getRemoteServiceReferences(
 				adapters[1], getClient(0).getConnectedID(), IConcatService.class.getName(),
-				getFilterFromServiceProperties(props));
+				getFilterFromServiceProperties(customizeProperties(props)));
 
 		assertTrue(refs != null);
 		assertTrue(refs.length > 0);
@@ -251,7 +250,7 @@
 		props.put("foo", "bar");
 		props.put("foo1", "bar");
 		registerService(adapters[0], IConcatService.class.getName(),
-				createService(), props, 0);
+				createService(), customizeProperties(props), 0);
 
 		// Create dictionary that is *not* the same as props, so the filter
 		// should miss
@@ -280,8 +279,7 @@
 	protected IRemoteService registerAndGetRemoteService() {
 		final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
 		return registerAndGetRemoteService(adapters[0], adapters[1],
-				getClient(0).getConnectedID(), IConcatService.class.getName(), null, 0);
-
+				getClient(0).getConnectedID(), IConcatService.class.getName(), customizeProperties(null), 0);
 	}
 
 	protected IRemoteCallListener createRemoteCallListener() {
@@ -344,7 +342,6 @@
 		} catch (final ECFException e) {
 			// Exception should occur
 		}
-
 	}
 
 	public void testCallAsynch() throws Exception {
@@ -410,10 +407,12 @@
 				}
 			}
 		});
+
 		// Now register service on server (adapters[0]).  This should result in notification on client (adapters[1])
 		// in above handleServiceEvent
-		adapters[0].registerRemoteService(new String[] { IConcatService.class
-				.getName() }, createService(), null);
+		adapters[0].registerRemoteService(new String[] { IConcatService.class.getName() }, createService(),
+				customizeProperties(null));
+
 		// wait until block above called asynchronously
 		int count = 0;
 		synchronized (lock) {
@@ -425,6 +424,9 @@
 				}
 			}
 		}
+
+		assertTrue(done);
+
 		if (remoteService == null) return;
 		// We've got the remote service, so we're good to go
 		assertTrue(remoteService != null);
@@ -434,4 +436,8 @@
 		traceCallEnd("callAsynch");
 		assertNotNull(result);
 	}
+
+	protected Dictionary customizeProperties(Dictionary props) {
+		return props;
+	}
 }

Back to the top