Search in sources :

Example 91 with DatabaseConnection

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));
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) EDatabaseTypeName(org.talend.core.database.EDatabaseTypeName) Test(org.junit.Test)

Example 92 with DatabaseConnection

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());
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Test(org.junit.Test)

Example 93 with DatabaseConnection

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());
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Test(org.junit.Test)

Example 94 with DatabaseConnection

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());
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Test(org.junit.Test)

Example 95 with DatabaseConnection

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;
}
Also used : IHadoopSubnodeRepositoryContentHandler(org.talend.repository.hadoopcluster.ui.viewer.handler.IHadoopSubnodeRepositoryContentHandler) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Aggregations

DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)211 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)66 Connection (org.talend.core.model.metadata.builder.connection.Connection)53 ConnectionItem (org.talend.core.model.properties.ConnectionItem)42 ArrayList (java.util.ArrayList)41 PersistenceException (org.talend.commons.exception.PersistenceException)41 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)39 Test (org.junit.Test)33 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)30 Property (org.talend.core.model.properties.Property)30 Item (org.talend.core.model.properties.Item)26 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)20 IElementParameter (org.talend.core.model.process.IElementParameter)19 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)18 RepositoryNode (org.talend.repository.model.RepositoryNode)18 SQLException (java.sql.SQLException)17 TdTable (org.talend.cwm.relational.TdTable)17 Catalog (orgomg.cwm.resource.relational.Catalog)17 List (java.util.List)15 ReturnCode (org.talend.utils.sugars.ReturnCode)14