Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-8114

Allow to do polling of code failing on asserts

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Do
    • Apache Sling Testing Clients 1.2.0
    • None
    • None

    Description

      Currently if you polling check uses assertions , it will not be retried, this is due to this line

      https://github.com/apache/sling-org-apache-sling-testing-clients/blob/master/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java#L118

      Which is only catching Exceptions while failing Assertions are an error kind (AssertionError).

      It would be nice to handle it so that code wouldn't have to "transform" it to exception.

      To reproduce simply use assertion in your polling check and let it fail if a counter is lower than a value. make the polling retries so that at the next retry counter it should pass.

       

      int count = 0;

      new Polling(() -> 

      Unknown macro: {  count++;   Assert.assertTrue(count == 2);  return true;         }

      ).poll(2000, 500);

      Observation: it exist the poll directly as the assert fail already.

      Expected: It should have polled until the check pass here.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            petitbear68 Thierry Ygé
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: