-
Notifications
You must be signed in to change notification settings - Fork 12
Troubleshooting
Qaiser Abbasi edited this page Jan 17, 2015
·
5 revisions
This section contains reappearing problems altogether with a solution for it.
Due to the nature of usual Java EE applications you might have some bean configurations e.g. @Remote view bean, which are normally only provided by a Java EE application server. This cause a 'UnsatisfiedResolutionException' during the execution of the CDI Beantests.
Note: Import statements are intentionally missing.
Example
@Remote
@Stateless
public interface RandomService {}
@Stateless
public class BusinessService {
@Ejb RandomService service;
}
Simply provide a mock instance via a CDI producer method/field. The mock instance can either provided with the help of a mocking framework such as Mockito or you create a custom mock.
Example
public class MockProvider {
private static RandomService serviceMock = Mockito.mock(RandomService.class);
@Produces
public static RandomService getServiceMock() {
return serviceMock;
}
}