Source:
<code>public void testScpVirtualOnDirWithPattern() throws Exception { Path remoteDir = Files.createTempDirectory("remote"); sshd.setFileSystemFactory(new VirtualFileSystemFactory(remoteDir)); <START> try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port) <END> .verify(CONNECT_TIMEOUT, TimeUnit.SECONDS) .getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(AUTH_TIMEOUT, TimeUnit.SECONDS); ScpClient scp = createScpClient(session); Path targetPath = detectTargetFolder(); Path scpRoot = CommonTestSupportUtils.resolve(targetPath, ScpHelper.SCP_COMMAND_PREFIX, getClass().getSimpleName(), getCurrentTestName()); CommonTestSupportUtils.deleteRecursive(scpRoot); Path localDir = assertHierarchyTargetFolderExists(scpRoot.resolve("local")); Path local1 = localDir.resolve("file-1.txt"); byte[] data = CommonTestSupportUtils.writeFile(local1, getClass().getName() + "#" + getCurrentTestName() + IoUtils.EOL); Path local2 = localDir.resolve("file-2.txt"); Files.write(local2, data); scp.upload(localDir.toString() + File.separator + "*", "/"); Path remote1 = remoteDir.resolve(local1.getFileName()); Path remote2 = remoteDir.resolve(local2.getFileName()); assertFileLength(remote1, data.length, TimeUnit.SECONDS.toMillis(11L)); assertFileLength(remote2, data.length, TimeUnit.SECONDS.toMillis(11L)); Files.delete(local1); Files.delete(local2); scp.download("/*", localDir); assertFileLength(local1, data.length, TimeUnit.SECONDS.toMillis(11L)); assertFileLength(local2, data.length, TimeUnit.SECONDS.toMillis(11L)); Files.delete(remote1); Files.delete(remote2); Files.delete(remoteDir); } }</code><technical_language>Please getTempTargetRelativeFile (method inherited JUnitTestSupport) - file(s) reside target folder is cleaned mvn clean is invoked. code leaves "orphan" directories files in user's /tmp folder</technical_language>

Target:
public void testScpVirtualOnDirWithPattern() throws Exception { Path remoteDir = assertHierarchyTargetFolderExists(getTempTargetFolder()); sshd.setFileSystemFactory(new VirtualFileSystemFactory(remoteDir)); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port) .verify(CONNECT_TIMEOUT, TimeUnit.SECONDS) .getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(AUTH_TIMEOUT, TimeUnit.SECONDS); ScpClient scp = createScpClient(session); Path targetPath = detectTargetFolder(); Path scpRoot = CommonTestSupportUtils.resolve(targetPath, ScpHelper.SCP_COMMAND_PREFIX, getClass().getSimpleName(), getCurrentTestName()); CommonTestSupportUtils.deleteRecursive(scpRoot); Path localDir = assertHierarchyTargetFolderExists(scpRoot.resolve("local")); Path local1 = localDir.resolve("file-1.txt"); byte[] data = CommonTestSupportUtils.writeFile(local1, getClass().getName() + "#" + getCurrentTestName() + IoUtils.EOL); Path local2 = localDir.resolve("file-2.txt"); Files.write(local2, data); scp.upload(localDir.toString() + File.separator + "*", "/"); Path remote1 = remoteDir.resolve(local1.getFileName()); Path remote2 = remoteDir.resolve(local2.getFileName()); assertFileLength(remote1, data.length, TimeUnit.SECONDS.toMillis(11L)); assertFileLength(remote2, data.length, TimeUnit.SECONDS.toMillis(11L)); Files.delete(local1); Files.delete(local2); scp.download("/*", localDir); assertFileLength(local1, data.length, TimeUnit.SECONDS.toMillis(11L)); assertFileLength(local2, data.length, TimeUnit.SECONDS.toMillis(11L)); } }