use of com.adaptris.ftp.CommonsNetFtpClient in project interlok by adaptris.
the class TestCommonsNetFtp method testSetTimeout.
@Test
public void testSetTimeout() throws Exception {
Assume.assumeTrue(areTestsEnabled());
String oldName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("testSetTimeout");
CommonsNetFtpClient client = new CommonsNetFtpClient(config.getProperty(FTP_HOST));
client.setTimeout(client.getTimeout());
client.setKeepAliveTimeout(client.getKeepAliveTimeout());
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.ftp.CommonsNetFtpClient in project interlok by adaptris.
the class TestCommonsNetFtp method testBug1924.
@Test
public void testBug1924() throws Exception {
Assume.assumeTrue(areTestsEnabled());
String oldName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("testBug1924");
// Use an arbitarily small timeout to a range that almost certainly
// shouldn't exist when the tests are running.
CommonsNetFtpClient client = new CommonsNetFtpClient("192.168.17.1", 21, 1);
client.disconnect();
fail("Successfully connected, with a timeout of 1ms (surely not possible!)");
} catch (SocketTimeoutException e) {
// expected.
;
} catch (NoRouteToHostException e) {
// also possibly expected
;
} catch (IOException e) {
// also possibly expected from FtpCommonsNetClient
;
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.ftp.CommonsNetFtpClient in project interlok by adaptris.
the class TestCommonsNetFtp method testConnectWithTimeout.
@Test
public void testConnectWithTimeout() throws Exception {
Assume.assumeTrue(areTestsEnabled());
String oldName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("testBug1924");
// Use an arbitarily small timeout.
CommonsNetFtpClient client = new CommonsNetFtpClient("192.168.17.1", 21, 1);
client.setAdditionalDebug(true);
client.connect(config.getProperty(FTP_USERNAME), config.getProperty(FTP_PASSWORD));
client.disconnect();
fail("Successfully connected, with a timeout of 1ms (surely not possible!)");
} catch (SocketTimeoutException e) {
// expected.
;
} catch (NoRouteToHostException e) {
// also possibly expected
;
} catch (IOException e) {
// also possibly expected from FtpCommonsNetClient
;
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.ftp.CommonsNetFtpClient in project interlok by adaptris.
the class TestCommonsNetFtp method testGetLastModifiedWithTimezone.
@Test
public void testGetLastModifiedWithTimezone() throws Exception {
Assume.assumeTrue(areTestsEnabled());
String oldName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("testGetLastModifiedWithTimezone");
FileTransferClient client = connectClientImpl();
client.chdir(getRemoteGetDirectory());
long mtime = client.lastModified(getRemoteGetFilename());
client.disconnect();
CommonsNetFtpClient tzClient = (CommonsNetFtpClient) connectClientImpl();
tzClient.setServerTimezone(TimeZone.getTimeZone(ALTERNATE_TZ));
tzClient.chdir(getRemoteGetDirectory());
long tztime = tzClient.lastModified(getRemoteGetFilename());
tzClient.disconnect();
logR.debug("testGetLastModifiedWithTimezone : " + new Date(tztime));
assertNotSame("" + new Date(mtime), mtime, tztime);
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.ftp.CommonsNetFtpClient in project interlok by adaptris.
the class TestCommonsNetFtp method testGetLastModifiedDateWithTimezone.
@Test
public void testGetLastModifiedDateWithTimezone() throws Exception {
Assume.assumeTrue(areTestsEnabled());
String oldName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("testGetLastModifiedDateWithTimezone");
FileTransferClient client = connectClientImpl();
client.chdir(getRemoteGetDirectory());
Date mtime = client.lastModifiedDate(getRemoteGetFilename());
client.disconnect();
CommonsNetFtpClient tzClient = (CommonsNetFtpClient) connectClientImpl();
tzClient.setServerTimezone(TimeZone.getTimeZone(ALTERNATE_TZ));
tzClient.chdir(getRemoteGetDirectory());
Date tzDate = tzClient.lastModifiedDate(getRemoteGetFilename());
tzClient.disconnect();
logR.debug("testGetLastModifiedWithTimezone : " + tzDate);
assertNotSame("" + mtime, mtime, tzDate);
} finally {
Thread.currentThread().setName(oldName);
}
}
Aggregations