@Test public void testInit() throws Exception { filter.init(filterConfig); Assert.assertTrue(filter.getTransactionTimeThreshold() == null); PrintStream stdErr = System.err; ByteArrayOutputStream stdErrStream = new ByteArrayOutputStream(); System.setErr(new PrintStream(stdErrStream)); filterConfig.addInitParameter( MonetaPerformanceFilter.PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS, "10crap"); filter.init(filterConfig); Assert.assertTrue(stdErrStream.size() > 0); Assert.assertTrue(stdErrStream.toString().contains("NumberFormatException")); Assert.assertTrue(stdErrStream.toString().contains("10crap")); System.setErr(stdErr); filterConfig.addInitParameter( MonetaPerformanceFilter.PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS, "10"); filter.init(filterConfig); Assert.assertTrue(filter.getTransactionTimeThreshold().equals(10L)); }
public void init(FilterConfig filterConfig) throws ServletException { String transTimeStr = filterConfig.getInitParameter(PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS); if (StringUtils.isNotBlank(transTimeStr)) { try { transactionTimeThreshold = Long.valueOf(transTimeStr); } catch (Exception e) { MonetaException ex = (MonetaException) new MonetaException("Invalid filter parameter - must be numeric", e) .addContextValue("parm name", PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS) .addContextValue("parm value", transTimeStr); this.logger.warn(ExceptionUtils.getFullStackTrace(e)); } } }
MonetaPerformanceFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { String transTimeStr = filterConfig.getInitParameter(PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS); if (StringUtils.isNotBlank(transTimeStr)) { try { transactionTimeThreshold = Long.valueOf(transTimeStr); } catch (Exception e) { MonetaException ex = (MonetaException) new MonetaException("Invalid filter parameter - must be numeric", e) .addContextValue("parm name", PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS) .addContextValue("parm value", transTimeStr); this.logger.warn(ExceptionUtils.getFullStackTrace(e)); } } } }
MonetaPerformanceFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { String transTimeStr = filterConfig.getInitParameter(PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS); if (StringUtils.isNotBlank(transTimeStr)) { try { transactionTimeThreshold = Long.valueOf(transTimeStr); } catch (Exception e) { MonetaException ex = (MonetaException) new MonetaException("Invalid filter parameter - must be numeric", e) .addContextValue("parm name", PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS) .addContextValue("parm value", transTimeStr); this.logger.warn(ExceptionUtils.getFullStackTrace(e)); } } }  }
MonetaPerformanceFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { String transTimeStr = filterConfig.getInitParameter(PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS); if (StringUtils.isNotBlank(transTimeStr)) { try { transactionTimeThreshold = Long.valueOf(transTimeStr); } catch (Exception e) { MonetaException ex = (MonetaException) new MonetaException("Invalid filter parameter - must be numeric", e) .addContextValue("parm name", PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS) .addContextValue("parm value", transTimeStr); this.logger.warn(ExceptionUtils.getFullStackTrace(e)); } } }  void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain); void destroy(); void init(FilterConfig filterConfig); }
MonetaPerformanceFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { String transTimeStr = filterConfig.getInitParameter(PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS); if (StringUtils.isNotBlank(transTimeStr)) { try { transactionTimeThreshold = Long.valueOf(transTimeStr); } catch (Exception e) { MonetaException ex = (MonetaException) new MonetaException("Invalid filter parameter - must be numeric", e) .addContextValue("parm name", PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS) .addContextValue("parm value", transTimeStr); this.logger.warn(ExceptionUtils.getFullStackTrace(e)); } } }  void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain); void destroy(); void init(FilterConfig filterConfig); static final String PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS; }