From a9e83bcf6352b6cad7065446c2aadcfa8373de60 Mon Sep 17 00:00:00 2001 From: Ali Ince Date: Thu, 12 Sep 2024 17:38:18 +0100 Subject: [PATCH] Test for multiple URIs (#641) --- .../kafka/connect/sink/Neo4jSinkTaskTest.kt | 2 +- .../source/Neo4jSourceConnectorConfigTest.kt | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/sink/Neo4jSinkTaskTest.kt b/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/sink/Neo4jSinkTaskTest.kt index a0420250..4152a061 100644 --- a/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/sink/Neo4jSinkTaskTest.kt +++ b/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/sink/Neo4jSinkTaskTest.kt @@ -72,7 +72,7 @@ class Neo4jSinkTaskTest { @After fun after() { - session.run("MATCH (n) DETACH DELETE n") + session.run("MATCH (n) DETACH DELETE n").consume() task.stop() } diff --git a/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/source/Neo4jSourceConnectorConfigTest.kt b/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/source/Neo4jSourceConnectorConfigTest.kt index 8101f0df..de48b797 100644 --- a/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/source/Neo4jSourceConnectorConfigTest.kt +++ b/kafka-connect-neo4j/src/test/kotlin/streams/kafka/connect/source/Neo4jSourceConnectorConfigTest.kt @@ -3,6 +3,7 @@ package streams.kafka.connect.source import org.apache.kafka.common.config.ConfigException import org.junit.Test import streams.kafka.connect.common.Neo4jConnectorConfig +import java.net.URI import kotlin.test.assertEquals class Neo4jSourceConnectorConfigTest { @@ -78,4 +79,25 @@ class Neo4jSourceConnectorConfigTest { assertEquals("$a:7687", config.serverUri[0].toString()) assertEquals("$b:7687", config.serverUri[1].toString()) } + + @Test + fun `should parse multiple URIs`() { + val originals = mapOf( + Neo4jSourceConnectorConfig.SOURCE_TYPE to SourceType.QUERY.toString(), + Neo4jSourceConnectorConfig.SOURCE_TYPE_QUERY to "MATCH (n) RETURN n", + Neo4jSourceConnectorConfig.TOPIC to "topic", + Neo4jSourceConnectorConfig.STREAMING_POLL_INTERVAL to "10", + Neo4jSourceConnectorConfig.STREAMING_FROM to StreamingFrom.NOW.toString(), + Neo4jConnectorConfig.SERVER_URI to "neo4j://192.168.0.1:7687,neo4j://192.168.0.3:7687,neo4j://192.168.0.2" + ) + val config = Neo4jSourceConnectorConfig(originals) + + assertEquals( + config.serverUri, listOf( + URI("neo4j://192.168.0.1:7687"), + URI("neo4j://192.168.0.3:7687"), + URI("neo4j://192.168.0.2:7687"), + ) + ) + } } \ No newline at end of file