Derby
  1. Derby
  2. DERBY-5620

Replace illegal characters from test name when creating the failure folder

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.9.1.0
    • Fix Version/s: 10.9.1.0
    • Component/s: Test
    • Labels:
      None

      Description

      Since the name of a JUnit test case can be any string, it should be sanitized and bad characters should be replaced with a valid one.

      1. derby-5620-2a-alphanum.diff
        1 kB
        Kristian Waagan
      2. derby-5620-1a-replace_illegal_fs_chars.diff
        1 kB
        Kristian Waagan

        Activity

        Hide
        Kristian Waagan added a comment -

        Closing.

        Show
        Kristian Waagan added a comment - Closing.
        Hide
        Kristian Waagan added a comment -

        Thanks, Dag

        Committed patch 2a to trunk with revision 1291657.

        Show
        Kristian Waagan added a comment - Thanks, Dag Committed patch 2a to trunk with revision 1291657.
        Hide
        Dag H. Wanvik added a comment -

        Looks good to me. +1

        Show
        Dag H. Wanvik added a comment - Looks good to me. +1
        Hide
        Kristian Waagan added a comment -

        Thanks, Dag.
        Something along the lines of patch 2a?

        BTW, this code must be CDC/J2ME compatible.

        Show
        Kristian Waagan added a comment - Thanks, Dag. Something along the lines of patch 2a? BTW, this code must be CDC/J2ME compatible.
        Hide
        Dag H. Wanvik added a comment -

        Thanks for fixing this! Why not just replace all non-identifier characters with underscore or dash?

        Show
        Dag H. Wanvik added a comment - Thanks for fixing this! Why not just replace all non-identifier characters with underscore or dash?
        Hide
        Kristian Waagan added a comment -

        It could be argued that the way to solve this is to do nothing, let runBare fail when/if the test fails, and then change the test name. The reason why I consider another solutions is that using "special characters" in the test name may be nice when dynamically generating test cases.
        As an example, I was using "client 10.1.3.1 <> server 10.8.2.2" as the name of the test case.

        Show
        Kristian Waagan added a comment - It could be argued that the way to solve this is to do nothing, let runBare fail when/if the test fails, and then change the test name. The reason why I consider another solutions is that using "special characters" in the test name may be nice when dynamically generating test cases. As an example, I was using "client 10.1.3.1 <> server 10.8.2.2" as the name of the test case.
        Hide
        Kristian Waagan added a comment -

        Attaching patch 1a, which replaces a set of characters from the string returned by TestCase.getName().

        I suspect the list isn't exhaustive, but it may already include characters that are allowed in some file system. The point here is just to make sure the directory creation works. In my case it failed due to putting '<>' in a test name (compatibility test).
        More characters that should go in?
        Is there perhaps a method in the Java-API that will remove illegal chars?

        Patch ready for review.

        Show
        Kristian Waagan added a comment - Attaching patch 1a, which replaces a set of characters from the string returned by TestCase.getName(). I suspect the list isn't exhaustive, but it may already include characters that are allowed in some file system. The point here is just to make sure the directory creation works. In my case it failed due to putting '<>' in a test name (compatibility test). More characters that should go in? Is there perhaps a method in the Java-API that will remove illegal chars? Patch ready for review.

          People

          • Assignee:
            Kristian Waagan
            Reporter:
            Kristian Waagan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development