Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about MultipartFile with Junit

 
karas huang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about my pool english, i'm come from taiwan,
I can use google translate to express my problem, I hope seniors understanding.
JAVA has just entered less than six months,
I recently encountered this problem ... no clue
Architecture is Spring + hibernate

The main problem is actually very short,
I used several methods are unable to successfully simulate a file allows itself controller to eat,
Cause is a program that has been unable to pass the test, relative to the coverage itself has been unable to meet the requirements.

controller


Use of the following two results,
PropertyUtils.getProperty went here are signs (green background),
But continued to go down to determine the file size, not passed.

Junit part1.


Junit part2.


Thanks for watch, i really need your help with this....
 
E Armitage
Rancher
Posts: 989
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is easy to read the code and test it if you collect conditions into meaningful methods.
So replace
with

Now you have two conditions to test instead of four conditions. You can then write and test the notEmpty method separately which will be easy to do.

Also, don't use in unit tests. Load the file from the classpath using
 
karas huang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you so much,
i used your way,
then i fix the fileinput problem,
at the last,
i have other problem with MockMultipartHttpServletRequest,
but i still fix that.

Thanks you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic