Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyResourceConfigurerTests class throwing exception during build in 4 test methods [SPR-12794] #17391

Closed
spring-issuemaster opened this issue Mar 7, 2015 · 3 comments

Comments

@spring-issuemaster
Copy link
Collaborator

commented Mar 7, 2015

rahul chaudhary opened SPR-12794 and commented

In spring-beans module when test class PropertyResourceConfigurerTests execute during build 4 test cases fails

PropertyResourceConfigurerTests. testPropertyPlaceholderConfigurer
PropertyResourceConfigurerTests. testPropertyPlaceholderConfigurerWithOverridingSystemProperty
PropertyResourceConfigurerTests. testPropertyPlaceholderConfigurerWithParentChildSeparation
PropertyResourceConfigurerTests. testPropertyPlaceholderConfigurerWithSystemPropertyFallback

I am attaching stack trace. these 4 test method test against System operating system and set a property on TestBean touchy as ${os.name} which ultimately flow reaches to BeanWrapperImpl to set the property on bean and in this class at call writeMethod.invoke(this.object, value); throws exception since I am running windows 8.1 hence value comes as Windows 8.1 and this method call throw exception of beancreation saying that value contain a . character

Please help :-)


Attachments:

Referenced from: commits 0920266, 6fe85c2, f2b9a0a

Backported to: 3.2.14

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 8, 2015

rahul chaudhary commented

Hi Juergen,

I found the cause for the problem in your TestBean clas setter for property touchy is something like this
public void setTouchy(String touchy) throws Exception {
if (touchy.indexOf('.') != -1) {
throw new Exception("Can't contain a .");
}
if (touchy.indexOf(',') != -1) {
throw new NumberFormatException("Number format exception: contains a ,");
}
this.touchy = touchy;
}
hence when property os.name return Windows 8.1 it contain the . so exception is thrown .... can you please help me understand why this check was added and if its alright can I add following change in this first if
if (touchy.indexOf('.') != -1 && !touchy.equalsIgnoreCase(System.getProperty("os.name"))) {
throw new Exception("Can't contain a .");
}

this actually solves the problem.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 10, 2015

Juergen Hoeller commented

Thanks for raising this! Indeed, we shouldn't rely on such subtleties in those tests... I've revised them to use a different TestBean property for the os.name checks, i.e. "country" instead of "touchy". That seems to be the easiest way to make those tests less fragile.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 10, 2015

rahul chaudhary commented

Thanks Juergen :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.