Posts

Showing posts with the label jersey-test-framework

Mockito with Jersey Test and JAX-RS - UnsatisfiedDependencyException

Mockito with Jersey Test and JAX-RS - UnsatisfiedDependencyException Trying to test a fairly simple JAX-RS endpoint @ApplicationScoped @Path("mypath") public class MyRestService { @Inject private Logger logger; @Inject private EjbService ejbService; @GET public String myMethod() { logger.info("..."); return ejbService.myMethod(); } } with Mockito and Jersey Test @RunWith(MockitoJUnitRunner.class) public class MyRestServiceTest extends JerseyTest { @Mock private EjbService ejbService; @Mock private Logger logger; @InjectMocks private MyRestService myRestService; ... @Override protected Application configure() { MockitoAnnotations.initMocks(this); return new ResourceConfig().register(myRestService); } } The Grizzly container is returning a org.glassfish.hk2.api.UnsatisfiedDependencyException for Logger and EjbService even thought the dependencies are injected correct...