use of org.talend.components.api.container.RuntimeContainer in project components by Talend.
the class JDBCTypeMappingTestIT method testGetSchema.
@Test
public void testGetSchema() throws Exception {
TJDBCInputDefinition definition = new TJDBCInputDefinition();
TJDBCInputProperties properties = DBTestUtils.createCommonJDBCInputProperties(allSetting, definition);
properties.main.schema.setValue(DBTestUtils.createTestSchema3(true, tablename));
properties.tableSelection.tablename.setValue(tablename);
properties.sql.setValue(DBTestUtils.getSQL(tablename));
JDBCSource source = DBTestUtils.createCommonJDBCSource(properties);
RuntimeContainer container = new DefaultComponentRuntimeContainerImpl() {
@Override
public String getCurrentComponentId() {
return "tJDBCInput1";
}
};
java.net.URL mappings_url = this.getClass().getResource("/mappings");
mappings_url = DBTestUtils.correctURL(mappings_url);
container.setComponentData(container.getCurrentComponentId(), ComponentConstants.MAPPING_URL_SUBFIX, mappings_url);
Schema schema = source.getEndpointSchema(container, tablename);
assertEquals(tablename, schema.getName().toUpperCase());
List<Field> columns = schema.getFields();
testMetadata(columns);
}
use of org.talend.components.api.container.RuntimeContainer in project components by Talend.
the class MarkLogicSourceOrSinkTest method testValidateWithReferenceConnection.
@Test
public void testValidateWithReferenceConnection() {
RuntimeContainer container = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
when(container.getComponentData(anyString(), eq(MarkLogicConnection.CONNECTION))).thenReturn(mockedClient);
MarkLogicConnectionProperties connectionProperties = new MarkLogicConnectionProperties("connection");
connectionProperties.init();
MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProperties");
inputProperties.connection.referencedComponent.setReference(connectionProperties);
inputProperties.connection.referencedComponent.componentInstanceId.setValue(MarkLogicConnectionDefinition.COMPONENT_NAME + "_1");
inputProperties.init();
sourceOrSink.initialize(container, inputProperties);
ValidationResult vr = sourceOrSink.validate(container);
assertEquals(ValidationResult.Result.OK, vr.getStatus());
}
use of org.talend.components.api.container.RuntimeContainer in project components by Talend.
the class MarkLogicWriterTest method prepareDocManagerText.
private DocumentManager prepareDocManagerText(MarkLogicOutputProperties.Action action, MarkLogicOutputProperties.DocType docType, Object docContent) throws IOException {
MarkLogicSink sink = new MarkLogicSink();
MarkLogicOutputProperties properties = new MarkLogicOutputProperties("outputProperties");
properties.init();
properties.connection.referencedComponent.componentInstanceId.setValue("Not null value");
properties.docType.setValue(docType);
properties.action.setValue(action);
sink.ioProperties = properties;
RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
Mockito.when(mockedContainer.getComponentData(anyString(), anyString())).thenReturn(mockedClient);
DocumentManager markLogicDocMngrMock = mock(DocumentManager.class);
writer = sink.createWriteOperation().createWriter(mockedContainer);
GenericData.Record indexedRecord = new GenericData.Record(properties.datasetProperties.main.schema.getValue());
indexedRecord.put(0, "docId");
indexedRecord.put(1, docContent);
writer.open("123");
writer.docMgr = markLogicDocMngrMock;
writer.write(indexedRecord);
return markLogicDocMngrMock;
}
use of org.talend.components.api.container.RuntimeContainer in project components by Talend.
the class MarkLogicWriterTest method testInitDocManagerXML.
@Test
public void testInitDocManagerXML() throws IOException {
MarkLogicSink sink = new MarkLogicSink();
MarkLogicOutputProperties properties = new MarkLogicOutputProperties("outputProperties");
properties.init();
properties.connection.referencedComponent.componentInstanceId.setValue("Not null value");
properties.docType.setValue(MarkLogicOutputProperties.DocType.XML);
sink.ioProperties = properties;
RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
Mockito.when(mockedContainer.getComponentData(anyString(), anyString())).thenReturn(mockedClient);
writer = sink.createWriteOperation().createWriter(mockedContainer);
writer.open("123");
verify(mockedClient).newXMLDocumentManager();
}
use of org.talend.components.api.container.RuntimeContainer in project components by Talend.
the class MarkLogicWriterTest method testInitDocManagerMixed.
@Test
public void testInitDocManagerMixed() throws IOException {
MarkLogicSink sink = new MarkLogicSink();
MarkLogicOutputProperties properties = new MarkLogicOutputProperties("outputProperties");
properties.init();
properties.connection.referencedComponent.componentInstanceId.setValue("Not null value");
sink.ioProperties = properties;
RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
Mockito.when(mockedContainer.getComponentData(anyString(), anyString())).thenReturn(mockedClient);
writer = sink.createWriteOperation().createWriter(mockedContainer);
writer.open("123");
verify(mockedClient).newDocumentManager();
}
Aggregations