Search in sources :

Example 1 with TSnowflakeCloseProperties

use of org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties in project components by Talend.

the class SnowflakeCloseSourceOrSinkTest method reset.

@Before
public void reset() {
    closeSourceOrSink = new SnowflakeCloseSourceOrSink();
    closeSourceOrSink.initialize(null, new TSnowflakeCloseProperties("connection"));
}
Also used : TSnowflakeCloseProperties(org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties) Before(org.junit.Before)

Example 2 with TSnowflakeCloseProperties

use of org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties in project components by Talend.

the class SnowflakeReadersTestIT method testCloseExistingConnection.

@Test
public void testCloseExistingConnection() throws Throwable {
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps);
    final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SnowflakeSourceOrSink snowflakeSourceOrSink = new SnowflakeSourceOrSink();
    snowflakeSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, snowflakeSourceOrSink.validate(connContainer).getStatus());
    TSnowflakeCloseProperties closeProps = (TSnowflakeCloseProperties) getComponentService().getComponentProperties(TSnowflakeCloseDefinition.COMPONENT_NAME);
    closeProps.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SnowflakeCloseSourceOrSink snowflakeCloseSourceOrSink = new SnowflakeCloseSourceOrSink();
    snowflakeCloseSourceOrSink.initialize(connContainer, closeProps);
    assertEquals(ValidationResult.Result.OK, snowflakeCloseSourceOrSink.validate(connContainer).getStatus());
}
Also used : DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) SnowflakeSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeSourceOrSink) SnowflakeCloseSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeCloseSourceOrSink) TSnowflakeCloseProperties(org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 3 with TSnowflakeCloseProperties

use of org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties in project components by Talend.

the class SnowflakeReadersTestIT method testSameConnectionForSeveralReaders.

@Test(expected = IOException.class)
public void testSameConnectionForSeveralReaders() throws Throwable {
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps);
    final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
    SnowflakeSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(connContainer).getStatus());
    TSnowflakeOutputProperties props = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
    setupProps(props.getConnectionProperties());
    setupTableWithStaticValues(props);
    props.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
    List<IndexedRecord> rows = readRows(props, connContainer);
    assertEquals(100, rows.size());
    // Read second time with the same properties but with new reader.
    rows = readRows(props, connContainer);
    assertEquals(100, rows.size());
    TSnowflakeCloseProperties closeProps = (TSnowflakeCloseProperties) getComponentService().getComponentProperties(TSnowflakeCloseDefinition.COMPONENT_NAME);
    closeProps.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SnowflakeCloseSourceOrSink snowflakeCloseSourceOrSink = new SnowflakeCloseSourceOrSink();
    snowflakeCloseSourceOrSink.initialize(connContainer, closeProps);
    assertEquals(ValidationResult.Result.OK, snowflakeCloseSourceOrSink.validate(connContainer).getStatus());
    // After close, exception should be thrown by the reader, if we try to read with the same connection.
    rows = readRows(props, connContainer);
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) SnowflakeSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeSourceOrSink) SnowflakeCloseSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeCloseSourceOrSink) TSnowflakeCloseProperties(org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Aggregations

TSnowflakeCloseProperties (org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties)3 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)2 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)2 SnowflakeConnectionProperties (org.talend.components.snowflake.SnowflakeConnectionProperties)2 SnowflakeCloseSourceOrSink (org.talend.components.snowflake.runtime.SnowflakeCloseSourceOrSink)2 SnowflakeSourceOrSink (org.talend.components.snowflake.runtime.SnowflakeSourceOrSink)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 Before (org.junit.Before)1 TSnowflakeOutputProperties (org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties)1