use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AttributesTest method testRemoveAttribute.
/**
* Remove a version attribute
*
* @throws Exception
*/
public static void testRemoveAttribute() throws Exception {
Jar javax = new Jar("test");
Manifest m = new Manifest();
m.getMainAttributes().putValue("Export-Package", "javax.microedition.io;common=split;test=abc;mandatory:=\"common,test\"");
javax.setManifest(m);
Jar[] cp = { javax, new Jar(IO.getFile("jar/osgi.jar")) };
Builder bmaker = new Builder();
Properties p = new Properties();
p.put("Import-Package", "javax.microedition.io;common=!;test=abc,*");
p.put("Export-Package", "org.osgi.service.io");
bmaker.setClasspath(cp);
bmaker.setProperties(p);
Jar jar = bmaker.build();
assertTrue(bmaker.check());
jar.getManifest().write(System.err);
Manifest manifest = jar.getManifest();
Attributes main = manifest.getMainAttributes();
String imprt = main.getValue("Import-Package");
assertNotNull("Import package header", imprt);
Parameters map = Processor.parseHeader(imprt, null);
Map<String, String> attrs = map.get("javax.microedition.io");
assertNotNull(attrs);
assertNull(attrs.get("common"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AttributesTest method testOverrideAttribute.
/**
* Override a version attribute
*
* @throws Exception
*/
public static void testOverrideAttribute() throws Exception {
File[] cp = { IO.getFile("jar/osgi.jar") };
Builder bmaker = new Builder();
Properties p = new Properties();
p.put("Export-Package", "org.osgi.framework;version=1.1");
bmaker.setClasspath(cp);
bmaker.setProperties(p);
Jar jar = bmaker.build();
System.err.println(jar.getResources());
// System.err.println(bmaker.getExports());
System.err.println("Warnings: " + bmaker.getWarnings());
System.err.println("Errors : " + bmaker.getErrors());
jar.getManifest().write(System.err);
Manifest manifest = jar.getManifest();
Attributes main = manifest.getMainAttributes();
String export = main.getValue("Export-Package");
assertNotNull("Export package header", export);
Parameters map = Processor.parseHeader(export, null);
assertEquals("1.1", map.get("org.osgi.framework").get("version"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AttributesTest method testSimple.
/**
* See if we inherit the version from the osgi.jar file.
*
* @throws Exception
*/
public static void testSimple() throws Exception {
File[] cp = { IO.getFile("jar/osgi.jar") };
Builder bmaker = new Builder();
Properties p = new Properties();
p.put("Export-Package", "org.osgi.framework");
bmaker.setClasspath(cp);
bmaker.setProperties(p);
Jar jar = bmaker.build();
System.err.println(jar.getResources());
// System.err.println(bmaker.getExports());
System.err.println("Warnings: " + bmaker.getWarnings());
System.err.println("Errors : " + bmaker.getErrors());
jar.getManifest().write(System.err);
Manifest manifest = jar.getManifest();
Attributes main = manifest.getMainAttributes();
String export = main.getValue("Export-Package");
assertNotNull("Export package header", export);
Parameters map = Processor.parseHeader(export, null);
assertEquals("1.3", map.get("org.osgi.framework").get("version"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class BuilderTest method testExportedVersionsNotPickedUp.
/**
* Complaint that exported versions were not picked up from external bundle.
*/
public static void testExportedVersionsNotPickedUp() throws Exception {
Builder b = new Builder();
try {
b.addClasspath(IO.getFile("jar/jsr311-api-1.1.1.jar"));
b.setProperty("Export-Package", "javax.ws.rs.core");
Jar jar = b.build();
assertTrue(b.check());
String ip = jar.getManifest().getMainAttributes().getValue(Constants.EXPORT_PACKAGE);
Parameters map = Processor.parseHeader(ip, null);
assertEquals("1.1.1", map.get("javax.ws.rs.core").get("version"));
} finally {
b.close();
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class BuilderTest method testUnProvidedVersion.
public static void testUnProvidedVersion() throws Exception {
Builder b = new Builder();
try {
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.addClasspath(new File("bin"));
b.setProperty(Constants.EXPORT_PACKAGE, "org.osgi.service.event;provide:=false");
b.setProperty("Private-Package", "test.refer");
Jar jar = b.build();
assertTrue(b.check());
String ip = jar.getManifest().getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
Parameters map = Processor.parseHeader(ip, null);
assertEquals("[1.0,2)", map.get("org.osgi.service.event").get("version"));
} finally {
b.close();
}
}
Aggregations