Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2012-03-09 10:42:19 +0000
committerGlyn Normington2012-03-09 10:42:19 +0000
commit31b4e2346f1ce3b0a4e2181dbeb40aaf2317831c (patch)
tree7ec16a2d4833187953aea4096c8a6e9b3ab8f420 /org.eclipse.virgo.kernel.deployer.test/src/test
parent2fe7228ebd78bda142a5da59752956765e4fce58 (diff)
downloadorg.eclipse.virgo.kernel-31b4e2346f1ce3b0a4e2181dbeb40aaf2317831c.tar.gz
org.eclipse.virgo.kernel-31b4e2346f1ce3b0a4e2181dbeb40aaf2317831c.tar.xz
org.eclipse.virgo.kernel-31b4e2346f1ce3b0a4e2181dbeb40aaf2317831c.zip
373635: rework test since Gemini Blueprint service reference lifecycle is different to that of Spring DM 1.2.1
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.test/src/test')
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java41
1 files changed, 4 insertions, 37 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java
index a15014d7..897e4c88 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java
@@ -16,7 +16,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -31,19 +30,15 @@ import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.install.artifact.ScopeServiceRepository;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
-import org.eclipse.virgo.kernel.install.artifact.ScopeServiceRepository;
-
/**
*/
public class ServiceScopingTests extends AbstractParTests {
@@ -59,27 +54,8 @@ public class ServiceScopingTests extends AbstractParTests {
BundleContext context = this.framework.getBundleContext();
- // check global is wired to b
- Collection<ServiceReference<Appendable>> refs = context.getServiceReferences(Appendable.class, "(provider=global)");
- assertNotNull(refs);
- assertEquals(1, refs.size());
- Bundle[] usingBundles = refs.iterator().next().getUsingBundles();
- assertEquals(1, usingBundles.length);
- Bundle b = usingBundles[0];
- assertNotNull(b);
- assertTrue(b.getSymbolicName().endsWith("scoping.service.module.b"));
-
- Bundle[] bundles = context.getBundles();
- for (Bundle bund : bundles) {
- if (bund.getSymbolicName().contains("scoping.service.module.a")) {
- assertContainsServiceReference(bund.getServicesInUse(), "(&(objectClass=java.lang.Appendable)(provider=local))");
- } else if (bund.getSymbolicName().contains("scoping.service.module.b")) {
- assertContainsServiceReference(bund.getServicesInUse(), "(&(objectClass=java.lang.Appendable)(provider=global))");
- }
- }
-
// check unable to access scoped service from unscoped view
- refs = context.getServiceReferences(Appendable.class, "(provider=local)");
+ Collection<ServiceReference<Appendable>> refs = context.getServiceReferences(Appendable.class, "(provider=local)");
assertEquals("refs should be empty", refs.size(), 0);
// check able to publish into global from app
@@ -177,6 +153,7 @@ public class ServiceScopingTests extends AbstractParTests {
// Check that bundle two is wired to the service from bundle one.
@SuppressWarnings("rawtypes")
ServiceReference<List> serviceReference = bundle.getBundleContext().getServiceReference(List.class);
+ assertNotNull(serviceReference);
assertEquals("service-scoping-1-service.scoping.one", serviceReference.getBundle().getSymbolicName());
// Check that the service is not visible outside the scope
@@ -185,17 +162,7 @@ public class ServiceScopingTests extends AbstractParTests {
this.deployer.undeploy(deployed);
}
-
- private void assertContainsServiceReference(ServiceReference<?>[] refs, String filter) throws InvalidSyntaxException {
- Filter f = FrameworkUtil.createFilter(filter);
- for (ServiceReference<?> serviceReference : refs) {
- if (f.match(serviceReference)) {
- return;
- }
- }
- fail("No service with filter '" + filter + "'");
- }
-
+
private Set<String> knownScopes() throws Exception {
BundleContext context = this.framework.getBundleContext();
ServiceReference<ScopeServiceRepository> reference = context.getServiceReference(ScopeServiceRepository.class);

Back to the top