Search in sources :

Example 21 with Builder

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

the class BNDAnnotationTest method testAnnotations.

public void testAnnotations() throws Exception {
    Builder b = builder("*MyComponent");
    Document doc = doc(b, "acomp");
    print(doc, "");
    assertAttribute(doc, "test.component.BNDAnnotationTest$MyComponent", "scr:component/implementation/@class");
    assertAttribute(doc, "acomp", "scr:component/@name");
    assertAttribute(doc, "abc", "scr:component/@factory");
    assertAttribute(doc, "true", "scr:component/service/@servicefactory");
    assertAttribute(doc, "activatex", "scr:component/@activate");
    assertAttribute(doc, "modifiedx", "scr:component/@modified");
    assertAttribute(doc, "deactivatex", "scr:component/@deactivate");
    assertAttribute(doc, "org.osgi.service.log.LogService", "scr:component/service/provide/@interface");
    assertAttribute(doc, "(abc=3)", "scr:component/reference/@target");
    assertAttribute(doc, "setLog", "scr:component/reference/@bind");
    assertAttribute(doc, "unsetLog", "scr:component/reference/@unbind");
    assertAttribute(doc, "0..1", "scr:component/reference/@cardinality");
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 22 with Builder

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

the class BNDAnnotationTest method testActivateWithMultipleArguments.

public void testActivateWithMultipleArguments() throws Exception {
    Builder b = builder("*.ActivateWithMultipleArguments");
    Document doc = doc(b, "amcomp");
    assertAttribute(doc, "whatever", "scr:component/@activate");
}
Also used : Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document)

Example 23 with Builder

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

the class VersionPolicyTest method testImportMicroNotTruncated.

/**
	 * Check if we can set a specific version on the import that does not use a
	 * version policy.
	 */
public static void testImportMicroNotTruncated() throws Exception {
    Builder b = new Builder();
    b.addClasspath(IO.getFile("jar/osgi.jar"));
    b.setProperty("Import-Package", "org.osgi.service.event;version=${@}, org.osgi.service.log;version=\"${range;[==,=+)}\"");
    b.build();
    String s = b.getImports().getByFQN("org.osgi.service.event").get("version");
    String l = b.getImports().getByFQN("org.osgi.service.log").get("version");
    assertEquals("1.0.1", s);
    assertEquals("[1.3,1.4)", l);
}
Also used : Builder(aQute.bnd.osgi.Builder)

Example 24 with Builder

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

the class VersionPolicyTest method testDisableDefaultPackageVersion.

/**
	 * Test disable default package versions.
	 */
public static void testDisableDefaultPackageVersion() throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setProperty("Bundle-Version", "1.2.3");
    a.setProperty("Export-Package", "test.refer");
    a.setProperty("-nodefaultversion", "true");
    Jar jar = a.build();
    Manifest m = jar.getManifest();
    Parameters exports = Processor.parseHeader(m.getMainAttributes().getValue(Constants.EXPORT_PACKAGE), null);
    Map<String, String> attrs = exports.get("test.refer");
    assertNotNull(attrs);
    assertNull(attrs.get("version"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Manifest(java.util.jar.Manifest) File(java.io.File)

Example 25 with Builder

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

the class VersionPolicyTest method testConsumerType.

/**
	 * Tests if the implementation of the EventHandler (which is marked as a
	 * ConsumerType) causes the import of the api package to use the consumer
	 * version policy.
	 */
public static void testConsumerType() throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setPrivatePackage("test.versionpolicy.uses");
    a.setExportPackage("test.versionpolicy.api");
    a.setProperty("build", "123");
    Jar jar = a.build();
    assertTrue(a.check());
    Manifest m = jar.getManifest();
    m.write(System.err);
    Domain d = Domain.domain(m);
    Parameters parameters = d.getImportPackage();
    Attrs attrs = parameters.get("test.versionpolicy.api");
    assertNotNull(attrs);
    assertEquals("[1.2,2)", attrs.get("version"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Attrs(aQute.bnd.header.Attrs) Jar(aQute.bnd.osgi.Jar) Manifest(java.util.jar.Manifest) Domain(aQute.bnd.osgi.Domain) File(java.io.File)

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