You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/11/10 02:21:59 UTC

[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #3279: Fix #3276 to make sure all objects have been deleted after each test …

zhfeng commented on a change in pull request #3279:
URL: https://github.com/apache/camel-quarkus/pull/3279#discussion_r746198352



##########
File path: integration-test-groups/aws2/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/Aws2S3Test.java
##########
@@ -36,6 +37,19 @@
 @QuarkusTestResource(Aws2TestResource.class)
 class Aws2S3Test {
 
+    @AfterEach
+    public void after() {
+
+        // Make sure all create objects have been deleted
+        final String[] objects = RestAssured.given()
+                .get("/aws2/s3/object-keys")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body().as(String[].class);
+        Assertions.assertTrue(objects.length == 0);

Review comment:
       Good point ! The other issue could be if one of the test leaks the object, and remain tests which running after it will be all failed even if there are no leak objects with them. This might make a confusion to the author. So what about
   
   ```java
       private int objects_num_before;
       private int objects_num_after;
   
       @BeforeEach
       public void before() {
           objects_num_before = getObjects().length;
       }
   
       @AfterEach
       public void after(TestInfo testInfo) {
           
           // Make sure all create objects have been deleted after test
           objects_num_after = getObjects().length;
           if (objects_num_after != objects_num_before) {
               Assertions.fail("There is object leak after " + testInfo.getTestMethod().get().getName());
           }
       }
   
       private String[] getObjects() {
           final String[] objects = RestAssured.given()
                   .get("/aws2/s3/object-keys")
                   .then()
                   .statusCode(200)
                   .extract()
                   .body().as(String[].class);
   
           return objects;
       }
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org