Package io.debezium.connector.mongodb
Class AbstractMongoConnectorIT
- java.lang.Object
-
- io.debezium.embedded.AbstractConnectorTest
-
- io.debezium.connector.mongodb.AbstractMongoConnectorIT
-
- All Implemented Interfaces:
Testing
- Direct Known Subclasses:
CloudEventsConverterIT,FieldRenamesIT,MongoMetricsIT,TransactionMetadataIT
public abstract class AbstractMongoConnectorIT extends AbstractConnectorTest
A common abstract base class for the Mongodb connector integration testing.- Author:
- Chris Cranford
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.debezium.embedded.AbstractConnectorTest
AbstractConnectorTest.SourceRecords
-
Nested classes/interfaces inherited from interface io.debezium.util.Testing
Testing.Debug, Testing.Files, Testing.InterruptableFunction, Testing.Network, Testing.Print, Testing.Timer
-
-
Field Summary
Fields Modifier and Type Field Description protected Configurationconfigprotected io.debezium.connector.mongodb.MongoDbTaskContextcontextprotected LogInterceptorlogInterceptor-
Fields inherited from class io.debezium.embedded.AbstractConnectorTest
engine, logger, logTestName, OFFSET_STORE_PATH, pollTimeoutInMs, skipTestRule
-
-
Constructor Summary
Constructors Constructor Description AbstractMongoConnectorIT()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterEach()voidbeforEach()private static booleancollectionExists(com.mongodb.client.MongoDatabase database, String collectionName)protected BiConsumer<String,Throwable>connectionErrorHandler(int numErrorsBeforeFailing)protected voiddeleteDocuments(String dbName, String collectionName, org.bson.Document filter)Deletes a document in a collection based on a specified filter.protected voiddropAndInsertDocuments(String dbName, String collectionName, org.bson.Document... documents)Drops the specified collection if it exists and inserts all documents into the empty collection.protected voidinsertDocuments(String dbName, String collectionName, org.bson.Document... documents)Inserts all documents in the specified collection.protected voidinsertDocumentsInTx(String dbName, String collectionName, org.bson.Document... documents)Inserts all documents in the specified collection within a transaction.protected List<org.bson.Document>loadTestDocuments(String pathOnClasspath)Load test documents from the classpath.protected io.debezium.connector.mongodb.ConnectionContext.MongoPrimaryprimary()protected voidstoreDocuments(com.mongodb.client.MongoCollection<org.bson.Document> collection, String pathOnClasspath)protected voidstoreDocuments(String dbName, String collectionName, String pathOnClasspath)protected voidupdateDocument(String dbName, String collectionName, org.bson.Document filter, org.bson.Document document)Updates a document in a collection based on a specified filter.-
Methods inherited from class io.debezium.embedded.AbstractConnectorTest
assertBeginTransaction, assertConfigurationErrors, assertConfigurationErrors, assertConfigurationErrors, assertConnectorIsRunning, assertConnectorNotRunning, assertDelete, assertEndTransaction, assertEngineIsRunning, assertHasNoSourceQuery, assertInsert, assertKey, assertNoConfigurationErrors, assertNoRecordsToConsume, assertOffset, assertOffset, assertOnlyTransactionRecordsToConsume, assertRecordTransactionMetadata, assertSchemaMatchesStruct, assertSchemaMatchesStruct, assertSourceQuery, assertTombstone, assertTombstone, assertUpdate, assertValueField, configValue, consumeAvailableRecords, consumeDmlRecordsByTopic, consumeDmlRecordsByTopic, consumeDmlRecordsByTopic, consumeRecord, consumeRecords, consumeRecords, consumeRecords, consumeRecordsByTopic, consumeRecordsByTopic, consumeRecordsByTopic, debug, getMaximumEnqueuedRecordCount, getSnapshotMetricsObjectName, getStreamingMetricsObjectName, getStreamingMetricsObjectName, getStreamingNamespace, initializeConnectorTestFramework, isStreamingRunning, isStreamingRunning, isTransactionRecord, loggingCompletion, print, readLastCommittedOffset, readLastCommittedOffsets, setConsumeTimeout, skipAvroValidation, start, start, start, start, start, startAndConsumeTillEnd, startAndConsumeTillEnd, stopConnector, stopConnector, validate, waitForAvailableRecords, waitForConnectorShutdown, waitForSnapshotToBeCompleted, waitForStreamingRunning, waitForStreamingRunning, waitTimeForRecords, waitTimeForRecordsAfterNulls
-
-
-
-
Field Detail
-
config
protected Configuration config
-
context
protected io.debezium.connector.mongodb.MongoDbTaskContext context
-
logInterceptor
protected LogInterceptor logInterceptor
-
-
Method Detail
-
beforEach
public void beforEach()
-
afterEach
public void afterEach()
-
loadTestDocuments
protected List<org.bson.Document> loadTestDocuments(String pathOnClasspath)
Load test documents from the classpath.- Parameters:
pathOnClasspath- the path on the classpath to the file containing the documents to load- Returns:
- list of loaded documents; never null but may contain no entries.
-
dropAndInsertDocuments
protected void dropAndInsertDocuments(String dbName, String collectionName, org.bson.Document... documents)
Drops the specified collection if it exists and inserts all documents into the empty collection. NOTE: This method will only drop the collection if the documents list is provided.- Parameters:
dbName- the database namecollectionName- the collection namedocuments- the documents to be inserted, can be empty
-
insertDocuments
protected void insertDocuments(String dbName, String collectionName, org.bson.Document... documents)
Inserts all documents in the specified collection.- Parameters:
dbName- the database namecollectionName- the collection namedocuments- the documents to be inserted, can be empty
-
insertDocumentsInTx
protected void insertDocumentsInTx(String dbName, String collectionName, org.bson.Document... documents)
Inserts all documents in the specified collection within a transaction.- Parameters:
dbName- the database namecollectionName- the collection namedocuments- the documents to be inserted, can be empty
-
updateDocument
protected void updateDocument(String dbName, String collectionName, org.bson.Document filter, org.bson.Document document)
Updates a document in a collection based on a specified filter.- Parameters:
dbName- the database namecollectionName- the collection namefilter- the document filterdocument- the document fields to be updated
-
deleteDocuments
protected void deleteDocuments(String dbName, String collectionName, org.bson.Document filter)
Deletes a document in a collection based on a specified filter.- Parameters:
dbName- the database namecollectionName- the collection namefilter- the document filter
-
primary
protected io.debezium.connector.mongodb.ConnectionContext.MongoPrimary primary()
-
connectionErrorHandler
protected BiConsumer<String,Throwable> connectionErrorHandler(int numErrorsBeforeFailing)
-
collectionExists
private static boolean collectionExists(com.mongodb.client.MongoDatabase database, String collectionName)
-
storeDocuments
protected void storeDocuments(String dbName, String collectionName, String pathOnClasspath)
-
storeDocuments
protected void storeDocuments(com.mongodb.client.MongoCollection<org.bson.Document> collection, String pathOnClasspath)
-
-