Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-09-15 14:40:39 +0000
committerThomas Watson2008-09-15 14:40:39 +0000
commit0c6bdad7c26040810650f260fc702770a1c7227a (patch)
tree454b1fc82f33257f31ab92146823ac0d705a0305
parente6c1904d1e197e24c54781724de13dd8cda4612f (diff)
downloadrt.equinox.framework-0c6bdad7c26040810650f260fc702770a1c7227a.tar.gz
rt.equinox.framework-0c6bdad7c26040810650f260fc702770a1c7227a.tar.xz
rt.equinox.framework-0c6bdad7c26040810650f260fc702770a1c7227a.zip
FrameWorkUtil test with SystemBundle.v20080915-1045
-rw-r--r--bundles/org.eclipse.osgi.tests/.classpath1
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties5
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/META-INF/MANIFEST.MF8
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java51
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java38
5 files changed, 102 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath
index 7da2403f3..c54717082 100644
--- a/bundles/org.eclipse.osgi.tests/.classpath
+++ b/bundles/org.eclipse.osgi.tests/.classpath
@@ -80,6 +80,7 @@
<classpathentry kind="src" output="bundle_tests/activator.error4" path="bundles_src/activator.error4"/>
<classpathentry kind="src" output="bundle_tests/security.a" path="bundles_src/security.a"/>
<classpathentry kind="src" output="bundle_tests/security.a.frag.a" path="bundles_src/security.a.frag.a"/>
+ <classpathentry kind="src" output="bundle_tests/test.filter.a" path="bundles_src/test.filter.a"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index 53fc7a0e4..0b638c4d0 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -175,6 +175,8 @@ source.bundle_tests/security.a.jar = bundles_src/security.a/
manifest.bundle_tests/security.a.jar = META-INF/MANIFEST.MF
source.bundle_tests/security.a.frag.a.jar = bundles_src/security.a.frag.a/
manifest.bundle_tests/security.a.frag.a.jar = META-INF/MANIFEST.MF
+source.bundle_tests/test.filter.a.jar = bundles_src/test.filter.a/
+manifest.bundle_tests/test.filter.a.jar = META-INF/MANIFEST.MF
jars.compile.order = bundle_tests/ext.framework.b.jar,\
osgitests.jar,\
@@ -255,4 +257,5 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\
bundle_tests/activator.error3,\
bundle_tests/activator.error4,\
bundle_tests/security.a.jar,\
- bundle_tests/security.a.frag.a.jar
+ bundle_tests/security.a.frag.a.jar,\
+ bundle_tests/test.filter.a.jar
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..0f42f8d80
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: test.filter.a
+Bundle-SymbolicName: test.filter.a
+Bundle-Version: 1.0.0
+Bundle-Activator: test.filter.a.Activator
+Import-Package: org.osgi.framework,
+ org.osgi.util.tracker
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java
new file mode 100644
index 000000000..aab1a6619
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java
@@ -0,0 +1,51 @@
+package test.filter.a;
+
+import java.util.Hashtable;
+import org.osgi.framework.*;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ final boolean[] serviceChanged = {false};
+ ServiceListener listener = new ServiceListener() {
+ public void serviceChanged(ServiceEvent event) {
+ serviceChanged[0] = true;
+ }
+ };
+ context.addServiceListener(listener, "(&(objectClass=java.lang.String)(test=*))");
+ final boolean[] modifiedService = {false};
+ ServiceTracker tracker = new ServiceTracker(context, FrameworkUtil.createFilter("(&(objectClass=java.lang.String)(test=*))"), new ServiceTrackerCustomizer() {
+
+ public Object addingService(ServiceReference reference) {
+ return reference;
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ modifiedService[0] = true;
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ tracker.open();
+ Hashtable props = new Hashtable();
+ props.put("test", "value1");
+ ServiceRegistration registration = context.registerService(String.class.getName(), "test", props);
+ props.put("test", "value2");
+ registration.setProperties(props);
+ if (!serviceChanged[0])
+ throw new Exception("did not call service listener");
+ if (!modifiedService[0])
+ throw new Exception("did not call tracker customer");
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ //nothing; framework will clean up our listeners
+ }
+
+}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 4184c5540..4297fd85e 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -493,4 +493,42 @@ public class SystemBundleTests extends AbstractBundleTests {
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
}
+
+ public void testSystemBundle09() {
+ // test FrameworkUtil.createFilter
+ File config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle09"); //$NON-NLS-1$
+ Properties configuration = new Properties();
+ configuration.put(SystemBundle.STORAGE, config.getAbsolutePath());
+ Equinox equinox = new Equinox();
+ equinox.init(configuration);
+ try {
+ equinox.start();
+ } catch (BundleException e) {
+ fail("Failed to start the framework", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); //$NON-NLS-1$
+
+ Bundle testFilterA = null;
+ try {
+ testFilterA = equinox.getBundleContext().installBundle(installer.getBundleLocation("test.filter.a")); //$NON-NLS-1$
+ } catch (BundleException e) {
+ fail("Unexpected exception installing", e); //$NON-NLS-1$
+ }
+ try {
+ testFilterA.start();
+ } catch (BundleException e) {
+ fail("Unexpected exception starting test bundle", e);
+ }
+ try {
+ equinox.stop();
+ } catch (BundleException e) {
+ fail("Unexpected erorr stopping framework", e); //$NON-NLS-1$
+ }
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
+ }
}

Back to the top