use of com.marklogic.client.DatabaseClient in project components by Talend.
the class TMarkLogicCloseStandalone method runAtDriver.
@Override
public void runAtDriver(RuntimeContainer container) {
if (container != null) {
DatabaseClient containerClient = (DatabaseClient) container.getComponentData(properties.getReferencedComponentId(), MarkLogicConnection.CONNECTION);
if (containerClient != null) {
containerClient.release();
LOGGER.info("Connection released");
}
}
}
use of com.marklogic.client.DatabaseClient 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 com.marklogic.client.DatabaseClient 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 com.marklogic.client.DatabaseClient 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 com.marklogic.client.DatabaseClient 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