use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testFTPPathWithoutSpecialCharactersInAuth.
@Test
public void testFTPPathWithoutSpecialCharactersInAuth() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
config.configuration(String.format("%s://%s:%s@%s:%d%s", FTP_PREFIX, USER, PASSWORD_WITHOUT_SPECIAL_CHARACTERS, HOST, FTP_DEFAULT_PORT, PATH), null);
config.validate(collector);
Assert.assertEquals(config.getPathFromConfig(), config.getPath());
Assert.assertEquals(0, config.getFileSystemProperties(collector).size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testFTPWithFileSystemProperties.
@Test
public void testFTPWithFileSystemProperties() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
config.configuration(String.format("%s://%s:%s@%s:%d%s", FTP_PREFIX, USER, PASSWORD_WITHOUT_SPECIAL_CHARACTERS, HOST, FTP_DEFAULT_PORT, PATH), "{\"fs.sftp.impl\": \"org.apache.hadoop.fs.sftp.SFTPFileSystem\"}");
config.validate(collector);
Assert.assertEquals(config.getPathFromConfig(), config.getPath());
Assert.assertEquals(1, config.getFileSystemProperties(collector).size());
Assert.assertEquals(SFTP_FS_CLASS, config.getFileSystemProperties(collector).get(FS_SFTP_IMPL));
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testMissingAuthInPath.
@Test
public void testMissingAuthInPath() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
config.configuration(String.format("%s://%s:%d%s", FTP_PREFIX, HOST, FTP_DEFAULT_PORT, PATH), null);
try {
config.validate(collector);
Assert.fail();
} catch (ValidationException e) {
Assert.assertEquals(1, e.getFailures().size());
Assert.assertEquals(String.format("Missing authentication in url: %s.", config.getPathFromConfig()), e.getFailures().get(0).getMessage());
}
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testSFTPPathWithSpecialCharactersInAuth.
@Test
public void testSFTPPathWithSpecialCharactersInAuth() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
final HashMap<String, String> fileSystemProperties = new HashMap<>();
config.configuration(String.format("%s://%s:%s@%s:%d%s", SFTP_PREFIX, USER, PASSWORD_WITH_SPECIAL_CHARACTERS, HOST, SFTP_DEFAULT_PORT, PATH), null);
config.validate(collector);
fileSystemProperties.put("fs.sftp.host", HOST);
fileSystemProperties.put(String.format("fs.sftp.user.%s", HOST), USER);
fileSystemProperties.put(String.format("fs.sftp.password.%s.%s", HOST, USER), PASSWORD_WITH_SPECIAL_CHARACTERS);
fileSystemProperties.put("fs.sftp.host.port", String.valueOf(SFTP_DEFAULT_PORT));
Assert.assertEquals(fileSystemProperties, config.getFileSystemProperties(collector));
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testSFTPPathWithSystemPropertiesAndSpecialCharactersInAuth.
@Test
public void testSFTPPathWithSystemPropertiesAndSpecialCharactersInAuth() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
final HashMap<String, String> fileSystemProperties = new HashMap<>();
config.configuration(String.format("%s://%s:%s@%s:%d%s", SFTP_PREFIX, USER, PASSWORD_WITH_SPECIAL_CHARACTERS, HOST, SFTP_DEFAULT_PORT, PATH), "{\"fs.sftp.impl\": \"org.apache.hadoop.fs.sftp.SFTPFileSystem\"}");
config.validate(collector);
fileSystemProperties.put("fs.sftp.host", HOST);
fileSystemProperties.put(String.format("fs.sftp.user.%s", HOST), USER);
fileSystemProperties.put(String.format("fs.sftp.password.%s.%s", HOST, USER), PASSWORD_WITH_SPECIAL_CHARACTERS);
fileSystemProperties.put("fs.sftp.host.port", String.valueOf(SFTP_DEFAULT_PORT));
fileSystemProperties.put(FS_SFTP_IMPL, SFTP_FS_CLASS);
Assert.assertEquals(5, config.getFileSystemProperties(collector).size());
Assert.assertEquals(fileSystemProperties, config.getFileSystemProperties(collector));
}
Aggregations