Search in sources :

Example 81 with Builder

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

the class VerifierPluginTest method testNoVerifierPluginExecution.

public static void testNoVerifierPluginExecution() throws Exception {
    final AtomicBoolean executedCheck = new AtomicBoolean(false);
    AnalyzerPlugin analyzerPlugin = new AnalyzerPlugin() {

        @Override
        public boolean analyzeJar(Analyzer analyzer) throws Exception {
            // The following is null when AnalyzerPlugins execute
            Packages exports = analyzer.getExports();
            if (exports == null) {
                executedCheck.set(true);
            }
            return false;
        }
    };
    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(analyzerPlugin);
        Jar jar = b.build();
    }
    assertTrue(executedCheck.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Packages(aQute.bnd.osgi.Packages) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Analyzer(aQute.bnd.osgi.Analyzer) AnalyzerPlugin(aQute.bnd.service.AnalyzerPlugin) File(java.io.File)

Example 82 with Builder

use of aQute.bnd.osgi.Builder 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)

Example 83 with Builder

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

the class VerifierTest method testBundleActivationPolicyMultiple.

public static void testBundleActivationPolicyMultiple() throws Exception {
    Builder v = new Builder();
    v.setProperty("Private-Package", "test.activator");
    v.addClasspath(new File("bin"));
    v.setProperty(Constants.BUNDLE_ACTIVATIONPOLICY, "lazy;hello:=1,2");
    v.build();
    assertTrue(v.check("Bundle-ActivationPolicy has too many arguments lazy;hello:=1,2"));
}
Also used : Builder(aQute.bnd.osgi.Builder) File(java.io.File)

Example 84 with Builder

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

the class VerifierTest method testFilePath.

private void testFilePath(String path, String pattern, boolean good) throws Exception {
    Builder b = new Builder();
    try {
        b.setProperty("-includeresource", path + ";literal='x'");
        if (pattern != null)
            b.setProperty(Constants.INVALIDFILENAMES, pattern);
        b.build();
        if (good)
            assertTrue(b.check());
        else
            assertTrue(b.check("Invalid file/directory"));
    } finally {
        b.close();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder)

Example 85 with Builder

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

the class VerifierTest method testBundleActivationPolicyNone.

public static void testBundleActivationPolicyNone() throws Exception {
    Builder v = new Builder();
    v.setProperty("Private-Package", "test.activator");
    v.addClasspath(new File("bin"));
    v.build();
    assertTrue(v.check());
}
Also used : Builder(aQute.bnd.osgi.Builder) File(java.io.File)

Aggregations

Builder (aQute.bnd.osgi.Builder)440 Jar (aQute.bnd.osgi.Jar)228 File (java.io.File)203 Properties (java.util.Properties)99 Manifest (java.util.jar.Manifest)99 Resource (aQute.bnd.osgi.Resource)83 Attributes (java.util.jar.Attributes)43 DocumentBuilder (javax.xml.parsers.DocumentBuilder)41 XmlTester (aQute.bnd.test.XmlTester)39 Parameters (aQute.bnd.header.Parameters)35 Document (org.w3c.dom.Document)27 Attrs (aQute.bnd.header.Attrs)21 JarResource (aQute.bnd.osgi.JarResource)20 LogService (org.osgi.service.log.LogService)17 ProjectBuilder (aQute.bnd.build.ProjectBuilder)16 Domain (aQute.bnd.osgi.Domain)16 ArrayList (java.util.ArrayList)14 DependencyGraphBuilder (org.apache.maven.shared.dependency.graph.DependencyGraphBuilder)13 HashMap (java.util.HashMap)12 Project (aQute.bnd.build.Project)10