Search in sources :

Example 31 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class JdbcDatasetRuntimeTest method testBasic.

@Test
public void testBasic() throws Exception {
    JDBCDatasetProperties props = createDatasetProperties();
    final List<IndexedRecord> consumed = new ArrayList<>();
    RuntimeInfo ri = def.getRuntimeInfo(props);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        DatasetRuntime runtime = (DatasetRuntime) si.getInstance();
        runtime.initialize(null, props);
        assertThat(runtime, not(nullValue()));
        Schema s = runtime.getSchema();
        assertThat(s, not(nullValue()));
        runtime.getSample(100, new Consumer<IndexedRecord>() {

            @Override
            public void accept(IndexedRecord ir) {
                consumed.add(ir);
            }
        });
    }
    assertThat(consumed, hasSize(2));
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) IndexedRecord(org.apache.avro.generic.IndexedRecord) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) DatasetRuntime(org.talend.components.common.dataset.runtime.DatasetRuntime) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) Test(org.junit.Test)

Example 32 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class JDBCDatastoreDefinitionTest method testGetRuntimeInfo.

/**
 * Run the RuntimeInfo getRuntimeInfo(JDBCDatastoreProperties) method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 17-6-23 PM2:14
 */
@Test
public void testGetRuntimeInfo() throws Exception {
    AllSetting allSetting = Mockito.mock(AllSetting.class);
    Mockito.when(allSetting.getDriverClass()).thenReturn("anyDriverClass");
    JDBCDatastoreProperties properties = Mockito.mock(JDBCDatastoreProperties.class);
    Mockito.when(properties.getRuntimeSetting()).thenReturn(allSetting);
    JDBCDatastoreDefinition fixture = new JDBCDatastoreDefinition();
    RuntimeInfo result = fixture.getRuntimeInfo(properties);
    assertNotNull(result);
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 33 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class JDBCOutputDefinitionTest method getRuntimeInfo.

@Test
public void getRuntimeInfo() throws Exception {
    AllSetting allSetting = Mockito.mock(AllSetting.class);
    Mockito.when(allSetting.getDriverClass()).thenReturn("anyDriverClass");
    JDBCOutputProperties anyProperties = Mockito.mock(JDBCOutputProperties.class);
    Mockito.when(anyProperties.getRuntimeSetting()).thenReturn(allSetting);
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(ExecutionEngine.BEAM, anyProperties, null);
    assertEquals(JDBCOutputDefinition.BEAM_RUNTIME, runtimeInfo.getRuntimeClassName());
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 34 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class TJDBCOutputDefinitionTest method testGetRuntimeInfo.

/**
 * Run the RuntimeInfo getRuntimeInfo(ExecutionEngine,ComponentProperties,ConnectorTopology) method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 17-6-20 PM3:13
 */
@Test
public void testGetRuntimeInfo() throws Exception {
    AllSetting allSetting = Mockito.mock(AllSetting.class);
    Mockito.when(allSetting.getDriverClass()).thenReturn("anyDriverClass");
    TJDBCOutputProperties properties = Mockito.mock(TJDBCOutputProperties.class);
    Mockito.when(properties.getRuntimeSetting()).thenReturn(allSetting);
    TJDBCOutputDefinition fixture = new TJDBCOutputDefinition();
    ExecutionEngine engine = ExecutionEngine.DI;
    RuntimeInfo result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.INCOMING);
    assertNotNull(result);
    result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.INCOMING_AND_OUTGOING);
    assertNotNull(result);
    result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.NONE);
    assertNull(result);
    result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.OUTGOING);
    assertNull(result);
}
Also used : ExecutionEngine(org.talend.components.api.component.runtime.ExecutionEngine) AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 35 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class AggregateDefinitionTest method testGetRuntimeInfo.

@Test
public void testGetRuntimeInfo() {
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(ExecutionEngine.BEAM, null, ConnectorTopology.INCOMING_AND_OUTGOING);
    assertEquals("org.talend.components.processing.runtime.aggregate.AggregateRuntime", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Aggregations

RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)131 Test (org.junit.Test)120 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)27 Ignore (org.junit.Ignore)21 JarRuntimeInfo (org.talend.components.api.component.runtime.JarRuntimeInfo)17 ArrayList (java.util.ArrayList)13 AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)11 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)8 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)7 URL (java.net.URL)6 Schema (org.apache.avro.Schema)6 ComponentException (org.talend.components.api.exception.ComponentException)5 ValidationResult (org.talend.daikon.properties.ValidationResult)5 File (java.io.File)3 NamedThing (org.talend.daikon.NamedThing)3 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)3 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)3 FileWriter (java.io.FileWriter)2 GenericRecord (org.apache.avro.generic.GenericRecord)2