Search in sources :

Example 6 with Builder

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

the class BNDAnnotationTest method builder.

private Builder builder(String spec, int errors, int warnings) throws IOException, Exception, AssertionFailedError {
    Builder b = new Builder();
    b.setExceptions(true);
    b.setClasspath(new File[] { new File("bin") });
    b.setProperty("Service-Component", spec);
    b.setProperty("Private-Package", "test.component");
    b.setProperty("-dsannotations", "");
    b.setProperty("-fixupmessages.bndannodeprecated", "Bnd DS annotations are deprecated");
    b.build();
    assertOk(b, errors, warnings);
    return b;
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) File(java.io.File)

Example 7 with Builder

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

the class BNDAnnotationTest method testNoUnbindDynamic.

public void testNoUnbindDynamic() throws Exception {
    Builder b = builder("*NoUnbindDynamic", 1, 0);
    assertTrue(b.getErrors().get(0).endsWith("dynamic but has no unbind method."));
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder)

Example 8 with Builder

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

the class BNDAnnotationTest method testExplicitUnbind.

public void testExplicitUnbind() throws Exception {
    Builder b = builder("*ExplicitUnbind", 1, 0);
    Document doc = doc(b, "explicitunbind");
    assertEquals("setLog", xpath.evaluate("component/reference/@bind", doc));
    assertEquals("killLog", xpath.evaluate("component/reference/@unbind", doc));
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 9 with Builder

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

the class BNDAnnotationTest method testMultipleArguments.

public void testMultipleArguments() throws Exception {
    Builder b = builder("*.(MultipleArguments|ReferenceArgument)");
    Document doc = doc(b, "mcomp");
    assertAttribute(doc, "bindWithMap", "scr:component/reference/@bind");
    assertAttribute(doc, "org.osgi.service.log.LogService", "scr:component/reference/@interface");
    doc = doc(b, "rcomp");
    assertAttribute(doc, "bindReference", "scr:component/reference/@bind");
    assertAttribute(doc, "org.osgi.service.log.LogService", "scr:component/reference/@interface");
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 10 with Builder

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

the class BNDAnnotationTest method testConfig.

public void testConfig() throws Exception {
    Builder b = builder("*MetatypeConfig*");
    assertTrue(b.check());
    System.err.println(b.getJar().getResources().keySet());
    // Check component name
    {
        Resource cr = b.getJar().getResource("OSGI-INF/config.xml");
        cr.write(System.err);
        Document d = db.parse(cr.openInputStream());
        assertEquals("config", xpath.evaluate("/scr:component/@name", d, XPathConstants.STRING));
    }
    // Check if config properly linked
    {
        Resource mr = b.getJar().getResource("OSGI-INF/metatype/config.xml");
        mr.write(System.err);
        Document d = db.parse(mr.openInputStream());
        assertEquals("config", xpath.evaluate("//Designate/@factoryPid", d, XPathConstants.STRING));
        assertEquals("config", xpath.evaluate("//Object/@ocdref", d, XPathConstants.STRING));
    }
    // Now with default name
    {
        Resource cr2 = b.getJar().getResource("OSGI-INF/test.component.BNDAnnotationTest$MetatypeConfig2.xml");
        cr2.write(System.err);
        Document d = db.parse(cr2.openInputStream());
        assertEquals("test.component.BNDAnnotationTest$MetatypeConfig2", xpath.evaluate("//scr:component/@name", d, XPathConstants.STRING));
    }
    {
        Resource mr2 = b.getJar().getResource("OSGI-INF/metatype/test.component.BNDAnnotationTest$MetatypeConfig2.xml");
        mr2.write(System.err);
        Document d = db.parse(mr2.openInputStream());
        assertEquals("test.component.BNDAnnotationTest$MetatypeConfig2", xpath.evaluate("//Designate/@pid", d, XPathConstants.STRING));
        assertEquals("test.component.BNDAnnotationTest$MetatypeConfig2", xpath.evaluate("//Object/@ocdref", d, XPathConstants.STRING));
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Resource(aQute.bnd.osgi.Resource) Document(org.w3c.dom.Document)

Aggregations

Builder (aQute.bnd.osgi.Builder)426 Jar (aQute.bnd.osgi.Jar)225 File (java.io.File)197 Manifest (java.util.jar.Manifest)93 Properties (java.util.Properties)91 Resource (aQute.bnd.osgi.Resource)82 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 Domain (aQute.bnd.osgi.Domain)16 ArrayList (java.util.ArrayList)13 Project (aQute.bnd.build.Project)10 Baseline (aQute.bnd.differ.Baseline)9 Packages (aQute.bnd.osgi.Packages)9 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)9