use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class BNDAnnotationTest method testBrokenName.
public void testBrokenName() throws Exception {
Builder b = builder("*Broken*", 0, 2);
Jar build = b.getJar();
assertTrue(b.check("Invalid component name"));
Domain m = Domain.domain(build.getManifest());
Parameters parameters = m.getParameters("Service-Component");
assertEquals(2, parameters.size());
System.out.println(parameters);
assertTrue(parameters.keySet().contains("OSGI-INF/Hello-World-Bnd---------$.xml"));
assertTrue(parameters.keySet().contains("OSGI-INF/Hello-World.xml"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class VersionPolicyTest method testDisableDefaultPackageVersion.
/**
* Test disable default package versions.
*/
public static void testDisableDefaultPackageVersion() throws Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setProperty("Bundle-Version", "1.2.3");
a.setProperty("Export-Package", "test.refer");
a.setProperty("-nodefaultversion", "true");
Jar jar = a.build();
Manifest m = jar.getManifest();
Parameters exports = Processor.parseHeader(m.getMainAttributes().getValue(Constants.EXPORT_PACKAGE), null);
Map<String, String> attrs = exports.get("test.refer");
assertNotNull(attrs);
assertNull(attrs.get("version"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class VersionPolicyTest method testConsumerType.
/**
* Tests if the implementation of the EventHandler (which is marked as a
* ConsumerType) causes the import of the api package to use the consumer
* version policy.
*/
public static void testConsumerType() throws Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setPrivatePackage("test.versionpolicy.uses");
a.setExportPackage("test.versionpolicy.api");
a.setProperty("build", "123");
Jar jar = a.build();
assertTrue(a.check());
Manifest m = jar.getManifest();
m.write(System.err);
Domain d = Domain.domain(m);
Parameters parameters = d.getImportPackage();
Attrs attrs = parameters.get("test.versionpolicy.api");
assertNotNull(attrs);
assertEquals("[1.2,2)", attrs.get("version"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Analyzer method divideRegularAndDynamicImports.
Pair<Packages, Parameters> divideRegularAndDynamicImports() {
Packages regularImports = new Packages(imports);
Parameters dynamicImports = getDynamicImportPackage();
Iterator<Entry<PackageRef, Attrs>> regularImportsIterator = regularImports.entrySet().iterator();
while (regularImportsIterator.hasNext()) {
Entry<PackageRef, Attrs> packageEntry = regularImportsIterator.next();
PackageRef packageRef = packageEntry.getKey();
Attrs attrs = packageEntry.getValue();
String resolution = attrs.get(Constants.RESOLUTION_DIRECTIVE);
if (Constants.RESOLUTION_DYNAMIC.equals(resolution)) {
attrs.remove(Constants.RESOLUTION_DIRECTIVE);
dynamicImports.put(packageRef.fqn, attrs);
regularImportsIterator.remove();
}
}
return new Pair<>(regularImports, dynamicImports);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Analyzer method check.
/**
* Check if we have an a check option
*/
public boolean check(Check key) {
if (checks == null) {
Parameters p = new Parameters(getProperty("-check"), this);
checks = new HashSet<Check>();
for (String k : p.keySet()) try {
if (k.equalsIgnoreCase("all")) {
checks = EnumSet.allOf(Check.class);
break;
}
Check c = Enum.valueOf(Check.class, k.toUpperCase().replace('-', '_'));
checks.add(c);
} catch (Exception e) {
error("Invalid -check constant, allowed values are %s", Arrays.toString(Check.values()));
}
if (!checks.isEmpty())
checks = EnumSet.copyOf(checks);
}
return checks.contains(key) || checks.contains(Check.ALL);
}
Aggregations