Skip to content

Commit 4067cbb

Browse files
committed
test: unit test for valid JSON schema config
Signed-off-by: Dale Lane <[email protected]>
1 parent 860a239 commit 4067cbb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/com/ibm/eventstreams/connect/mqsource/MQSourceConnectorTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,29 @@ public void testValidateRetryDelayConfigWithDefaultValues() {
187187
.anyMatch(msg -> msg.contains("The value of 'mq.reconnect.delay.max.ms' must be greater than or equal to the value of 'mq.reconnect.delay.min.ms'.")));
188188
}
189189

190+
// verify that valid JSON schema config will be accepted
191+
@Test
192+
public void testValidJsonSchemaConfig() {
193+
final Map<String, String> configProps = new HashMap<String, String>();
194+
configProps.put("mq.queue.manager", "placeholder");
195+
configProps.put("mq.queue", "placeholder");
196+
configProps.put("topic", "placeholder");
197+
configProps.put("mq.record.builder", "com.ibm.eventstreams.connect.mqsource.builders.JsonRecordBuilder");
198+
configProps.put("mq.record.builder.json.schemas.enable", "true");
199+
configProps.put("mq.record.builder.json.schema.content", "{\n" +
200+
" \"type\": \"struct\", \n" +
201+
" \"fields\": [\n" +
202+
" {\n" +
203+
" \"field\": \"test\", \n" +
204+
" \"type\": \"string\"\n" +
205+
" }\n" +
206+
" ]\n" +
207+
"}");
208+
209+
final Config config = new MQSourceConnector().validate(configProps);
210+
assertTrue(config.configValues().stream().allMatch(cv -> cv.errorMessages().size() == 0));
211+
}
212+
190213
// verify that providing a schema that isn't JSON will be rejected
191214
@Test
192215
public void testValidateJsonSchemaConfig() {

0 commit comments

Comments
 (0)