use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testSplitWhenPrivateOverlapsExport.
/**
* Got a split package warning during verify when private overlaps with
* export
*/
public static void testSplitWhenPrivateOverlapsExport() throws Exception {
Builder b = new Builder();
try {
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.setProperty("Private-Package", "org.osgi.service.*");
b.setProperty("Export-Package", "org.osgi.service.event");
b.build();
assertTrue(b.check());
} finally {
b.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testConditional2.
/**
* It looks like Conditional-Package can add the same package multiple
* times. So lets test this.
*/
public static void testConditional2() throws Exception {
Properties base = new Properties();
base.put(Analyzer.EXPORT_PACKAGE, "org.osgi.service.log");
base.put(Analyzer.CONDITIONAL_PACKAGE, "org.osgi.*");
Builder analyzer = new Builder();
try {
analyzer.setProperties(base);
analyzer.setClasspath(new File[] { IO.getFile("jar/osgi.jar") });
analyzer.build();
assertTrue(analyzer.check("private references"));
Jar jar = analyzer.getJar();
assertTrue(analyzer.check());
assertNotNull(analyzer.getExports().getByFQN("org.osgi.service.log"));
assertNotNull(jar.getDirectories().get("org/osgi/framework"));
} finally {
analyzer.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class CalltreeTest method testCalltree.
@SuppressWarnings("restriction")
public static void testCalltree() throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Private-Package", "test");
b.build();
Collection<Clazz> clazzes = b.getClassspace().values();
assertTrue(clazzes.size() > 10);
CalltreeResource.writeCalltree(pw, clazzes);
pw.close();
System.err.println(sw.toString());
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ContainerTest method testBundleClasspath.
public void testBundleClasspath() throws Exception {
try (Builder b = new Builder()) {
b.addClasspath(new File("bin"));
b.setBundleClasspath(".,osgi.jar");
b.setIncludeResource("jar/osgi.jar");
b.setExportPackage("test.annotation");
b.setProperty("Hello", "World");
b.build();
assertTrue(b.check());
File testjar = IO.getFile(tmp, "test.jar");
b.getJar().write(testjar);
Attrs attrs = new Attrs();
attrs.put("expand-bcp", "true");
Container c = new Container(testjar, null, attrs);
List<File> files = new ArrayList<>();
c.contributeFiles(files, b);
assertEquals(2, files.size());
assertEquals(files.get(0).getCanonicalFile(), testjar.getCanonicalFile());
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ContractTest method testUnused.
/**
* Make sure we do not add a contract if not used
*
* @throws Exception
*/
public void testUnused() throws Exception {
Jar bjara = getContractExporter("atest", "2.5", "${exports}");
Builder a = newBuilder();
a.setTrace(true);
a.addClasspath(bjara);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("test.packageinfo,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check());
Domain domain = Domain.domain(ajar.getManifest());
Parameters p = domain.getRequireCapability();
p.remove("osgi.ee");
assertEquals(0, p.size());
}
Aggregations