### Question:
ThreaddumpCommand implements CliCommand { @Override public int run(ProcessStream process) throws CmdLineException { runtime.toString(process.out(), porcelain ? Mode.MACHINE : Mode.HUMAN); return 0; }  @Override String getName(); @Override String getDescription(); @Override int run(ProcessStream process);  }### Answer:
@Test public void cli() throws Exception { run("threaddump", "--in", "threaddump:" + Util.asFile(Util.resource("jstack/deadlock.log")).getAbsolutePath()); assertThat(this, succeeded()); assertThat(err.toString(), equalTo("")); String parsed = out.toString(); stdin(parsed); run("threaddump", "--in", "threaddump:-"); assertThat(this, succeeded()); String reparsed = out.toString(); assertThat(parsed, equalTo(reparsed)); assertThat(parsed, containsString("\"Handling GET /hudson/job/some_job/ : ajp-127.0.0.1-8009-133\" daemon prio=10 tid=0x2ad443486800 nid=18245")); }
@Test public void porcelain() throws Exception { final String log = Util.asFile(Util.resource("jstack/producer-consumer.log")).getAbsolutePath(); run("threaddump", "--in", "threaddump:" + log); assertThat(this, succeeded()); assertThat(out.toString(), containsString("\"blocked_thread\" prio=10 tid=0x2ad39c16b800 nid=32297")); assertThat(out.toString(), containsString("- waiting to lock <0x4063a9378> (a hudson.model.Queue)")); run("threaddump", "--in", "threaddump:" + log, "--porcelain"); assertThat(this, succeeded()); assertThat(out.toString(), containsString("\"blocked_thread\" prio=10 tid=0x00002ad39c16b800 nid=0x7e29")); assertThat(out.toString(), containsString("- waiting to lock <0x00000004063a9378> (a hudson.model.Queue)")); }
@Test public void hasHelp() { run("help", "threaddump"); assertThat(out.toString(), containsString("Allows to capture threaddump from factory such as jmx or process for later analysis")); }