use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class ConnectionUtilsTest method testIsGeneralJdbc.
/**
* Test method for
* {@link org.talend.cwm.db.connection.ConnectionUtils#isGeneralJdbc(org.talend.core.model.metadata.builder.connection.Connection)}
* .
*/
@Test
public void testIsGeneralJdbc() {
DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
EDatabaseTypeName generalJdbcType = EDatabaseTypeName.GENERAL_JDBC;
createDatabaseConnection.setDatabaseType(generalJdbcType.getDisplayName());
Assert.assertTrue("Current DatabaseType of connection should be " + EDatabaseTypeName.GENERAL_JDBC.getDisplayName(), // $NON-NLS-1$
ConnectionUtils.isGeneralJdbc(createDatabaseConnection));
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class ConnectionUtilsTest method testCheckGeneralJdbcJarFilePathDriverClassNameCase2.
/**
* Test method for
* {@link org.talend.cwm.db.connection.ConnectionUtils#checkGeneralJdbcJarFilePathDriverClassName(org.talend.core.model.metadata.builder.connection.DatabaseConnection)}
* . case 2 driverClass is null or empty
*/
@Test
public void testCheckGeneralJdbcJarFilePathDriverClassNameCase2() {
String driverClass = StringUtils.EMPTY;
// $NON-NLS-1$
String driverName = "mysql-connector-java-5.1.12-bin.jar";
CopyTheJarFile();
DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
createDatabaseConnection.setDriverClass(driverClass);
createDatabaseConnection.setDriverJarPath(driverName);
// driver class is empty case
ReturnCode rc = ConnectionUtils.checkJdbcJarFilePathDriverClassName(createDatabaseConnection);
// $NON-NLS-1$
Assert.assertFalse("The driver of conection is empty so that should not be found", rc.isOk());
// $NON-NLS-1$
Assert.assertEquals(Messages.getString("ConnectionUtils.DriverClassEmpty"), rc.getMessage());
// driver class is Null case
driverClass = null;
createDatabaseConnection.setDriverClass(driverClass);
rc = ConnectionUtils.checkJdbcJarFilePathDriverClassName(createDatabaseConnection);
// $NON-NLS-1$
Assert.assertFalse("The driver of conection is Null so that should not be found", rc.isOk());
// $NON-NLS-1$
Assert.assertEquals(Messages.getString("ConnectionUtils.DriverClassEmpty"), rc.getMessage());
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class ConnectionUtilsTest method testCheckGeneralJdbcJarFilePathDriverClassNameCase4.
/**
* Test method for
* {@link org.talend.cwm.db.connection.ConnectionUtils#checkGeneralJdbcJarFilePathDriverClassName(org.talend.core.model.metadata.builder.connection.DatabaseConnection)}
* . case 4 The jar can not be found case
*/
@Test
public void testCheckGeneralJdbcJarFilePathDriverClassNameCase4() {
// $NON-NLS-1$
String driverClass = "om.mysql.jdbc.Driver";
// $NON-NLS-1$
String driverName = "mysql-connector-java-5.1.12-bin111111.jar";
CopyTheJarFile();
DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
createDatabaseConnection.setDriverClass(driverClass);
createDatabaseConnection.setDriverJarPath(driverName);
ReturnCode rc = ConnectionUtils.checkJdbcJarFilePathDriverClassName(createDatabaseConnection);
// $NON-NLS-1$
Assert.assertFalse("The driver is not exist so that should not be found", rc.isOk());
// $NON-NLS-1$
Assert.assertEquals(Messages.getString("ConnectionUtils.JarFileCanNotBeFound"), rc.getMessage());
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class ConnectionUtilsTest method testCheckGeneralJdbcJarFilePathDriverClassNameCase3.
/**
* Test method for
* {@link org.talend.cwm.db.connection.ConnectionUtils#checkGeneralJdbcJarFilePathDriverClassName(org.talend.core.model.metadata.builder.connection.DatabaseConnection)}
* . case 3 driverName is null or empty
*/
@Test
public void testCheckGeneralJdbcJarFilePathDriverClassNameCase3() {
// $NON-NLS-1$
String driverClass = "om.mysql.jdbc.Driver";
String driverName = StringUtils.EMPTY;
CopyTheJarFile();
DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
createDatabaseConnection.setDriverClass(driverClass);
createDatabaseConnection.setDriverJarPath(driverName);
// driver name is empty case
ReturnCode rc = ConnectionUtils.checkJdbcJarFilePathDriverClassName(createDatabaseConnection);
// $NON-NLS-1$
Assert.assertFalse("The class of driver is empty so that should not be found", rc.isOk());
// $NON-NLS-1$
Assert.assertEquals(Messages.getString("ConnectionUtils.DriverJarFileEmpty"), rc.getMessage());
// driver name is Null case
driverClass = null;
createDatabaseConnection.setDriverJarPath(driverName);
rc = ConnectionUtils.checkJdbcJarFilePathDriverClassName(createDatabaseConnection);
// $NON-NLS-1$
Assert.assertFalse("The class of driver is Null so that should not be found", rc.isOk());
// $NON-NLS-1$
Assert.assertEquals(Messages.getString("ConnectionUtils.DriverJarFileEmpty"), rc.getMessage());
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tbd-studio-se by Talend.
the class HCRepositoryUtil method getRepositoryTypeOfHadoopSubItem.
public static String getRepositoryTypeOfHadoopSubItem(Item item) {
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
DatabaseConnection dbConnection = (DatabaseConnection) dbItem.getConnection();
return dbConnection.getDatabaseType().toUpperCase();
}
for (IHadoopSubnodeRepositoryContentHandler handler : HadoopSubnodeRepositoryContentManager.getHandlers()) {
if (handler.isProcess(item) && handler.getProcessType() != null) {
return handler.getProcessType().getType().toUpperCase();
}
}
return null;
}
Aggregations