Class LarvaTool

java.lang.Object
org.frankframework.larva.LarvaTool

public class LarvaTool extends Object
Author:
Jaco de Groot
  • Field Details

    • RESULT_ERROR

      public static final int RESULT_ERROR
      See Also:
    • RESULT_OK

      public static final int RESULT_OK
      See Also:
    • RESULT_AUTOSAVED

      public static final int RESULT_AUTOSAVED
      See Also:
    • globalTimeoutMillis

      protected static int globalTimeoutMillis
  • Constructor Details

  • Method Details

    • createInstance

      public static LarvaTool createInstance(org.springframework.context.ApplicationContext applicationContext, OutputStream out)
    • createInstance

      public static LarvaTool createInstance(org.springframework.context.ApplicationContext ibisContext, Writer out)
    • createInstance

      public static LarvaTool createInstance(jakarta.servlet.ServletContext servletContext, jakarta.servlet.http.HttpServletRequest request, Writer out)
    • setTimeout

      public static void setTimeout(int newTimeout)
    • runScenarios

      public static TestRunStatus runScenarios(jakarta.servlet.ServletContext application, jakarta.servlet.http.HttpServletRequest request, Writer out)
    • runScenarios

      public static TestRunStatus runScenarios(org.springframework.context.ApplicationContext applicationContext, LarvaConfig config, LarvaWriter out, TestExecutionObserver testExecutionObserver, String execute)
    • runScenarios

      public TestRunStatus runScenarios(String execute)
      Returns:
      negative: error condition 0: all scenarios passed positive: number of scenarios that failed
    • createScenarioRunner

      public ScenarioRunner createScenarioRunner()
    • debugMessage

      public void debugMessage(String message)
    • errorMessage

      public void errorMessage(String message)
    • warningMessage

      public void warningMessage(String message)
    • errorMessage

      public void errorMessage(String message, Exception exception)
    • windiff

      public void windiff(String expectedFileName, String result, String expected) throws IOException, SenderException
      Throws:
      IOException
      SenderException
    • writeFile

      public static void writeFile(String fileName, String content) throws IOException
      Throws:
      IOException
    • messageToString

      @Nullable public String messageToString(Message message)
      Read the message into a string. If the message had no data, return an empty string. If there was an error reading the message, return null and show an error message in the Larva output. If the message was read as part of a step, the caller should return RESULT_ERROR.
      Parameters:
      message - Message to read
      Returns:
      Message data, or "" if the message was empty. Returns NULL if there was an error reading the message.
    • compareResult

      public int compareResult(Scenario scenario, String step, String stepDisplayName, String fileName, String stepSaveFileName, Message expectedResultMessage, Message actualResultMessage, Properties properties)
    • prepareResultForCompare

      public String prepareResultForCompare(String input, Properties properties, Map<String,Map<String,Map<String,String>>> ignoreMap)
    • doActionBetweenKeys

      public String doActionBetweenKeys(String key, String value, Properties properties, Map<String,Map<String,Map<String,String>>> ignoreMap, LarvaTool.BetweenKeysAction action)
    • doActionWithSingleKey

      public String doActionWithSingleKey(String keyName, String value, Properties properties, Map<String,Map<String,Map<String,String>>> ignoreMap, LarvaTool.SingleKeyAction action)
    • ignoreContentBetweenKeys

      public static String ignoreContentBetweenKeys(String string, String key1, String key2)
    • ignoreKeysAndContentBetweenKeys

      public static String ignoreKeysAndContentBetweenKeys(String string, String key1, String key2)
    • removeKeysAndContentBetweenKeys

      public static String removeKeysAndContentBetweenKeys(String string, String key1, String key2)
    • ignoreKey

      public static String ignoreKey(String string, String key)
    • removeKey

      public static String removeKey(String string, String key)
    • replaceKey

      public static String replaceKey(String string, String from, String to)
    • decodeUnzipContentBetweenKeys

      public String decodeUnzipContentBetweenKeys(String string, String key1, String key2, boolean replaceNewlines)
    • canonicaliseFilePathContentBetweenKeys

      public String canonicaliseFilePathContentBetweenKeys(String string, String key1, String key2)
    • ignoreCurrentTimeBetweenKeys

      public String ignoreCurrentTimeBetweenKeys(String string, String key1, String key2, String pattern, String margin, boolean errorMessageOnRemainingString, boolean isControlString)
    • formatDecimalContentBetweenKeys

      public String formatDecimalContentBetweenKeys(String string, String key1, String key2)
    • ignoreContentBeforeKey

      public static String ignoreContentBeforeKey(String string, String key)
    • ignoreContentAfterKey

      public static String ignoreContentAfterKey(String string, String key)
    • ignoreRegularExpression

      public static String ignoreRegularExpression(String string, String regex)
    • removeRegularExpression

      public static String removeRegularExpression(String string, String regex)
    • replaceRegularExpression

      public static String replaceRegularExpression(String string, String from, String to)
    • createParametersMapFromParamProperties

      public Map<String,Object> createParametersMapFromParamProperties(Properties properties)
      Create a Map for a specific property based on other properties that are the same except for a .param1.name, .param1.value or .param1.valuefile suffix. The property with the .name suffix specifies the key for the Map, the property with the value suffix specifies the value for the Map. A property with a the .valuefile suffix can be used as an alternative for a property with a .value suffix to specify the file to read the value for the Map from. More than one param can be specified by using param2, param3 etc.
      Parameters:
      properties - Properties object from which to create the map
      Returns:
      A map with parameters
    • formatString

      public String formatString(String string)
      Replace all linefeed-characters with the platform-specific linefeed-character for the current platform.
    • mapPropertiesToIgnores

      public static Map<String,Map<String,Map<String,String>>> mapPropertiesToIgnores(Properties properties)
      This method is used to provide a way to implement ignores based on an identifier. For example: ignoreContentBetweenKeys.fieldA.key1= ignoreContentBetweenKeys.fieldA.key2=
      Parameters:
      properties - Properties to be checked
      Returns:
      Mapinvalid input: '<'String, Mapinvalid input: '<'String, Mapinvalid input: '<'String, String>>> as Mapinvalid input: '<''ignoreContentBetweenKeys', Mapinvalid input: '<''fieldA', Mapinvalid input: '<''key1', ''>
    • findAttributesForIgnore

      public static List<String> findAttributesForIgnore(String propertyName)
      This method is used to de-couple the need of providing a set of attributes when calling mapPropertiesByIdentifier(). Caller of mapPropertiesByIdentifier() should not necessarily know about all attributes related to an ignore.
      Parameters:
      propertyName - The name of the ignore we are checking, in the example 'ignoreContentBetweenKeys'