/* * (non-Javadoc) * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); ApplicationSetupBean appSetup = new ApplicationSetupBean(); appSetup.setName("test"); appSetup.setRootControlName("root"); appSetup.setRootControlClassName(Page.class.getName()); JWicRuntime rt = TestJWicRuntimeProvider.getJWicRuntime(); sc = rt.createSessionContext(appSetup, new Locale("en", "EN"), TimeZone.getDefault(), null); control = createControl((Page) sc.getTopControl()); ac = sc.getActionController(); }
/* (non-Javadoc) * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) */ @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!Trace.isEnabled()) { chain.doFilter(req, res); } else { ITraceContext traceCtx = Trace.startTrace(); try { traceCtx.setAttribute(ATTR_REMOTE_ADDR, req.getRemoteAddr()); if (req instanceof HttpServletRequest) { HttpServletRequest hReq = (HttpServletRequest) req; traceCtx.setAttribute(ATTR_QUERY_STRING, hReq.getQueryString()); traceCtx.setAttribute(ATTR_METHOD, hReq.getMethod()); traceCtx.setAttribute(ATTR_REQUEST_URI, hReq.getRequestURI()); traceCtx.setAttribute(ATTR_REMOTE_USER, hReq.getRemoteUser()); String s = hReq.getParameter("__action"); if (s != null) { traceCtx.setAttribute(ATTR_JWIC_ACTION, s); } s = hReq.getParameter("__ctrlid"); if (s != null) { traceCtx.setAttribute(ATTR_JWIC_CONTROL, s); } } chain.doFilter(req, res); if (req instanceof HttpServletRequest) { HttpServletRequest hReq = (HttpServletRequest) req; String s = hReq.getParameter("_msid"); if (s != null) { // JWic Session ID -> See if its a XWic App and store info. SessionContext ctx = JWicRuntime.getJWicRuntime().getSessionContext(hReq.getSession().getId(), s, hReq); if (ctx != null) { if (ctx.getApplication() instanceof ExtendedApplication) { ExtendedApplication eApp = (ExtendedApplication) ctx.getApplication(); Site site = eApp.getSite(); if (site != null) { traceCtx.setAttribute(ATTR_SITE_MODULE, site.getActiveModuleKey()); traceCtx.setAttribute(ATTR_SITE_SUBMODULE, site.getActiveSubModuleKey()); BreadCrumbControl bcc = (BreadCrumbControl) site.getControl("breadCrumb"); if (bcc != null) { StringBuilder path = new StringBuilder(); for (String key : bcc.getBreadCrumbs()) { if (path.length() != 0) { path.append(" >> "); } path.append(bcc.getCrumbTitle(key)); } traceCtx.setAttribute(ATTR_USER_PATH, path.toString()); } } } } } } } finally { // log trace information? Trace.endTrace(); Trace.getDataManager().handleTraceResult(traceCtx); } } }
/* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); sc.destroy(); // destroy the session. }