@SuppressWarnings({"deprecation"})
public class VerifierTest {
@Test(groups = { UNIT })
public void testResolve() throws BundleException {
VerifierService verifier = new VerifierServiceImpl();
VerifyEnvironment env = verifier.createEnvironment(new HashMap<String, String>() {
{
put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, VerifierService.EE_1_6);
put(Constants.FRAMEWORK_OS_NAME, "macosx");
put(Constants.FRAMEWORK_OS_VERSION, "10.5");
}
}, new VerifyReporter() {
public void reportWire(BundleRevision importer,
BundleRequirement reqirement, BundleRevision exporter,
BundleCapability capability) {
System.out.println("WIRE: " + importer + " - " + reqirement + " - " + capability + " -> " + exporter);
}
public void reportLog(LogEntry logEntry) {
System.out.println("Log(" + logEntry.getTime() + "): " + logEntry.getLevel() + " " + logEntry.getMessage());
if (logEntry.getException() != null) {
logEntry.getException().printStackTrace();
}
}
public void reportException(Exception ex) {
ex.printStackTrace();
}
});
Set<BundleRevision> bundles = new HashSet<BundleRevision>();
bundles.add(env.addBundle(0, new HashMap<String, String>(){
{
put(Constants.BUNDLE_MANIFESTVERSION, "2");
put(Constants.BUNDLE_SYMBOLICNAME, FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME);
put(Constants.EXPORT_PACKAGE, VerifierService.SYSTEM_PACKAGES + "," + VerifierService.JRE_1_6_PACKAGES);
}
}));
bundles.add(env.addBundle(1, new HashMap<String, String>() {
{
put(Constants.BUNDLE_MANIFESTVERSION, "2");
put(Constants.BUNDLE_SYMBOLICNAME, "org.test.foo");
put(Constants.IMPORT_PACKAGE, "org.foo, org.osgi.framework");
}
}));
bundles.add(env.addBundle(2, new HashMap<String, String>() {
{
put(Constants.BUNDLE_MANIFESTVERSION, "2");
put(Constants.BUNDLE_SYMBOLICNAME, "org.test.foo2");
put(Constants.EXPORT_PACKAGE, "org.foo" +
"");
}
}));
AssertJUnit.assertTrue(" Unable to resolve resolvable state.", env.verifyResolve(bundles, null, null));
}