Announcement Announcement Module
Collapse
No announcement yet.
No message found under code for locale 'en_US' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No message found under code for locale 'en_US'

    Hi.

    I've been using Grails and STS since Sept 2012. I recently upgraded to STS 3.2 from 3.0, and now have a problem running integration tests that use messageSource. The integration tests run fine under grails command-line, but consistently fail when trying to run tests from within STS. I've created a sample integration test, in a new Grails project, that demonstrates the problem.

    package sample
    import groovy.util.GroovyTestCase
    import org.junit.*
    import static org.junit.Assert.*
    class LocalizedMessageTests extends GroovyTestCase {
    def messageSource
    @Test
    void testLocalizedMessage() {
    String localizedMessage = messageSource.getMessage('default.optimistic.locki ng.failure', ['RECORD-PK'] as String[], Locale.default)
    assertEquals "Another user has updated this RECORD-PK while you were editing", localizedMessage
    }
    }

    This results in an exception:
    org.springframework.context.NoSuchMessageException : No message found under code 'default.optimistic.locking.failure' for locale 'en_US'.
    at sample.LocalizedMessageTests.testLocalizedMessage( LocalizedMessageTests.groovy:9)

    This all worked until upgrading to STS 3.2. I tried backing off to an earlier release, but still have the same problem, so I am not entirely sure when the problem got injected. I'm currently running grails 2.2.0 that I installed on its own from the grails distribution site.

    I've searched the web, various forums, about creating your own messageSource bean, or adding i18n to the classpath, but not sure those solutions are needed as it had worked before, and still works from grails command-line. I just can't figure out what happened in my STS installation where I now have this inconsistency between Grails command-line and STS.

    Any help or advice would be greatly appreciated. Thanks.

    Brian Bell.

  • #2
    > but consistently fail when trying to run tests from within STS...

    Not sure why this would be happening, but, can you be more specific. There are different ways to run Grails tests from within STS.

    For example you can 'Run As >> Junit Test'.
    Or you can 'Run As >> Grails command (test-app)'.

    So how are you running them?

    If you are using 'Run As >> Junit Test' then it may be the reason why the tests are failing. Generally Grails integration tests don't run the same as they do inside of Grails test-app command. So... in this case please try run as test-app and see if that works any better.

    If you are already using Run as test-app then I'm not sure. Perhaps its a problem with how the GGTS launcher works. If you can provide a sample project to reproduce I could try to debug it and see if its something we can fix.

    Kris

    Comment


    • #3
      I always have run tests using the 'Grails Command History' button on the STS toolbar. This is where it fails.

      However, if I choose the 'Run As Grails Command' option, as you had suggested, that works. So it appears that there is a difference between using the 'Grails Command History' button and 'Run As Grails Command' command.

      To try and duplicate this problem, simply create a new Grails project. Create a sample package under integration tests, and add this test case.

      package sample
      import groovy.util.GroovyTestCase
      import org.junit.*
      import static org.junit.Assert.*
      class LocalizedMessageTests extends GroovyTestCase {
      def messageSource
      @Test
      void testLocalizedMessage() {
      String localizedMessage = messageSource.getMessage('default.optimistic.locki ng.failure', ['RECORD-PK'] as String[], Locale.default)
      assertEquals "Another user has updated this RECORD-PK while you were editing", localizedMessage
      }
      }

      And then enter 'test-app' from the 'Grails Command History' button.

      Regardless of whether you're able to replicate this problem or not, you've been a tremendous help. I'm now able to proceed with my project simply by using the 'Run As Grails Command'. I can't believe it was that easy to get past this problem simply by launching 'test-app' using a different method.

      Thank You.
      Brian.

      Comment

      Working...
      X