@Test public void moveIfFeatureEnabled() throws Exception { Mockery context = new Mockery(); final Logger logger = context.mock(Logger.class); final IoFilterChain filterChain = context.mock(IoFilterChain.class, "filterChain"); final IoFilterChain toFilterChain = context.mock(IoFilterChain.class, "toFilterChain"); final WsCheckAliveFilter filter = new WsCheckAliveFilter(STANDARD_INACTIVITY_TIMEOUT_MILLIS, logger); context.checking(new Expectations() { { oneOf(filterChain).remove(FILTER_NAME); will(returnValue(filter)); oneOf(logger).isDebugEnabled(); will(returnValue(true)); oneOf(logger).debug(with(any(String.class))); oneOf(toFilterChain).addLast(FILTER_NAME, filter); } }); WsCheckAliveFilter.moveIfFeatureEnabled(filterChain, toFilterChain, FILTER_NAME, STANDARD_INACTIVITY_TIMEOUT_MILLIS, logger); }
public static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain, String filterName, long inactivityTimeout, Logger logger) { if (inactivityTimeout > 0) { IoFilter filter = fromChain.remove(filterName); if (logger.isDebugEnabled()) { logger.debug(String.format("Moving %s filter %s to child filter chain", filterName, filter)); } toChain.addLast(filterName, filter); } }
WsCheckAliveFilter extends IoFilterAdapter<IoSessionEx> { public static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain, String filterName, long inactivityTimeout, Logger logger) { if (inactivityTimeout > 0) { IoFilter filter = fromChain.remove(filterName); if (logger.isDebugEnabled()) { logger.debug(String.format("Moving %s filter %s to child filter chain", filterName, filter)); } toChain.addLast(filterName, filter); } } }
WsCheckAliveFilter extends IoFilterAdapter<IoSessionEx> { public static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain, String filterName, long inactivityTimeout, Logger logger) { if (inactivityTimeout > 0) { IoFilter filter = fromChain.remove(filterName); if (logger.isDebugEnabled()) { logger.debug(String.format("Moving %s filter %s to child filter chain", filterName, filter)); } toChain.addLast(filterName, filter); } } WsCheckAliveFilter(long inactivityTimeout, Logger logger);   WsCheckAliveFilter(long inactivityTimeout, IoSession wsSession, Logger logger); }
WsCheckAliveFilter extends IoFilterAdapter<IoSessionEx> { public static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain, String filterName, long inactivityTimeout, Logger logger) { if (inactivityTimeout > 0) { IoFilter filter = fromChain.remove(filterName); if (logger.isDebugEnabled()) { logger.debug(String.format("Moving %s filter %s to child filter chain", filterName, filter)); } toChain.addLast(filterName, filter); } } WsCheckAliveFilter(long inactivityTimeout, Logger logger);   WsCheckAliveFilter(long inactivityTimeout, IoSession wsSession, Logger logger); static void validateSystemProperties(Properties configuration, Logger logger); static void addIfFeatureEnabled(IoFilterChain filterChain, String filterName, long inactivityTimeoutIn, Logger logger); static void addIfFeatureEnabled(IoFilterChain filterChain, String filterName, long inactivityTimeoutIn,
                                           IoSessionEx wsSession, Logger logger); static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain,
                                            String filterName, long inactivityTimeout, Logger logger); static void updateExtensions(IoFilterChain filterChain); @Override void onPostAdd(IoFilterChain filterChain, String name, NextFilter nextFilter); @Override void onPreRemove(IoFilterChain filterChain,
                            String name,
                            NextFilter nextFilter); }
WsCheckAliveFilter extends IoFilterAdapter<IoSessionEx> { public static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain, String filterName, long inactivityTimeout, Logger logger) { if (inactivityTimeout > 0) { IoFilter filter = fromChain.remove(filterName); if (logger.isDebugEnabled()) { logger.debug(String.format("Moving %s filter %s to child filter chain", filterName, filter)); } toChain.addLast(filterName, filter); } } WsCheckAliveFilter(long inactivityTimeout, Logger logger);   WsCheckAliveFilter(long inactivityTimeout, IoSession wsSession, Logger logger); static void validateSystemProperties(Properties configuration, Logger logger); static void addIfFeatureEnabled(IoFilterChain filterChain, String filterName, long inactivityTimeoutIn, Logger logger); static void addIfFeatureEnabled(IoFilterChain filterChain, String filterName, long inactivityTimeoutIn,
                                           IoSessionEx wsSession, Logger logger); static void moveIfFeatureEnabled(IoFilterChain fromChain, IoFilterChain toChain,
                                            String filterName, long inactivityTimeout, Logger logger); static void updateExtensions(IoFilterChain filterChain); @Override void onPostAdd(IoFilterChain filterChain, String name, NextFilter nextFilter); @Override void onPreRemove(IoFilterChain filterChain,
                            String name,
                            NextFilter nextFilter); static final long DISABLE_INACTIVITY_TIMEOUT; static final long DEFAULT_WS_INACTIVITY_TIMEOUT_MILLIS; }