Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java39
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java68
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java67
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java13
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java72
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java51
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java1
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java9
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java4
-rw-r--r--incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java143
-rw-r--r--[-rwxr-xr-x]tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractChatTest.java32
-rw-r--r--[-rwxr-xr-x]tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractConnectTest.java6
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/datashare/ChannelTest.java14
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/remoteservice/RemoteServiceRetrieval.java84
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceProxyTest.java2
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTest.java2
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTrackerTest.java2
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice/src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java94
19 files changed, 473 insertions, 233 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
index 9c66f2572..bd1a3566d 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
@@ -58,8 +58,6 @@ public class Activator implements BundleActivator {
private ServiceRegistration endpointDescriptionFactoryRegistration;
private IExecutor executor;
-
- private LocatorServiceListener locatorServiceListener;
private ServiceTracker locatorServiceTracker;
private ServiceTracker endpointListenerServiceTracker;
@@ -69,7 +67,8 @@ public class Activator implements BundleActivator {
private LogService logService = null;
private Object logServiceTrackerLock = new Object();
-
+ private Map<IDiscoveryLocator, LocatorServiceListener> locatorListeners;
+
/*
* (non-Javadoc)
*
@@ -94,8 +93,7 @@ public class Activator implements BundleActivator {
executor = new ThreadsExecutor();
- // Create service listener
- locatorServiceListener = new LocatorServiceListener();
+ locatorListeners = new HashMap();
// Create locator service tracker
locatorServiceTracker = new ServiceTracker(context,
IDiscoveryLocator.class.getName(),
@@ -117,17 +115,23 @@ public class Activator implements BundleActivator {
void openLocator(IDiscoveryLocator locator) {
if (locator == null || context == null)
return;
- locator.addServiceListener(locatorServiceListener);
- processInitialLocatorServices(locator);
+ synchronized (locatorListeners) {
+ LocatorServiceListener locatorListener = new LocatorServiceListener(locator);
+ locatorListeners.put(locator, locatorListener);
+ processInitialLocatorServices(locator,locatorListener);
+ }
}
void shutdownLocator(IDiscoveryLocator locator) {
if (locator == null || context == null)
return;
- locator.removeServiceListener(locatorServiceListener);
+ synchronized (locatorListeners) {
+ LocatorServiceListener locatorListener = locatorListeners.remove(locator);
+ if (locatorListener != null) locatorListener.close();
+ }
}
- private void processInitialLocatorServices(final IDiscoveryLocator locator) {
+ private void processInitialLocatorServices(final IDiscoveryLocator locator, final LocatorServiceListener locatorListener) {
IProgressRunnable runnable = new IProgressRunnable() {
public Object run(IProgressMonitor arg0) throws Exception {
if (context == null)
@@ -136,7 +140,7 @@ public class Activator implements BundleActivator {
if (context == null)
return null;
for (int i = 0; i < serviceInfos.length; i++) {
- locatorServiceListener.handleService(serviceInfos[i], true);
+ locatorListener.handleService(serviceInfos[i], true);
}
return null;
}
@@ -144,6 +148,19 @@ public class Activator implements BundleActivator {
executor.execute(runnable, null);
}
+ private void shutdownLocatorListeners() {
+ synchronized (locatorListeners) {
+ for(IDiscoveryLocator l: locatorListeners.keySet()) {
+ LocatorServiceListener locatorListener = locatorListeners.get(l);
+ if (locatorListener != null) {
+ l.removeServiceListener(locatorListener);
+ locatorListener.close();
+ }
+ }
+ locatorListeners.clear();
+ }
+ }
+
void shutdownLocators() {
Object[] locators = locatorServiceTracker.getServices();
if (locators != null) {
@@ -202,7 +219,7 @@ public class Activator implements BundleActivator {
locatorServiceTracker.close();
locatorServiceTracker = null;
}
- locatorServiceListener.close();
+ shutdownLocatorListeners();
executor = null;
Activator.context = null;
Activator.instance = null;
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
index 7da6a491e..b9202384b 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
@@ -15,11 +15,13 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceEvent;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.IServiceListener;
import org.eclipse.ecf.discovery.identity.IServiceID;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator.EndpointListenerHolder;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.DiscoveredEndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionFactory;
import org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap;
@@ -39,6 +41,8 @@ class LocatorServiceListener implements IServiceListener {
private ListenerQueue queue;
private EventManager eventManager;
+ private IDiscoveryLocator locator;
+
class EndpointListenerEvent {
private EndpointListenerHolder holder;
@@ -59,16 +63,6 @@ class LocatorServiceListener implements IServiceListener {
}
}
- public LocatorServiceListener() {
- }
-
- public void serviceDiscovered(IServiceEvent anEvent) {
- synchronized (initializationLock) {
- initialize();
- }
- handleService(anEvent.getServiceInfo(), true);
- }
-
private void initialize() {
if (!initialized) {
ThreadGroup eventGroup = new ThreadGroup(
@@ -83,6 +77,8 @@ class LocatorServiceListener implements IServiceListener {
public void dispatchEvent(Object eventListener,
Object listenerObject, int eventAction,
Object eventObject) {
+ if (locator == null)
+ return;
EndpointListenerHolder endpointListenerHolder = ((EndpointListenerEvent) eventObject)
.getEndpointListenerHolder();
final boolean discovered = ((EndpointListenerEvent) eventObject)
@@ -126,8 +122,23 @@ class LocatorServiceListener implements IServiceListener {
}
}
+ public LocatorServiceListener(IDiscoveryLocator locator) {
+ this.locator = locator;
+ }
+
+ public void serviceDiscovered(IServiceEvent anEvent) {
+ synchronized (initializationLock) {
+ if (locator == null)
+ return;
+ initialize();
+ }
+ handleService(anEvent.getServiceInfo(), true);
+ }
+
public void serviceUndiscovered(IServiceEvent anEvent) {
synchronized (initializationLock) {
+ if (locator == null)
+ return;
initialize();
}
handleService(anEvent.getServiceInfo(), false);
@@ -148,13 +159,19 @@ class LocatorServiceListener implements IServiceListener {
private void handleOSGiServiceEndpoint(IServiceID serviceId,
IServiceInfo serviceInfo, boolean discovered) {
- synchronized (listenerLock) {
- EndpointDescription description = createEndpointDescription(
- serviceId, serviceInfo, discovered);
- if (description != null) {
+ if (locator == null)
+ return;
+ DiscoveredEndpointDescription discoveredEndpointDescription = getEndpointDescription(
+ serviceId, serviceInfo, discovered);
+ if (discovered) {
+ // XXX todo we check to make sure that the locator is the same one
+ }
+ if (discoveredEndpointDescription != null) {
+ synchronized (listenerLock) {
Activator.EndpointListenerHolder[] endpointListenerHolders = Activator
.getDefault().getMatchingEndpointListenerHolders(
- description);
+ discoveredEndpointDescription
+ .getEndpointDescription());
if (endpointListenerHolders != null) {
for (int i = 0; i < endpointListenerHolders.length; i++) {
queue.dispatchEventAsynchronous(0,
@@ -162,14 +179,22 @@ class LocatorServiceListener implements IServiceListener {
endpointListenerHolders[i], discovered));
}
} else {
- logError("No matching EndpointListeners found for"
+ logWarning("No matching EndpointListeners found for"
+ (discovered ? "discovered" : "undiscovered")
+ " serviceInfo=" + serviceInfo);
}
+
}
+ } else {
+ logWarning("handleOSGiServiceEvent discoveredEndpointDescription is null for service info="
+ + serviceInfo + ",discovered=" + discovered);
}
}
+ private void logWarning(String message) {
+ // XXX todo
+ }
+
private void logError(String message) {
logError(message, null);
}
@@ -181,8 +206,8 @@ class LocatorServiceListener implements IServiceListener {
}
}
- private EndpointDescription createEndpointDescription(IServiceID serviceId,
- IServiceInfo serviceInfo, boolean discovered) {
+ private DiscoveredEndpointDescription getEndpointDescription(
+ IServiceID serviceId, IServiceInfo serviceInfo, boolean discovered) {
// Get activator
Activator activator = Activator.getDefault();
if (activator == null)
@@ -200,9 +225,9 @@ class LocatorServiceListener implements IServiceListener {
// Else get endpoint description factory to create
// EndpointDescription
// for given serviceID and serviceInfo
- return (discovered) ? factory
- .createDiscoveredEndpointDescription(serviceInfo) : factory
- .getUndiscoveredEndpointDescription(serviceId);
+ return (discovered) ? factory.createDiscoveredEndpointDescription(
+ locator, serviceInfo) : factory
+ .getUndiscoveredEndpointDescription(locator, serviceId);
} catch (Exception e) {
logError("Exception calling IEndpointDescriptionFactory."
+ ((discovered) ? "createDiscoveredEndpointDescription"
@@ -228,6 +253,7 @@ class LocatorServiceListener implements IServiceListener {
}
}
}
+ locator = null;
}
}
} \ No newline at end of file
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java
index 8fbdc22e7..fa277dd3f 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java
@@ -1,18 +1,75 @@
package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceInfo;
+import org.eclipse.ecf.discovery.IServiceProperties;
import org.eclipse.ecf.discovery.identity.IServiceID;
-public abstract class AbstractEndpointDescriptionFactory extends AbstractMetadataFactory implements IEndpointDescriptionFactory {
+public abstract class AbstractEndpointDescriptionFactory extends
+ AbstractMetadataFactory implements IEndpointDescriptionFactory {
+
+ protected List<DiscoveredEndpointDescription> discoveredEndpointDescriptions = new ArrayList();
- public EndpointDescription createDiscoveredEndpointDescription(
- IServiceInfo discoveredServiceInfo) {
+ private DiscoveredEndpointDescription findDiscoveredEndpointDescription(
+ EndpointDescription endpointDescription) {
+ synchronized (discoveredEndpointDescriptions) {
+ for (DiscoveredEndpointDescription d : discoveredEndpointDescriptions) {
+ EndpointDescription ed = d.getEndpointDescription();
+ if (ed.equals(endpointDescription))
+ return d;
+ }
+ }
return null;
}
- public EndpointDescription getUndiscoveredEndpointDescription(
- IServiceID serviceID) {
+ public DiscoveredEndpointDescription createDiscoveredEndpointDescription(
+ IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo) {
+ try {
+ EndpointDescription endpointDescription = createEndpointDescription(
+ locator, discoveredServiceInfo);
+ synchronized (discoveredEndpointDescriptions) {
+ DiscoveredEndpointDescription ded = findDiscoveredEndpointDescription(endpointDescription);
+ if (ded != null) return ded;
+ else return createDiscoveredEndpointDescription(locator,discoveredServiceInfo,endpointDescription);
+ }
+ } catch (Exception e) {
+ logError("createDiscoveredEndpointDescription",
+ "Exception creating discovered endpoint description", e);
+ return null;
+ }
+ }
+
+ public DiscoveredEndpointDescription getUndiscoveredEndpointDescription(
+ IDiscoveryLocator locator, IServiceID serviceID) {
+ // XXX todo
return null;
}
+ protected EndpointDescription createEndpointDescription(
+ IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo) {
+ IServiceProperties discoveredServiceProperties = discoveredServiceInfo
+ .getServiceProperties();
+ Map props = decodeServiceProperties(discoveredServiceProperties);
+ return new EndpointDescription(props);
+
+ }
+
+ protected DiscoveredEndpointDescription createDiscoveredEndpointDescription(
+ IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo,
+ EndpointDescription endpointDescription) {
+ return new DiscoveredEndpointDescription(
+ locator.getServicesNamespace(), discoveredServiceInfo.getServiceID(), endpointDescription);
+ }
+
+
+ public void close() {
+ synchronized (discoveredEndpointDescriptions) {
+ discoveredEndpointDescriptions.clear();
+ }
+ super.close();
+ }
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
index abf5d7406..b4e9429be 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
@@ -13,6 +13,8 @@ import java.util.StringTokenizer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
+import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.IServiceProperties;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
@@ -39,7 +41,6 @@ public abstract class AbstractMetadataFactory {
RemoteConstants.ENDPOINT_REMOTESERVICEFILTER
});
-
protected String[] getStringArrayWithDefault(
Map<String, Object> properties, String key, String[] def) {
if (properties == null)
@@ -144,14 +145,8 @@ public abstract class AbstractMetadataFactory {
return (ID[]) result.toArray(new ID[] {});
}
- protected ID createID(String namespace, String name) {
- try {
- return IDFactory.getDefault().createID(namespace, name);
- } catch (IDCreateException e) {
- logError("createID", "Exception creating id for namespace="
- + namespace + ",name=" + name, e);
- return null;
- }
+ protected ID createID(String namespace, String name) throws IDCreateException {
+ return IDFactory.getDefault().createID(namespace, name);
}
protected Map decodeServiceProperties(IServiceProperties props) {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
index 1efb90480..e491f8646 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
@@ -51,42 +51,46 @@ public abstract class AbstractServiceInfoFactory extends
}
public IServiceInfo createServiceInfoForDiscovery(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser) {
- Namespace advertiserNamespace = advertiser.getServicesNamespace();
- ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
- advertiserNamespace);
- IServiceInfo existingServiceInfo = null;
- synchronized (serviceInfos) {
- existingServiceInfo = serviceInfos.get(key);
- // If it's already there, then we return null
- if (existingServiceInfo != null)
- return null;
- IServiceTypeID serviceTypeID = createServiceTypeID(
- endpointDescription, advertiser);
- String serviceName = createServiceName(endpointDescription,
- advertiser, serviceTypeID);
- URI uri = null;
- try {
- uri = createURI(endpointDescription, advertiser, serviceTypeID,
- serviceName);
- } catch (URISyntaxException e) {
- String message = "URI could not be created for endpoint description="
- + endpointDescription;
- logError("createURI", message, e);
- throw new RuntimeException(message, e);
+ IDiscoveryAdvertiser advertiser,
+ EndpointDescription endpointDescription) {
+ try {
+ Namespace advertiserNamespace = advertiser.getServicesNamespace();
+ ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
+ advertiserNamespace);
+ IServiceInfo existingServiceInfo = null;
+ synchronized (serviceInfos) {
+ existingServiceInfo = serviceInfos.get(key);
+ // If it's already there, then we return null
+ if (existingServiceInfo != null)
+ return null;
+ IServiceTypeID serviceTypeID = createServiceTypeID(
+ endpointDescription, advertiser);
+ String serviceName = createServiceName(endpointDescription,
+ advertiser, serviceTypeID);
+ URI uri = createURI(endpointDescription, advertiser,
+ serviceTypeID, serviceName);
+ IServiceProperties serviceProperties = createServiceProperties(
+ endpointDescription, advertiser, serviceTypeID,
+ serviceName, uri);
+ IServiceInfo newServiceInfo = createServiceInfo(uri, serviceName, serviceTypeID, serviceProperties);
+ // put into map using key
+ serviceInfos.put(key, newServiceInfo);
+ return newServiceInfo;
}
- IServiceProperties serviceProperties = createServiceProperties(
- endpointDescription, advertiser, serviceTypeID,
- serviceName, uri);
- IServiceInfo newServiceInfo = new ServiceInfo(uri, serviceName,
- serviceTypeID, serviceProperties);
- // put into map using key
- serviceInfos.put(key, newServiceInfo);
- return newServiceInfo;
+ } catch (Exception e) {
+ logError(
+ "createServiceInfoForDiscovery",
+ "Exception creating service info for endpointDescription="
+ + endpointDescription + ",advertiser=" + advertiser,
+ e);
+ return null;
}
}
+ protected IServiceInfo createServiceInfo(URI uri, String serviceName, IServiceTypeID serviceTypeID, IServiceProperties serviceProperties) {
+ return new ServiceInfo(uri, serviceName,
+ serviceTypeID, serviceProperties);
+ }
protected IServiceProperties createServiceProperties(
EndpointDescription endpointDescription,
@@ -184,8 +188,8 @@ public abstract class AbstractServiceInfoFactory extends
}
public IServiceInfo removeServiceInfoForUndiscovery(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser) {
+ IDiscoveryAdvertiser advertiser,
+ EndpointDescription endpointDescription) {
Namespace advertiserNamespace = advertiser.getServicesNamespace();
ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
advertiserNamespace);
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java
new file mode 100644
index 000000000..4afdf59ec
--- /dev/null
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java
@@ -0,0 +1,51 @@
+package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.discovery.identity.IServiceID;
+
+public class DiscoveredEndpointDescription {
+
+ private Namespace discoveryLocatorNamespace;
+ private IServiceID serviceID;
+ private EndpointDescription endpointDescription;
+ private int hashCode = 7;
+
+ public DiscoveredEndpointDescription(Namespace discoveryLocatorNamespace, IServiceID serviceID,
+ EndpointDescription endpointDescription) {
+ this.discoveryLocatorNamespace = discoveryLocatorNamespace;
+ this.serviceID = serviceID;
+ this.endpointDescription = endpointDescription;
+ this.hashCode = 31 * this.hashCode
+ + discoveryLocatorNamespace.getName().hashCode();
+ this.hashCode = 31 * this.hashCode + endpointDescription.hashCode();
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public boolean equals(Object other) {
+ if (other == null)
+ return false;
+ if (other == this)
+ return true;
+ if (!(other instanceof DiscoveredEndpointDescription))
+ return false;
+ DiscoveredEndpointDescription o = (DiscoveredEndpointDescription) other;
+ return (this.discoveryLocatorNamespace
+ .equals(o.discoveryLocatorNamespace) && this.endpointDescription
+ .equals(o.endpointDescription));
+ }
+
+ public Namespace getDiscoveryLocatorNamespace() {
+ return discoveryLocatorNamespace;
+ }
+
+ public IServiceID getServiceID() {
+ return serviceID;
+ }
+
+ public EndpointDescription getEndpointDescription() {
+ return endpointDescription;
+ }
+}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
index 3cd765127..e0e3cd1fa 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
@@ -73,6 +73,7 @@ public class EndpointDescription extends
public boolean equals(Object other) {
if (other == null)
return false;
+ if (other == this) return true;
if (!(other instanceof EndpointDescription))
return false;
EndpointDescription o = (EndpointDescription) other;
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java
index a0d737f0e..69b9aa2f0 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.identity.IServiceID;
@@ -20,23 +21,25 @@ public interface IEndpointDescriptionFactory {
* associated distribution system (e.g. ECFEndpointDescription). Implementers should return
* <code>null</code> if no notification should occur.
*
+ * @param locator the locator responsible for the discoveredServiceInfo. Must not be <code>null</code>.
* @param discoveredServiceInfo the discovered service info. Must not be <code>null</code>.
- * @return EndpointDescription that will be used to notify EndpointListeners
+ * @return DiscoveredEndpointDescription that will be used to notify EndpointListeners
* about a new EndpointDescription. If <code>null</code> is returned, no
* notification should be performed by the calling code.
*/
- public EndpointDescription createDiscoveredEndpointDescription(IServiceInfo discoveredServiceInfo);
+ public DiscoveredEndpointDescription createDiscoveredEndpointDescription(IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo);
/**
* Get an EndpointDescription for an undiscovered remote service. Implementers of this
* factory service may return the type of EndpointDescription appropriate for the
* associated distribution system (e.g. ECFEndpointDescription). Implementers should return
* <code>null</code> if no notification should occur.
*
+ * @param locator the locator responsible for the discoveredServiceInfo. Must not be <code>null</code>.
* @param serviceId the discovered service ID. Must not be <code>null</code>.
* @return EndpointDescription that will be used to notify EndpointListeners
* about an undiscovered EndpointDescription. If <code>null</code> is returned, no
* notification should be performed by the calling code.
*/
- public EndpointDescription getUndiscoveredEndpointDescription(IServiceID serviceID);
+ public DiscoveredEndpointDescription getUndiscoveredEndpointDescription(IDiscoveryLocator locator, IServiceID serviceID);
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
index 6e7d0648e..ecc7a2820 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
@@ -5,8 +5,8 @@ import org.eclipse.ecf.discovery.IServiceInfo;
public interface IServiceInfoFactory {
- public IServiceInfo createServiceInfoForDiscovery(EndpointDescription endpointDescription, IDiscoveryAdvertiser advertiser);
+ public IServiceInfo createServiceInfoForDiscovery(IDiscoveryAdvertiser advertiser, EndpointDescription endpointDescription);
- public IServiceInfo removeServiceInfoForUndiscovery(EndpointDescription endpointDescription, IDiscoveryAdvertiser advertiser);
+ public IServiceInfo removeServiceInfoForUndiscovery(IDiscoveryAdvertiser advertiser, EndpointDescription endpointDescription);
}
diff --git a/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java b/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
index d94d4c851..12ba47a7a 100644
--- a/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
@@ -72,6 +72,7 @@ public class Activator implements BundleActivator {
return result;
}
+
private void testParseServiceDescription() {
try {
URL file = context.getBundle().getEntry("/endpointdescription1.xml");
@@ -84,7 +85,7 @@ public class Activator implements BundleActivator {
Map props = convertProperties(d.getProperties());
EndpointDescription ed = new EndpointDescription(props);
System.out.println("endpoint description="+ed);
- IServiceInfo serviceInfo = serviceInfoFactory.createServiceInfoForDiscovery(ed,null);
+ IServiceInfo serviceInfo = serviceInfoFactory.createServiceInfoForDiscovery(null, ed);
System.out.println("serviceInfo="+serviceInfo);
}
} catch (Exception e) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
index dfdd989ef..a639c48d7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
@@ -240,17 +240,18 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
}
// Add to local registry
final RemoteServiceRegistrationImpl reg = new RemoteServiceRegistrationImpl();
- reg.publish(this, localRegistry, service, clazzes, properties);
-
- // Only send add registrations if we are connected
- if (isConnected()) {
- final ID[] targets = getTargetsFromProperties(properties);
- RemoteServiceRegistrationImpl[] regs = new RemoteServiceRegistrationImpl[] {reg};
- if (targets == null)
- sendAddRegistrations(null, null, regs);
- else
- for (int i = 0; i < targets.length; i++)
- sendAddRegistrations(targets[i], null, regs);
+ synchronized (localRegistry) {
+ reg.publish(this, localRegistry, service, clazzes, properties);
+ // Only send add registrations if we are connected
+ if (isConnected()) {
+ final ID[] targets = getTargetsFromProperties(properties);
+ RemoteServiceRegistrationImpl[] regs = new RemoteServiceRegistrationImpl[] {reg};
+ if (targets == null)
+ sendAddRegistrations(null, null, regs);
+ else
+ for (int i = 0; i < targets.length; i++)
+ sendAddRegistrations(targets[i], null, regs);
+ }
}
fireRemoteServiceListeners(createRegisteredEvent(reg));
@@ -455,6 +456,10 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
synchronized (registryUpdateRequests) {
registryUpdateRequests.clear();
}
+ synchronized (localRegistry) {
+ localRegistry.unpublishServices();
+ localRegistryUnregistrationTargets.clear();
+ }
super.dispose(containerID);
}
@@ -516,22 +521,9 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
// Skip if the targetContainerID is null
if (targetContainerID == null)
continue;
- RemoteServiceRegistryImpl remoteRegistryForContainer = null;
- // No change to the registrys while we look for the appropriate registry
- synchronized (remoteRegistrys) {
- remoteRegistryForContainer = (RemoteServiceRegistryImpl) remoteRegistrys.get(targetContainerID);
- // If one is found, then we simply add any entrys to referencesFound and we're done
- // for that container
- if (remoteRegistryForContainer != null) {
- addReferencesFromRegistry(clazz, remoteFilter, remoteRegistryForContainer, referencesFound);
- continue;
- }
- }
- // This block is only reached if remoteRegistryForContainer is null
sendRegistryUpdateRequestAndWait(targetContainerID);
- // Now we check remoteRegistrys again
synchronized (remoteRegistrys) {
- remoteRegistryForContainer = (RemoteServiceRegistryImpl) remoteRegistrys.get(targetContainerID);
+ RemoteServiceRegistryImpl remoteRegistryForContainer = (RemoteServiceRegistryImpl) remoteRegistrys.get(targetContainerID);
if (remoteRegistryForContainer != null)
addReferencesFromRegistry(clazz, remoteFilter, remoteRegistryForContainer, referencesFound);
}
@@ -1203,6 +1195,12 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
Trace.entering(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_ENTERING, this.getClass(), "sendAddRegistrations", new Object[] {receiver, requestId, regs}); //$NON-NLS-1$
try {
sendSharedObjectMsgTo(receiver, SharedObjectMsg.createMsg(null, ADD_REGISTRATIONS, getLocalContainerID(), requestId, regs));
+ // if the receiver is in response to an explicit remote request (receiver != null && requestId != null)
+ // then for all registrations add a target for unregistration, so that upon unregistration we can
+ if (receiver != null && requestId != null) {
+ for (int i = 0; i < regs.length; i++)
+ addTargetForUnregister(regs[i], receiver);
+ }
} catch (final IOException e) {
log(ADD_REGISTRATION_ERROR_CODE, ADD_REGISTRATION_ERROR_MESSAGE, e);
}
@@ -1600,6 +1598,44 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
Trace.exiting(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_EXITING, this.getClass(), FIRE_REQUEST);
}
+ // RemoteServiceRegistrationImpl -> List<ID>
+ private Map localRegistryUnregistrationTargets = new HashMap();
+
+ private void addTargetForUnregister(RemoteServiceRegistrationImpl serviceRegistration, ID targetContainerID) {
+ List existingTargets = (List) localRegistryUnregistrationTargets.get(serviceRegistration);
+ if (existingTargets == null) {
+ existingTargets = new ArrayList();
+ }
+ existingTargets.add(targetContainerID);
+ Trace.trace(Activator.PLUGIN_ID, "addTargetForUnregister localContainerID=" + getLocalContainerID() + ",targetContainerID=" + targetContainerID + ",serviceRegistration=" + serviceRegistration); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ localRegistryUnregistrationTargets.put(serviceRegistration, existingTargets);
+ }
+
+ private void sendUnregisterToTargets(RemoteServiceRegistrationImpl serviceRegistration, ID[] otherTargets) {
+ List allTargets = new ArrayList();
+ // First add in otherTargets
+ if (otherTargets != null) {
+ allTargets.addAll(Arrays.asList(otherTargets));
+ }
+ // Then add any explicitly registered targets
+ List registeredTargets = (List) localRegistryUnregistrationTargets.remove(serviceRegistration);
+ if (registeredTargets != null) {
+ allTargets.addAll(registeredTargets);
+ }
+ // Now allTargets should have all the container IDs of unregistration messages so we send to all
+ for (Iterator i = allTargets.iterator(); i.hasNext();) {
+ ID unregistrationTarget = (ID) i.next();
+ ID registrationLocalContainerID = serviceRegistration.getContainerID();
+ Long serviceId = new Long(serviceRegistration.getServiceId());
+ Trace.trace(Activator.PLUGIN_ID, "sendUnregisterToTargets " + "localContainerID=" + getLocalContainerID() + ",targetContainerID=" + unregistrationTarget + ",serviceRegistration=" + serviceRegistration); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ try {
+ this.sendSharedObjectMsgTo(unregistrationTarget, SharedObjectMsg.createMsg(UNREGISTER, new Object[] {registrationLocalContainerID, serviceId}));
+ } catch (final IOException e) {
+ log(UNREGISTER_ERROR_CODE, UNREGISTER_ERROR_MESSAGE, e);
+ }
+ }
+ }
+
protected void sendUnregister(RemoteServiceRegistrationImpl serviceRegistration) {
Trace.entering(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_ENTERING, this.getClass(), "sendUnregister", new Object[] {serviceRegistration}); //$NON-NLS-1$
synchronized (localRegistry) {
@@ -1616,21 +1652,41 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
} catch (final IOException e) {
log(UNREGISTER_ERROR_CODE, UNREGISTER_ERROR_MESSAGE, e);
}
- } else
- // Send an unregister message to all targetIds
- for (int i = 0; i < targetIds.length; i++) {
- try {
- this.sendSharedObjectMsgTo(targetIds[i], SharedObjectMsg.createMsg(UNREGISTER, new Object[] {containerID, serviceId}));
- } catch (final IOException e) {
- log(UNREGISTER_ERROR_CODE, UNREGISTER_ERROR_MESSAGE, e);
- }
- }
+ }
+ // And send unregister explicitly to targets
+ sendUnregisterToTargets(serviceRegistration, targetIds);
}
}
fireRemoteServiceListeners(createUnregisteredEvent(serviceRegistration));
Trace.exiting(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_EXITING, this.getClass(), "sendUnregister"); //$NON-NLS-1$
}
+ protected void handleUnregister(ID containerID, Long serviceId) {
+ Trace.entering(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_ENTERING, this.getClass(), "handleUnregister", new Object[] {containerID, serviceId}); //$NON-NLS-1$
+ RemoteServiceRegistrationImpl registration = null;
+ synchronized (remoteRegistrys) {
+ // get registry for given containerID
+ final RemoteServiceRegistryImpl serviceRegistry = (RemoteServiceRegistryImpl) remoteRegistrys.get(containerID);
+ if (serviceRegistry != null) {
+ registration = serviceRegistry.findRegistrationForServiceId(serviceId.longValue());
+ if (registration != null) {
+ serviceRegistry.unpublishService(registration);
+ unregisterServiceRegistrationsForContainer(registration.getContainerID());
+ // If there are no remaining registration for this remote service registry,
+ // then remove the registry from the remoteRegistrys
+ RemoteServiceRegistrationImpl[] registrations = serviceRegistry.getRegistrations();
+ Trace.trace(Activator.PLUGIN_ID, "handleUnregister localContainerID=" + getLocalContainerID() + ",registrationRemoved=" + registration + ",containerID=" + containerID); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (registrations.length == 0) {
+ remoteRegistrys.remove(containerID);
+ }
+ }
+ }
+ }
+ if (registration != null)
+ fireRemoteServiceListeners(createUnregisteredEvent(registration));
+ Trace.exiting(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_EXITING, this.getClass(), "handleUnregister"); //$NON-NLS-1$
+ }
+
/**
* @since 3.2
*/
@@ -1662,25 +1718,6 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
}
}
- protected void handleUnregister(ID containerID, Long serviceId) {
- Trace.entering(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_ENTERING, this.getClass(), "handleUnregister", new Object[] {containerID, serviceId}); //$NON-NLS-1$
- RemoteServiceRegistrationImpl registration = null;
- synchronized (remoteRegistrys) {
- // get registry for given containerID
- final RemoteServiceRegistryImpl serviceRegistry = (RemoteServiceRegistryImpl) remoteRegistrys.get(containerID);
- if (serviceRegistry != null) {
- registration = serviceRegistry.findRegistrationForServiceId(serviceId.longValue());
- if (registration != null) {
- serviceRegistry.unpublishService(registration);
- unregisterServiceRegistrationsForContainer(registration.getContainerID());
- }
- }
- }
- if (registration != null)
- fireRemoteServiceListeners(createUnregisteredEvent(registration));
- Trace.exiting(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_EXITING, this.getClass(), "handleUnregister"); //$NON-NLS-1$
- }
-
protected IRemoteServiceUnregisteredEvent createUnregisteredEvent(final RemoteServiceRegistrationImpl registration) {
return new IRemoteServiceUnregisteredEvent() {
diff --git a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractChatTest.java b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractChatTest.java
index 659400c3e..30ccd3f04 100755..100644
--- a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractChatTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractChatTest.java
@@ -30,14 +30,18 @@ import org.eclipse.ecf.presence.im.IChatMessageEvent;
public abstract class AbstractChatTest extends AbstractPresenceTestCase {
IChatManager chat0, chat1 = null;
- public static final int WAITTIME = 3000;
+ public static final int SLEEPTIME = new Integer(
+ System.getProperty(
+ "org.eclipse.ecf.tests.presence.AbstractChatTest.SLEEPTIME",
+ "5000")).intValue();
List receivedChatMessages = new ArrayList();
IIMMessageListener listener = new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatMessageEvent) {
- final IChatMessage chatmessage = ((IChatMessageEvent) messageEvent).getChatMessage();
+ final IChatMessage chatmessage = ((IChatMessageEvent) messageEvent)
+ .getChatMessage();
System.out.println("received chat message=" + chatmessage);
receivedChatMessages.add(chatmessage);
}
@@ -58,7 +62,6 @@ public abstract class AbstractChatTest extends AbstractPresenceTestCase {
chat1.addMessageListener(listener);
for (int i = 0; i < 2; i++) {
connectClient(i);
- sleep(WAITTIME);
}
}
@@ -73,9 +76,9 @@ public abstract class AbstractChatTest extends AbstractPresenceTestCase {
}
public void testSendIM() throws Exception {
- sleep(WAITTIME);
- chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), "abcdef");
- sleep(WAITTIME);
+ chat0.getChatMessageSender().sendChatMessage(
+ getClient(1).getConnectedID(), "abcdef");
+ sleep(SLEEPTIME);
assertHasEvent(receivedChatMessages, IChatMessage.class);
final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
assertTrue(message.getBody().equals("abcdef"));
@@ -87,13 +90,15 @@ public abstract class AbstractChatTest extends AbstractPresenceTestCase {
}
public void testSendIM2() throws Exception {
- sleep(WAITTIME);
final Map sendprops = new HashMap();
sendprops.put("prop1", "this");
- final ID sendthreadid = IDFactory.getDefault().createStringID("thread1");
+ final ID sendthreadid = IDFactory.getDefault()
+ .createStringID("thread1");
// Send the whole thing
- chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), sendthreadid, IChatMessage.Type.CHAT, "subject1", "uvwxyz", sendprops);
- sleep(WAITTIME);
+ chat0.getChatMessageSender().sendChatMessage(
+ getClient(1).getConnectedID(), sendthreadid,
+ IChatMessage.Type.CHAT, "subject1", "uvwxyz", sendprops);
+ sleep(SLEEPTIME);
assertHasEvent(receivedChatMessages, IChatMessage.class);
final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
@@ -111,12 +116,13 @@ public abstract class AbstractChatTest extends AbstractPresenceTestCase {
}
public void testSendMessageProperties() throws Exception {
- sleep(WAITTIME);
final Map sendprops = new HashMap();
sendprops.put("prop2", "that");
// Send the whole thing
- chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), null, IChatMessage.Type.CHAT, null, null, sendprops);
- sleep(WAITTIME);
+ chat0.getChatMessageSender().sendChatMessage(
+ getClient(1).getConnectedID(), null, IChatMessage.Type.CHAT,
+ null, null, sendprops);
+ sleep(SLEEPTIME);
assertHasEvent(receivedChatMessages, IChatMessage.class);
final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
diff --git a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractConnectTest.java b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractConnectTest.java
index cd864677e..e1062fa06 100755..100644
--- a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractConnectTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/AbstractConnectTest.java
@@ -20,7 +20,9 @@ import org.eclipse.ecf.core.identity.ID;
public abstract class AbstractConnectTest extends AbstractPresenceTestCase {
public static final int CLIENT_COUNT = 2;
- public static final int WAITTIME = 3000;
+ public static final int SLEEPTIME = new Integer(System.getProperty(
+ "org.eclipse.ecf.tests.presence.AbstractConnectTest.SLEEPTIME", "1000"))
+ .intValue();
protected void setUp() throws Exception {
super.setUp();
@@ -36,7 +38,7 @@ public abstract class AbstractConnectTest extends AbstractPresenceTestCase {
assertNotNull(serverConnectID);
connectClient(client, serverConnectID, getConnectContext(clientIndex));
assertEquals(serverConnectID, client.getConnectedID());
- sleep(WAITTIME);
+ sleep(SLEEPTIME);
client.disconnect();
assertNull(client.getConnectedID());
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/datashare/ChannelTest.java b/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/datashare/ChannelTest.java
index fd4771965..a1a529a59 100644
--- a/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/datashare/ChannelTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/datashare/ChannelTest.java
@@ -26,6 +26,8 @@ public class ChannelTest extends ContainerAbstractTestCase {
private static final String CHANNEL_NAME = "channel";
+ private static final int SLEEPTIME = new Integer(System.getProperty("org.eclipse.ecf.tests.provider.xmpp.datashare.ChannelTest.SLEEPTIME","5000")).intValue();
+
private static final int SEND_MESSAGE_COUNT = 5;
private ID channelID;
@@ -65,7 +67,7 @@ public class ChannelTest extends ContainerAbstractTestCase {
*/
protected void tearDown() throws Exception {
// This is a possible workaround for what appears to be Smack bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=321032
- Thread.sleep(2000);
+ Thread.sleep(SLEEPTIME);
cleanUpClients();
super.tearDown();
}
@@ -74,7 +76,7 @@ public class ChannelTest extends ContainerAbstractTestCase {
final IChannel ch0 = getChannelContainer(0).getChannel(channelID);
ID target1 = getClient(1).getConnectedID();
ch0.sendMessage(target1, new String("hello").getBytes());
- sleep(3000);
+ sleep(SLEEPTIME);
}
public void testBiSendMessage() throws Exception {
@@ -86,7 +88,7 @@ public class ChannelTest extends ContainerAbstractTestCase {
ch0.sendMessage(target1, new String("hello").getBytes());
ch1.sendMessage(target0, new String("hello").getBytes());
- sleep(3000);
+ sleep(SLEEPTIME);
}
@@ -95,9 +97,8 @@ public class ChannelTest extends ContainerAbstractTestCase {
ID target1 = getClient(1).getConnectedID();
for(int i=0; i < SEND_MESSAGE_COUNT; i++) {
ch0.sendMessage(target1, new String("hello. msg#="+i).getBytes());
- sleep(500);
}
- sleep(3000);
+ sleep(SLEEPTIME);
}
public void testBiSendMessages() throws Exception {
@@ -109,10 +110,9 @@ public class ChannelTest extends ContainerAbstractTestCase {
for(int i=0; i < SEND_MESSAGE_COUNT; i++) {
ch0.sendMessage(target1, new String("hello. msg#="+i).getBytes());
- sleep(500);
ch1.sendMessage(target0, new String("hello. msg#="+i).getBytes());
}
- sleep(3000);
+ sleep(SLEEPTIME);
}
protected IChannelListener getIChannelListener(final ID containerid) throws Exception {
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/remoteservice/RemoteServiceRetrieval.java b/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/remoteservice/RemoteServiceRetrieval.java
index dca613ac1..e97bdc353 100644
--- a/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/remoteservice/RemoteServiceRetrieval.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.xmpp/src/org/eclipse/ecf/tests/provider/xmpp/remoteservice/RemoteServiceRetrieval.java
@@ -18,6 +18,7 @@ import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.ContainerFactory;
import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.security.ConnectContextFactory;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.util.ECFException;
@@ -25,6 +26,7 @@ import org.eclipse.ecf.provider.xmpp.identity.XMPPID;
import org.eclipse.ecf.remoteservice.IRemoteService;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
+import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
import org.eclipse.ecf.tests.provider.xmpp.XMPPS;
import org.osgi.framework.InvalidSyntaxException;
@@ -32,6 +34,11 @@ public class RemoteServiceRetrieval extends TestCase {
private XMPPClient[] xmppClients;
+ private static final int SLEEPTIME = new Integer(
+ System.getProperty(
+ "org.eclipse.ecf.tests.provider.xmpp.remoteservice.RemoteServiceRetrieval.SLEEPTIME",
+ "6000")).intValue();
+
public void setUp() {
try {
createXMPPClients();
@@ -57,8 +64,7 @@ public class RemoteServiceRetrieval extends TestCase {
/*
* Make sure that the right service is returned for the right client.
*/
- public void testRightServiceForClients() throws InvalidSyntaxException,
- ECFException {
+ public void testRightServiceForClients() throws Exception {
// Client 1 tries to retrieve services registered by client 2 & 3
IExampleService remoteService1 = getClient(0).getRemoteService(
@@ -94,21 +100,26 @@ public class RemoteServiceRetrieval extends TestCase {
assertEquals(getClient(1).getClientID(), remoteService6.getClientID());
}
- public void testConnectAndDisconnectClients() throws ECFException,
- InvalidSyntaxException {
+ public void testRegisterAndUnregisterRemoteServices() throws Exception {
// Client 0 tries to get service from client 1
IExampleService remoteService1 = getClient(0).getRemoteService(
getClient(1));
assertNotNull(remoteService1);
-
- // disconnect client 1, no services available for client 1
- getClient(1).disconnect();
+ // unregister remote service on client 1, no services available for
+ // client 1
+ getClient(1).unregisterRemoteService();
+ // wait for unregistration to propogate
+ Thread.sleep(SLEEPTIME);
+ // Now lookup and make sure the reference is now null
IExampleService remoteService2 = getClient(0).getRemoteService(
getClient(1));
assertNull(remoteService2);
- // connect client 1 again, services are available again
- getClient(1).connect();
+ // register remote service on client 1
+ registerRemoteServiceOnClient(getClient(1));
+ // wait for registration to propogate
+ Thread.sleep(SLEEPTIME);
+
IExampleService remoteService3 = getClient(0).getRemoteService(
getClient(1));
assertNotNull(remoteService3);
@@ -118,27 +129,18 @@ public class RemoteServiceRetrieval extends TestCase {
* Remote service registration without filterIDs.
*/
private void registerRemoteServicesNoFilterIDs() {
- IExampleService clientService1 = new ExampleService(getClient(0)
- .getClientID());
- IExampleService clientService2 = new ExampleService(getClient(1)
- .getClientID());
- IExampleService clientService3 = new ExampleService(getClient(2)
- .getClientID());
-
- getClient(0).getRemoteServiceAdapter().registerRemoteService(
- new String[] { IExampleService.class.getName() },
- clientService1, null);
- getClient(1).getRemoteServiceAdapter().registerRemoteService(
- new String[] { IExampleService.class.getName() },
- clientService2, null);
- getClient(2).getRemoteServiceAdapter().registerRemoteService(
- new String[] { IExampleService.class.getName() },
- clientService3, null);
+ registerRemoteServiceOnClient(getClient(0));
+ registerRemoteServiceOnClient(getClient(1));
+ registerRemoteServiceOnClient(getClient(2));
+ }
+
+ private void registerRemoteServiceOnClient(XMPPClient client) {
+ client.registerRemoteService(IExampleService.class.getName(), new ExampleService(client.getClientID()));
}
public void tearDown() {
for (int clientNumber = 0; clientNumber <= 2; clientNumber++) {
- getClient(clientNumber).disconnect();
+ getClient(clientNumber).tearDown();
}
}
@@ -169,6 +171,7 @@ public class RemoteServiceRetrieval extends TestCase {
private XMPPID clientID;
private IConnectContext connectContext;
private IRemoteServiceContainerAdapter adapter;
+ private IRemoteServiceRegistration registration;
public XMPPClient(String username, String password)
throws ContainerCreateException, URISyntaxException {
@@ -188,8 +191,15 @@ public class RemoteServiceRetrieval extends TestCase {
assertNotNull(connectContext);
}
- IRemoteServiceContainerAdapter getRemoteServiceAdapter() {
- return adapter;
+ void tearDown() {
+ unregisterRemoteService();
+ try {
+ Thread.sleep(SLEEPTIME);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ container.disconnect();
}
XMPPID getClientID() {
@@ -200,15 +210,27 @@ public class RemoteServiceRetrieval extends TestCase {
container.connect(clientID, connectContext);
}
- void disconnect() {
- container.disconnect();
+ public void registerRemoteService(String svcInterface, Object svc) {
+ this.registration = adapter.registerRemoteService(
+ new String[] { svcInterface }, svc, null);
+ }
+
+ void unregisterRemoteService() {
+ if (registration != null) {
+ // unregister the remote service registration
+ registration.unregister();
+ }
}
private IExampleService getRemoteService(XMPPClient toClient)
throws InvalidSyntaxException, ECFException {
IRemoteServiceReference[] remoteServiceReferences = adapter
- .getRemoteServiceReferences(toClient.getClientID(),
+ .getRemoteServiceReferences(
+ new ID[] { toClient.getClientID() },
IExampleService.class.getName(), null);
+ if (remoteServiceReferences == null
+ || remoteServiceReferences.length == 0)
+ return null;
assertEquals(1, remoteServiceReferences.length);
IRemoteService remoteService = adapter
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceProxyTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceProxyTest.java
index f0d4a969e..d7635298c 100644
--- a/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceProxyTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceProxyTest.java
@@ -161,7 +161,7 @@ public class RemoteServiceProxyTest extends AbstractRemoteServiceTest {
.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
traceCallEnd("callAsynch");
assertNotNull(result);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTest.java
index def61ac4a..276bb87ff 100644
--- a/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTest.java
@@ -103,7 +103,7 @@ public class RemoteServiceTest extends AbstractRemoteServiceTest {
.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
traceCallEnd("callAsynch");
assertNotNull(result);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTrackerTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTrackerTest.java
index 28a873124..306bcec07 100644
--- a/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTrackerTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.generic/src/org/eclipse/ecf/tests/remoteservice/generic/RemoteServiceTrackerTest.java
@@ -147,7 +147,7 @@ public class RemoteServiceTrackerTest extends AbstractRemoteServiceTest {
.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
traceCallEnd("callAsynch");
assertNotNull(result);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice/src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice/src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java
index ce593a0fc..8e309f626 100644
--- a/tests/bundles/org.eclipse.ecf.tests.remoteservice/src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice/src/org/eclipse/ecf/tests/remoteservice/AbstractRemoteServiceTest.java
@@ -40,7 +40,9 @@ import org.osgi.framework.InvalidSyntaxException;
public abstract class AbstractRemoteServiceTest extends
ContainerAbstractTestCase {
- protected static final long ASYNC_WAITTIME = new Long(System.getProperty("org.eclipse.ecf.tests.remoteservice.asyncWaittime","3000")).longValue();
+ protected static final int SLEEPTIME = new Integer(System.getProperty(
+ "org.eclipse.ecf.tests.remoteservice.AbstractRemoteServiceTest.SLEEPTIME", "5000"))
+ .intValue();
protected IRemoteServiceContainerAdapter[] adapters = null;
@@ -48,7 +50,7 @@ public abstract class AbstractRemoteServiceTest extends
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.ecf.tests.ContainerAbstractTestCase#getClientContainerName()
*/
@@ -61,7 +63,8 @@ public abstract class AbstractRemoteServiceTest extends
}
protected void setupRemoteServiceAdapters() throws Exception {
- if (server != null) server.getAdapter(IRemoteServiceContainerAdapter.class);
+ if (server != null)
+ server.getAdapter(IRemoteServiceContainerAdapter.class);
final int clientCount = getClientCount();
for (int i = 0; i < clientCount; i++) {
adapters[i] = (IRemoteServiceContainerAdapter) getClients()[i]
@@ -73,10 +76,12 @@ public abstract class AbstractRemoteServiceTest extends
return adapters;
}
- protected IRemoteServiceListener createRemoteServiceListener(final boolean server) {
+ protected IRemoteServiceListener createRemoteServiceListener(
+ final boolean server) {
return new IRemoteServiceListener() {
public void handleServiceEvent(IRemoteServiceEvent event) {
- System.out.println((server?"server":"client")+"handleServiceEvent(" + event + ")");
+ System.out.println((server ? "server" : "client")
+ + "handleServiceEvent(" + event + ")");
if (event instanceof IRemoteServiceRegisteredEvent) {
if (server) {
ids[0] = event.getReference().getID();
@@ -90,7 +95,8 @@ public abstract class AbstractRemoteServiceTest extends
protected void addRemoteServiceListeners() {
for (int i = 0; i < adapters.length; i++) {
- adapters[i].addRemoteServiceListener(createRemoteServiceListener(i==0));
+ adapters[i]
+ .addRemoteServiceListener(createRemoteServiceListener(i == 0));
}
}
@@ -105,9 +111,11 @@ public abstract class AbstractRemoteServiceTest extends
}
protected IRemoteServiceReference[] getRemoteServiceReferences(
- IRemoteServiceContainerAdapter adapter, ID target, ID[] idFilter, String clazz, String filter) throws ContainerConnectException {
+ IRemoteServiceContainerAdapter adapter, ID target, ID[] idFilter,
+ String clazz, String filter) throws ContainerConnectException {
try {
- return adapter.getRemoteServiceReferences(target, idFilter, clazz, filter);
+ return adapter.getRemoteServiceReferences(target, idFilter, clazz,
+ filter);
} catch (final InvalidSyntaxException e) {
fail("should not happen");
}
@@ -115,7 +123,9 @@ public abstract class AbstractRemoteServiceTest extends
}
protected IRemoteService getRemoteService(
- IRemoteServiceContainerAdapter adapter, ID target, ID[] idFilter, String clazz, String filter, int sleepTime) throws ContainerConnectException {
+ IRemoteServiceContainerAdapter adapter, ID target, ID[] idFilter,
+ String clazz, String filter, int sleepTime)
+ throws ContainerConnectException {
final IRemoteServiceReference[] refs = getRemoteServiceReferences(
adapter, target, idFilter, clazz, filter);
if (refs == null || refs.length == 0)
@@ -143,8 +153,9 @@ public abstract class AbstractRemoteServiceTest extends
protected IRemoteService registerAndGetRemoteService(
IRemoteServiceContainerAdapter server,
- IRemoteServiceContainerAdapter client, ID target, ID[] idFilter, String serviceName,
- Dictionary serviceProperties, int sleepTime) throws ContainerConnectException {
+ IRemoteServiceContainerAdapter client, ID target, ID[] idFilter,
+ String serviceName, Dictionary serviceProperties, int sleepTime)
+ throws ContainerConnectException {
registerService(server, serviceName, createService(),
serviceProperties, sleepTime);
return getRemoteService(client, target, idFilter, serviceName,
@@ -184,63 +195,66 @@ public abstract class AbstractRemoteServiceTest extends
assertNotNull(adapters);
for (int i = 0; i < adapters.length; i++)
assertNotNull(adapters[i]);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testRemoteServiceNamespace() throws Exception {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
assertNotNull(adapters);
- for(int i=0; i < adapters.length; i++) {
+ for (int i = 0; i < adapters.length; i++) {
Namespace namespace = adapters[i].getRemoteServiceNamespace();
assertNotNull(namespace);
}
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
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(), customizeProperties(null), 0);
+ IConcatService.class.getName(), createService(),
+ customizeProperties(null), 0);
assertNotNull(reg);
IRemoteServiceID remoteServiceID = reg.getID();
assertNotNull(remoteServiceID);
assertNotNull(remoteServiceID.getContainerID());
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testUnregisterService() throws Exception {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
// adapter [0] is the service 'server'
final IRemoteServiceRegistration reg = registerService(adapters[0],
- IConcatService.class.getName(), createService(), customizeProperties(null), 0);
+ IConcatService.class.getName(), createService(),
+ customizeProperties(null), SLEEPTIME);
assertNotNull(reg);
assertNotNull(reg.getContainerID());
reg.unregister();
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
protected ID getConnectTargetID() {
return null;
}
-
+
protected ID[] getIDFilter() {
return null;
}
-
+
public void testGetServiceReferences() throws Exception {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
// Register service on client[0]
registerService(adapters[0], IConcatService.class.getName(),
- createService(), customizeProperties(null), 3000);
+ createService(), customizeProperties(null), SLEEPTIME);
final IRemoteServiceReference[] refs = getRemoteServiceReferences(
- adapters[1], getConnectTargetID(), getIDFilter(), IConcatService.class.getName(), null);
+ adapters[1], getConnectTargetID(), getIDFilter(),
+ IConcatService.class.getName(), null);
assertTrue(refs != null);
assertTrue(refs.length > 0);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testGetServiceReferencesWithFilter() throws Exception {
@@ -249,15 +263,16 @@ public abstract class AbstractRemoteServiceTest extends
props.put("foo", "bar");
props.put("foo1", "bar");
registerService(adapters[0], IConcatService.class.getName(),
- createService(), customizeProperties(props), 3000);
+ createService(), customizeProperties(props), SLEEPTIME);
final IRemoteServiceReference[] refs = getRemoteServiceReferences(
- adapters[1], getConnectTargetID(), getIDFilter(), IConcatService.class.getName(),
+ adapters[1], getConnectTargetID(), getIDFilter(),
+ IConcatService.class.getName(),
getFilterFromServiceProperties(props));
assertTrue(refs != null);
assertTrue(refs.length > 0);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testGetServiceReferencesWithFilterFail() throws Exception {
@@ -266,7 +281,7 @@ public abstract class AbstractRemoteServiceTest extends
props.put("foo", "bar");
props.put("foo1", "bar");
registerService(adapters[0], IConcatService.class.getName(),
- createService(), customizeProperties(props), 0);
+ createService(), customizeProperties(props), SLEEPTIME);
// Create dictionary that is *not* the same as props, so the filter
// should miss
@@ -275,10 +290,11 @@ public abstract class AbstractRemoteServiceTest extends
final String missFilter = getFilterFromServiceProperties(missProps);
final IRemoteServiceReference[] refs = getRemoteServiceReferences(
- adapters[1], getConnectTargetID(), getIDFilter(), IConcatService.class.getName(), missFilter);
+ adapters[1], getConnectTargetID(), getIDFilter(),
+ IConcatService.class.getName(), missFilter);
assertTrue(refs == null);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testGetService() throws Exception {
@@ -287,17 +303,19 @@ public abstract class AbstractRemoteServiceTest extends
if (service == null)
return;
assertNotNull(service);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
protected IRemoteCall createRemoteConcat(String first, String second) {
return createRemoteCall("concat", new Object[] { first, second });
}
- protected IRemoteService registerAndGetRemoteService() throws ContainerConnectException {
+ protected IRemoteService registerAndGetRemoteService()
+ throws ContainerConnectException {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
return registerAndGetRemoteService(adapters[0], adapters[1],
- getClient(0).getConnectedID(), getIDFilter(), IConcatService.class.getName(), customizeProperties(null), 5000);
+ getClient(0).getConnectedID(), getIDFilter(),
+ IConcatService.class.getName(), customizeProperties(null), SLEEPTIME);
}
protected IRemoteCallListener createRemoteCallListener() {
@@ -321,7 +339,7 @@ public abstract class AbstractRemoteServiceTest extends
assertNotNull(result);
assertTrue(result.equals("Eclipse ".concat("is cool")));
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
protected void traceCallStart(String callType) {
@@ -361,7 +379,7 @@ public abstract class AbstractRemoteServiceTest extends
} catch (final ECFException e) {
// Exception should occur
}
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testCallAsynch() throws Exception {
@@ -372,7 +390,7 @@ public abstract class AbstractRemoteServiceTest extends
service.callAsync(createRemoteConcat("ECF ", "is cool"),
createRemoteCallListener());
traceCallEnd("callAsynch");
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testFireAsynch() throws Exception {
@@ -382,7 +400,7 @@ public abstract class AbstractRemoteServiceTest extends
traceCallStart("fireAsynch");
service.fireAsync(createRemoteConcat("Eclipse ", "sucks"));
traceCallEnd("fireAsynch");
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testProxy() throws Exception {
@@ -394,7 +412,7 @@ public abstract class AbstractRemoteServiceTest extends
traceCallStart("getProxy");
final String result = proxy.concat("ECF ", "sucks");
traceCallEnd("getProxy", result);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
public void testAsyncResult() throws Exception {
@@ -406,7 +424,7 @@ public abstract class AbstractRemoteServiceTest extends
"ECF AsynchResults ", "are cool"));
traceCallEnd("callAsynchResult", result);
assertNotNull(result);
- Thread.sleep(ASYNC_WAITTIME);
+ Thread.sleep(SLEEPTIME);
}
protected Dictionary customizeProperties(Dictionary props) {

Back to the top