Test fixes

This commit is contained in:
David Solin
2016-08-24 08:35:08 -05:00
parent 79c1ae2bb0
commit 3f29879eca
2 changed files with 6 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
*/ */
package net.schmizz.sshj.sftp; package net.schmizz.sshj.sftp;
import net.schmizz.sshj.common.LoggerFactory;
import net.schmizz.sshj.common.SSHException; import net.schmizz.sshj.common.SSHException;
import net.schmizz.sshj.connection.channel.direct.Session.Subsystem; import net.schmizz.sshj.connection.channel.direct.Session.Subsystem;
import org.junit.Before; import org.junit.Before;
@@ -43,6 +44,7 @@ public class PacketReaderTest {
engine = Mockito.mock(SFTPEngine.class); engine = Mockito.mock(SFTPEngine.class);
subsystem = Mockito.mock(Subsystem.class); subsystem = Mockito.mock(Subsystem.class);
Mockito.when(engine.getLoggerFactory()).thenReturn(LoggerFactory.DEFAULT);
Mockito.when(engine.getSubsystem()).thenReturn(subsystem); Mockito.when(engine.getSubsystem()).thenReturn(subsystem);
Mockito.when(subsystem.getInputStream()).thenReturn(pipedin); Mockito.when(subsystem.getInputStream()).thenReturn(pipedin);

View File

@@ -20,12 +20,13 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import net.schmizz.sshj.common.LoggerFactory;
import static net.schmizz.sshj.sftp.PathHelper.DEFAULT_PATH_SEPARATOR; import static net.schmizz.sshj.sftp.PathHelper.DEFAULT_PATH_SEPARATOR;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
public class SFTPClientTest { public class SFTPClientTest {
private final SFTPEngine sftpEngine = mock(SFTPEngine.class); private final SFTPEngine sftpEngine = mock(SFTPEngine.class);
private final SFTPClient client = new SFTPClient(sftpEngine);
@Before @Before
public void setPathHelper() throws Exception { public void setPathHelper() throws Exception {
@@ -39,6 +40,7 @@ public class SFTPClientTest {
} }
}, DEFAULT_PATH_SEPARATOR); }, DEFAULT_PATH_SEPARATOR);
when(sftpEngine.getPathHelper()).thenReturn(helper); when(sftpEngine.getPathHelper()).thenReturn(helper);
when(sftpEngine.getLoggerFactory()).thenReturn(LoggerFactory.DEFAULT);
} }
@Before @Before
@@ -49,6 +51,7 @@ public class SFTPClientTest {
@Test @Test
public void doesNotTryToCreateDirectoryTwiceWhenPathHasTrailingSeparator() throws Exception { public void doesNotTryToCreateDirectoryTwiceWhenPathHasTrailingSeparator() throws Exception {
SFTPClient client = new SFTPClient(sftpEngine);
client.mkdirs("/folder/directory/"); client.mkdirs("/folder/directory/");
verify(sftpEngine, times(1)).makeDir("/folder/directory"); verify(sftpEngine, times(1)).makeDir("/folder/directory");
} }