use of aQute.bnd.osgi.Packages in project bnd by bndtools.
the class BuilderTest method assertVersionEquals.
static void assertVersionEquals(String input, String output) throws Exception {
File[] cp = { IO.getFile("jar/osgi.jar") };
Builder bmaker = new Builder();
try {
bmaker.setClasspath(cp);
Properties p = new Properties();
p.put(Analyzer.EXPORT_PACKAGE, "test.activator");
p.put(Analyzer.IMPORT_PACKAGE, "org.osgi.framework;version=\"" + input + "\"");
bmaker.setProperties(p);
bmaker.build();
assertTrue(bmaker.check("The JAR is empty"));
Packages imports = bmaker.getImports();
Map<String, String> framework = imports.get(bmaker.getPackageRef("org.osgi.framework"));
assertEquals(output, framework.get("version"));
} finally {
bmaker.close();
}
}
use of aQute.bnd.osgi.Packages in project bnd by bndtools.
the class BuilderTest method testImportRangeCalculatedFromClasspath_4.
/**
* Check if we imported the package with the correct version range when
* there's an empty package in front of it in the classpath. Second form
* calling builds().
*/
public static void testImportRangeCalculatedFromClasspath_4() throws Exception {
Properties base = new Properties();
base.put(Analyzer.IMPORT_PACKAGE, "javax.servlet,javax.servlet.http");
String pwd = System.getProperty("user.dir");
base.put("pwd", new File(pwd).toURI().toString());
base.put("-classpath", "${pwd}/jar/jsp-api.jar,${pwd}/jar/servlet-api.jar");
Builder analyzer = new Builder();
try {
analyzer.addClasspath(new File("bin"));
analyzer.setPrivatePackage("test");
analyzer.setProperties(base);
analyzer.builds();
assertTrue(analyzer.check());
Packages imports = analyzer.getImports();
Attrs attrs = imports.getByFQN("javax.servlet.http");
assertEquals("[3.0,4)", attrs.getVersion());
attrs = imports.getByFQN("javax.servlet");
assertEquals("[3.0,4)", attrs.getVersion());
} finally {
analyzer.close();
}
}
Aggregations