Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

null pointer exception while running unit test  RSS feed

 
irshad irshadoz
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

i am running my unit test but for some reason i am getting a null pointer on this line

[code=java

mav.addObject(
"failLog",
messageSource.getMessage("login.user.fail", new String[] {
"a", "b" }, request.getLocale()));
][/code]

Please find below the method that my unit test will be based on:



Please find below my unit test:



Please see stack trace below:



line 100 for my loginController is shown below:


I am assuming that i need to mock message source. If this is the cause of my exception, how can i mock the messagesource in my unit test please?

However when i run my application it works fine no null pointer, its only when i run the unit test that i get the null pointer exception.

Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36441
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is messageSource defined? I don't see it as an instance variable, parameter or local variable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!