final org.apache.karaf.features.internal.model.Feature f = new org.apache.karaf.features.internal.model.Feature("f1", "1.0");
f.setResolver("obr");
f.getBundle().add(new Bundle(requirement));
final RepositoryAdmin admin = createMock(RepositoryAdmin.class);
final Resolver resolver = createMock(Resolver.class);
final Resource resource = createMock(Resource.class);
final ObrResolver obrResolver = new ObrResolver();
obrResolver.setRepositoryAdmin(admin);
final Capture<Requirement> captureReq = new Capture<Requirement>();
expect(admin.getHelper()).andReturn(new DataModelHelperImpl()).anyTimes();
expect(admin.getSystemRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
expect(admin.getLocalRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
expect(admin.listRepositories()).andReturn(new org.apache.felix.bundlerepository.Repository[0]);
expect(admin.resolver(EasyMock.<org.apache.felix.bundlerepository.Repository[]>anyObject())).andReturn(resolver);
resolver.add(EasyMock.capture(captureReq));
expect(resolver.resolve(Resolver.NO_OPTIONAL_RESOURCES)).andReturn(true);
expect(resolver.getAddedResources()).andReturn(new Resource[] { });
expect(resolver.getRequiredResources()).andReturn(new Resource[] { resource });
expect(resolver.getReason(resource)).andAnswer(new IAnswer<Reason[]>() {
public Reason[] answer() throws Throwable {
return new Reason[] { new ReasonImpl( resource, captureReq.getValue()) };
}
});
expect(resource.getURI()).andReturn("foo:bar");
replay(admin, resolver, resource);
List<BundleInfo> bundles = obrResolver.resolve(f);
assertNotNull(bundles);
assertEquals(1, bundles.size());