Search in sources :

Example 11 with JDBCSource

use of org.talend.components.jdbc.runtime.JDBCSource in project components by Talend.

the class JDBCInputTestIT method testGetSchemaFromQueryWithException2.

@Test(expected = ComponentException.class)
public void testGetSchemaFromQueryWithException2() throws Exception {
    TJDBCInputDefinition definition = new TJDBCInputDefinition();
    TJDBCInputProperties properties = DBTestUtils.createCommonJDBCInputProperties(allSetting, definition);
    properties.connection.driverClass.setValue("notexist");
    JDBCSource source = DBTestUtils.createCommonJDBCSource(properties);
    try {
        source.getSchemaFromQuery(null, "select * from " + tablename);
    } catch (ComponentException e) {
        String message = CommonUtils.getClearExceptionInfo(e);
        assertTrue(message.contains("notexist"));
        throw e;
    }
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) TJDBCInputProperties(org.talend.components.jdbc.tjdbcinput.TJDBCInputProperties) JDBCSource(org.talend.components.jdbc.runtime.JDBCSource) TJDBCInputDefinition(org.talend.components.jdbc.tjdbcinput.TJDBCInputDefinition) Test(org.junit.Test)

Example 12 with JDBCSource

use of org.talend.components.jdbc.runtime.JDBCSource in project components by Talend.

the class JDBCInputTestIT method testGetSchemaWithException.

@Test(expected = ComponentException.class)
public void testGetSchemaWithException() throws Exception {
    TJDBCInputDefinition definition = new TJDBCInputDefinition();
    TJDBCInputProperties properties = DBTestUtils.createCommonJDBCInputProperties(allSetting, definition);
    properties.connection.driverClass.setValue("notexist");
    JDBCSource source = DBTestUtils.createCommonJDBCSource(properties);
    try {
        source.getEndpointSchema(null, tablename);
    } catch (ComponentException e) {
        String message = CommonUtils.getClearExceptionInfo(e);
        assertTrue(message.contains("notexist"));
        throw e;
    }
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) TJDBCInputProperties(org.talend.components.jdbc.tjdbcinput.TJDBCInputProperties) JDBCSource(org.talend.components.jdbc.runtime.JDBCSource) TJDBCInputDefinition(org.talend.components.jdbc.tjdbcinput.TJDBCInputDefinition) Test(org.junit.Test)

Aggregations

JDBCSource (org.talend.components.jdbc.runtime.JDBCSource)12 Test (org.junit.Test)9 TJDBCInputDefinition (org.talend.components.jdbc.tjdbcinput.TJDBCInputDefinition)9 TJDBCInputProperties (org.talend.components.jdbc.tjdbcinput.TJDBCInputProperties)9 ComponentException (org.talend.components.api.exception.ComponentException)5 Schema (org.apache.avro.Schema)3 Field (org.apache.avro.Schema.Field)3 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)3 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)3 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Reader (org.talend.components.api.component.runtime.Reader)1 ReaderDataProvider (org.talend.components.api.component.runtime.ReaderDataProvider)1 JDBCInputReader (org.talend.components.jdbc.runtime.reader.JDBCInputReader)1 NamedThing (org.talend.daikon.NamedThing)1