Search in sources :

Example 6 with Verifier

use of aQute.bnd.osgi.Verifier in project bnd by bndtools.

the class BuilderTest method testMissingImportsWithoutDynamicImport.

/**
	 * #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 testMissingImportsWithoutDynamicImport() throws Exception {
    Builder b = new Builder();
    try {
        b.addClasspath(new File("bin"));
        b.setPedantic(true);
        b.setExportPackage("test.classreference;version=1");
        b.setImportPackage("!*");
        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();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Verifier(aQute.bnd.osgi.Verifier) File(java.io.File)

Example 7 with Verifier

use of aQute.bnd.osgi.Verifier in project bnd by bndtools.

the class BuilderTest method testMissingImportWithRequireBundle.

/**
	 * A Require-Bundle should not fail on missing imports, just warn
	 * 
	 * @throws Exception
	 */
public void testMissingImportWithRequireBundle() 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("Require-Bundle", "com.abc");
        b.build();
        assertTrue(b.check());
        Verifier v = new Verifier(b.getJar());
        v.verify();
        assertTrue(v.check());
    } finally {
        b.close();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Verifier(aQute.bnd.osgi.Verifier) File(java.io.File)

Example 8 with Verifier

use of aQute.bnd.osgi.Verifier 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();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Verifier(aQute.bnd.osgi.Verifier) File(java.io.File)

Example 9 with Verifier

use of aQute.bnd.osgi.Verifier in project bnd by bndtools.

the class VerifierTest method testnativeCode.

public static void testnativeCode() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setProperty("-resourceonly", "true");
    b.setProperty("Include-Resource", "native/win32/NTEventLogAppender-1.2.dll;literal='abc'");
    b.setProperty("Bundle-NativeCode", "native/win32/NTEventLogAppender-1.2.dll; osname=Win32; processor=x86");
    b.build();
    Verifier v = new Verifier(b);
    v.verifyNative();
    System.err.println(v.getErrors());
    assertEquals(0, v.getErrors().size());
    v.close();
    b.close();
}
Also used : Builder(aQute.bnd.osgi.Builder) Verifier(aQute.bnd.osgi.Verifier) File(java.io.File)

Example 10 with Verifier

use of aQute.bnd.osgi.Verifier in project bnd by bndtools.

the class bnd method _verify.

/**
	 * Verify jars.
	 * 
	 * @throws Exception
	 */
@Description("Verify jars")
public void _verify(verifyOptions opts) throws Exception {
    for (String path : opts._arguments()) {
        File f = getFile(path);
        if (!f.isFile()) {
            error("No such file: %s", f);
        } else {
            Jar jar = new Jar(f);
            if (jar.getManifest() == null || jar.getBsn() == null)
                error("Not a bundle %s", f);
            else {
                Verifier v = new Verifier(jar);
                getInfo(v, f.getName());
                v.close();
            }
            jar.close();
        }
    }
}
Also used : Jar(aQute.bnd.osgi.Jar) Verifier(aQute.bnd.osgi.Verifier) File(java.io.File) Description(aQute.lib.getopt.Description)

Aggregations

Verifier (aQute.bnd.osgi.Verifier)15 Jar (aQute.bnd.osgi.Jar)6 File (java.io.File)6 Builder (aQute.bnd.osgi.Builder)5 Manifest (java.util.jar.Manifest)4 Attrs (aQute.bnd.header.Attrs)3 Parameters (aQute.bnd.header.Parameters)3 Analyzer (aQute.bnd.osgi.Analyzer)2 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)2 Domain (aQute.bnd.osgi.Domain)2 Resource (aQute.bnd.osgi.Resource)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 PomFromManifest (aQute.bnd.maven.PomFromManifest)1 Def (aQute.bnd.osgi.Clazz.Def)1 Descriptors (aQute.bnd.osgi.Descriptors)1 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)1 FileResource (aQute.bnd.osgi.FileResource)1