Interface ILogScanner


public interface ILogScanner
Provides utility text scanning routines for tests and Managers to use, intended for use with logs or batch jobs etc.
The scanner will remember where the last scan got to, so the next search will continue from that point.
You can obtain an implementation of this interface using the LogScanner annotation. You will need a separate object per log you will be scanning.
  • Method Details

    • setScannable

      ILogScanner setScannable(ITextScannable scannable) throws TextScanException
      Set the scannable that will be used with this scanner and will update
      Parameters:
      scannable - The scannable to be associated with this scanner
      Returns:
      this interface for fluent use
      Throws:
      TextScanException - If a scannable has already been set, updateText called or is null, or the first update fails
    • updateScannable

      ILogScanner updateScannable() throws TextScanException
      Update the scannable.
      Returns:
      this interface for fluent use
      Throws:
      TextScanException
    • reset

      ILogScanner reset()
      Resets this scanner so it can be reused
      Returns:
      this interface for fluent use
    • checkpoint

      ILogScanner checkpoint() throws TextScanException
      Sets the checkpoint to the end of the current log
      Returns:
      this interface for fluent use
      Throws:
      TextScanException
    • setCheckpoint

      ILogScanner setCheckpoint(long checkpoint) throws TextScanException
      Manually set a checkpoint to the supplied value
      Returns:
      this interface for fluent use
      Throws:
      TextScanException
    • resetCheckpoint

      ILogScanner resetCheckpoint()
      Resets the checkpoint back to zero
      Returns:
      this interface for fluent use
    • getCheckpoint

      long getCheckpoint()
      Returns the current position of the checkpoint. A value of -1 means the ITextScannable has not been checkpointed
      Returns:
      the current checkpoint
    • scan

      Search the log for regex patterns. It will search initially search for any occurrence of the failPattern before searching for the searchPattern. The search will find at least "count" number of searchPatterns in the text.
      NOTE: This method will scan from the start of the log, it will not use the checkpoint
      Parameters:
      searchPattern - The regex to search for
      failPattern - Failure regex to search for, can be null meaning no fail search
      count - at least how many occurrences of the searchPattern must exist
      Returns:
      This log scanner for fluent calls
      Throws:
      FailTextFoundException - If the failurePattern was found
      MissingTextException - If no occurrences of the searchPattern was found
      IncorrectOccurrencesException - If insufficient occurrences were found, if there are zero occurrences, then MissingTextException will be thrown
      TextScanException - If any other problem found
    • scan

      Convenience method for scan(Pattern.Compile("\Q" + searchString + "\E"), Pattern.Compile("\Q" + failString + "\E"), count)
      Parameters:
      searchString - The text to search for
      failString - Failure text to search for, can be null meaning no fail search
      count - at least how many occurrences of the searchText must exist
      Returns:
      This log scanner for fluent calls
      Throws:
      FailTextFoundException - If the failText was found
      MissingTextException - If no occurrences of the searchText was found
      IncorrectOccurrencesException - If insufficient occurrences were found, if there are zero occurrences, then MissingTextException will be thrown
      TextScanException - If any other problem found
    • scanSinceCheckpoint

      ILogScanner scanSinceCheckpoint(Pattern searchPattern, Pattern failPattern, int count) throws FailTextFoundException, MissingTextException, IncorrectOccurrencesException, TextScanException
      Search the log for regex patterns, from the last checkpoint. It will search initially search for any occurrence of the failPattern before searching for the searchPattern. The search will find at least "count" number of searchPatterns in the text.
      NOTE: This method will scan from the start of the log, it will not use the checkpoint
      Parameters:
      searchPattern - The regex to search for
      failPattern - Failure regex to search for, can be null meaning no fail search
      count - At least how many occurrences of the searchPattern must exist
      Returns:
      This log scanner for fluent calls
      Throws:
      FailTextFoundException - If the failurePattern was found
      MissingTextException - If no occurrences of the searchPattern was found
      IncorrectOccurrencesException - If insufficient occurrences were found, if there are zero occurrences, then MissingTextException will be thrown
      TextScanException - If any other problem found
    • scanSinceCheckpoint

      ILogScanner scanSinceCheckpoint(String searchString, String failString, int count) throws FailTextFoundException, MissingTextException, IncorrectOccurrencesException, TextScanException
      Convenience method for scanSinceCheckpoint(Pattern.Compile("\Q" + searchString + "\E"), Pattern.Compile("\Q" + failString + "\E"), count)
      Parameters:
      searchString - The text to search for
      failString - Failure text to search for, can be null meaning no fail search
      count - at least how many occurrences of the searchString must exist
      Returns:
      This log scanner for fluent calls
      Throws:
      FailTextFoundException - If the failString was found
      MissingTextException - If no occurrences of the searchString was found
      IncorrectOccurrencesException - If insufficient occurrences were found, if there are zero occurrences, then MissingTextException will be thrown
      TextScanException - If any other problem found
    • scanForMatch

      String scanForMatch(Pattern searchPattern, Pattern failPattern, int occurrance) throws MissingTextException, IncorrectOccurrencesException, TextScanException
      Search the log for regex patterns. It will search initially search for any occurrence of the failPattern before searching for the searchPattern. The search will find at least "count" number of searchPatterns in the text. Useful for returning the actual value of the searchPattern
      Parameters:
      searchPattern - The regex to search for
      failPattern - Failure regex to search for, can be null meaning no fail search
      occurrance - The occurrence to be returned
      Returns:
      The text of the searchPattern found
      Throws:
      MissingTextException - The searchPattern was not found at all
      IncorrectOccurrencesException - If the specified occurrence was not found
      TextScanException - If any other problem found
    • scanForMatch

      String scanForMatch(String searchString, String failString, int occurrance) throws MissingTextException, IncorrectOccurrencesException, TextScanException
      Convenience method for scanForMatch(Pattern.Compile("\Q" + searchString + "\E"), Pattern.Compile("\Q" + searchString + "\E"), occurrence)
      Parameters:
      searchString - The text to search for
      failString - Failure text to search for, can be null meaning no fail search
      occurrance - The occurrence to be returned
      Returns:
      The text of the searchPattern found
      Throws:
      MissingTextException - The searchPattern was not found at all
      IncorrectOccurrencesException - If the specified occurrence was not found
      TextScanException - If any other problem found
    • scanForMatchSinceCheckpoint

      String scanForMatchSinceCheckpoint(Pattern searchPattern, Pattern failPattern, int occurrance) throws MissingTextException, IncorrectOccurrencesException, TextScanException
      Search the log for regex patterns, from the last checkpoint. It will search initially search for any occurrence of the failPattern before searching for the searchPattern. The search will find at least "count" number of searchPatterns in the text. Useful for returning the actual value of the searchPattern
      Parameters:
      searchPattern - The regex to search for
      failPattern - Failure regex to search for, can be null meaning no fail search
      occurrance - The occurrence to be returned
      Returns:
      The text of the searchPattern found
      Throws:
      MissingTextException - The searchPattern was not found at all
      IncorrectOccurrencesException - If the specified occurrence was not found
      TextScanException - If any other problem found
    • scanForMatchSinceCheckpoint

      String scanForMatchSinceCheckpoint(String searchString, String failString, int occurrance) throws MissingTextException, IncorrectOccurrencesException, TextScanException
      Convenience method for scanForMatchSinceCheckpoint(Pattern.Compile("\Q" + searchString + "\E"), Pattern.Compile("\Q" + searchString + "\E"), occurrence)
      Parameters:
      searchString - The text to search for
      failString - Failure text to search for, can be null meaning no fail search
      occurrance - The occurrence to be returned
      Returns:
      The text of the searchPattern found
      Throws:
      MissingTextException - The searchString was not found at all
      IncorrectOccurrencesException - If the specified occurrence was not found
      TextScanException - If any other problem found