@Test public void shouldAddLoggingFilterWhenUserIdIsScopedIpv6Address() throws Exception { final IoConnectorEx connector = context.mock(IoConnectorEx .class, "connector"); final IoFilterChain filterChain = context.mock(IoFilterChain.class, "filterChain"); final InetSocketAddress address = new InetSocketAddress(Inet6Address.getByAddress( null, new byte[]{(byte) 0xfe, (byte) 0x80, 0, 0, 0, 0, 0, 0, (byte) 0x90, (byte) 0xea, 0x3e, (byte) 0xe4, 0x77, (byte) 0xad, 0x77, (byte) 0xec}, 15), 2121); context.checking(new Expectations() { { oneOf(logger).isInfoEnabled(); will(returnValue(true)); oneOf(logger).isTraceEnabled(); will(returnValue(false)); oneOf(sessionEx).getService(); will(returnValue(connector)); oneOf(sessionEx).getLocalAddress(); will(returnValue(address)); oneOf(sessionEx).getRemoteAddress(); will(returnValue(address)); oneOf(sessionEx).getFilterChain(); will(returnValue(filterChain)); oneOf(filterChain).addLast(with("tcp#logging"), with(any(ExceptionLoggingFilter.class))); } }); LoggingFilter.addIfNeeded(logger, sessionEx, "tcp"); }
public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } LoggingFilter(Logger logger);  LoggingFilter(Logger logger, IoSession session, String transportName);  LoggingFilter(Logger logger, String sessionIdFormat); }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } LoggingFilter(Logger logger);  LoggingFilter(Logger logger, IoSession session, String transportName);  LoggingFilter(Logger logger, String sessionIdFormat); static boolean addIfNeeded(Logger logger, IoSession session, String transportName); LogLevel getLevel(); Logger getLogger(); String getFormat(); @Override void sessionCreated(NextFilter nextFilter,
                               IoSession session); @Override void sessionOpened(NextFilter nextFilter,
                              IoSession session); @Override void messageReceived(NextFilter nextFilter,
                                IoSession session,
                                Object message); @Override void messageSent(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); @Override void sessionIdle(NextFilter nextFilter,
                            IoSession session,
                            IdleStatus status); @Override void exceptionCaught(NextFilter nextFilter,
                                IoSession session,
                                Throwable cause); @Override void sessionClosed(NextFilter nextFilter,
                              IoSession session); @Override void filterWrite(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); static void moveAfterCodec(IoSession session); }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } LoggingFilter(Logger logger);  LoggingFilter(Logger logger, IoSession session, String transportName);  LoggingFilter(Logger logger, String sessionIdFormat); static boolean addIfNeeded(Logger logger, IoSession session, String transportName); LogLevel getLevel(); Logger getLogger(); String getFormat(); @Override void sessionCreated(NextFilter nextFilter,
                               IoSession session); @Override void sessionOpened(NextFilter nextFilter,
                              IoSession session); @Override void messageReceived(NextFilter nextFilter,
                                IoSession session,
                                Object message); @Override void messageSent(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); @Override void sessionIdle(NextFilter nextFilter,
                            IoSession session,
                            IdleStatus status); @Override void exceptionCaught(NextFilter nextFilter,
                                IoSession session,
                                Throwable cause); @Override void sessionClosed(NextFilter nextFilter,
                              IoSession session); @Override void filterWrite(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); static void moveAfterCodec(IoSession session);  }