Search in sources :

Example 16 with Builder

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

the class BNDAnnotationTest method testTypeVersusDetailed.

public void testTypeVersusDetailed() throws Exception {
    Builder b = builder("*.TypeVersusDetailed");
    Document doc = doc(b, "xcomp");
    print(doc, "");
    assertAttribute(doc, "bind2", "component/reference[1]/@bind");
    assertAttribute(doc, "dynamic", "component/reference[1]/@policy");
    assertAttribute(doc, "0..n", "component/reference[1]/@cardinality");
    assertAttribute(doc, "bind", "component/reference[2]/@bind");
    assertAttribute(doc, "dynamic", "component/reference[2]/@policy");
    assertAttribute(doc, "0..n", "component/reference[2]/@cardinality");
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 17 with Builder

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

the class BNDAnnotationTest method testAnnotationsStrangeBindMethods.

public void testAnnotationsStrangeBindMethods() throws Exception {
    Builder b = builder("*MyComponent2");
    Document doc = doc(b, "acomp");
    assertEquals("addLogMultiple", xpath.evaluate("//@bind", doc));
    assertEquals("", xpath.evaluate("//@unbind", doc));
    assertAttribute(doc, "logMultiple", "scr:component/reference[1]/@name");
    assertAttribute(doc, "addLogMultiple", "scr:component/reference[1]/@bind");
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 18 with Builder

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

the class BNDAnnotationTest method testConfigurationPolicy.

public void testConfigurationPolicy() throws Exception {
    Builder b = builder("*.ConfigurationPolicyTest");
    Document doc = doc(b, "cpcomp");
    assertEquals("java.io.Serializable", doc.getElementsByTagName("provide").item(0).getAttributes().getNamedItem("interface").getTextContent());
    assertEquals("org.osgi.service.event.EventAdmin", doc.getElementsByTagName("provide").item(1).getAttributes().getNamedItem("interface").getTextContent());
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 19 with Builder

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

the class BNDAnnotationTest method testMixedBndStandard.

public void testMixedBndStandard() throws Exception {
    Builder b = builder("*MixedBndStd", 5, 0);
    List<String> errors = new ArrayList<String>(b.getErrors());
    Collections.sort(errors);
    assertEquals("The DS component mixed-bnd-std uses bnd annotations to declare it as a component, but also uses the standard DS annotation: org.osgi.service.component.annotations.Activate on method start with signature ()V. It is an error to mix these two types of annotations", errors.get(0));
    assertEquals("The DS component mixed-bnd-std uses bnd annotations to declare it as a component, but also uses the standard DS annotation: org.osgi.service.component.annotations.Deactivate on method stop with signature ()V. It is an error to mix these two types of annotations", errors.get(1));
    assertEquals("The DS component mixed-bnd-std uses bnd annotations to declare it as a component, but also uses the standard DS annotation: org.osgi.service.component.annotations.Modified on method update with signature (Ljava/util/Map;)V. It is an error to mix these two types of annotations", errors.get(2));
    assertEquals("The DS component mixed-bnd-std uses bnd annotations to declare it as a component, but also uses the standard DS annotation: org.osgi.service.component.annotations.Reference on field ea. It is an error to mix these two types of annotations", errors.get(3));
    assertEquals("The DS component mixed-bnd-std uses bnd annotations to declare it as a component, but also uses the standard DS annotation: org.osgi.service.component.annotations.Reference on method setLog with signature (Lorg/osgi/service/log/LogService;)V. It is an error to mix these two types of annotations", errors.get(4));
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ArrayList(java.util.ArrayList)

Example 20 with Builder

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

the class BNDAnnotationTest method testBrokenName.

public void testBrokenName() throws Exception {
    Builder b = builder("*Broken*", 0, 2);
    Jar build = b.getJar();
    assertTrue(b.check("Invalid component name"));
    Domain m = Domain.domain(build.getManifest());
    Parameters parameters = m.getParameters("Service-Component");
    assertEquals(2, parameters.size());
    System.out.println(parameters);
    assertTrue(parameters.keySet().contains("OSGI-INF/Hello-World-Bnd---------$.xml"));
    assertTrue(parameters.keySet().contains("OSGI-INF/Hello-World.xml"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Jar(aQute.bnd.osgi.Jar) Domain(aQute.bnd.osgi.Domain)

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