1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*******************************************************************************
* Copyright (c) 2007, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.osgi.tests.bundles;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
public class ExtensionBundleTests extends AbstractBundleTests {
public static Test suite() {
return new TestSuite(ExtensionBundleTests.class);
}
public void testFrameworkExtension01() throws Exception {
Bundle fwkext = installer.installBundle("ext.framework.a", false); //$NON-NLS-1$
Bundle importer = installer.installBundle("ext.framework.a.importer"); //$NON-NLS-1$
installer.resolveBundles(new Bundle[] {fwkext, importer});
importer.start();
importer.stop();
Object[] results = simpleResults.getResults(2);
assertTrue("1.0", results.length == 2); //$NON-NLS-1$
assertEquals("1.1", "success", results[0]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("1.2", "success", results[1]); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testFrameworkExtension02() throws Exception {
Bundle fwkext = installer.installBundle("ext.framework.a", false); //$NON-NLS-1$
Bundle importer = installer.installBundle("ext.framework.a.requires"); //$NON-NLS-1$
installer.resolveBundles(new Bundle[] {fwkext, importer});
importer.start();
importer.stop();
Object[] results = simpleResults.getResults(2);
assertTrue("1.0", results.length == 2); //$NON-NLS-1$
assertEquals("1.1", "success", results[0]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("1.2", "success", results[1]); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testExtClasspathExtension01() throws Exception {
Bundle fwkext = installer.installBundle("ext.extclasspath.a", false); //$NON-NLS-1$
Bundle importer = installer.installBundle("ext.extclasspath.a.importer"); //$NON-NLS-1$
installer.resolveBundles(new Bundle[] {fwkext, importer});
importer.start();
importer.stop();
Object[] results = simpleResults.getResults(2);
assertTrue("1.0", results.length == 2); //$NON-NLS-1$
assertEquals("1.1", "success", results[0]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("1.2", "success", results[1]); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testExtensionBundleWithRequireCapabilityOsgiEeInstalls() {
Bundle b = null;
try {
b = installer.installBundle("ext.framework.osgiee.b", false);
} catch (BundleException e) {
fail("Extension bundle with Require-Capability only in osgi.ee. namespace failed to install", e);
}
assertTrue("Could not resolve bundle: " + b, installer.resolveBundles(new Bundle[] {b}));
BundleWiring wiring = b.adapt(BundleWiring.class);
assertNotNull("No wiring for bundle: " + b, wiring);
List<BundleWire> allRequired = wiring.getRequiredWires(null);
assertEquals("Wrong number of wires: " + allRequired, 2, allRequired.size());
BundleWire hostWire = wiring.getRequiredWires(HostNamespace.HOST_NAMESPACE).get(0);
assertEquals("Wrong provider for host: " + hostWire.getProvider().getBundle(), 0, hostWire.getProvider().getBundle().getBundleId());
BundleWire eeWire = wiring.getRequiredWires(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE).get(0);
assertEquals("Wrong provider for osgi.ee: " + eeWire.getProvider().getBundle(), 0, eeWire.getProvider().getBundle().getBundleId());
}
}
|