use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testFromOSGiDirective.
/**
* Test the from: directive on expanding packages.
*/
public static void testFromOSGiDirective() throws Exception {
Builder b = new Builder();
try {
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.addClasspath(IO.getFile("jar/org.eclipse.osgi-3.5.0.jar"));
b.setProperty("Export-Package", "org.osgi.framework;from:=osgi");
b.build();
assertTrue(b.check());
assertEquals("1.3", b.getExports().getByFQN("org.osgi.framework").get("version"));
assertEquals("osgi", b.getExports().getByFQN("org.osgi.framework").get(Constants.FROM_DIRECTIVE));
} finally {
b.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testIncludeResourceFromZipDeep.
public static void testIncludeResourceFromZipDeep() throws Exception {
Builder bmaker = new Builder();
try {
Properties p = new Properties();
p.put("Include-Resource", "@jar/easymock.jar!/**");
bmaker.setProperties(p);
Jar jar = bmaker.build();
assertTrue(bmaker.check());
assertEquals(59, jar.getResources().size());
} finally {
bmaker.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testLastModifiedForManifest.
/**
* Test if the Manifest gets the last modified date
*/
public void testLastModifiedForManifest() throws Exception {
File file = new File("tmp.jar");
try {
long time = System.currentTimeMillis();
Builder b = new Builder();
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.setExportPackage("org.osgi.framework");
Jar build = b.build();
try {
assertTrue(b.check());
build.write("tmp.jar");
Jar ajr = new Jar(file);
try {
Resource r = ajr.getResource("META-INF/MANIFEST.MF");
assertNotNull(r);
long t = r.lastModified();
Date date = new Date(t);
System.out.println(date + " " + t);
// TODO we need to adapt the timestamp handling
assertTrue(date + " " + t, t == 1142555622000L);
} finally {
ajr.close();
}
} finally {
build.close();
}
} finally {
file.delete();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testImportRangeCalculatedFromClasspath_2.
/**
* 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.
*/
public static void testImportRangeCalculatedFromClasspath_2() 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.build();
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();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testMissingImportsWithDynamicImport.
/**
* #479 I have now tested this locally. Apparently the fix doesn't change
* the reported behavior. In my test bundle, I have removed all imports. Bnd
* builds this with no errors reported. I add: DynamicImport-Package: dummy
*/
public void testMissingImportsWithDynamicImport() throws Exception {
Builder b = new Builder();
try {
b.addClasspath(new File("bin"));
b.setPedantic(true);
b.setExportPackage("test.classreference;version=1");
b.setImportPackage("!*");
b.setProperty(Constants.DYNAMICIMPORT_PACKAGE, "dummy");
b.build();
assertTrue(b.check());
Verifier v = new Verifier(b.getJar());
try {
v.verify();
assertTrue(v.check("Unresolved references to \\[javax.swing\\] by class\\(es\\)"));
} finally {
v.close();
}
} finally {
b.close();
}
}
Aggregations