0

Executions.getCurrent() returns null in JUnit test

asked 2014-04-14 09:28:37 +0800

Jardo gravatar image Jardo
11 1

Hi I'm writing JUnit tests for classes in some web application and one of the classes calls Executions.getCurrent() which returns null and I end up with a null pointer exception. How can I solve this? Is there a way to create or mock the current execution?

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-04-14 10:10:39 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Can you please give more code for below issue ,If you are not using Server here so it will throw Null Pointer exception because Executions.getCurrent() for a web application you have to test this in Jetty Server then it should work

link publish delete flag offensive edit
0

answered 2014-04-16 09:32:44 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

When you run a JUnit Testcase, you are running it in JUnit runtime, it is not in a application server/zk environment, so you are not able to get a Execution.

link publish delete flag offensive edit
0

answered 2014-04-16 09:46:46 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

When you test the GUI you can better use selenium or otherwise for testing purposes check if your execution isn't null so you know that you are in a test case.
I've done this also when you call execution params, witch are null when you are running testcases.

greetz chill.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-04-14 09:28:37 +0800

Seen: 28 times

Last updated: Apr 16 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More