Skip to content

Commit

Permalink
Fix environment-dependent test failures for the default ssh directory…
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikurube committed Feb 8, 2024
1 parent 6cf442d commit b0ae88d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/org/embulk/output/sftp/TestSftpFileOutputPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public class TestSftpFileOutputPlugin
@Rule
public TemporaryFolder testFolder = new TemporaryFolder();

public String oldVfsSftpSshdir = null;
public String dotSshFolder = null;

private static final ConfigMapperFactory CONFIG_MAPPER_FACTORY = SftpFileOutputPlugin.CONFIG_MAPPER_FACTORY;
private static final ConfigMapper CONFIG_MAPPER = SftpFileOutputPlugin.CONFIG_MAPPER;
private static final TaskMapper TASK_MAPPER = SftpFileOutputPlugin.TASK_MAPPER;
Expand Down Expand Up @@ -165,6 +168,10 @@ public class TestSftpFileOutputPlugin
public void createResources()
throws IOException
{
this.dotSshFolder = testFolder.newFolder().getAbsolutePath();
this.oldVfsSftpSshdir = System.getProperty("vfs.sftp.sshdir");
System.setProperty("vfs.sftp.sshdir", this.dotSshFolder);

// setup the plugin
SftpFileOutputPlugin sftpFileOutputPlugin = new SftpFileOutputPlugin();
runner = new FileOutputRunner(sftpFileOutputPlugin);
Expand Down Expand Up @@ -226,6 +233,14 @@ public void cleanup() throws InterruptedException
catch (Exception e) {
logger.debug(e.getMessage(), e);
}
finally {
if (this.oldVfsSftpSshdir == null) {
System.clearProperty("vfs.sftp.sshdir");
}
else {
System.setProperty("vfs.sftp.sshdir", this.oldVfsSftpSshdir);
}
}
}

private List<String> lsR(List<String> fileNames, Path dir)
Expand Down

0 comments on commit b0ae88d

Please sign in to comment.