• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

null pointer exception while running unit test

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is messageSource defined? I don't see it as an instance variable, parameter or local variable.
reply
    Bookmark Topic Watch Topic
  • New Topic