This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new d7c3737 Debezium tests are using JUnit 4 Assertions and Assumptions #3289 d7c3737 is described below commit d7c3737c1e2412957bae192cd0b7e1167800869d Author: JiriOndrusek <ondrusek.j...@gmail.com> AuthorDate: Thu Nov 11 14:10:29 2021 +0100 Debezium tests are using JUnit 4 Assertions and Assumptions #3289 --- .../debezium/common/it/AbstractDebeziumTest.java | 10 +++++----- .../debezium/common/it/mongodb/DebeziumMongodbTest.java | 16 +++++++++------- .../common/it/sqlserver/DebeziumSqlserverTest.java | 14 ++++++++------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumTest.java b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumTest.java index 26b0c30..c76bdc9 100644 --- a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumTest.java +++ b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumTest.java @@ -24,13 +24,14 @@ import io.restassured.RestAssured; 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. @@ -86,12 +87,11 @@ public abstract class AbstractDebeziumTest { 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 { @@ -130,7 +130,7 @@ public abstract class AbstractDebeziumTest { //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() { diff --git a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/mongodb/DebeziumMongodbTest.java b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/mongodb/DebeziumMongodbTest.java index 75be837..5ef6cf6 100644 --- a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/mongodb/DebeziumMongodbTest.java +++ b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/mongodb/DebeziumMongodbTest.java @@ -33,10 +33,9 @@ import org.bson.Document; 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; @@ -45,6 +44,9 @@ 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.Assumptions.assumeTrue; @QuarkusTest @QuarkusTestResource(DebeziumMongodbTestResource.class) @@ -75,16 +77,16 @@ class DebeziumMongodbTest extends AbstractDebeziumTest { 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 @@ -124,7 +126,7 @@ class DebeziumMongodbTest extends AbstractDebeziumTest { @Override protected void isInitialized(String s) { - Assert.assertNotNull(s, mongoClient); + assertNotNull(mongoClient, s); } @Test @@ -157,7 +159,7 @@ class DebeziumMongodbTest extends AbstractDebeziumTest { @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"); diff --git a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/sqlserver/DebeziumSqlserverTest.java b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/sqlserver/DebeziumSqlserverTest.java index 241f997..6f29e19 100644 --- a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/sqlserver/DebeziumSqlserverTest.java +++ b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/sqlserver/DebeziumSqlserverTest.java @@ -30,16 +30,18 @@ import org.apache.camel.quarkus.component.debezium.common.it.Type; 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) @@ -67,9 +69,9 @@ class DebeziumSqlserverTest extends AbstractDebeziumTest { } } - @Before + @BeforeEach public void before() { - org.junit.Assume.assumeTrue(connection != null); + assumeTrue(connection != null); } @AfterAll @@ -108,8 +110,8 @@ class DebeziumSqlserverTest extends AbstractDebeziumTest { 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; } }