OfframpConsole implements Callable<Void> { @Override public Void call() throws Exception { configureOutput(); validateRequiredOptions(); if (debug) { final String hidden = String.join("", Collections.nCopies(this.password != null ? this.password.length() : 0, "*")); cliout.print(this.getClass() + " was configured with:\n" + "\thost: " + this.host + "\n" + "\tusername: " + this.username + "\n" + "\tpassword: " + hidden + "\n" + "\troadName: " + this.roadName + "\n" + "\tstreamName: " + this.streamName + "\n" + "\tdefaultOffset: " + this.defaultOffset + "\n" + "\tinitialRequestAmount: " + this.initialRequestAmount + "\n" + "\treplenishingRequestAmount: " + this.replenishingRequestAmount + "\n" + "\tcommitIntervalMs: " + this.commitIntervalMs + "\n" + "\tnumToConsume: " + this.numToConsume + "\n" + "\ttlsTrustAll: " + this.tlsTrustAll + "\n"); } OfframpOptions<JsonNode> options = getOptions(); runClient(options); return null; }  static void main(String[] args); @Override Void call();  }
@Test @SuppressWarnings("unchecked") public void testHelp() throws Exception { String[] args = { "--help" }; CommandLine.call(offrampConsoleSpied, args); String[] lines = outBuffer.toString().split("\n"); String defaultOffsetHelp = ""; for (int i = 0; i < lines.length; i++) { if (lines[i].contains("--defaultOffset")) { defaultOffsetHelp = String.join("\n", Arrays.copyOfRange(lines, i, i + 4)); } } assertThat(defaultOffsetHelp, containsString(DefaultOffset.LATEST.name())); assertThat(defaultOffsetHelp, containsString(DefaultOffset.EARLIEST.name())); assertThat(defaultOffsetHelp, containsString(String.format("(default: %s)", DefaultOffset.LATEST.name()))); }
@Test public void testHostUri() throws Exception { exit.expectSystemExitWithStatus(2); String[] args = { "--host='bla\\:bla:baz'", "--roadName=route66", "--streamName=left" }; CommandLine.call(offrampConsoleSpied, args); offrampConsoleSpied.call(); }