@Test
public void testTwitter() throws Exception
{
// provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
// Use the superclasses' getUrlToEba() method instead of the pax-exam mavenBundle() method because pax-exam is running in a
// diffference bundle which doesn't have visibility to the META-INF/maven/dependencies.properties file used to figure out the
// version of the maven artifact.
URL twitterEbaUrl = getUrlToEba("org.apache.aries.samples.twitter",
"org.apache.aries.samples.twitter.eba");
URL twitterCommonLangJar_url = getUrlToBundle("commons-lang", "commons-lang");
URL twitterJar_url = getUrlToBundle("org.apache.aries.samples.twitter", "org.apache.aries.samples.twitter.twitter4j");
// add the repository xml to the repository admin
StringBuilder repositoryXML = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/obr/twitter/TwitterRepository.xml")));
String line;
while ((line = reader.readLine()) != null) {
repositoryXML.append(line);
repositoryXML.append("\r\n");
}
//replace the jar file url with the real url related to the environment
String repo = repositoryXML.toString().replaceAll("commons.lang.location", twitterCommonLangJar_url.toExternalForm());
repo = repo.replaceAll("twitter4j.location", twitterJar_url.toExternalForm());
FileWriter writer = new FileWriter("twitterRepo.xml");
writer.write(repo);
writer.close();
repositoryAdmin.addRepository(new File("twitterRepo.xml").toURI().toURL());
AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(twitterEbaUrl);
app = manager.resolve(app);
DeploymentMetadata depMeta = app.getDeploymentMetadata();
List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();