Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-01-23 05:43:37 +0000
committerslewis2014-01-23 05:43:37 +0000
commit0f9437b178c2b41bd21c7eda7fb4dc35a0e9fa77 (patch)
treefc52500b60b9f2a68dea2075c6afdce552152c9b /tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf
parent732b22ce3f389cb8ef3e9cba5255fd50b12b3733 (diff)
downloadorg.eclipse.ecf-0f9437b178c2b41bd21c7eda7fb4dc35a0e9fa77.tar.gz
org.eclipse.ecf-0f9437b178c2b41bd21c7eda7fb4dc35a0e9fa77.tar.xz
org.eclipse.ecf-0f9437b178c2b41bd21c7eda7fb4dc35a0e9fa77.zip
Added test case for ExportRegistration.update behavior.
AbstractRemoteServiceRegisterTest.testRegisterAndUpdateProperties Change-Id: I5a6c45cb4151ca5cde4c1050a81f3551a2026387
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf')
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java b/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java
index 56e703c6d..658319b19 100644
--- a/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
+import java.util.Map;
import java.util.Properties;
import java.util.Vector;
@@ -20,6 +21,8 @@ import org.eclipse.ecf.remoteservice.Constants;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportReference;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
@@ -239,4 +242,44 @@ public abstract class AbstractRemoteServiceRegisterTest extends
listenerReg.unregister();
}
+ public void testRegisterAndUpdateProperties() throws Exception {
+ // register RemoteServiceAdminListener
+ ServiceRegistration listenerReg = getContext().registerService(RemoteServiceAdminListener.class.getName(), createRemoteServiceAdminListener(), null);
+ // Create server container
+ this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
+ // Create props
+ Properties props = getServiceProperties();
+ // Put "1" for "testonekey"
+ props.put("testonekey", "1");
+ // Actually register with default service (IConcatService) as a remote service
+ registration = registerDefaultService(props);
+ Thread.sleep(REGISTER_WAIT/2);
+ // remoteServiceAdminEvents should have the Export registration
+ assertTrue(remoteServiceAdminEvents.size() > 0);
+ // Get ExportReference
+ ExportReference exportRef = remoteServiceAdminEvents.get(0).getExportReference();
+ EndpointDescription oldED = exportRef.getExportedEndpoint();
+ assertNotNull(oldED);
+ Map<String,?> oldEDProperties = oldED.getProperties();
+ assertNotNull(oldEDProperties);
+ assertTrue("1".equals(oldEDProperties.get("testonekey")));
+ assertTrue(oldEDProperties.get("testtwokey")==null);
+
+ // Change testonekey value to "two" and set a new property "testtwokey" to "2"
+ props.put("testonekey", "two");
+ props.put("testtwokey", "2");
+ // Set/update the properties on the registration
+ this.registration.setProperties(props);
+
+ // Now get new EndpointDescription and test that new properties have been changed in EndpointDescription
+ EndpointDescription updatedED = exportRef.getExportedEndpoint();
+ assertNotNull(updatedED);
+ Map<String,?> updatedEDProperties = updatedED.getProperties();
+ assertNotNull(updatedEDProperties);
+ assertTrue("two".equals(updatedEDProperties.get("testonekey")));
+ assertTrue("2".equals(updatedEDProperties.get("testtwokey")));
+
+ listenerReg.unregister();
+ }
+
}

Back to the top