Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debezium tests are using JUnit 4 Assertions and Assumptions #3289 #3290

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import io.restassured.response.Response;
import org.hamcrest.Matcher;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Abstract parent for debezium based tests.
Expand Down Expand Up @@ -86,12 +87,11 @@ public void testInsert() throws SQLException {
break;
}

Assert.assertTrue("Debezium does not respond (consider changing timeout in AbstractDebeziumResource).",
i < REPEAT_COUNT);
assertTrue(i < REPEAT_COUNT, "Debezium does not respond (consider changing timeout in AbstractDebeziumResource).");
}

protected void isInitialized(String s) {
Assert.assertNotNull(s, getConnection());
assertNotNull(getConnection(), s);
}

protected void insertCompany(String name, String city) throws SQLException {
Expand Down Expand Up @@ -130,7 +130,7 @@ public void testDelete() throws SQLException {
//validate that event for delete is in queue
receiveResponse(204, is(emptyOrNullString()));
}
Assert.assertTrue("No records were deleted", i > 1);
assertTrue(i > 1, "No records were deleted");
}

protected Response receiveResponse() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -45,6 +44,9 @@

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.Assumptions.assumeTrue;

@QuarkusTest
@QuarkusTestResource(DebeziumMongodbTestResource.class)
Expand Down Expand Up @@ -75,16 +77,16 @@ public static void setUp() throws SQLException {
LOG.warn("Container is not running. Connection is not created.");
}

org.junit.Assume.assumeTrue(mongoClient != null);
assumeTrue(mongoClient != null);

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

companies = db.getCollection("companies");
}

@Before
@BeforeEach
public void before() {
org.junit.Assume.assumeTrue(mongoClient != null);
assumeTrue(mongoClient != null);
}

@AfterAll
Expand Down Expand Up @@ -124,7 +126,7 @@ protected void insertCompany(String name, String city) {

@Override
protected void isInitialized(String s) {
Assert.assertNotNull(s, mongoClient);
assertNotNull(mongoClient, s);
}

@Test
Expand Down Expand Up @@ -157,7 +159,7 @@ public void testUpdate() throws SQLException {
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testDelete() throws SQLException {
DeleteResult dr = companies.deleteMany(new Document().append("name", COMPANY_2));
Assert.assertEquals("Only one company should be deleted.", 1, dr.getDeletedCount());
assertEquals(1, dr.getDeletedCount(), "Only one company should be deleted.");

//validate that event for delete is in queue
receiveResponse(200, equalTo("d"), "/receiveOperation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
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;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

@QuarkusTest
@QuarkusTestResource(DebeziumSqlserverTestResource.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
Expand Down Expand Up @@ -67,9 +69,9 @@ public static void setUp() throws SQLException {
}
}

@Before
@BeforeEach
public void before() {
org.junit.Assume.assumeTrue(connection != null);
assumeTrue(connection != null);
}

@AfterAll
Expand Down Expand Up @@ -108,8 +110,8 @@ public void testReceiveInitCompany() {
continue;
}

Assert.assertEquals("r", record.getOperation());
Assert.assertEquals("Struct{NAME=init,CITY=init}", record.getValue());
assertEquals("r", record.getOperation());
assertEquals("Struct{NAME=init,CITY=init}", record.getValue());
break;
}
}
Expand Down