Search in sources :

Example 26 with Analyzer

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

the class ClazzTest method testNoClassBound.

public void testNoClassBound() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        // From aQute.lib.collections.SortedList.fromIterator()
        c.parseDescriptor("<T::Ljava/lang/Comparable<*>;>(Ljava/util/Iterator<TT;>;)LaQute/lib/collections/SortedList<TT;>;", Modifier.PUBLIC);
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Analyzer(aQute.bnd.osgi.Analyzer)

Example 27 with Analyzer

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

the class ClazzTest method testCaughtExceptions.

public void testCaughtExceptions() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("bin/test/ClazzTest$Catching.class"), new ClassDataCollector() {
        });
        assertTrue(c.getReferred().toString().contains("org.xml.sax"));
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Analyzer(aQute.bnd.osgi.Analyzer) ClassDataCollector(aQute.bnd.osgi.ClassDataCollector) FileInputStream(java.io.FileInputStream)

Example 28 with Analyzer

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

the class ClazzTest method testRecursiveAnnotation.

public void testRecursiveAnnotation() throws Exception {
    File file = IO.getFile("bin/test/ClazzTest$RecursiveAnno.class");
    try (Analyzer analyzer = new Analyzer()) {
        Clazz clazz = new Clazz(analyzer, file.getPath(), new FileResource(file));
        clazz.parseClassFile();
        analyzer.getClassspace().put(clazz.getClassName(), clazz);
        AnnotationReader.getDefinition(clazz, analyzer, EnumSet.noneOf(DSAnnotations.Options.class), new XMLAttributeFinder(analyzer), AnnotationReader.V1_3);
    }
}
Also used : XMLAttributeFinder(aQute.bnd.xmlattribute.XMLAttributeFinder) FileResource(aQute.bnd.osgi.FileResource) Clazz(aQute.bnd.osgi.Clazz) Analyzer(aQute.bnd.osgi.Analyzer) File(java.io.File)

Example 29 with Analyzer

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

the class PropertiesTest method testProperties.

public static void testProperties() throws Exception {
    Analyzer analyzer = new Analyzer();
    analyzer.setProperties(IO.getFile("src/test/variables.mf"));
    assertEquals("aQute.test", analyzer.getProperty("Header"));
    System.err.println("property " + analyzer.getProperty("Header"));
}
Also used : Analyzer(aQute.bnd.osgi.Analyzer)

Example 30 with Analyzer

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

Aggregations

Analyzer (aQute.bnd.osgi.Analyzer)55 File (java.io.File)21 Clazz (aQute.bnd.osgi.Clazz)14 Properties (java.util.Properties)14 Manifest (java.util.jar.Manifest)12 Jar (aQute.bnd.osgi.Jar)11 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)9 ClassDataCollector (aQute.bnd.osgi.ClassDataCollector)8 Parameters (aQute.bnd.header.Parameters)7 FileResource (aQute.bnd.osgi.FileResource)7 FileInputStream (java.io.FileInputStream)6 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)5 Description (aQute.lib.getopt.Description)5 Attrs (aQute.bnd.header.Attrs)4 Descriptors (aQute.bnd.osgi.Descriptors)4 Packages (aQute.bnd.osgi.Packages)4 Resource (aQute.bnd.osgi.Resource)4 Map (java.util.Map)4 PomFromManifest (aQute.bnd.maven.PomFromManifest)3 Domain (aQute.bnd.osgi.Domain)3