Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: jtharness-3_2_2-MR1-Rel-b01
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      54

      Description

      I just noticed javatest Status class replaces all whitespace characters to a
      single space in its reason field. As a result, the output becomes very unreadable.

      My javatest version:
      JavaTest, version 3.2.1 fcs b22

      Please consider:
      leaving the reason field as is;
      exposing a public getReason() and setReason() to make it easier to subclass;

      javatest.Status source code:
      https://jtharness.dev.java.net/source/browse/jtharness/trunk/code/src/com/sun/javatest/Status.java?rev=848&view=markup

      This seems to be unnecessary and wasteful (parsing every character for every
      test) because sometimes the reason fields are indeed long. It's actually a good
      practice to display details as to why tests failed including stacktrace. Nobody
      can read stacktrace in one single line.

      /**

      • Create a Status object. See {@link #passed}

        ,

        {@link #failed}

        ,

        {@link #error}
      • etc. for more convenient factory methods to create Status objects.
      • @param type The type code for the Status object.
      • @param reason A short string to store in the status. Unprintable characters
      • (i.e. outside the range 040C to 177C) in the string are replaced by a space.
      • @throws IllegalArgumentException if the specified type is invalid.

      */

      public Status(int type, String reason) throws IllegalArgumentException

      {

      if (type < 0 || type >= NUM_STATES)

      throw new IllegalArgumentException(String.valueOf(type));

      // if we find any bad characters in the reason string (e.g. newline)

      // we rewrite the string replacing all such characters with a space.

      for (int i = 0; i < reason.length(); i++) {

      if (!isPrintable(reason.charAt)) {

      StringBuffer r = new StringBuffer(reason.length());

      for (int j = 0; j < reason.length(); j++)

      { char c = reason.charAt(j); r.append(isPrintable(c) ? c : ' '); }

      reason = r.toString();

      break;

      }

      }

        Activity

        Hide
        bkurotsu added a comment -

        Assign to Dima.

        Show
        bkurotsu added a comment - Assign to Dima.
        Hide
        fda added a comment -

        Replacing newLine characters with whitespace is done intentionally to fit a
        single line box when displaying in GUI. Status is not designed to contain such
        data as a stack trace, it's purposed to contain the test execution summary.

        Of course it's a good style to print out as much details as possible when test
        fails, but there is another way to do that: use output or error stream.

        Whitespace characters aren't replacing with a single one: "p a s s e d"
        will be printed as is.

        I'm closing this issue as "not an issue"

        Show
        fda added a comment - Replacing newLine characters with whitespace is done intentionally to fit a single line box when displaying in GUI. Status is not designed to contain such data as a stack trace, it's purposed to contain the test execution summary. Of course it's a good style to print out as much details as possible when test fails, but there is another way to do that: use output or error stream. Whitespace characters aren't replacing with a single one: "p a s s e d" will be printed as is. I'm closing this issue as "not an issue"

          People

          • Assignee:
            fda
            Reporter:
            Cheng Fang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: