JiriOndrusek commented on a change in pull request #2694: URL: https://github.com/apache/camel-quarkus/pull/2694#discussion_r642456761
########## File path: integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java ########## @@ -66,4 +78,169 @@ public void testSqlStoredComponent() { .statusCode(200) .body(is("15")); } + + @Test + public void testConsumer() throws InterruptedException { + testConsumer(1, "consumerRoute"); + } + + @Test + public void testClasspathConsumer() throws InterruptedException { + testConsumer(2, "consumerClasspathRoute"); + } + + @Test + public void testFileConsumer() throws InterruptedException { + testConsumer(3, "consumerFileRoute"); + } + + private void testConsumer(int id, String routeId) throws InterruptedException { + route(routeId, "start", "Started"); + + Map project = CollectionHelper.mapOf("ID", id, "PROJECT", routeId, "LICENSE", "222", "PROCESSED", false); + Map updatedProject = CollectionHelper.mapOf("ID", id, "PROJECT", routeId, "LICENSE", "XXX", "PROCESSED", false); + + postMapWithParam("/sql/insert", + "table", "projects", + project) + .statusCode(201); + + //wait for the record to be caught + Thread.sleep(500); + + RestAssured.get("/sql/get/results/" + routeId) + .then() + .statusCode(200) + .body("size()", is(1), "$", hasItem(project)); + + //update + postMapWithParam("/sql/update", + "table", "projects", + updatedProject) + .statusCode(201); + + Thread.sleep(500); + + RestAssured.get("/sql/get/results/" + routeId) + .then() + .statusCode(200) + .body("size()", is(1), "$", hasItem(updatedProject)); + + route(routeId, "stop", "Stopped"); + } + + @Test + public void testTransacted() throws InterruptedException { + + postMap("/sql/toDirect/transacted", CollectionHelper.mapOf(SqlConstants.SQL_QUERY, + "insert into projects values (5, 'Transacted', 'ASF', false)", + "rollback", false)) + .statusCode(204); + + postMap("/sql/toDirect/transacted", CollectionHelper.mapOf(SqlConstants.SQL_QUERY, + "select * from projects where project = 'Transacted'")) + .statusCode(200) + .body("size()", is(1)); + + postMap("/sql/toDirect/transacted", CollectionHelper.mapOf(SqlConstants.SQL_QUERY, + "insert into projects values (6, 'Transacted', 'ASF', false)", + "rollback", true)) + .statusCode(200) + .body(is("java.lang.Exception:forced Exception")); + + postMap("/sql/toDirect/transacted", + CollectionHelper.mapOf(SqlConstants.SQL_QUERY, "select * from projects where project = 'Transacted'")) + .statusCode(200) + .body("size()", is(1)); + } + + @Test + public void testDefaultErrorCode() throws InterruptedException { + postMap("/sql/toDirect/transacted", CollectionHelper.mapOf(SqlConstants.SQL_QUERY, "select * from NOT_EXIST order id")) + .statusCode(200) + .body(startsWith("org.springframework.jdbc.BadSqlGrammarException")); + } + + @Test + public void testIdempotentRepository() { + // add value with key 1 + postMapWithParam("/sql/toDirect/idempotent", + "body", "one", + CollectionHelper.mapOf("messageId", "1")) + .statusCode(200); + + // add value with key 2 + postMapWithParam("/sql/toDirect/idempotent", + "body", "two", + CollectionHelper.mapOf("messageId", "2")) + .statusCode(200); + + // add same value with key 3 + postMapWithParam("/sql/toDirect/idempotent", + "body", "three", + CollectionHelper.mapOf("messageId", "3")) + .statusCode(200); + + // add another value with key 1 -- this one is supposed to be skipped + postMapWithParam("/sql/toDirect/idempotent", + "body", "four", + CollectionHelper.mapOf("messageId", "1")) + .statusCode(200); + + // get all values from the result map + await().atMost(5, TimeUnit.SECONDS).until(() -> (Iterable<? extends String>) RestAssured + .get("/sql/get/results/idempotentRoute").then().extract().as(List.class), + containsInAnyOrder("one", "two", "three")); + } + + @Test + @Disabled //see https://github.com/apache/camel-quarkus/issues/2693 + public void testAggregationRepository() { + postMapWithParam("/sql/toDirect/aggregation", "body", "A", CollectionHelper.mapOf("messageId", "123")) + .statusCode(200); + + postMapWithParam("/sql/toDirect/aggregation", "body", "B", CollectionHelper.mapOf("messageId", "123")) + .statusCode(200); + + postMapWithParam("/sql/toDirect/aggregation", "body", "C", CollectionHelper.mapOf("messageId", "123")) + .statusCode(200); + + postMapWithParam("/sql/toDirect/aggregation", "body", "D", CollectionHelper.mapOf("messageId", "123")) + .statusCode(200); Review comment: I tried to keep all parametetrs (like url, body, params) in the main call (not helper method) - from my POV it seems more understandable and shows that all the calls are the same. But I don't have any problem with keeping restassured code intact... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org