use of org.apache.felix.bundlerepository.Repository in project aries by apache.
the class OBRResolverTest method testProvisionExcludeLocalRepo.
/**
* Test the resolution should fail because the required package org.apache.aries.util is provided by the local runtime,
* which is not included when provisioning.
*
* @throws Exception
*/
@Test(expected = ResolverException.class)
public void testProvisionExcludeLocalRepo() throws Exception {
// do not provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar");
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
//installing requires a valid url for the bundle in repository.xml.
app = manager.resolve(app);
}
use of org.apache.felix.bundlerepository.Repository in project aries by apache.
the class OBRResolverTest method testBlogAppResolveFail.
@Test(expected = ResolverException.class)
public void testBlogAppResolveFail() throws ResolverException, Exception {
// provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
//installing requires a valid url for the bundle in repository.xml.
app = manager.resolve(app);
}
use of org.apache.felix.bundlerepository.Repository in project aries by apache.
the class OBRResolverTest method clearRepository.
@After
public void clearRepository() {
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
if ((repos != null) && (repos.length > 0)) {
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
}
}
use of org.apache.felix.bundlerepository.Repository in project aries by apache.
the class RepositoryGenerator method find.
/**
* the format of resource is like bundlesymbolicname;version=1.0.0, for example com.ibm.ws.eba.example.blog.api;version=1.0.0,
*/
@SuppressWarnings({ "rawtypes", "unused" })
public Resource find(String resource) throws SubsystemException {
generateOBR();
Content content = new ContentImpl(resource);
String symbolicName = content.getContentName();
// this version could possibly be a range
String version = content.getVersion().toString();
StringBuilder filterString = new StringBuilder();
filterString.append("(&(name" + "=" + symbolicName + "))");
filterString.append("(version" + "=" + version + "))");
//org.apache.felix.bundlerepository.Resource[] res = this.repositoryAdmin.discoverResources(filterString.toString());
Repository[] repos = this.repositoryAdmin.listRepositories();
org.apache.felix.bundlerepository.Resource res = null;
for (Repository repo : repos) {
org.apache.felix.bundlerepository.Resource[] resources = repo.getResources();
for (int i = 0; i < resources.length; i++) {
if (resources[i].getSymbolicName().equals(symbolicName)) {
if (resources[i].getVersion().compareTo(new Version(version)) == 0) {
res = resources[i];
break;
}
}
}
}
if (res == null) {
// throw new SubsystemException("unable to find the resource " + resource);
return null;
}
Map props = res.getProperties();
Object type = props.get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE);
return new FelixResourceAdapter(res);
}
use of org.apache.felix.bundlerepository.Repository in project aries by apache.
the class Aries1608Test method createRepositoryXml.
private URL createRepositoryXml(DataModelHelper helper) throws Exception {
File dir;
String cwd = new File("").getAbsolutePath();
if (cwd.endsWith(File.separator + "target")) {
dir = new File("test-classes/aries1608");
} else {
dir = new File("target/test-classes/aries1608");
}
File jar = new File(dir, "aries1608provider.jar");
assertTrue("The bundle jar does not exist: " + jar.getAbsolutePath(), jar.exists());
Resource resource = helper.createResource(jar.toURI().toURL());
Repository repository = helper.repository(new Resource[] { resource });
File file = new File(dir, "repository.xml");
FileWriter fw = new FileWriter(file);
try {
helper.writeRepository(repository, fw);
return file.toURI().toURL();
} finally {
fw.close();
}
}
Aggregations