|
From: Darren D. <da...@da...> - 2004-11-17 16:44:14
|
I'm getting a repeatable test failing on several different UNIX/Linux=20
machines despite an obvious attempt to make it work on such OS's..
[junit] FAILED
[junit] null
[junit] junit.framework.AssertionFailedError
[junit] at=20
org.springframework.beans.factory.config.PropertyResourceConfigurerTests.te=
stPropertyPlaceholderConfigurerWithSystemPropertiesInLocation(PropertyResou=
rceConfigurerTests.java:271)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at=20
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3=
9)
[junit] at=20
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp=
l.java:25)
the problem is in the following code;=20
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 =3D System.getProperty("user.dir");
if (userDir.startsWith("/")) {
userDir =3D userDir.substring(1);
}
assertTrue(ex.getMessage().indexOf(userDir + "/test/" + userDir) !=3D -=
1);
}
}
in the last assertTrue statement, the exception message still contains a=20
userDir that has *not* been stripped of its leading / and so the test=20
fails. I'm unsure how this has ever worked on UNIX but clearly the change=
=20
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,=20
I've changed the assert line to;
assertTrue(
ex.getMessage().indexOf(userDir + "/test/" + userDir) !=3D -1
||
ex.getMessage().indexOf(userDir + "/test//" + userDir) !=3D -1
);
which works on my installation - can someone verify this on Windows? If=20
it's ok, I'll commit it.
Cheers,
=2D-=20
Darren Davison
Public Key: #DD356B0D
|