irshad irshadoz

Greenhorn
+ Follow
since Jan 16, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by irshad irshadoz

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.
12 years ago
thanks a lot for the clear explanation problem resolved
12 years ago
Hello Jeanne,

thanks a lot for your quick response..my apologies the example i gave above it was mainly to describe the scenario of my issue as i thought it was the return type issue. Please see the method which i want to carry out unit test for below:





My issue is that i don't know how to mock the boolean variable isUserValid? The variable isUserValid returns a boolean whereas my method validateViewLogin above returns a type ModelAndView. Basically i was trying to mock the isUserValid to return true so as to test the flow when the user is valid.

I was planning a unit test as shown below:



My assert will be if user validation is successful page login will be displayed

When i run my unit test i get this error message:


I know i am getting this error because
returns a boolean and my method expecting ModelAndView.How can i solve this to be able to carry out my unit test .




Any advice please?

This is my controller to validate a user when submitting a form with username, password and i am using spring framework.

thanks in advance
12 years ago
Hello all,

i am new to unit testing, and i am using mockito for my unit test. My question is i am writing unit test for methodB as it can be shown below but it is dependent on a variable from methodA in order to complete the test. how can i mock valueMethodA in methodB?





i can mock the return value when the return type are the same but this case they are different, methodA returns an int type whereas methodB returns boolean. how to mock valueMethodA?

Any advice is most welcome.

Thnks in advacnce
12 years ago
my apologies its working fine i got the url wrong
12 years ago
Hello,

i am new to spring and i have created an application using SpringMvc 3.0 famework. My issue is that when i run my application in eclipse juno on Tomcat 7 i get the page not found error message.

I am assuming that my mapping is not done correctly.

Please see below my config:

Web.xml (path:market\src\main\webapp\WEB-INF\Web.xml) :



My file presentation.xml(path:market\src\main\resources\spring\presentation.xml)


this is my controller:



My login.jsp is found in the following folder :

market\src\main\webapp\WEB-INF\views\

Any ideas why i get the page not found error?

i should get the page login.jsp instead

thanks in advance.
12 years ago