Skip to content

Commit

Permalink
Improve testing code and dependencies (#80)
Browse files Browse the repository at this point in the history
* Improve testing code

* Improve testing code

* Improve testing code
  • Loading branch information
ismailsimsek authored Feb 12, 2023
1 parent 226ef86 commit f7b5d60
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 29 deletions.
12 changes: 0 additions & 12 deletions debezium-server-bigquery-sinks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-server-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.awaitility.Awaitility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.debezium.server.bigquery.ConfigSource.*;
import static io.debezium.server.bigquery.TestConfigSource.*;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
package io.debezium.server.bigquery;

import io.debezium.serde.DebeziumSerdes;
import io.debezium.util.Testing;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;

import com.fasterxml.jackson.databind.JsonNode;
Expand All @@ -20,8 +22,11 @@

class BatchUtilTest {

final String serdeWithSchema = Testing.Files.readResourceAsString("json/serde-with-schema.json");
final String unwrapWithSchema = Testing.Files.readResourceAsString("json/unwrap-with-schema.json");
final String serdeWithSchema = Files.readString(Path.of("src/test/resources/json/serde-with-schema.json"));
final String unwrapWithSchema = Files.readString(Path.of("src/test/resources/json/unwrap-with-schema.json"));

BatchUtilTest() throws IOException {
}

@Test
public void testValuePayloadWithSchemaAsJsonNode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@

package io.debezium.server.bigquery;

import io.debezium.server.TestConfigSource;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.microprofile.config.spi.ConfigSource;

public class ConfigSource extends TestConfigSource {
public class TestConfigSource implements ConfigSource {
public static String BQ_LOCATION = "EU";
// overriden by user src/test/resources/application.properties
public static String BQ_PROJECT = "test";
public static String BQ_DATASET = "stage";
public static String BQ_CRED_FILE = ""; // "/path/to/application_credentials.json"
public static List<String> TABLES = List.of("customers", "geom", "orders", "products", "products_on_hand",
"test_data_types", "test_table");
protected Map<String, String> config = new HashMap<>();

public ConfigSource() {
public TestConfigSource() {
config.put("debezium.sink.type", "bigquerybatch");
config.put("debezium.source.include.schema.changes", "false");
config.put("debezium.source.decimal.handling.mode", "double");
Expand Down Expand Up @@ -67,10 +71,24 @@ public ConfigSource() {
config.put("quarkus.log.category.\"com.google.cloud.bigquery\".level", "INFO");
}


@Override
public Map<String, String> getProperties() {
return config;
}

@Override
public String getValue(String propertyName) {
return config.get(propertyName);
}

@Override
public String getName() {
return "test";
}

@Override
public int getOrdinal() {
// Configuration property precedence is based on ordinal values and since we override the
// properties in TestConfigSource, we should give this a higher priority.
return super.getOrdinal() + 1;
public Set<String> getPropertyNames() {
return config.keySet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Map;

import org.junit.jupiter.api.*;
import static io.debezium.server.bigquery.ConfigSource.*;
import static io.debezium.server.bigquery.TestConfigSource.*;


@Disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static io.debezium.server.bigquery.ConfigSource.BQ_DATASET;
import static io.debezium.server.bigquery.TestConfigSource.BQ_DATASET;
import static org.junit.jupiter.api.Assertions.assertEquals;

@QuarkusTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import static io.debezium.server.bigquery.ConfigSource.TABLES;
import static io.debezium.server.bigquery.TestConfigSource.TABLES;

public class SourceMysqlDB implements QuarkusTestResourceLifecycleManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.ImageFromDockerfile;
import static io.debezium.server.bigquery.ConfigSource.TABLES;
import static io.debezium.server.bigquery.TestConfigSource.TABLES;

public class SourcePostgresqlDB implements QuarkusTestResourceLifecycleManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# */
#

io.debezium.server.bigquery.ConfigSource
io.debezium.server.bigquery.TestConfigSource

0 comments on commit f7b5d60

Please sign in to comment.