Skip to content

Commit

Permalink
DebeziumMongodbTest skipped tests #3213
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Nov 16, 2021
1 parent b2755b3 commit 50a1de6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

@QuarkusTest
Expand All @@ -54,9 +54,6 @@
class DebeziumMongodbTest extends AbstractDebeziumTest {
private static final Logger LOG = Logger.getLogger(DebeziumMongodbTest.class);

//constant with value of Type.mongodb.getJdbcProperty
public static final String PROPERTY_JDBC = "mongodb_jdbc";

private static MongoClient mongoClient;

private static MongoCollection companies;
Expand All @@ -74,10 +71,10 @@ public static void setUp() throws SQLException {
if (mongoUrl.isPresent()) {
mongoClient = MongoClients.create(mongoUrl.get());
} else {
LOG.warn("Container is not running. Connection is not created.");
fail("Container is not running. Connection is not created.");
}

assumeTrue(mongoClient != null);
assertNotNull(mongoClient, String.format("Can not create client for url '%s'.", mongoUrl.get()));

MongoDatabase db = mongoClient.getDatabase("test");

Expand Down Expand Up @@ -108,7 +105,6 @@ protected String getCompanyTableName() {

@Test
@Order(0)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testReceiveInit() {
receiveResponse()
.then()
Expand All @@ -131,14 +127,12 @@ protected void isInitialized(String s) {

@Test
@Order(1)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testInsert() throws SQLException {
super.testInsert();
}

@Test
@Order(2)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testUpdate() throws SQLException {
Document doc = new Document().append("name", COMPANY_2).append("city", CITY_2);
companies.insertOne(doc);
Expand All @@ -156,7 +150,6 @@ public void testUpdate() throws SQLException {

@Test
@Order(3)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testDelete() throws SQLException {
DeleteResult dr = companies.deleteMany(new Document().append("name", COMPANY_2));
assertEquals(1, dr.getDeletedCount(), "Only one company should be deleted.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

@QuarkusTest
@QuarkusTestResource(DebeziumMysqlTestResource.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class DebeziumMysqlTest extends AbstractDebeziumTest {
private static final Logger LOG = Logger.getLogger(DebeziumMysqlTest.class);

//has to be constant and has to be equal to Type.mysql.getJdbcProperty
public static final String PROPERTY_JDBC = "mysql_jdbc";
private static Connection connection;

public DebeziumMysqlTest() {
Expand All @@ -53,13 +51,11 @@ public DebeziumMysqlTest() {
@BeforeAll
public static void setUp() throws SQLException {
Config config = ConfigProvider.getConfig();
Optional<String> jdbcUrl = config.getOptionalValue(PROPERTY_JDBC, String.class);
Optional<String> jdbcUrl = config.getOptionalValue(Type.mysql.getPropertyJdbc(), String.class);

if (jdbcUrl.isPresent()) {
connection = DriverManager.getConnection(jdbcUrl.get());
} else {
LOG.warn("Container is not running. Connection is not created.");
}
Assumptions.assumeTrue(jdbcUrl.isPresent(), "Driver for mySql database is not provided. Container won't start.");

connection = DriverManager.getConnection(jdbcUrl.get());
}

@AfterAll
Expand All @@ -71,35 +67,13 @@ public static void cleanUp() throws SQLException {

@Test
@Order(0)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testReceiveEmptyMessages() {
//receive all empty messages before other tests
receiveResponse("/receiveEmptyMessages")
.then()
.statusCode(204);
}

@Test
@Order(1)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testInsert() throws SQLException {
super.testInsert();
}

@Test
@Order(2)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testUpdate() throws SQLException {
super.testUpdate();
}

@Test
@Order(3)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testDelete() throws SQLException {
super.testDelete();
}

@Override
protected Connection getConnection() {
return connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
Expand All @@ -48,9 +47,6 @@
class DebeziumSqlserverTest extends AbstractDebeziumTest {
private static final Logger LOG = Logger.getLogger(DebeziumSqlserverTest.class);

//has to be constant and has to be equal to Type.mysql.getJdbcProperty
public static final String PROPERTY_JDBC = "sqlserver_jdbc";

private static Connection connection;

public DebeziumSqlserverTest() {
Expand All @@ -62,6 +58,9 @@ public static void setUp() throws SQLException {
Config config = ConfigProvider.getConfig();
final Optional<String> jdbcUrl = config.getOptionalValue(Type.sqlserver.getPropertyJdbc(), String.class);

assumeTrue(jdbcUrl.isPresent(),
"Ms SQL EULA is not accepted. Container won't start.");

if (jdbcUrl.isPresent()) {
connection = DriverManager.getConnection(jdbcUrl.get());
} else {
Expand Down Expand Up @@ -93,8 +92,10 @@ protected String getCompanyTableName() {

@Test
@Order(0)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testReceiveInitCompany() {
Config config = ConfigProvider.getConfig();
assumeTrue(config.getOptionalValue(Type.sqlserver.getPropertyJdbc(), String.class).isPresent());

int i = 0;

while (i++ < AbstractDebeziumTest.REPEAT_COUNT) {
Expand All @@ -115,26 +116,4 @@ public void testReceiveInitCompany() {
break;
}
}

@Test
@Order(1)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testInsert() throws SQLException {
super.testInsert();
}

@Test
@Order(2)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testUpdate() throws SQLException {
super.testUpdate();
}

@Test
@Order(3)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testDelete() throws SQLException {
super.testDelete();
}

}

0 comments on commit 50a1de6

Please sign in to comment.