VagrantStrategy implements ClusterStrategy { public SshConfig getSshConfig(Node node) throws IOException { Path nodePath = getPath(node); String sshConfigStr = executor.execute(nodePath, "vagrant", "ssh-config").getOutput(); try { return sshConfigParser.parse(sshConfigStr); } catch (InvalidSshConfigException e) { throw new IOException("Vagrant reported invalid ssh config: " + sshConfigStr, e); } } protected  VagrantStrategy(); @Override boolean isAvailable(); @Override Node createNode(Cluster cluster); @Override NodeStatus getNodeStatus(Node node); @Override void startNode(Node node); @Override void stopNode(Node node); @Override void destroyNode(Node node); SshConfig getSshConfig(Node node); static final String NAME; }
@Test public void testGetSshConfig() throws IOException { SshConfig config = new SshConfig("localhost", 22, "vagrant"); Files.createDirectories(vagrantPath); when(executor.execute(vagrantPath, "vagrant", "ssh-config")).thenReturn( new ExecutionResult(0, "the ssh result", "")); when(sshConfigParser.parse("the ssh result")).thenReturn(config); assertThat(strategy.getSshConfig(prepareNode()), is(config)); }