public static void ensureApplication(long langId) {
if (!Application.exists()) {
Application a = (Application)Application.get(Application.getAppName());
ThreadContext.setApplication(a);
ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest(a, new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get());
ThreadContext.setRequestCycle(new RequestCycle(rctx));
WebSession s = WebSession.get();
s.setLanguage(langId);