Search in sources :

Example 46 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class ContractTest method testSimple.

public void testSimple() throws Exception {
    Jar bjar = getContractExporter("test", "2.5", "${exports}");
    Builder a = newBuilder();
    a.setTrace(true);
    a.addClasspath(bjar);
    a.setProperty(Constants.CONTRACT, "*");
    a.setImportPackage("org.osgi.service.cm,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(a.check());
    Domain domain = Domain.domain(ajar.getManifest());
    Parameters rc = domain.getRequireCapability();
    rc.remove("osgi.ee");
    System.out.println(rc);
    assertEquals(1, rc.size());
    Packages ps = a.getImports();
    assertTrue(ps.containsFQN("org.osgi.service.cm"));
    Attrs attrs = ps.getByFQN("org.osgi.service.cm");
    assertNotNull(attrs);
    assertNull(attrs.getVersion());
}
Also used : Parameters(aQute.bnd.header.Parameters) Packages(aQute.bnd.osgi.Packages) Builder(aQute.bnd.osgi.Builder) Attrs(aQute.bnd.header.Attrs) Jar(aQute.bnd.osgi.Jar) Domain(aQute.bnd.osgi.Domain)

Example 47 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class ContractTest method testWarningVersion.

/**
	 * Test the warnings that we have no no version
	 * 
	 * @throws Exception
	 */
public void testWarningVersion() throws Exception {
    Jar bjara = getContractExporter("abc", (String[]) null, "${exports}");
    Builder a = newBuilder();
    a.setTrace(true);
    a.addClasspath(bjara);
    a.setProperty(Constants.CONTRACT, "*");
    a.setImportPackage("test.packageinfo,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(a.check("Contract \\[name=abc;version=0.0.0;from=biz.aQute.bndlib.tests] does not declare a version"));
    Domain domain = Domain.domain(ajar.getManifest());
    Parameters p = domain.getRequireCapability();
    p.remove("osgi.ee");
    assertEquals(0, p.size());
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Domain(aQute.bnd.osgi.Domain)

Example 48 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class ContractTest method testMultiple.

public void testMultiple() throws Exception {
    Jar bjar = getContractExporter("abc", new String[] { "2.5", "2.6", "3.0", "3.1" }, "${exports}");
    Builder a = newBuilder();
    a.setTrace(true);
    a.addClasspath(bjar);
    a.setProperty(Constants.CONTRACT, "*");
    a.setImportPackage("org.osgi.service.cm,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(a.check());
    Domain domain = Domain.domain(ajar.getManifest());
    Parameters rc = domain.getRequireCapability();
    rc.remove("osgi.ee");
    System.out.println(rc);
    assertEquals(1, rc.size());
    assertNotNull(rc);
    assertEquals(1, rc.size());
    Attrs attrs = rc.get("osgi.contract");
    assertEquals("(&(osgi.contract=abc)(version=3.1.0))", attrs.get("filter:"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Attrs(aQute.bnd.header.Attrs) Jar(aQute.bnd.osgi.Jar) Domain(aQute.bnd.osgi.Domain)

Example 49 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class UsesTest method checkUses.

private static void checkUses(String export, String uses) throws IOException, Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setExportPackage(export);
    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.getExportPackage();
    Attrs attrs = parameters.get(export);
    assertNotNull(attrs);
    assertEquals(uses, attrs.get("uses:"));
}
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)

Example 50 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class ResourceTest method testImportExportService.

public void testImportExportService() throws Exception {
    ResourceBuilder rb = new ResourceBuilder();
    rb.addImportServices(new Parameters(is));
    rb.addExportServices(new Parameters(es));
    Resource build = rb.build();
    assertConfigAdminServices(build);
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Parameters(aQute.bnd.header.Parameters) Resource(org.osgi.resource.Resource)

Aggregations

Parameters (aQute.bnd.header.Parameters)157 Attrs (aQute.bnd.header.Attrs)78 File (java.io.File)45 Jar (aQute.bnd.osgi.Jar)44 Manifest (java.util.jar.Manifest)39 Builder (aQute.bnd.osgi.Builder)35 Domain (aQute.bnd.osgi.Domain)24 ArrayList (java.util.ArrayList)20 Map (java.util.Map)16 Attributes (java.util.jar.Attributes)16 IOException (java.io.IOException)14 HashMap (java.util.HashMap)13 Version (aQute.bnd.version.Version)11 Instructions (aQute.bnd.osgi.Instructions)9 HashSet (java.util.HashSet)9 Requirement (org.osgi.resource.Requirement)9 FileNotFoundException (java.io.FileNotFoundException)8 Properties (java.util.Properties)8 Matcher (java.util.regex.Matcher)8 Analyzer (aQute.bnd.osgi.Analyzer)7