@Inject annotation for interface property getting null value in junit

451 Views Asked by At

I am using @Inject annotation for injecting interface(IFMJobHandler is an interface) in my class like this

@Inject
@Reference
IFMJobHandler jobHandler;

While running application with JUnit test, jobHandler property returning null value because of spring annotations for that interface.

Kindly let me know to solve this issue

1

There are 1 best solutions below

0
mark_o On

Most likely the problem is that you are trying to run a simple unit test. But in such case there's no Spring Context and nothing is injected. See this link about how to run Spring test - testing