use of org.wso2.carbon.identity.event.services.IdentityEventServiceImpl in project carbon-identity-framework by wso2.
the class IdentityEventServiceComponent method activate.
@Activate
protected void activate(ComponentContext context) {
try {
IdentityEventServiceDataHolder.getInstance().setEventMgtService(new IdentityEventServiceImpl(eventHandlerList, Integer.parseInt(IdentityEventConfigBuilder.getInstance().getThreadPoolSize())));
context.getBundleContext().registerService(IdentityEventService.class.getName(), IdentityEventServiceDataHolder.getInstance().getEventMgtService(), null);
} catch (IdentityEventException e) {
log.error("Error while initiating IdentityMgtService.");
}
if (log.isDebugEnabled()) {
log.debug("Identity Management Listener is enabled");
}
}
use of org.wso2.carbon.identity.event.services.IdentityEventServiceImpl in project carbon-identity-framework by wso2.
the class FrameworkUtilsTest method testGetSessionContextFromCacheExpiredSession.
@Test
public void testGetSessionContextFromCacheExpiredSession() throws FrameworkException {
cacheEntry.setContext(context);
setMockedSessionContextCache();
when(mockedSessionContextCache.getValueFromCache(cacheKey)).thenReturn(cacheEntry);
when(mockedSessionContextCache.isSessionExpired(any(SessionContextCacheKey.class), any(SessionContextCacheEntry.class))).thenReturn(true);
IdentityEventService identityEventService = new IdentityEventServiceImpl(Collections.EMPTY_LIST, 1);
FrameworkServiceDataHolder.getInstance().setIdentityEventService(identityEventService);
AuthenticationContext authenticationContext = new AuthenticationContext();
SessionContext sessionContext = FrameworkUtils.getSessionContextFromCache(request, authenticationContext, DUMMY_CACHE_KEY);
assertNull(sessionContext);
}
use of org.wso2.carbon.identity.event.services.IdentityEventServiceImpl in project carbon-identity-framework by wso2.
the class IdentityEventServiceImplTest method testHandleEvent.
@Test
public void testHandleEvent() throws IdentityEventException {
Event event = new Event("eventName");
event.addEventProperty("value", "value");
abstractEventHandler = mock(AbstractEventHandler.class);
doReturn(true).when(abstractEventHandler).canHandle(any(MessageContext.class));
doReturn(true).when(abstractEventHandler).isAssociationAsync(anyString());
List list = new ArrayList();
list.add(abstractEventHandler);
IdentityEventServiceComponent.eventHandlerList = list;
List abstractEventHandlerList = new ArrayList();
abstractEventHandlerList.add(abstractEventHandler);
IdentityEventService identityEventService = new IdentityEventServiceImpl(abstractEventHandlerList, 1);
identityEventService.handleEvent(event);
Mockito.verify(abstractEventHandler).canHandle(any(MessageContext.class));
}
Aggregations