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-projects-issues opened this issue Mar 7, 2015 · 3 comments
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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-projects-issues
Copy link
Collaborator Author

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-projects-issues
Copy link
Collaborator Author

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-projects-issues
Copy link
Collaborator Author

rahul chaudhary commented

Thanks Juergen :-)

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.6 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants