public static void main(String[] args) { Launcher.main(new String[]{"bare"}); } }
@Test public void testThatALauncherCanAddACommand() { Launcher myLauncher = new Launcher() { @Override protected void load() { super.load(); register(FooCommand.class); } }; myLauncher.dispatch(new String[]{"foo"}); assertThat(myLauncher.getCommandNames()).contains("foo"); assertWaitUntil(spy::get); }
@Test public void testFatJarWithoutMainVerticle() throws IOException { setManifest("MANIFEST-Launcher-No-Main-Verticle.MF"); record(); cli.dispatch(new Launcher(), new String[0]); stop(); assertThat(output.toString()).contains("Usage:"); }
@Test public void testFatJarWithMissingCommandHelp() throws Exception { // Copy the right manifest File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher.MF"); if (!manifest.isFile()) { throw new IllegalStateException("Cannot find the MANIFEST-Launcher.MF file"); } File target = new File("target/test-classes/META-INF/MANIFEST.MF"); Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); Launcher launcher = new Launcher() { @Override public PrintStream getPrintStream() { return stream; } }; String[] args = {"not-a-command", "--help"}; launcher.dispatch(args); assertTrue(out.toString().contains("The command 'not-a-command' is not a valid command.")); }
@Override public void beforeStartingVertx(VertxOptions options) { beforeStartingVertxInvoked = true; this.options = options; if (clusterHost != null) { options.setClusterHost(clusterHost); options.setClusterPort(clusterPort); options.setClusterPublicHost(clusterPublicHost); options.setClusterPublicPort(clusterPublicPort); super.beforeStartingVertx(options); } }
@Override public void beforeDeployingVerticle(DeploymentOptions deploymentOptions) { super.beforeDeployingVerticle(deploymentOptions); }
public static void main(String[] args) { Launcher.executeCommand("run", Client.class.getName()); }
@Override public void afterConfigParsed(JsonObject config) { super.afterConfigParsed(config); this.config = config; }
@Override public void afterStartingVertx(Vertx vertx) { super.afterStartingVertx(vertx); }
@Test public void testStartingApplicationInRedeployMode() { cli.dispatch(new Launcher(), new String[]{"run", HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.txt", "--launcher-class=" + Launcher.class.getName() }); assertWaitUntil(() -> { try { return RunCommandTest.getHttpCode() == 200; } catch (IOException e) { return false; } }); }
@Test public void testFatJarWithCommandHelp() throws Exception { // Copy the right manifest File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher.MF"); if (!manifest.isFile()) { throw new IllegalStateException("Cannot find the MANIFEST-Launcher.MF file"); } File target = new File("target/test-classes/META-INF/MANIFEST.MF"); Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); Launcher launcher = new Launcher() { @Override public PrintStream getPrintStream() { return stream; } }; String[] args = {"hello", "--help"}; launcher.dispatch(args); assertTrue(out.toString().contains("Usage")); assertTrue(out.toString().contains("hello")); assertTrue(out.toString().contains("A simple command to wish you a good day.")); // Description text. }
@Test public void testThatALauncherCanHideACommand() { Launcher myLauncher = new Launcher() { @Override protected void load() { super.load(); unregister("start"); } }; record(); myLauncher.dispatch(new String[]{"start"}); stop(); assertThat(output.toString()).contains("The command 'start' is not a valid command."); assertThat(myLauncher.getCommandNames()).doesNotContain("start"); }
@Override public void beforeStartingVertx(VertxOptions options) { beforeStartingVertxInvoked = true; this.options = options; if (clusterHost != null) { options.setClusterHost(clusterHost); options.setClusterPort(clusterPort); options.setClusterPublicHost(clusterPublicHost); options.setClusterPublicPort(clusterPublicPort); super.beforeStartingVertx(options); } }
@Override public void beforeDeployingVerticle(DeploymentOptions deploymentOptions) { super.beforeDeployingVerticle(deploymentOptions); if (deploymentOptions.getConfig() == null) { deploymentOptions.setConfig(new JsonObject()); } File conf = new File("src/conf/config.json"); deploymentOptions.getConfig().mergeIn(getConfiguration(conf)); }
public static void main(String[] args) { Launcher.executeCommand("run", Server.class.getName()); }
@Test public void testRunVerticleWithMainVerticleInManifestWithCustomCommand() throws Exception { // Copy the right manifest File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher-hello.MF"); if (!manifest.isFile()) { throw new IllegalStateException("Cannot find the MANIFEST-Launcher-hello.MF file"); } File target = new File("target/test-classes/META-INF/MANIFEST.MF"); Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); Launcher launcher = new Launcher(); HelloCommand.called = false; String[] args = {"--name=vert.x"}; launcher.dispatch(args); assertWaitUntil(() -> HelloCommand.called); }
@Test public void testDeploymentOfJavaVerticleWithCluster() throws IOException { cli.dispatch(new Launcher(), new String[] {"run", HttpTestVerticle.class.getName(), "-cluster"}); assertWaitUntil(() -> { try { return getHttpCode() == 200; } catch (IOException e) { return false; } }); assertThat(getContent().getBoolean("clustered")).isTrue(); }
@Test public void testFatJarWithHelp() throws Exception { // Copy the right manifest File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher.MF"); if (!manifest.isFile()) { throw new IllegalStateException("Cannot find the MANIFEST-Launcher.MF file"); } File target = new File("target/test-classes/META-INF/MANIFEST.MF"); Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); Launcher launcher = new Launcher() { @Override public PrintStream getPrintStream() { return stream; } }; String[] args = {"--help"}; launcher.dispatch(args); assertTrue(out.toString().contains("Usage")); assertTrue(out.toString().contains("run")); assertTrue(out.toString().contains("version")); assertTrue(out.toString().contains("bare")); }