Darren,
The original hack used to work until the test was modified - someone
added the second user.dir and it must have worked fine for Windows but
it broke the test on Linux again.
It now seems to work fine again under both Windows and Linux with your
new tweak to the hack :)
Thomas
Darren Davison wrote:
>I'm getting a repeatable test failing on several different UNIX/Linux
>machines despite an obvious attempt to make it work on such OS's..
>
>[junit] FAILED
>[junit] null
>[junit] junit.framework.AssertionFailedError
>[junit] at
>org.springframework.beans.factory.config.PropertyResourceConfigurerTests.testPropertyPlaceholderConfigurerWithSystemPropertiesInLocation(PropertyResourceConfigurerTests.java:271)
>[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>[junit] at
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>[junit] at
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
>
>the problem is in the following code;
>
> try {
> ac.refresh();
> fail("Should have thrown BeanDefinitionStoreException");
> }
> catch (BeanInitializationException ex) {
> // expected
> assertTrue(ex.getCause() instanceof FileNotFoundException);
> // slight hack for Linux/Unix systems
> String userDir = System.getProperty("user.dir");
> if (userDir.startsWith("/")) {
> userDir = userDir.substring(1);
> }
> assertTrue(ex.getMessage().indexOf(userDir + "/test/" + userDir) != -1);
> }
>}
>
>in the last assertTrue statement, the exception message still contains a
>userDir that has *not* been stripped of its leading / and so the test
>fails. I'm unsure how this has ever worked on UNIX but clearly the change
>was put in because it failed in the past *without* it.
>
>Since I don't think the test is supposed to verify file system semantics,
>I've changed the assert line to;
>
>assertTrue(
> ex.getMessage().indexOf(userDir + "/test/" + userDir) != -1
> ||
> ex.getMessage().indexOf(userDir + "/test//" + userDir) != -1
>);
>
>which works on my installation - can someone verify this on Windows? If
>it's ok, I'll commit it.
>
>Cheers,
>
>
>
|