aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1079500 - in /aries/trunk/subsystem/subsystem-scope-itests/src/test: bundles/tb3/ bundles/tb3/META-INF/ bundles/tb3/org/ bundles/tb3/org/apache/ bundles/tb3/org/apache/aries/ bundles/tb3/org/apache/aries/subsystem/ bundles/tb3/org/apache/a...
Date Tue, 08 Mar 2011 19:31:32 GMT
Author: gcc
Date: Tue Mar  8 19:31:30 2011
New Revision: 1079500

URL: http://svn.apache.org/viewvc?rev=1079500&view=rev
Log:
ARIES-603
Added missing tests that didn't make it in from ARIES-594.

Added:
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/META-INF/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/tb3/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/tb3/Activator.java
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/META-INF/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/tb4/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/tb4/Activator.java
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/META-INF/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/META-INF/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/META-INF/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/tb7/
    aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/tb7/Activator.java
    aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BundleVisibilityTest.java

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/META-INF/MANIFEST.MF?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/META-INF/MANIFEST.MF
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TB3
+Bundle-SymbolicName: org.apache.aries.subsystem.scope.itests.tb3
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.osgi.framework;version="1.3.0",
+ org.apache.aries.subsystem.scope,
+ org.apache.aries.subsystem.scope.itests
+Bundle-Activator: org.apache.aries.subsystem.scope.itests.tb3.Activator

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/tb3/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/tb3/Activator.java?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/tb3/Activator.java
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb3/org/apache/aries/subsystem/scope/itests/tb3/Activator.java
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,32 @@
+package org.apache.aries.subsystem.scope.itests.tb3;
+
+import org.apache.aries.subsystem.scope.Scope;
+import org.apache.aries.subsystem.scope.itests.ScopeProvider;
+import org.apache.aries.subsystem.scope.itests.Utils;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+	private ServiceRegistration<ScopeProvider> scopeProviderReg;
+	private ServiceReference<Scope> scopeRef;
+
+	public void start(BundleContext bundleContext) throws Exception {
+		scopeRef = bundleContext.getServiceReference(Scope.class);
+		final Scope scope = bundleContext.getService(scopeRef);
+		scopeProviderReg = bundleContext.registerService(
+				ScopeProvider.class, 
+				new ScopeProvider() {
+					public Scope getScope() {
+						return scope;
+					}
+				}, 
+				null);
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception {
+		Utils.unregisterQuietly(scopeProviderReg);
+		Utils.ungetQuietly(scopeRef, bundleContext);
+	}
+}

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/META-INF/MANIFEST.MF?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/META-INF/MANIFEST.MF
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TB4
+Bundle-SymbolicName: org.apache.aries.subsystem.scope.itests.tb4
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.osgi.framework;version="1.3.0",
+ org.apache.aries.subsystem.scope,
+ org.apache.aries.subsystem.scope.itests
+Bundle-Activator: org.apache.aries.subsystem.scope.itests.tb4.Activator

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/tb4/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/tb4/Activator.java?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/tb4/Activator.java
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb4/org/apache/aries/subsystem/scope/itests/tb4/Activator.java
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,34 @@
+package org.apache.aries.subsystem.scope.itests.tb4;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.aries.subsystem.scope.itests.BundleProvider;
+import org.apache.aries.subsystem.scope.itests.Utils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+	private ServiceRegistration<BundleProvider> bundleProviderReg;
+
+	public void start(final BundleContext bundleContext) throws Exception {
+		bundleProviderReg = bundleContext.registerService(
+				BundleProvider.class, 
+				new BundleProvider() {
+					public Bundle getBundle(long id) {
+						return bundleContext.getBundle(id);
+					}
+					
+					public Collection<Bundle> getBundles() {
+						return Arrays.asList(bundleContext.getBundles());
+					}
+				}, 
+				null);
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception {
+		Utils.unregisterQuietly(bundleProviderReg);
+	}
+}

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/META-INF/MANIFEST.MF?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb5/META-INF/MANIFEST.MF
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TB5
+Bundle-SymbolicName: org.apache.aries.subsystem.scope.itests.tb5
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.apache.aries.subsystem.scope.itests.tb6
+

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/META-INF/MANIFEST.MF?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb6/META-INF/MANIFEST.MF
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TB6
+Bundle-SymbolicName: org.apache.aries.subsystem.scope.itests.tb6
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.apache.aries.subsystem.scope.itests.tb6
+

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/META-INF/MANIFEST.MF?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/META-INF/MANIFEST.MF
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TB7
+Bundle-SymbolicName: org.apache.aries.subsystem.scope.itests.tb7
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.osgi.framework;version="1.3.0",
+  org.apache.aries.subsystem.scope.itests
+Bundle-Activator: org.apache.aries.subsystem.scope.itests.tb7.Activator

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/tb7/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/tb7/Activator.java?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/tb7/Activator.java
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/bundles/tb7/org/apache/aries/subsystem/scope/itests/tb7/Activator.java
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,22 @@
+package org.apache.aries.subsystem.scope.itests.tb7;
+
+import org.apache.aries.subsystem.scope.itests.Service;
+import org.apache.aries.subsystem.scope.itests.Utils;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+	private ServiceRegistration<Service> serviceReg;
+
+	public void start(final BundleContext bundleContext) throws Exception {
+		serviceReg = bundleContext.registerService(
+				Service.class, 
+				new Service() {}, 
+				null);
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception {
+		Utils.unregisterQuietly(serviceReg);
+	}
+}

Added: aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BundleVisibilityTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BundleVisibilityTest.java?rev=1079500&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BundleVisibilityTest.java
(added)
+++ aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BundleVisibilityTest.java
Tue Mar  8 19:31:30 2011
@@ -0,0 +1,92 @@
+package org.apache.aries.subsystem.scope.itests;
+
+import static org.junit.Assert.assertEquals;
+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 java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.aries.subsystem.scope.InstallInfo;
+import org.apache.aries.subsystem.scope.Scope;
+import org.apache.aries.subsystem.scope.ScopeUpdate;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Bundles may only see other bundles within the same scope. The one exception
+ * is the system bundle, which may be seen by all bundles regardless of scope.
+ */
+@RunWith(JUnit4TestRunner.class)
+public class BundleVisibilityTest extends AbstractTest {
+	/**
+	 * Install a bundle into the same scope as this one. Both bundles should be
+	 * able to see each other.
+	 * @throws Exception
+	 */
+	@Test
+	public void test1() throws Exception {
+		assertTrue(scope.getBundles().contains(bundleContext.getBundle()));
+		ScopeUpdate scopeUpdate = scope.newScopeUpdate();
+		String location = getBundleLocation("tb-4.jar");
+		assertNull(bundleContext.getBundle(location));
+		URL url = new URL(location);
+		InstallInfo installInfo = new InstallInfo(location, url.openStream());
+		scopeUpdate.getBundlesToInstall().add(installInfo);
+		scopeUpdate.commit();
+		Bundle bundle = bundleContext.getBundle(location);
+		assertTrue(scope.getBundles().contains(bundle));
+		bundle.start();
+		ServiceReference<BundleProvider> bundleProviderRef = bundleContext.getServiceReference(BundleProvider.class);
+		BundleProvider bundleProvider = bundleContext.getService(bundleProviderRef);
+		assertTrue(bundleProvider.getBundles().contains(bundleContext.getBundle()));
+		assertTrue(Arrays.asList(bundleContext.getBundles()).contains(bundle));
+		assertNotNull(bundleContext.getBundle(bundle.getBundleId()));
+		assertNotNull(bundleProvider.getBundle(bundle.getBundleId()));
+		bundleContext.ungetService(bundleProviderRef);
+		bundle.uninstall();
+	}
+	
+	/**
+	 * Install a bundle into a different scope than this one. Neither bundle
+	 * should be able to see the other.
+	 * @throws Exception
+	 */
+	@Test
+	public void test2() throws Exception {
+		assertTrue(scope.getBundles().contains(bundleContext.getBundle()));
+		ScopeUpdate scopeUpdate = scope.newScopeUpdate();
+		ScopeUpdate child = scopeUpdate.newChild("tb4");
+		scopeUpdate.getChildren().add(child);
+		String location = getBundleLocation("tb-4.jar");
+		assertNull(bundleContext.getBundle(location));
+		URL url = new URL(location);
+		InstallInfo installInfo = new InstallInfo(location, url.openStream());
+		child.getBundlesToInstall().add(installInfo);
+		addPackageImportPolicy("org.osgi.framework", child);
+		addPackageImportPolicy("org.apache.aries.subsystem.scope", child);
+		addPackageImportPolicy("org.apache.aries.subsystem.scope.itests", child);
+		addServiceExportPolicy(BundleProvider.class, child);
+		scopeUpdate.commit();
+		Bundle bundle = bundleContext.getBundle(location);
+		assertNotNull(bundle);
+		Collection<Scope> childScopes = scope.getChildren();
+		assertEquals(1, childScopes.size());
+		assertTrue(childScopes.iterator().next().getBundles().contains(bundle));
+		bundle.start();
+		ServiceReference<BundleProvider> bundleProviderRef = bundleContext.getServiceReference(BundleProvider.class);
+		BundleProvider bundleProvider = bundleContext.getService(bundleProviderRef);
+		assertFalse(Arrays.asList(bundleContext.getBundles()).contains(bundle));
+		assertNull(bundleContext.getBundle(bundle.getBundleId()));
+		assertFalse(bundleProvider.getBundles().contains(bundleContext.getBundle()));
+		assertNull(bundleProvider.getBundle(bundleContext.getBundle().getBundleId()));
+		bundleContext.ungetService(bundleProviderRef);
+		bundle.uninstall();
+	}
+}



Mime
View raw message