use of aQute.bnd.osgi.Verifier in project bnd by bndtools.
the class NativeHeader method testWildcard.
public static void testWildcard() throws Exception {
Verifier v = new Verifier(b);
v.doNative("x.so ;y.so;osname=Linux;processor=amd64,*");
assertOk(v);
}
use of aQute.bnd.osgi.Verifier in project bnd by bndtools.
the class NativeHeader method testWildcardNotAtEnd.
public static void testWildcardNotAtEnd() throws Exception {
Verifier v = new Verifier(b);
v.doNative("x.so;osname=win32,*,x.dll");
assertBad(v, "may only END in wildcard");
}
use of aQute.bnd.osgi.Verifier in project bnd by bndtools.
the class VerifierTest method testFailedOSGiJar.
public static void testFailedOSGiJar() throws Exception {
Jar jar = new Jar("jar/osgi.residential-4.3.0.jar");
Verifier v = new Verifier(jar);
assertTrue(v.check());
}
use of aQute.bnd.osgi.Verifier in project bnd by bndtools.
the class VerifierTest method verifyMetaPersistence.
/**
* Verify that the Meta-Persistence header is correctly verified
*
* @throws Exception
*/
public void verifyMetaPersistence() throws Exception {
Builder b = new Builder();
b.setIncludeResource("foo.xml;literal='I exist'");
Jar inner = b.build();
assertTrue(b.check());
Jar outer = new Jar("x");
outer.putResource("foo.jar", new JarResource(inner));
Manifest m = new Manifest();
m.getMainAttributes().putValue(Constants.META_PERSISTENCE, "foo.jar, foo.jar!/foo.xml, absent.xml");
outer.setManifest(m);
Verifier v = new Verifier(outer);
v.verifyMetaPersistence();
assertTrue(v.check("Meta-Persistence refers to resources not in the bundle: \\[absent.xml\\]"));
}
use of aQute.bnd.osgi.Verifier in project bndtools by bndtools.
the class Printer method doPrint.
private void doPrint(File file, int options) throws ZipException, IOException, Exception {
try (Jar jar = new Jar(file.getName(), file)) {
if ((options & VERIFY) != 0) {
Verifier verifier = new Verifier(jar);
verifier.setPedantic(isPedantic());
verifier.verify();
getInfo(verifier);
}
if ((options & MANIFEST) != 0) {
Manifest manifest = jar.getManifest();
if (manifest == null)
warning("JAR has no manifest " + file);
else {
out.println("[MANIFEST " + jar.getName() + "]");
printManifest(manifest);
}
out.println();
}
if ((options & IMPEXP) != 0) {
out.println("[IMPEXP]");
Manifest m = jar.getManifest();
if (m != null) {
Domain domain = Domain.domain(m);
Parameters imports = domain.getImportPackage();
Parameters exports = domain.getExportPackage();
for (String p : exports.keySet()) {
if (imports.containsKey(p)) {
Attrs attrs = imports.get(p);
if (attrs.containsKey(VERSION_ATTRIBUTE)) {
exports.get(p).put("imported-as", attrs.get(VERSION_ATTRIBUTE));
}
}
}
print("Import-Package", new TreeMap<String, Attrs>(imports));
print("Export-Package", new TreeMap<String, Attrs>(exports));
} else
warning("File has no manifest");
}
if ((options & (USES | USEDBY)) != 0) {
out.println();
try (Analyzer analyzer = new Analyzer()) {
analyzer.setPedantic(isPedantic());
analyzer.setJar(jar);
analyzer.analyze();
if ((options & USES) != 0) {
out.println("[USES]");
printMultiMap(analyzer.getUses());
out.println();
}
if ((options & USEDBY) != 0) {
out.println("[USEDBY]");
Map<PackageRef, Set<PackageRef>> usedBy = CollectionUtil.invertMapOfCollection(analyzer.getUses());
printMultiMap(usedBy);
}
analyzer.setJar((Jar) null);
}
out.println();
}
if ((options & COMPONENT) != 0) {
printComponents(jar);
out.println();
}
if ((options & METATYPE) != 0) {
printMetatype(jar);
out.println();
}
if ((options & LIST) != 0) {
out.println("[LIST]");
for (Map.Entry<String, Map<String, Resource>> entry : jar.getDirectories().entrySet()) {
String name = entry.getKey();
Map<String, Resource> contents = entry.getValue();
out.println(name);
if (contents != null) {
for (String element : contents.keySet()) {
int n = element.lastIndexOf('/');
if (n > 0)
element = element.substring(n + 1);
out.print(" ");
out.print(element);
String path = element;
if (name.length() != 0)
path = name + "/" + element;
Resource r = contents.get(path);
if (r != null) {
String extra = r.getExtra();
if (extra != null) {
out.print(" extra='" + escapeUnicode(extra) + "'");
}
}
out.println();
}
}
}
out.println();
}
}
}
Aggregations