Search in sources :

Example 46 with Analyzer

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

the class IncludeHeaderTest method testTopBottom.

// public void testMavenInclude() throws Exception {
// String b = "pom.modelVersion=b\n";
// File bb = new File("b.props");
// write(bb, b );
// bb.deleteOnExit();
//
// Analyzer analyzer = new Analyzer();
// Properties x = new Properties();
// x.put("pom.modelVersion", "set");
// x.put("pom.scope.test", "set");
// x.put("-include", "~maven/pom.xml,b.props");
// analyzer.setProperties(x);
// System.err.println(analyzer.getErrors());
// System.err.println(analyzer.getWarnings());
// assertEquals("b", analyzer.getProperty("pom.modelVersion")); // from b
// assertEquals("org.apache.felix.metatype",
// analyzer.getProperty("pom.artifactId")); // from pom
// assertEquals("org.apache.felix", analyzer.getProperty("pom.groupId")); //
// from parent pom
// assertEquals("set", analyzer.getProperty("pom.scope.test")); // Set
// }
public static void testTopBottom() throws Exception {
    Analyzer analyzer = new Analyzer();
    analyzer.setProperties(IO.getFile("src/test/include.bnd/top.bnd"));
    assertEquals("0.0.257", analyzer.getProperty("Bundle-Version"));
}
Also used : Analyzer(aQute.bnd.osgi.Analyzer)

Example 47 with Analyzer

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

the class IncludeHeaderTest method testIncludeWithProperty.

public static void testIncludeWithProperty() throws IOException {
    File home = new File(System.getProperty("user.home"));
    File include = new File(home, "includeheadertest.txt");
    try {
        FileOutputStream fw = new FileOutputStream(include);
        fw.write("IncludeHeaderTest: yes\n\r".getBytes());
        fw.write("a: 2\n\r".getBytes());
        fw.write("b: ${a}\n\r".getBytes());
        fw.close();
        Analyzer analyzer = new Analyzer();
        analyzer.setBase(IO.getFile("src/test"));
        Properties p = new Properties();
        p.put("a", "1");
        p.put("-include", "-iamnotthere.txt, ${user.home}/includeheadertest.txt");
        analyzer.setProperties(p);
        String value = analyzer.getProperty("IncludeHeaderTest");
        assertEquals("yes", value);
        assertEquals("2", analyzer.getProperty("a"));
        assertEquals("2", analyzer.getProperty("b"));
        assertEquals(0, analyzer.getErrors().size());
    } finally {
        include.delete();
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Analyzer(aQute.bnd.osgi.Analyzer) Properties(java.util.Properties) File(java.io.File)

Example 48 with Analyzer

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

the class IncludeHeaderTest method testUrlIncludes.

/**
	 * Test url includes props: a\ b\ c\ d last-props: end
	 */
public static void testUrlIncludes() throws IOException {
    Analyzer a = new Analyzer();
    Properties p = new Properties();
    p.setProperty("a", "1");
    p.setProperty("-include", "file:src/test/includeheadertest.prop");
    a.setProperties(p);
    assertEquals("1", a.getProperty("a"));
    assertEquals("end", a.getProperty("last-props"));
    assertEquals("abcd", a.getProperty("props"));
}
Also used : Analyzer(aQute.bnd.osgi.Analyzer) Properties(java.util.Properties)

Example 49 with Analyzer

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

the class ClazzTest method testUnusedClassConstant.

/**
	 * There is an unused class constant in the This actually looks wrong since
	 */
public void testUnusedClassConstant() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("testresources/TestWeavingHook.jclass"), new ClassDataCollector() {
        });
        // TODO test someething here
        System.out.println(c.getReferred());
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Analyzer(aQute.bnd.osgi.Analyzer) ClassDataCollector(aQute.bnd.osgi.ClassDataCollector) FileInputStream(java.io.FileInputStream)

Example 50 with Analyzer

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

the class ClazzTest method testModuleInfo.

public void testModuleInfo() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("jar/module-info.jclass"), new ClassDataCollector() {
        });
        assertTrue(c.isModule());
        Set<PackageRef> referred = c.getReferred();
        Descriptors d = new Descriptors();
        assertFalse(referred.contains(d.getPackageRef("")));
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Descriptors(aQute.bnd.osgi.Descriptors) Analyzer(aQute.bnd.osgi.Analyzer) ClassDataCollector(aQute.bnd.osgi.ClassDataCollector) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef) FileInputStream(java.io.FileInputStream)

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