use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testFragmentConstraints07.
public void testFragmentConstraints07() throws BundleException {
// same as testFragmentConstraints06 but with a cycle
int id = 0;
State state = buildEmptyState();
Hashtable manifest = new Hashtable();
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "x");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "b");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, d");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "c, d, e");
// $NON-NLS-1$
BundleDescription aFrag1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, e");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "c, d, f");
// $NON-NLS-1$
BundleDescription aFrag2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag3");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "c, d");
// $NON-NLS-1$
BundleDescription aFrag3 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a, b, c");
// $NON-NLS-1$
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "c");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "c1, c2, c3");
// $NON-NLS-1$
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "d");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "d1, d2, d3");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "x");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "a");
// $NON-NLS-1$
BundleDescription d = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
state.addBundle(a);
state.addBundle(aFrag1);
state.addBundle(aFrag2);
state.addBundle(aFrag3);
state.addBundle(b);
state.addBundle(c);
state.addBundle(d);
state.resolve();
// $NON-NLS-1$
assertTrue("0.1", a.isResolved());
// $NON-NLS-1$
assertFalse("0.2", aFrag1.isResolved());
// $NON-NLS-1$
assertFalse("0.3", aFrag2.isResolved());
// $NON-NLS-1$
assertTrue("0.4", aFrag3.isResolved());
// $NON-NLS-1$
assertTrue("0.5", b.isResolved());
// $NON-NLS-1$
assertTrue("0.6", c.isResolved());
// $NON-NLS-1$
assertTrue("0.7", d.isResolved());
ExportPackageDescription[] aResolvedImports = a.getResolvedImports();
ExportPackageDescription[] aSelectedExports = a.getSelectedExports();
ExportPackageDescription[] bSelectedExports = b.getSelectedExports();
ExportPackageDescription[] dResolvedImports = d.getResolvedImports();
// $NON-NLS-1$
assertEquals("1.0", 3, aResolvedImports.length);
// $NON-NLS-1$
assertEquals("1.1", 3, bSelectedExports.length);
for (int i = 0; i < aResolvedImports.length; i++) {
assertEquals(bSelectedExports[i], aResolvedImports[i]);
}
BundleDescription[] aResolvedRequires = a.getResolvedRequires();
// $NON-NLS-1$
assertEquals("1.0", 3, aResolvedRequires.length);
// $NON-NLS-1$
assertEquals("1.1", b, aResolvedRequires[0]);
// $NON-NLS-1$
assertEquals("1.2", c, aResolvedRequires[1]);
// $NON-NLS-1$
assertEquals("1.3", d, aResolvedRequires[2]);
// $NON-NLS-1$
assertEquals("2.0", 1, aSelectedExports.length);
// $NON-NLS-1$
assertEquals("2.1", 1, dResolvedImports.length);
// $NON-NLS-1$
assertEquals("2.2", aSelectedExports[0], dResolvedImports[0]);
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class TestDynamic_006 method testTest_005.
public void testTest_005() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
bundle_1 = create_bundle_1(sof);
bundle_2 = create_bundle_2(sof);
bundle_3 = create_bundle_3(sof);
// ***************************************************
// stage a
// expect to pass =true
// ***************************************************
addBundlesToState_a(state);
// ***************************************************
try {
state.resolve();
} catch (Throwable t) {
fail("unexpected exception class=" + t.getClass().getName() + " message=" + t.getMessage());
return;
}
checkBundlesResolved_a();
checkWiring_a();
// Dynamics
ExportPackageDescription exp = state.linkDynamicImport(bundle_1, "p.b");
assertNotNull("Package [p.b] is not wired when it should be ", exp);
assertEquals("Package [p.b] is wired incorrectly ", exp.getExporter(), bundle_3);
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class TestPropagation_001 method checkWiringState_1.
// end of method
public void checkWiringState_1() {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
for (int i = 0; i < exports.length; i++) {
ExportPackageDescription exp = exports[i];
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("x")) {
assertNotNull("Package [x] is not wired when it should be ", exp.getExporter());
assertEquals("Package [x] is wired incorrectly ", exp.getExporter(), bundle_3);
} else if (exportPackageName.equals("y")) {
assertNotNull("Package [y] is not wired when it should be ", exp.getExporter());
assertEquals("Package [y] is wired incorrectly ", exp.getExporter(), bundle_2);
}
}
// end for
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class TestRFC79_007 method checkWiringState_1.
// end of method
public void checkWiringState_1() {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
for (int i = 0; i < exports.length; i++) {
ExportPackageDescription exp = exports[i];
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("Q")) {
assertNotNull("Package [Q] is not wired when it should be ", exp.getExporter());
assertEquals("Package [Q] is wired incorrectly ", exp.getExporter(), bundle_2);
}
}
// end for
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class TestRFC79_007 method checkWiringState_4.
// end method
public void checkWiringState_4() {
ExportPackageDescription[] exports = bundle_4.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
for (int i = 0; i < exports.length; i++) {
ExportPackageDescription exp = exports[i];
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("R")) {
assertNotNull("Package [R] is not wired when it should be ", exp.getExporter());
assertEquals("Package [R] is wired incorrectly ", exp.getExporter(), bundle_1);
} else if (exportPackageName.equals("Q")) {
assertNotNull("Package [Q] is not wired when it should be ", exp.getExporter());
assertEquals("Package [Q] is wired incorrectly ", exp.getExporter(), bundle_5);
}
}
// end for
}
Aggregations