Derby
  1. Derby
  2. DERBY-5252

make GrantRevokeTest pass in non-English locale

    Details

      Description

      D:\derby\test>java junit.textui.TestRunner org.apache.derbyTesting.functionTests
      .tests.lang.GrantRevokeTest
      .......................F.F..F.F.........
      Time: 10.563
      There were 4 failures:
      1) testGrantOnNonexistantFunction(org.apache.derbyTesting.functionTests.tests.la
      ng.GrantRevokeTest)junit.framework.ComparisonFailure: null expected:<'S1.NOSUCH'
      [is not recognized as a function.]> but was:<'S1.NOSUCH' [未被识别为函数。]>
      at org.apache.derbyTesting.functionTests.tests.lang.GrantRevokeTest.test
      GrantOnNonexistantFunction(GrantRevokeTest.java:627)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:
      112)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      2) testGrantOnNonexistantFunctionForProcedure(org.apache.derbyTesting.functionTe
      sts.tests.lang.GrantRevokeTest)junit.framework.ComparisonFailure: null expected:
      <'S1.P1' [is not recognized as a function.]> but was:<'S1.P1' [未被识别为函数。]
      >
      at org.apache.derbyTesting.functionTests.tests.lang.GrantRevokeTest.test
      GrantOnNonexistantFunctionForProcedure(GrantRevokeTest.java:636)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:
      112)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      3) testGrantOnNonexistantProcedure(org.apache.derbyTesting.functionTests.tests.l
      ang.GrantRevokeTest)junit.framework.ComparisonFailure: null expected:<'S1.NOSUCH
      ' [is not recognized as a procedure.]> but was:<'S1.NOSUCH' [未被识别为过程。]>
      at org.apache.derbyTesting.functionTests.tests.lang.GrantRevokeTest.test
      GrantOnNonexistantProcedure(GrantRevokeTest.java:653)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:
      112)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      4) testGrantOnNonexistantProcedureForFunction(org.apache.derbyTesting.functionTe
      sts.tests.lang.GrantRevokeTest)junit.framework.ComparisonFailure: null expected:
      <'S1.F2' [is not recognized as a procedure.]> but was:<'S1.F2' [未被识别为过程。
      ]>
      at org.apache.derbyTesting.functionTests.tests.lang.GrantRevokeTest.test
      GrantOnNonexistantProcedureForFunction(GrantRevokeTest.java:662)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:
      112)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57
      )
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      at junit.extensions.TestSetup.run(TestSetup.java:27)

      FAILURES!!!
      Tests run: 36, Failures: 4, Errors: 0

      D:\derby\test>

      1. DERBY-5252-1.patch
        2 kB
        Houx Zhang
      2. DERBY-5252-setlocale-just-testing.patch
        1 kB
        Houx Zhang

        Issue Links

          Activity

          Hide
          Houx Zhang added a comment -

          In DERBY-5252-setlocale-just-testing.patch, LocaleTestSetup is used to give a English Locale. However, it still failed as before.

          I also logged in testGrantOnNonexistantProcedureForFunction(), and shows, it do be English locale in this function, but we still get a Chinese output.

          I think this issue is similiar with DERBY-5217.

          Show
          Houx Zhang added a comment - In DERBY-5252 -setlocale-just-testing.patch, LocaleTestSetup is used to give a English Locale. However, it still failed as before. I also logged in testGrantOnNonexistantProcedureForFunction(), and shows, it do be English locale in this function, but we still get a Chinese output. I think this issue is similiar with DERBY-5217 .
          Hide
          Bryan Pendleton added a comment -

          Since there are only 4 calls to getMessage() in this test, perhaps it would be better to
          leave the test running in the default locale (which can be any locale, not just English),
          and change those 4 calls to getMessage().

          We could either
          (a) remove those 4 calls to getMessage entirely, or
          (b) add some code like:

          if ( Locale.getDefault().getLanguage().equals("en") )
          assertEquals("'S1.NOSUCH' is not recognized as a procedure.", e.getMessage());

          Since the test does a assertSQLState() right before each call to getMessage(), I don't
          think that the getMessage() test is the most important part of the test, and maybe
          a solution such as this would be fine?

          However, I see those 4 getMessage() calls were specifically added in revision 765087 (
          http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java?r1=765086&r2=765087& )
          as part of the fix for DERBY-3610.

          Knut Anders, Dag: do you have any experience running your system in a locale other than English?
          Does the GrantRevokeTest pass for you when run in a non-English locale? What do you think about
          the getMessage() assertions that were added by DERBY-3610? Would it be helpful to guard them
          with some sort of locale-specific check?

          Show
          Bryan Pendleton added a comment - Since there are only 4 calls to getMessage() in this test, perhaps it would be better to leave the test running in the default locale (which can be any locale, not just English), and change those 4 calls to getMessage(). We could either (a) remove those 4 calls to getMessage entirely, or (b) add some code like: if ( Locale.getDefault().getLanguage().equals("en") ) assertEquals("'S1.NOSUCH' is not recognized as a procedure.", e.getMessage()); Since the test does a assertSQLState() right before each call to getMessage(), I don't think that the getMessage() test is the most important part of the test, and maybe a solution such as this would be fine? However, I see those 4 getMessage() calls were specifically added in revision 765087 ( http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java?r1=765086&r2=765087& ) as part of the fix for DERBY-3610 . Knut Anders, Dag: do you have any experience running your system in a locale other than English? Does the GrantRevokeTest pass for you when run in a non-English locale? What do you think about the getMessage() assertions that were added by DERBY-3610 ? Would it be helpful to guard them with some sort of locale-specific check?
          Hide
          Bryan Pendleton added a comment -

          Link to DERBY-3610 because it appears to have added the assertions that are failing in this issue.

          Show
          Bryan Pendleton added a comment - Link to DERBY-3610 because it appears to have added the assertions that are failing in this issue.
          Hide
          Houx Zhang added a comment -

          I also prefer the second method, and added a patch by following this idea. And the test can pass in Chinese Locale now. Please check it, thanks!

          D:\derby\test>java junit.textui.TestRunner org.apache.derbyTesting.functionTests
          .tests.lang.GrantRevokeTest
          ....................................
          Time: 8.094

          OK (36 tests)

          Show
          Houx Zhang added a comment - I also prefer the second method, and added a patch by following this idea. And the test can pass in Chinese Locale now. Please check it, thanks! D:\derby\test>java junit.textui.TestRunner org.apache.derbyTesting.functionTests .tests.lang.GrantRevokeTest .................................... Time: 8.094 OK (36 tests)
          Hide
          Bryan Pendleton added a comment -

          Hello Houx, did you happen to see Dag's comment on the mailing list?
          http://mail-archives.apache.org/mod_mbox/db-derby-dev/201105.mbox/%3Cx6k4d7yl5j.fsf@oracle.com%3E

          Show
          Bryan Pendleton added a comment - Hello Houx, did you happen to see Dag's comment on the mailing list? http://mail-archives.apache.org/mod_mbox/db-derby-dev/201105.mbox/%3Cx6k4d7yl5j.fsf@oracle.com%3E
          Hide
          Bryan Pendleton added a comment -

          I think the proposed patch is a clear improvement to the test, as it
          preserves the existing testing while also allowing the test to be
          run in other locales.

          Committed to the trunk as revision 1134139.

          Thank you, Houx, for the contribution!

          Show
          Bryan Pendleton added a comment - I think the proposed patch is a clear improvement to the test, as it preserves the existing testing while also allowing the test to be run in other locales. Committed to the trunk as revision 1134139. Thank you, Houx, for the contribution!
          Hide
          Myrna van Lunteren added a comment -

          Reopen to document backport to 10.8

          Show
          Myrna van Lunteren added a comment - Reopen to document backport to 10.8
          Hide
          Knut Anders Hatlen added a comment -

          [bulk update: close all resolved issues that haven't had any activity the last year]

          Show
          Knut Anders Hatlen added a comment - [bulk update: close all resolved issues that haven't had any activity the last year]

            People

            • Assignee:
              Houx Zhang
              Reporter:
              Houx Zhang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development