Search in sources :

Example 1 with RemoteOptions

use of aQute.bnd.main.RemoteCommand.RemoteOptions in project bnd by bndtools.

the class DistroCommandTest method testResolveAgainstDistro.

public void testResolveAgainstDistro() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    ResolveProcess process = new ResolveProcess();
    ResolverLogger logger = new ResolverLogger();
    MockRegistry registry = new MockRegistry();
    Processor model = new Processor();
    model.setProperty("-distro", distro.getAbsolutePath() + ";version=file");
    model.setProperty("-runfw", "org.eclipse.osgi");
    model.setProperty("-runrequires", "osgi.wiring.package;filter:='(osgi.wiring.package=com.liferay.dynamic.data.mapping.taglib.servlet.taglib)'");
    Map<Resource, List<Wire>> requiredResources = process.resolveRequired(model, null, registry, new BndResolver(logger), Collections.<ResolutionCallback>emptyList(), logger);
    assertEquals(1, requiredResources.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) ResolverLogger(biz.aQute.resolve.ResolverLogger) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) MockRegistry(aQute.bnd.main.testlib.MockRegistry) Resource(org.osgi.resource.Resource) CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) ResolveProcess(biz.aQute.resolve.ResolveProcess) ArrayList(java.util.ArrayList) List(java.util.List) BndResolver(biz.aQute.resolve.BndResolver) File(java.io.File)

Example 2 with RemoteOptions

use of aQute.bnd.main.RemoteCommand.RemoteOptions in project bnd by bndtools.

the class DistroCommandTest method testDistroJarNotResolvable.

public void testDistroJarNotResolvable() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    if (distro.exists()) {
        assertTrue(distro.delete());
    }
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    Domain domain = Domain.domain(distro);
    Parameters providedCapabilities = domain.getProvideCapability();
    assertTrue(providedCapabilities.containsKey("osgi.unresolvable"));
    Parameters requiredCapabilities = domain.getRequireCapability();
    assertTrue(requiredCapabilities.containsKey("osgi.unresolvable"));
    Attrs attrs = requiredCapabilities.get("osgi.unresolvable");
    assertEquals("(&(must.not.resolve=*)(!(must.not.resolve=*)))", attrs.get("filter:"));
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) Parameters(aQute.bnd.header.Parameters) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) Attrs(aQute.bnd.header.Attrs) Domain(aQute.bnd.osgi.Domain) File(java.io.File)

Example 3 with RemoteOptions

use of aQute.bnd.main.RemoteCommand.RemoteOptions in project bnd by bndtools.

the class DistroCommandTest method testMultipleCapabilitiesPerNamespace.

public void testMultipleCapabilitiesPerNamespace() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    ResourceBuilder builder = new ResourceBuilder();
    Domain manifest = Domain.domain(new Jar(distro).getManifest());
    builder.addManifest(manifest);
    Resource resource = builder.build();
    List<Capability> capabilities = resource.getCapabilities(null);
    assertNotNull(capabilities);
    List<Capability> extenderCaps = resource.getCapabilities(ExtenderNamespace.EXTENDER_NAMESPACE);
    int jspTaglibCapabilityCount = 0;
    for (Capability capability : extenderCaps) {
        Map<String, Object> attributes = capability.getAttributes();
        if ("jsp.taglib".equals(attributes.get(ExtenderNamespace.EXTENDER_NAMESPACE))) {
            jspTaglibCapabilityCount++;
        }
    }
    assertEquals(2, jspTaglibCapabilityCount);
    List<Capability> eeCaps = resource.getCapabilities(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
    assertTrue(eeCaps.size() > 0);
    Capability javaSECap = null;
    for (Capability capability : eeCaps) {
        Map<String, Object> attributes = capability.getAttributes();
        if ("JavaSE".equals(attributes.get(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE))) {
            javaSECap = capability;
        }
    }
    assertNotNull(javaSECap);
    @SuppressWarnings("null") Map<String, Object> attributes = javaSECap.getAttributes();
    assertTrue(attributes.containsKey("version"));
    @SuppressWarnings("unchecked") List<Version> versions = (List<Version>) attributes.get("version");
    assertTrue(versions.size() > 1);
    assertTrue(versions.contains(new Version("1.7.0")));
    assertTrue(versions.contains(new Version("1.6.0")));
    assertTrue(versions.contains(new Version("1.5.0")));
    assertTrue(versions.contains(new Version("1.4.0")));
    assertTrue(versions.contains(new Version("1.3.0")));
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Capability(org.osgi.resource.Capability) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) Version(org.osgi.framework.Version) Jar(aQute.bnd.osgi.Jar) ArrayList(java.util.ArrayList) List(java.util.List) Domain(aQute.bnd.osgi.Domain) File(java.io.File)

Example 4 with RemoteOptions

use of aQute.bnd.main.RemoteCommand.RemoteOptions in project bnd by bndtools.

the class DistroCommandTest method testDistroJarLastModified.

public void testDistroJarLastModified() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    if (distro.exists()) {
        assertTrue(distro.delete());
    }
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    assertTrue(distro.lastModified() > 0);
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

DistroOptions (aQute.bnd.main.RemoteCommand.DistroOptions)4 RemoteOptions (aQute.bnd.main.RemoteCommand.RemoteOptions)4 CommandLine (aQute.lib.getopt.CommandLine)4 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Domain (aQute.bnd.osgi.Domain)2 List (java.util.List)2 Resource (org.osgi.resource.Resource)2 Attrs (aQute.bnd.header.Attrs)1 Parameters (aQute.bnd.header.Parameters)1 MockRegistry (aQute.bnd.main.testlib.MockRegistry)1 Jar (aQute.bnd.osgi.Jar)1 Processor (aQute.bnd.osgi.Processor)1 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)1 BndResolver (biz.aQute.resolve.BndResolver)1 ResolveProcess (biz.aQute.resolve.ResolveProcess)1 ResolverLogger (biz.aQute.resolve.ResolverLogger)1 Version (org.osgi.framework.Version)1 Capability (org.osgi.resource.Capability)1