Package io.debezium.connector.oracle
Class OracleDefaultValueIT
- java.lang.Object
-
- io.debezium.embedded.AbstractConnectorTest
-
- io.debezium.connector.oracle.OracleDefaultValueIT
-
- All Implemented Interfaces:
Testing
public class OracleDefaultValueIT extends AbstractConnectorTest
Integration test that tests all supported data types and default value combinations during both snapshot and streaming phases in conjunction with schema changes to the table.- Author:
- Chris Cranford
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classOracleDefaultValueIT.AssertionTypeDefines the different assertion types for a given column definition.private static classOracleDefaultValueIT.ColumnDefinitionDefines a column definition and its attributes that are used by tests.-
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 private Configurationconfigprivate Consumer<Configuration.Builder>configUpdaterprivate io.debezium.connector.oracle.OracleConnectionconnection-
Fields inherited from class io.debezium.embedded.AbstractConnectorTest
engine, logger, logTestName, OFFSET_STORE_PATH, pollTimeoutInMs, skipTestRule
-
-
Constructor Summary
Constructors Constructor Description OracleDefaultValueIT()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafter()private static voidassertSchemaFieldDefaultAndNonNullValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object defaultValue)Asserts that the schema field's default value is the supplied value and that the emitted events field value is at least a non-null value; expectation is that the emitted event value is dynamic, likely based on some database function call, likeTO_DATEorTO_TIMESTAMP.private static voidassertSchemaFieldNoDefaultWithValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object fieldValue)Asserts that the schema field's default value is not set and that the emitted event value matches.private static voidassertSchemaFieldValueWithDefault(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedDefault, Consumer<Object> valueCheck)private static voidassertSchemaFieldWithDefaultSysdate(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue)private static voidassertSchemaFieldWithSameDefaultAndValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue)Asserts that the schema field's default value and after emitted event value are the same.voidbefore()private longgetOracleIntervalDaySecond(int days, int hours, int minutes, int seconds, int micros)private StringgetOracleIntervalDaySecondString(int days, int hours, int minutes, int seconds, int micros)private longgetOracleIntervalYearMonth(int years, int month)private StringgetOracleIntervalYearMonthString(int years, int month)voidshouldHandleCharacterDefaultTypes()voidshouldHandleDateTimeDefaultTypes()voidshouldHandleDefaultValueForNonOptionalColumnUsingUnparseableValues()voidshouldHandleDefaultValueFromSequencesAsNoDefault()private voidshouldHandleDefaultValuesCommon(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions)Handles executing the full common set of default value tests for the supplied column definitions.voidshouldHandleDefaultValuesWhereSqlMayContainsTrailingSpaces()voidshouldHandleFloatPointDefaultTypes()voidshouldHandleIntervalDefaultTypes()voidshouldHandleIntervalDefaultTypesAsString()voidshouldHandleNumericDefaultTypes()private voidtestDefaultValuesAlterTableAdd(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions)Alters the underlying table changing adding a new column prefixed withAto each of the column definition with the initial default value definition.private voidtestDefaultValuesAlterTableModifyExisting(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions)Alters the underlying table changing the default value to its second form.private voidTestDefaultValuesByRestartAndLoadingHistoryTopic()Restarts the connector and verifies when the database history topic is loaded that we can parse all the loaded history statements without failures.private voidtestDefaultValuesCreateTableAndSnapshot(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions)Creates the table and pre-inserts a record captured during the snapshot phase.-
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
-
connection
private io.debezium.connector.oracle.OracleConnection connection
-
configUpdater
private Consumer<Configuration.Builder> configUpdater
-
config
private Configuration config
-
-
Method Detail
-
shouldHandleNumericDefaultTypes
@FixFor("DBZ-3710") public void shouldHandleNumericDefaultTypes() throws Exception
- Throws:
Exception
-
shouldHandleFloatPointDefaultTypes
@FixFor("DBZ-3710") public void shouldHandleFloatPointDefaultTypes() throws Exception
- Throws:
Exception
-
shouldHandleCharacterDefaultTypes
@FixFor("DBZ-3710") public void shouldHandleCharacterDefaultTypes() throws Exception
- Throws:
Exception
-
shouldHandleDateTimeDefaultTypes
@FixFor("DBZ-3710") public void shouldHandleDateTimeDefaultTypes() throws Exception
- Throws:
Exception
-
shouldHandleIntervalDefaultTypes
@FixFor("DBZ-3710") public void shouldHandleIntervalDefaultTypes() throws Exception
- Throws:
Exception
-
shouldHandleIntervalDefaultTypesAsString
@FixFor("DBZ-1539") public void shouldHandleIntervalDefaultTypesAsString() throws Exception
- Throws:
Exception
-
shouldHandleDefaultValueFromSequencesAsNoDefault
@FixFor("DBZ-4208") public void shouldHandleDefaultValueFromSequencesAsNoDefault() throws Exception
- Throws:
Exception
-
shouldHandleDefaultValuesWhereSqlMayContainsTrailingSpaces
@FixFor("DBZ-4360") public void shouldHandleDefaultValuesWhereSqlMayContainsTrailingSpaces() throws Exception
- Throws:
Exception
-
shouldHandleDefaultValueForNonOptionalColumnUsingUnparseableValues
@FixFor("DBZ-4388") public void shouldHandleDefaultValueForNonOptionalColumnUsingUnparseableValues() throws Exception
- Throws:
Exception
-
getOracleIntervalYearMonth
private long getOracleIntervalYearMonth(int years, int month)
-
getOracleIntervalYearMonthString
private String getOracleIntervalYearMonthString(int years, int month)
-
getOracleIntervalDaySecond
private long getOracleIntervalDaySecond(int days, int hours, int minutes, int seconds, int micros)
-
getOracleIntervalDaySecondString
private String getOracleIntervalDaySecondString(int days, int hours, int minutes, int seconds, int micros)
-
shouldHandleDefaultValuesCommon
private void shouldHandleDefaultValuesCommon(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception
Handles executing the full common set of default value tests for the supplied column definitions.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
TestDefaultValuesByRestartAndLoadingHistoryTopic
private void TestDefaultValuesByRestartAndLoadingHistoryTopic() throws ExceptionRestarts the connector and verifies when the database history topic is loaded that we can parse all the loaded history statements without failures.- Throws:
Exception
-
testDefaultValuesCreateTableAndSnapshot
private void testDefaultValuesCreateTableAndSnapshot(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception
Creates the table and pre-inserts a record captured during the snapshot phase. The snapshot record will be validated against the supplied column definitions. The goal of this method is to test that when a table is snapshot which uses default values that both the in-memory schema representation and the snapshot pipeline change event have the right default value resolution.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
testDefaultValuesAlterTableModifyExisting
private void testDefaultValuesAlterTableModifyExisting(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception
Alters the underlying table changing the default value to its second form. This method then inserts a new record that is then validated against the supplied column definitions. The goal of this method is to test that when DDL modifies an existing column in an existing table that the right default value resolution occurs and that the in-memory schema representation is correct as well as the change event capture pipeline.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
testDefaultValuesAlterTableAdd
private void testDefaultValuesAlterTableAdd(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception
Alters the underlying table changing adding a new column prefixed withAto each of the column definition with the initial default value definition. The goal of this method is to test that when DDL adds a new column to an existing table that the right default value resolution occurs and that the in-memory schema representation is correct as well as the change event capture pipeline.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
assertSchemaFieldWithSameDefaultAndValue
private static void assertSchemaFieldWithSameDefaultAndValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue)Asserts that the schema field's default value and after emitted event value are the same.- Parameters:
record- the change event record, nevernullfieldName- the field name, nevernullexpectedValue- the expected value in the field's default and "after" struct
-
assertSchemaFieldNoDefaultWithValue
private static void assertSchemaFieldNoDefaultWithValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object fieldValue)Asserts that the schema field's default value is not set and that the emitted event value matches.- Parameters:
record- the change event record, nevernullfieldName- the field name, nevernullfieldValue- the expected value in the field's "after" struct
-
assertSchemaFieldDefaultAndNonNullValue
private static void assertSchemaFieldDefaultAndNonNullValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object defaultValue)Asserts that the schema field's default value is the supplied value and that the emitted events field value is at least a non-null value; expectation is that the emitted event value is dynamic, likely based on some database function call, likeTO_DATEorTO_TIMESTAMP.- Parameters:
record- the change event record, nevernullfieldName- the field name, nevernulldefaultValue- the expected schema field's default value
-
assertSchemaFieldWithDefaultSysdate
private static void assertSchemaFieldWithDefaultSysdate(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue)
-
-