/** * Creates a new {@link VertxCommandLauncher} using the default {@link ServiceCommandFactoryLoader}. It uses the * classloader having loaded {@link ServiceCommandFactoryLoader}. */ public VertxCommandLauncher() { this(Collections.singletonList(new ServiceCommandFactoryLoader())); }
@Test public void testNoCommandsWhenLoadedFromEmptyClassloader() { ClassLoader classLoader = new URLClassLoader(new URL[0], null); // We see the implementation from the classpath loader = new ServiceCommandFactoryLoader(classLoader); assertThat(loader.lookup()).isNotEmpty(); }
@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"); } }
/** * Creates a new {@link VertxCommandLauncher} using the default {@link ServiceCommandFactoryLoader}. It uses the * classloader having loaded {@link ServiceCommandFactoryLoader}. */ public VertxCommandLauncher() { this(Collections.singletonList(new ServiceCommandFactoryLoader())); }
@Test public void testNoCommandsWhenLoadedFromEmptyClassloader() { ClassLoader classLoader = new URLClassLoader(new URL[0], null); // We see the implementation from the classpath loader = new ServiceCommandFactoryLoader(classLoader); assertThat(loader.lookup()).isNotEmpty(); }
@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"); } }