JBehave
  1. JBehave
  2. JBEHAVE-857

Add unit test for our IOUtils, close for Exception missing

    Details

    • Type: Task Task
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7.3
    • Fix Version/s: 3.7.4, 3.8
    • Component/s: Core
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      the IOUtils class did have unit tests yet, the 2 stream toString methods are not closing the stream on exception.

      The unit test includes the exception close test and the close is now done in a finally block

        Activity

        Show
        Alexander Lehmann added a comment - https://github.com/alexlehm/jbehave-core/tree/jbehave_857
        Hide
        Mauro Talevi added a comment -

        Alex, patch pulled, but I was wondering if we can't do the tests much more simply using mocks.

        We don't want to repeat the tests already done by the commons-io IOUtils. Simply to test that the Reader or InputStream is closed after invocation of commons-io IOUtils.

        WDTY?

        Show
        Mauro Talevi added a comment - Alex, patch pulled, but I was wondering if we can't do the tests much more simply using mocks. We don't want to repeat the tests already done by the commons-io IOUtils. Simply to test that the Reader or InputStream is closed after invocation of commons-io IOUtils. WDTY?
        Hide
        Alexander Lehmann added a comment -

        I have almost no experience with mocks, I can take a look at how this can be done though.

        If we "trust" the tests for commons-io, we can keep only the shouldClose test methods.

        Show
        Alexander Lehmann added a comment - I have almost no experience with mocks, I can take a look at how this can be done though. If we "trust" the tests for commons-io, we can keep only the shouldClose test methods.
        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 3.7.4 [ 18964 ]
        Hide
        Mauro Talevi added a comment -

        It's actually not trivial in this case, and as you've already done the good work, let's keep it as it.

        Can you just look into the encoding issue? I had to comment out an assertion.

        Show
        Mauro Talevi added a comment - It's actually not trivial in this case, and as you've already done the good work, let's keep it as it. Can you just look into the encoding issue? I had to comment out an assertion.
        Hide
        Alexander Lehmann added a comment - - edited

        https://github.com/alexlehm/jbehave-core/tree/jbehave_857_2nd

        changed the tests to mock classes, removed utf-8 encoding, hopefully this will fix
        the encoding test failure

        (if that doesn't fix it, I think we can simply remove the last assert for InputStream)

        Show
        Alexander Lehmann added a comment - - edited https://github.com/alexlehm/jbehave-core/tree/jbehave_857_2nd changed the tests to mock classes, removed utf-8 encoding, hopefully this will fix the encoding test failure (if that doesn't fix it, I think we can simply remove the last assert for InputStream)
        Hide
        Mauro Talevi added a comment -

        Works a beauty!

        Show
        Mauro Talevi added a comment - Works a beauty!
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mauro Talevi made changes -
        Issue Type Bug [ 1 ] Task [ 3 ]
        Mauro Talevi made changes -
        Fix Version/s 3.8 [ 19104 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Alexander Lehmann
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: