use of org.talend.components.snowflake.runtime.SnowflakeSourceOrSink in project components by Talend.
the class SnowflakeReadersTestIT method testInputConnectionRef.
@Test
public void testInputConnectionRef() throws Throwable {
TSnowflakeInputProperties props = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
setupProps(props.connection);
SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(null, props);
assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(null).getStatus());
// Referenced properties simulating Snowflake connect component
SnowflakeConnectionProperties cProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
setupProps(cProps);
cProps.userPassword.password.setValue("xxx");
String compId = "comp1";
// Use the connection props of the Snowflake connect component
props.connection.referencedComponent.referenceType.setValue(ComponentReferenceProperties.ReferenceType.COMPONENT_INSTANCE);
props.connection.referencedComponent.componentInstanceId.setValue(compId);
props.connection.referencedComponent.setReference(cProps);
PropertiesTestUtils.checkAndAfter(getComponentService(), props.connection.getForm(Form.REFERENCE), "referencedComponent", props.connection);
resetUser();
SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(null, props);
SnowflakeSourceOrSink.validate(null);
assertEquals(ValidationResult.Result.ERROR, SnowflakeSourceOrSink.validate(null).getStatus());
resetUser();
setupProps(cProps);
setupTableWithStaticValues(props);
// Back to using the connection props of the Snowflake input component
props.connection.referencedComponent.referenceType.setValue(ComponentReferenceProperties.ReferenceType.THIS_COMPONENT);
props.connection.referencedComponent.componentInstanceId.setValue(null);
props.connection.referencedComponent.setReference(null);
// Check that the null referenced component works.
PropertiesTestUtils.checkAndAfter(getComponentService(), props.connection.getForm(Form.REFERENCE), "referencedComponent", props.connection);
resetUser();
SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(null, props);
ValidationResult result = SnowflakeSourceOrSink.validate(null);
LOGGER.info(String.valueOf(result));
assertEquals(ValidationResult.Result.OK, result.getStatus());
}
use of org.talend.components.snowflake.runtime.SnowflakeSourceOrSink 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());
}
use of org.talend.components.snowflake.runtime.SnowflakeSourceOrSink in project components by Talend.
the class SnowflakeReadersTestIT method testUseExistingConnection.
@Test
public void testUseExistingConnection() 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());
// Input component get connection from the tSnowflakeConnection
TSnowflakeInputProperties inProps = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
inProps.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
SnowflakeSourceOrSink SnowflakeInputSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeInputSourceOrSink.initialize(connContainer, inProps);
assertEquals(ValidationResult.Result.OK, SnowflakeInputSourceOrSink.validate(connContainer).getStatus());
}
use of org.talend.components.snowflake.runtime.SnowflakeSourceOrSink 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);
}
Aggregations