SshServer extends AbstractServer { public void setHostKeyPath(String hostKeyPath) { this.hostKeyPath = hostKeyPath; } SshServer();  SshServer(SshEndpointConfiguration endpointConfiguration); @Override AbstractPollableEndpointConfiguration getEndpointConfiguration(); int getPort(); void setPort(int port); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); String getAllowedKeyPath(); void setAllowedKeyPath(String allowedKeyPath); String getHostKeyPath(); void setHostKeyPath(String hostKeyPath); String getUserHomePath(); void setUserHomePath(String userHomePath); SshMessageConverter getMessageConverter(); void setMessageConverter(SshMessageConverter messageConverter);  }
@Test public void wrongHostKey() throws IOException, GeneralSecurityException { prepareServer(true); server.setHostKeyPath("file:/never/existing/directory"); server.start(); try { SessionContext sessionContext = Mockito.mock(SessionContext.class); org.apache.sshd.server.SshServer sshd = (org.apache.sshd.server.SshServer) ReflectionTestUtils.getField(server, "sshd"); KeyPairProvider prov = sshd.getKeyPairProvider(); assertTrue(prov instanceof FileKeyPairProvider); Iterable<KeyPair> keys = prov.loadKeys(sessionContext); assertFalse(keys.iterator().hasNext()); } finally { server.stop(); } }