Spring Framework
  1. Spring Framework
  2. SPR-8245

System environment related tests fail on Windows

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1 M1
    • Fix Version/s: 3.1 M2
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      See also http://blog.springsource.com/2009/03/03/building-spring-3/#comment-192070

          [junit] Testcase: getSystemEnvironment_withAndWithoutSecurityManager(org.spr
      ingframework.core.env.EnvironmentTests):        FAILED
          [junit]
          [junit] Expected: "42"
          [junit]      got: null
          [junit]
          [junit] junit.framework.AssertionFailedError:
          [junit] Expected: "42"
          [junit]      got: null
          [junit]
          [junit] Expected: "42"
          [junit]      got: null
          [junit]
          [junit]     at org.springframework.core.env.EnvironmentTests.getSystemEnviro
      nment_withAndWithoutSecurityManager(EnvironmentTests.java:263)
      
      from the JUnit XML report:
      
      
        <testcase classname="org.springframework.core.env.EnvironmentTests" name="getSystemProperties_withAndWithoutSecurityManager" time="0.022" />
        <testcase classname="org.springframework.core.env.EnvironmentTests" name="getSystemEnvironment_withAndWithoutSecurityManager" time="0.01">
          <failure message="
      Expected: &quot;42&quot;
           got: null
      " type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: 
      Expected: &quot;42&quot;
           got: null
      
      Expected: &quot;42&quot;
           got: null
      
      	at org.springframework.core.env.EnvironmentTests.getSystemEnvironment_withAndWithoutSecurityManager(EnvironmentTests.java:263)
      </failure>
      
      1. SPR-8245_EnvironmentTests.java.patch
        2 kB
        Stevo Slavić
      2. SPR-8245.patch
        5 kB
        Stevo Slavić

        Activity

        Hide
        Stevo Slavić added a comment -

        Here's a patch SPR-8245_EnvironmentTests.java.patch that works for me on Windows 7 x64. It's not tested if it works on Mac/Linux.

        Show
        Stevo Slavić added a comment - Here's a patch SPR-8245_EnvironmentTests.java.patch that works for me on Windows 7 x64. It's not tested if it works on Mac/Linux.
        Hide
        Stevo Slavić added a comment -

        For the same reason PropertyPlaceholderConfigurerTests.nullValueIsPreserved test fails.

        Show
        Stevo Slavić added a comment - For the same reason PropertyPlaceholderConfigurerTests.nullValueIsPreserved test fails.
        Hide
        Chris Beams added a comment -

        Stevo, thanks for the contribution. I've folded your patch in with the code that was already present, such that it hopefully satisfies all platforms - os x / linux / windows. My machine (OS X) is fine. The CI build will tell us about Linux. Perhaps you can next snapshot a try and reopen this issue if problems persist on Windows.

        Thanks,

        Chris

        Show
        Chris Beams added a comment - Stevo, thanks for the contribution. I've folded your patch in with the code that was already present, such that it hopefully satisfies all platforms - os x / linux / windows. My machine (OS X) is fine. The CI build will tell us about Linux. Perhaps you can next snapshot a try and reopen this issue if problems persist on Windows. Thanks, Chris
        Hide
        Stevo Slavić added a comment -

        Chris,

        Unfortunatelly it doesn't work, OS X and Linux part gets used on Windows since on Windows

        Object obj = field.get(env);
        

        returns not null obj which is instance of java.lang.ProcessEnvironment, and putting into it, seems to silently fail.

        I'm not sure what field.get(env) returns on Linux. If it's not java.lang.ProcessEnvironment then adding to OS X / Linux part something like:

        Object obj = field.get(env);
        if (obj != null && !obj.getClass().getName().equals("java.lang.ProcessEnvironment")) {
        	return (Map<String, String>) obj;
        }
        

        would do the trick.

        Btw, same issue in PropertyPlaceholderConfigurerTests hasn't been touched. Maybe this test support for obtaining modifiable environment could be factored out into a utility class to make it reusable and maintainable.

        Show
        Stevo Slavić added a comment - Chris, Unfortunatelly it doesn't work, OS X and Linux part gets used on Windows since on Windows Object obj = field.get(env); returns not null obj which is instance of java.lang.ProcessEnvironment, and putting into it, seems to silently fail. I'm not sure what field.get(env) returns on Linux. If it's not java.lang.ProcessEnvironment then adding to OS X / Linux part something like: Object obj = field.get(env); if (obj != null && !obj.getClass().getName().equals("java.lang.ProcessEnvironment")) { return (Map<String, String>) obj; } would do the trick. Btw, same issue in PropertyPlaceholderConfigurerTests hasn't been touched. Maybe this test support for obtaining modifiable environment could be factored out into a utility class to make it reusable and maintainable.
        Hide
        Chris Beams added a comment -

        I'm afraid this has become a losing battle. I've @Ignored these tests, at least for the moment. Stevo, would you please verify that you get a successful build now?

        Whether or not we have perfect coverage, I do want to make sure that the source builds under Windows for the upcoming 3.1 M2 release!

        Thanks.

        Show
        Chris Beams added a comment - I'm afraid this has become a losing battle. I've @Ignored these tests, at least for the moment. Stevo, would you please verify that you get a successful build now? Whether or not we have perfect coverage, I do want to make sure that the source builds under Windows for the upcoming 3.1 M2 release! Thanks.
        Hide
        Stevo Slavić added a comment -

        Yes, Ignored tests get skipped.

        Here is SPR-8245.patch which fixes both EnvironmentTests and PropertyPlaceholderConfigurerTests to work on Linux and Windows. Maybe someone could check if patch works for OS X as well.

        Only remaining failing tests on Windows are JibxMarshallerTests, I've reported that under separate issue SPR-8360

        Show
        Stevo Slavić added a comment - Yes, Ignored tests get skipped. Here is SPR-8245.patch which fixes both EnvironmentTests and PropertyPlaceholderConfigurerTests to work on Linux and Windows. Maybe someone could check if patch works for OS X as well. Only remaining failing tests on Windows are JibxMarshallerTests, I've reported that under separate issue SPR-8360
        Hide
        Chris Beams added a comment -

        Thanks, Stevo! Looks like this may finally have done the trick across platforms. I've committed the patch and asked Juergen to take a look at SPR-8360.

        Show
        Chris Beams added a comment - Thanks, Stevo! Looks like this may finally have done the trick across platforms. I've committed the patch and asked Juergen to take a look at SPR-8360 .

          People

          • Assignee:
            Chris Beams
            Reporter:
            Costin Leau
            Last updater:
            Trevor Marshall
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 46 weeks, 5 days ago