JDO
  1. JDO
  2. JDO-304

Query failure should print the query that failed in addition to the expected and actual results

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JDO 2 beta
    • Fix Version/s: JDO 2 rc1
    • Component/s: tck
    • Labels:
      None

      Description

      The failure message doesn't contain the failing query:
      [java] There were 2 failures:
      [java] 1) testNoNavigation(org.apache.jdo.tck.query.result.VariableInResult)junit.framework.AssertionFailedError: Assertion A14.6.9-3 (VariableInResult) failed:
      [java] Wrong query result:
      [java] expected: [Project(1, name orange, budget 2500000.99), Project(1, name orange, budget 2500000.99), Project(1, name orange, budget 2500000.99)]
      [java] got: [Project(1, name orange, budget 2500000.99)]

      1. Query.patch
        24 kB
        Craig L Russell
      2. QueryTest.patch
        4 kB
        Craig L Russell

        Activity

        Hide
        Craig L Russell added a comment -

        Please review this patch. After applying the patch, failing queries print the query and the expected and actual results.

        [java] 1) testNoNavigation(org.apache.jdo.tck.query.result.VariableInResult)junit.framework.AssertionFailedError: Assertion A14.6.9-3 (VariableInResult) failed:
        [java] Wrong query result:
        [java] query: SELECT p FROM org.apache.jdo.tck.pc.company.Employee WHERE projects.contains(p) & p.name == 'orange' VARIABLES Project p
        [java] expected: [Project(1, name orange, budget 2500000.99), Project(1, name orange, budget 2500000.99), Project(1, name orange, budget 2500000.99)]
        [java] got: [Project(1, name orange, budget 2500000.99)]

        Show
        Craig L Russell added a comment - Please review this patch. After applying the patch, failing queries print the query and the expected and actual results. [java] 1) testNoNavigation(org.apache.jdo.tck.query.result.VariableInResult)junit.framework.AssertionFailedError: Assertion A14.6.9-3 (VariableInResult) failed: [java] Wrong query result: [java] query: SELECT p FROM org.apache.jdo.tck.pc.company.Employee WHERE projects.contains(p) & p.name == 'orange' VARIABLES Project p [java] expected: [Project(1, name orange, budget 2500000.99), Project(1, name orange, budget 2500000.99), Project(1, name orange, budget 2500000.99)] [java] got: [Project(1, name orange, budget 2500000.99)]
        Hide
        Michael Bouschen added a comment -

        I like the idea of including the JDOQL query string into the error message. The patch QueryTest.patch changes the signature of methods checkQueryResultWithOrder checkQueryResultWithoutOrder defined in the query test superclass QueryTest. These methods are protected and a couple of test classes directly call these methods. These classes fail to compile after applying the patch (I got 56 compile errors). Either we change all the callers or we restore the methods with the old signature such that we have two overloaded versions of the methods. What do you think?

        Show
        Michael Bouschen added a comment - I like the idea of including the JDOQL query string into the error message. The patch QueryTest.patch changes the signature of methods checkQueryResultWithOrder checkQueryResultWithoutOrder defined in the query test superclass QueryTest. These methods are protected and a couple of test classes directly call these methods. These classes fail to compile after applying the patch (I got 56 compile errors). Either we change all the callers or we restore the methods with the old signature such that we have two overloaded versions of the methods. What do you think?
        Hide
        karan singh malhi added a comment -

        I think if just a couple of calls are being made to these methods then we should simply make changes in the the callers

        Show
        karan singh malhi added a comment - I think if just a couple of calls are being made to these methods then we should simply make changes in the the callers
        Hide
        Craig L Russell added a comment -

        Please review this patch.

        There were 19 test cases affected by the change. Both versions of the check methods are available. The version without the filter should only be used if the filter is null. This allows us to avoid updating the other test cases.

        Show
        Craig L Russell added a comment - Please review this patch. There were 19 test cases affected by the change. Both versions of the check methods are available. The version without the filter should only be used if the filter is null. This allows us to avoid updating the other test cases.
        Hide
        Craig L Russell added a comment -

        svn commit -m "JDO-304 updated query checking to include query filter"
        Sending query/api/CompileQuery.java
        Sending query/api/DeclareImports.java
        Sending query/api/DeclareParameters.java
        Sending query/api/ExecuteQuery.java
        Sending query/api/ExecuteQueryWithArray.java
        Sending query/api/ExecuteQueryWithMap.java
        Sending query/api/NewQueryFromRestoredSerializedQuery.java
        Sending query/api/NewQueryWithCandidateClassAndFilter.java
        Sending query/api/NewQueryWithCandidateClassCollectionFilter.java
        Sending query/api/NewQueryWithExtentAndFilter.java
        Sending query/api/SetFilter.java
        Sending query/jdoql/MultipleActiveQueryInstanceInSamePersistenceManager.java
        Sending query/jdoql/MultipleIdenticalImports.java
        Sending query/jdoql/OrderingSpecification.java
        Sending query/jdoql/ParenthesesMarkOperatorPrecedence.java
        Sending query/jdoql/QueryResultPassedToAnotherQuery.java
        Sending query/jdoql/WhiteSpaceIsACharacterAndIgnored.java
        Sending query/jdoql/keywords/UseOfThisToAcessHiddenField.java
        Sending query/jdoql/parameters/ParameterDeclaredWithSameNameAsFieldOfCandidateClass.java
        Transmitting file data ...................
        Committed revision 379541.

        Show
        Craig L Russell added a comment - svn commit -m " JDO-304 updated query checking to include query filter" Sending query/api/CompileQuery.java Sending query/api/DeclareImports.java Sending query/api/DeclareParameters.java Sending query/api/ExecuteQuery.java Sending query/api/ExecuteQueryWithArray.java Sending query/api/ExecuteQueryWithMap.java Sending query/api/NewQueryFromRestoredSerializedQuery.java Sending query/api/NewQueryWithCandidateClassAndFilter.java Sending query/api/NewQueryWithCandidateClassCollectionFilter.java Sending query/api/NewQueryWithExtentAndFilter.java Sending query/api/SetFilter.java Sending query/jdoql/MultipleActiveQueryInstanceInSamePersistenceManager.java Sending query/jdoql/MultipleIdenticalImports.java Sending query/jdoql/OrderingSpecification.java Sending query/jdoql/ParenthesesMarkOperatorPrecedence.java Sending query/jdoql/QueryResultPassedToAnotherQuery.java Sending query/jdoql/WhiteSpaceIsACharacterAndIgnored.java Sending query/jdoql/keywords/UseOfThisToAcessHiddenField.java Sending query/jdoql/parameters/ParameterDeclaredWithSameNameAsFieldOfCandidateClass.java Transmitting file data ................... Committed revision 379541.

          People

          • Assignee:
            Craig L Russell
            Reporter:
            Craig L Russell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development