use of act.session.SessionManager in project actframework by actframework.
the class ActTestBase method setup.
protected void setup() throws Exception {
initActMetricPlugin();
mockApp = mock(App.class);
Field f = App.class.getDeclaredField("INST");
f.setAccessible(true);
f.set(null, mockApp);
mockSingletonRegistry = mock(SingletonRegistry.class);
// when(mockApp.singletonRegistry()).thenReturn(mockSingletonRegistry);
mockJobManager = mock(JobManager.class);
when(mockApp.jobManager()).thenReturn(mockJobManager);
mockEventBus = mock(EventBus.class);
when(mockApp.eventBus()).thenReturn(mockEventBus);
mockAppConfig = mock(AppConfig.class);
when(mockAppConfig.possibleControllerClass(argThat(new StartsWith("testapp.controller.")))).thenReturn(true);
mockActionContext = mock(ActionContext.class);
when(mockActionContext.app()).thenReturn(mockApp);
when(mockActionContext.config()).thenReturn(mockAppConfig);
mockRouter = mock(Router.class);
when(mockApp.config()).thenReturn(mockAppConfig);
when(mockApp.router()).thenReturn(mockRouter);
when(mockApp.router(Matchers.same(""))).thenReturn(mockRouter);
when(mockApp.getInstance(any(Class.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
Class<?> cls = (Class) args[0];
if (SessionManager.class == cls) {
return new SessionManager(mockAppConfig);
}
return $.newInstance((Class) args[0]);
}
});
mockReq = mock(H.Request.class);
mockResp = mock(ActResponse.class);
when(mockReq.method()).thenReturn(H.Method.GET);
}
use of act.session.SessionManager in project actframework by actframework.
the class App method initSessionManager.
private void initSessionManager() {
sessionManager = new SessionManager(config);
singletonRegistry.register(SessionManager.class, sessionManager);
}
Aggregations