Package akka.testkit

Class EventFilter$


  • public class EventFilter$
    extends java.lang.Object
    Facilities for selectively filtering out expected events from logging so that you can keep your test run’s console output clean and do not miss real error messages.

    '''Also have a look at the akka.testkit package object’s filterEvents and filterException methods.'''

    The source filters do accept Class[_] arguments, matching any object which is an instance of the given class, e.g.

    
     EventFilter.info(source = classOf[MyActor]) // will match Info events from any MyActor instance
     

    The message object will be converted to a string before matching ("null" if it is null).

    • Field Detail

      • MODULE$

        public static final EventFilter$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • EventFilter$

        public EventFilter$()
    • Method Detail

      • apply

        public <A extends java.lang.Throwable> EventFilter apply​(java.lang.String message,
                                                                 java.lang.String source,
                                                                 java.lang.String start,
                                                                 java.lang.String pattern,
                                                                 int occurrences,
                                                                 scala.reflect.ClassTag<A> evidence$1)
        Create a filter for Error events. Give up to one of start and pattern:

        
         EventFilter[MyException]()                                         // filter only on exception type
         EventFilter[MyException]("message")                                // filter on exactly matching message
         EventFilter[MyException](source = obj)                             // filter on event source
         EventFilter[MyException](start = "Expected")                       // filter on start of message
         EventFilter[MyException](source = obj, pattern = "weird.*message") // filter on pattern and message
         

        ''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

        Parameters:
        message - (undocumented)
        source - (undocumented)
        start - (undocumented)
        pattern - (undocumented)
        occurrences - (undocumented)
        evidence$1 - (undocumented)
        Returns:
        (undocumented)
      • apply$default$1

        public <A extends java.lang.Throwable> java.lang.String apply$default$1()
      • apply$default$2

        public <A extends java.lang.Throwable> java.lang.String apply$default$2()
      • apply$default$3

        public <A extends java.lang.Throwable> java.lang.String apply$default$3()
      • apply$default$4

        public <A extends java.lang.Throwable> java.lang.String apply$default$4()
      • apply$default$5

        public <A extends java.lang.Throwable> int apply$default$5()
      • error

        public EventFilter error​(java.lang.String message,
                                 java.lang.String source,
                                 java.lang.String start,
                                 java.lang.String pattern,
                                 int occurrences)
        Create a filter for Error events. See apply() for more details.
        Parameters:
        message - (undocumented)
        source - (undocumented)
        start - (undocumented)
        pattern - (undocumented)
        occurrences - (undocumented)
        Returns:
        (undocumented)
      • error$default$1

        public java.lang.String error$default$1()
      • error$default$2

        public java.lang.String error$default$2()
      • error$default$3

        public java.lang.String error$default$3()
      • error$default$4

        public java.lang.String error$default$4()
      • error$default$5

        public int error$default$5()
      • warning

        public EventFilter warning​(java.lang.String message,
                                   java.lang.String source,
                                   java.lang.String start,
                                   java.lang.String pattern,
                                   int occurrences)
        Create a filter for Warning events. Give up to one of start and pattern:

        
         EventFilter.warning()                                         // filter only on warning event
         EventFilter.warning(source = obj)                             // filter on event source
         EventFilter.warning(start = "Expected")                       // filter on start of message
         EventFilter.warning(source = obj, pattern = "weird.*message") // filter on pattern and message
         

        ''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

        Parameters:
        message - (undocumented)
        source - (undocumented)
        start - (undocumented)
        pattern - (undocumented)
        occurrences - (undocumented)
        Returns:
        (undocumented)
      • warning$default$1

        public java.lang.String warning$default$1()
      • warning$default$2

        public java.lang.String warning$default$2()
      • warning$default$3

        public java.lang.String warning$default$3()
      • warning$default$4

        public java.lang.String warning$default$4()
      • warning$default$5

        public int warning$default$5()
      • info

        public EventFilter info​(java.lang.String message,
                                java.lang.String source,
                                java.lang.String start,
                                java.lang.String pattern,
                                int occurrences)
        Create a filter for Info events. Give up to one of start and pattern:

        
         EventFilter.info()                                         // filter only on info event
         EventFilter.info(source = obj)                             // filter on event source
         EventFilter.info(start = "Expected")                       // filter on start of message
         EventFilter.info(source = obj, pattern = "weird.*message") // filter on pattern and message
         

        ''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

        Parameters:
        message - (undocumented)
        source - (undocumented)
        start - (undocumented)
        pattern - (undocumented)
        occurrences - (undocumented)
        Returns:
        (undocumented)
      • info$default$1

        public java.lang.String info$default$1()
      • info$default$2

        public java.lang.String info$default$2()
      • info$default$3

        public java.lang.String info$default$3()
      • info$default$4

        public java.lang.String info$default$4()
      • info$default$5

        public int info$default$5()
      • debug

        public EventFilter debug​(java.lang.String message,
                                 java.lang.String source,
                                 java.lang.String start,
                                 java.lang.String pattern,
                                 int occurrences)
        Create a filter for Debug events. Give up to one of start and pattern:

        
         EventFilter.debug()                                         // filter only on debug type
         EventFilter.debug(source = obj)                             // filter on event source
         EventFilter.debug(start = "Expected")                       // filter on start of message
         EventFilter.debug(source = obj, pattern = "weird.*message") // filter on pattern and message
         

        ''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

        Parameters:
        message - (undocumented)
        source - (undocumented)
        start - (undocumented)
        pattern - (undocumented)
        occurrences - (undocumented)
        Returns:
        (undocumented)
      • debug$default$1

        public java.lang.String debug$default$1()
      • debug$default$2

        public java.lang.String debug$default$2()
      • debug$default$3

        public java.lang.String debug$default$3()
      • debug$default$4

        public java.lang.String debug$default$4()
      • debug$default$5

        public int debug$default$5()
      • custom

        public EventFilter custom​(scala.PartialFunction<Logging.LogEvent,​java.lang.Object> test,
                                  int occurrences)
        Create a custom event filter. The filter will affect those events for which the supplied partial function is defined and returns true.

        
         EventFilter.custom {
           case Warning(ref, "my warning") if ref == actor || ref == null => true
         }
         
        Parameters:
        test - (undocumented)
        occurrences - (undocumented)
        Returns:
        (undocumented)
      • custom$default$2

        public int custom$default$2()