use of org.osgi.resource.Resource in project bnd by bndtools.
the class PomRepositoryTest method testBndPomRepoURI.
public void testBndPomRepoURI() throws Exception {
final BndPomRepository bpr = new BndPomRepository();
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
bpr.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("pom", "https://repo1.maven.org/maven2/org/apache/felix/org.apache.felix.gogo.shell/0.12.0/org.apache.felix.gogo.shell-0.12.0.pom");
config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
config.put("releaseUrls", "https://repo1.maven.org/maven2/");
config.put("name", "test");
bpr.setProperties(config);
List<String> list = bpr.list(null);
assertNotNull(list);
assertEquals(1, list.size());
RequirementBuilder builder = bpr.newRequirementBuilder("osgi.identity");
builder.addDirective("filter", "(osgi.identity=org.apache.felix.gogo.runtime)");
Promise<Collection<Resource>> providers = bpr.findProviders(builder.buildExpression());
Collection<Resource> resources = providers.getValue();
assertFalse(resources.isEmpty());
assertEquals(1, resources.size());
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class PomRepositoryTest method testRepository.
public void testRepository() throws Exception {
MavenRepository repo = getRepo();
Revision revision = Revision.valueOf("bcel:bcel:5.1");
PomRepository pom = new PomRepository(repo, client, location).revisions(Collections.singleton(revision));
assertTrue(location.isFile());
try (XMLResourceParser xp = new XMLResourceParser(location)) {
List<Resource> parse = xp.parse();
assertEquals(parse.size(), pom.getResources().size());
}
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class PomRepositoryTest method testSearchRepoMultipleConfigurationsDontBreak.
public void testSearchRepoMultipleConfigurationsDontBreak() throws Exception {
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
BndPomRepository mcsrBnd320 = new BndPomRepository();
mcsrBnd320.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.2.0");
config.put("name", "bnd320");
mcsrBnd320.setProperties(config);
BndPomRepository mcsrBnd330 = new BndPomRepository();
mcsrBnd330.setRegistry(w);
config = new HashMap<>();
config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.3.0");
config.put("name", "bnd330");
mcsrBnd330.setProperties(config);
List<String> list320 = mcsrBnd320.list(null);
assertNotNull(list320);
assertEquals(1, list320.size());
List<String> list330 = mcsrBnd330.list(null);
assertNotNull(list330);
assertEquals(1, list330.size());
// check the first repo to make sure it's there.
RequirementBuilder builder = mcsrBnd320.newRequirementBuilder("osgi.identity");
builder.addDirective("filter", "(&(osgi.identity=biz.aQute.bnd)(version>=3.2.0)(!(version>=3.3.0)))");
Promise<Collection<Resource>> providers = mcsrBnd320.findProviders(builder.buildExpression());
Collection<Resource> resources = providers.getValue();
assertFalse(resources.isEmpty());
assertEquals(1, resources.size());
// make sure it's not in the second repo, otherwise the caches are
// messed up.
providers = mcsrBnd330.findProviders(builder.buildExpression());
resources = providers.getValue();
assertTrue(resources.isEmpty());
assertEquals(0, resources.size());
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class PomRepositoryTest method assertAllBndCap.
void assertAllBndCap(Map<Archive, Resource> value) {
for (Resource resource : value.values()) {
List<Capability> capabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
assertNotNull(capabilities);
assertEquals(1, capabilities.size());
capabilities = resource.getCapabilities("bnd.info");
Capability c = capabilities.get(0);
String a = (String) c.getAttributes().get("name");
Archive archive = Archive.valueOf(a);
assertNotNull(archive);
}
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class TestObrCapReqParsing method testObrContentReqs.
public static void testObrContentReqs() throws Exception {
FileInputStream stream = new FileInputStream("testdata/fullobr.xml");
URI baseUri = new File("testdata").toURI();
List<Resource> resources = parseIndex(stream, baseUri);
assertEquals(7, resources.size());
// Check package imports of emf.minimal 2.7.0
List<Requirement> pkgReqs = resources.get(0).getRequirements("osgi.wiring.package");
assertNotNull(pkgReqs);
assertEquals(20, pkgReqs.size());
// Check mandatory/optional and filters
assertNull(pkgReqs.get(0).getDirectives().get("resolution"));
assertEquals("optional", pkgReqs.get(5).getDirectives().get("resolution"));
assertEquals("(&(osgi.wiring.package=javax.crypto)(version>=0.0.0))", pkgReqs.get(0).getDirectives().get("filter"));
// Check service requires of felix.shell
List<Requirement> svcReqs = resources.get(4).getRequirements("osgi.service");
assertNotNull(svcReqs);
assertEquals(2, svcReqs.size());
assertEquals("(osgi.service=org.osgi.service.startlevel.StartLevel)", svcReqs.get(0).getDirectives().get("filter"));
assertEquals("(osgi.service=org.osgi.service.packageadmin.PackageAdmin)", svcReqs.get(1).getDirectives().get("filter"));
}
Aggregations