Search in sources :

Example 1 with VerifierPlugin

use of aQute.bnd.service.verifier.VerifierPlugin in project bnd by bndtools.

the class VerifierPluginTest method testVerifierPluginExecution.

public static void testVerifierPluginExecution() throws Exception {
    final AtomicBoolean executedCheck = new AtomicBoolean(false);
    VerifierPlugin verifier = new VerifierPlugin() {

        @Override
        public void verify(Analyzer analyzer) throws Exception {
            // the following is true only after the jar and manifest have
            // been analyzed
            Packages exports = analyzer.getExports();
            PackageRef packageRef = analyzer.getPackageRef("test/activator");
            if (exports.containsKey(packageRef)) {
                executedCheck.set(true);
            }
        }
    };
    try (Builder b = new Builder()) {
        b.setProperty("Bundle-SymbolicName", "p1");
        b.setProperty("Bundle-Version", "1.2.3");
        b.setExportPackage("test.activator");
        b.addClasspath(new File("bin"));
        b.getPlugins().add(verifier);
        Jar jar = b.build();
    }
    assertTrue(executedCheck.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VerifierPlugin(aQute.bnd.service.verifier.VerifierPlugin) Packages(aQute.bnd.osgi.Packages) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Analyzer(aQute.bnd.osgi.Analyzer) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef) File(java.io.File)

Aggregations

Analyzer (aQute.bnd.osgi.Analyzer)1 Builder (aQute.bnd.osgi.Builder)1 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)1 Jar (aQute.bnd.osgi.Jar)1 Packages (aQute.bnd.osgi.Packages)1 VerifierPlugin (aQute.bnd.service.verifier.VerifierPlugin)1 File (java.io.File)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1