Search in sources :

Example 1 with CommandFactory

use of io.vertx.core.spi.launcher.CommandFactory in project vert.x by eclipse.

the class ServiceCommandLoaderTest method ensureCommand.

private void ensureCommand(Collection<CommandFactory<?>> commands, String name) {
    List<CLI> clis = new ArrayList<>();
    for (CommandFactory command : commands) {
        CLI cli = command.define();
        clis.add(cli);
        if (cli.getName().equalsIgnoreCase(name)) {
            return;
        }
    }
    fail("Cannot find '" + name + "' in " + clis.stream().map(CLI::getName).collect(Collectors.toList()));
}
Also used : CLI(io.vertx.core.cli.CLI) ArrayList(java.util.ArrayList) CommandFactory(io.vertx.core.spi.launcher.CommandFactory)

Example 2 with CommandFactory

use of io.vertx.core.spi.launcher.CommandFactory in project vert.x by eclipse.

the class ServiceCommandLookupTest method ensureCommand.

private void ensureCommand(Collection<CommandFactory<?>> commands, String name) {
    List<CLI> clis = new ArrayList<>();
    for (CommandFactory command : commands) {
        CLI cli = command.define();
        clis.add(cli);
        if (cli.getName().equalsIgnoreCase(name)) {
            return;
        }
    }
    fail("Cannot find '" + name + "' in " + clis.stream().map(CLI::getName).collect(Collectors.toList()));
}
Also used : CLI(io.vertx.core.cli.CLI) ArrayList(java.util.ArrayList) CommandFactory(io.vertx.core.spi.launcher.CommandFactory)

Example 3 with CommandFactory

use of io.vertx.core.spi.launcher.CommandFactory in project vert.x by eclipse.

the class ServiceCommandLoaderTest method testCommandsWhenUsingClassloaderHierarchy.

@Test
public void testCommandsWhenUsingClassloaderHierarchy() {
    ClassLoader classLoader = new URLClassLoader(new URL[0], ServiceCommandLoaderTest.class.getClassLoader());
    loader = new ServiceCommandFactoryLoader(classLoader);
    Collection<CommandFactory<?>> commands = loader.lookup();
    ensureCommand(commands, "Hello");
    ensureCommand(commands, "Bye");
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) CommandFactory(io.vertx.core.spi.launcher.CommandFactory) Test(org.junit.Test)

Aggregations

CommandFactory (io.vertx.core.spi.launcher.CommandFactory)3 CLI (io.vertx.core.cli.CLI)2 ArrayList (java.util.ArrayList)2 URLClassLoader (java.net.URLClassLoader)1 Test (org.junit.Test)1