[jboss-osgi-commits] JBoss-OSGI SVN: r97299 - projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Wed Dec 2 11:05:03 EST 2009
Author: alesj
Date: 2009-12-02 11:05:02 -0500 (Wed, 02 Dec 2009)
New Revision: 97299
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
Log:
Test mix filtering.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-02 15:45:59 UTC (rev 97298)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-02 16:05:02 UTC (rev 97299)
@@ -22,6 +22,8 @@
package org.jboss.test.osgi.service;
import java.lang.reflect.Method;
+import java.util.Dictionary;
+import java.util.Hashtable;
import junit.framework.Test;
@@ -31,9 +33,9 @@
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.test.osgi.DeployersTest;
+import org.jboss.test.osgi.service.support.LazyBundle;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.c.C;
-import org.jboss.test.osgi.service.support.LazyBundle;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -117,6 +119,8 @@
Deployment bean = addBean("beanA", C.class, bmd, A.class);
try
{
+ KernelControllerContext kcc = getControllerContext("C", null);
+
Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle3");
try
{
@@ -138,15 +142,20 @@
ServiceReference ref1 = bundleContext1.getServiceReference(A.class.getName());
assertUsingBundles(ref1, LazyBundle.getBundle(getDeploymentUnit(bean)));
- KernelControllerContext kcc = getControllerContext("C");
change(kcc, ControllerState.DESCRIBED);
// we did un-injection, should be removed now
assertUsingBundles(ref1);
+
+ change(kcc, ControllerState.INSTALLED);
+ assertEquals(ControllerState.INSTALLED, kcc.getState());
}
finally
{
reg1.unregister();
}
+
+ // check if the bean was unwinded as well
+ assertEquals(ControllerState.DESCRIBED, kcc.getState());
}
finally
{
@@ -158,4 +167,54 @@
undeploy(bean);
}
}
+
+ public void testFiltering() throws Throwable
+ {
+ Deployment bean = addBean("beanA", A.class);
+ try
+ {
+ Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle1");
+ try
+ {
+ bundle1.start();
+ BundleContext bundleContext1 = bundle1.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> aClass = bundle1.loadClass(A.class.getName());
+ Object a = aClass.newInstance();
+ Dictionary<String, Object> dictionary = new Hashtable<String, Object>();
+ dictionary.put("a", "b");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), a, dictionary);
+ assertNotNull(reg1);
+ try
+ {
+ // OSGi service should bubble on top
+ ServiceReference osgiRef = bundleContext1.getServiceReference(A.class.getName());
+ assertNotNull(osgiRef);
+
+ ServiceReference[] refs = bundleContext1.getServiceReferences(A.class.getName(), null);
+ assertNotNull(refs);
+ assertEquals(2, refs.length);
+ assertSame(osgiRef, refs[0]);
+
+ refs = bundleContext1.getServiceReferences(A.class.getName(), "(a=b)");
+ assertNotNull(refs);
+ assertEquals(1, refs.length);
+ assertSame(osgiRef, refs[0]);
+ }
+ finally
+ {
+ reg1.unregister();
+ }
+ }
+ finally
+ {
+ uninstall(bundle1);
+ }
+ }
+ finally
+ {
+ undeploy(bean);
+ }
+ }
}
More information about the jboss-osgi-commits
mailing list