SshUtils implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { certificate = File.createTempFile(UUID.randomUUID().toString(), ".tmp"); InputStream certificateStreamOriginal = getClass().getResourceAsStream("/id_rsa.ppk"); FileOutputStream certificateStreamWorkingFile = new FileOutputStream(certificate); IOUtils.copy(certificateStreamOriginal, certificateStreamWorkingFile); IOUtils.closeQuietly(certificateStreamOriginal); IOUtils.closeQuietly(certificateStreamWorkingFile); }  void executeCommandOnHostViaSsh(String hostIp, String command); void sendFileToHost(File localfilePath, String remoteFileName, String remotePath, String address); @Override void afterPropertiesSet();  }
@Test @PrepareForTest(IOUtils.class) public void afterPropertiesSetTest() throws Exception { PowerMockito.mockStatic(IOUtils.class); spy.afterPropertiesSet(); PowerMockito.verifyStatic(); IOUtils.copy(Mockito.any(InputStream.class), Mockito.any(FileOutputStream.class)); IOUtils.closeQuietly(Mockito.any(InputStream.class)); IOUtils.closeQuietly(Mockito.any(FileOutputStream.class)); }