use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.
the class PomRepository method read.
void read() throws Exception {
if (isStale()) {
refresh();
} else {
try (XMLResourceParser parser = new XMLResourceParser(getLocation())) {
List<Resource> resources = parser.parse();
addAll(resources);
}
}
}
use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.
the class SearchRepository method read.
void read() throws Exception {
if (isStale()) {
refresh();
} else {
try (XMLResourceParser parser = new XMLResourceParser(getLocation())) {
List<Resource> resources = parser.parse();
addAll(resources);
}
}
}
use of aQute.bnd.osgi.repository.XMLResourceParser 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 aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.
the class RepositoryTest method testXMLParserSmall.
public void testXMLParserSmall() throws Exception {
URL url = RepositoryTest.class.getResource("repoindex-file.xml");
try (XMLResourceParser xrp = new XMLResourceParser(url.toURI())) {
xrp.setTrace(true);
List<Resource> resources = xrp.parse();
assertTrue(xrp.check());
assertNotNull(resources);
assertEquals(21, resources.size());
Requirement requirement = new RequirementBuilder("osgi.extender").addDirective("filter", "(osgi.extender=osgi.component)").buildSyntheticRequirement();
Map<Requirement, Collection<Capability>> caps = getResourcesRepository(resources).findProviders(Collections.singleton(requirement));
assertEquals(1, caps.get(requirement).size());
Resource res = caps.get(requirement).iterator().next().getResource();
assertEquals("org.apache.felix.scr", ResourceUtils.getIdentityCapability(res).getAttributes().get("osgi.identity"));
String location = ResourceUtils.getContentCapability(res).getAttributes().get("url").toString();
assertFalse(location, location.contains("file:"));
}
}
use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.
the class RepositoryTest method testXMLParserLarge.
public void testXMLParserLarge() throws Exception {
URL url = RepositoryTest.class.getResource("larger-repo.xml");
try (XMLResourceParser xrp = new XMLResourceParser(url.toURI())) {
xrp.setTrace(true);
List<Resource> resources = xrp.parse();
assertTrue(xrp.check());
assertNotNull(resources);
assertEquals(61, resources.size());
Requirement requirement = new RequirementBuilder("osgi.extender").addDirective("filter", "(osgi.extender=osgi.component)").buildSyntheticRequirement();
Map<Requirement, Collection<Capability>> caps = getResourcesRepository(resources).findProviders(Collections.singleton(requirement));
assertEquals(1, caps.get(requirement).size());
Resource res = caps.get(requirement).iterator().next().getResource();
assertEquals("org.apache.felix.scr", ResourceUtils.getIdentityCapability(res).getAttributes().get("osgi.identity"));
String location = ResourceUtils.getContentCapability(res).getAttributes().get("url").toString();
String base = url.toURI().toString();
assertFalse(location, location.startsWith(base));
}
}
Aggregations