Class ReplacementAspect


  • public final class ReplacementAspect
    extends Object
    Aspect to replace variables used in the feature files
    Author:
    Jose Fernandez
    • Constructor Detail

      • ReplacementAspect

        public ReplacementAspect()
    • Method Detail

      • replacementArguments

        protected void replacementArguments​(io.cucumber.core.backend.TestCaseState state)
      • replacePropertyPlaceholders

        @Deprecated
        protected static String replacePropertyPlaceholders​(String element,
                                                            org.aspectj.lang.JoinPoint pjp)
                                                     throws org.apache.commons.configuration2.ex.ConfigurationException,
                                                            URISyntaxException,
                                                            NonReplaceableException,
                                                            FileNotFoundException
        Deprecated.
        Deprecated. This same function can now be perform via StringSubstitutor with the EnvPropertyLookup (i.e. #{my.key} can be represented as ${envProperties:my.key})
        Replaces every placeholded element, enclosed in #{} with the corresponding value in a properties file.

        The file that contains all common configuration for the project (environment independent configuration) must be located in /resources/configuration/common.properties

        Environment-specific configuration can be located in a separated file. This configuration can override the configuration from the common file. All environment specific configuration files can be included at runtime via maven variable, setting the 'env' to the name of the file.

        for example, to use properties from the file pre.properties located in /resources/configuration/pre.properties, just pass -Denv=pre when running your tests

        Parameters:
        element - element to be replaced
        pjp - JoinPoint
        Returns:
        resulting string
        Throws:
        org.apache.commons.configuration2.ex.ConfigurationException - ConfigurationException
        URISyntaxException - URISyntaxException
        NonReplaceableException - NonReplaceableException
        FileNotFoundException - FileNotFoundException
      • replaceCodePlaceholders

        @Deprecated
        protected static String replaceCodePlaceholders​(String element,
                                                        org.aspectj.lang.JoinPoint pjp)
                                                 throws NonReplaceableException
        Deprecated.
        Deprecated. @{} functions can now be performed using StringSubstitutor with the ${} variable placeholder
        Replaces every placeholded element, enclosed in @{} with the corresponding attribute value in local Common class

        If the element starts with: - IP: We expect it to be followed by '.' + interface name (i.e. IP.eth0). It can contain other replacements.

        If the element starts with: - JSON: We expect it to be followed by '.' + path_to_json_file (relative to src/test/resources or target/test-classes). The json is read and its content is returned as a string

        If the element starts with: - FILE: We expect it to be followed by '.' + path_to_file (relative to src/test/resources or target/test-classes). The file is read and its content is returned as a string

        Parameters:
        element - element to be replaced
        pjp - JoinPoint
        Returns:
        String
        Throws:
        NonReplaceableException - exception
      • replaceReflectionPlaceholders

        @Deprecated
        protected static String replaceReflectionPlaceholders​(String element,
                                                              org.aspectj.lang.JoinPoint pjp)
        Deprecated.
        Deprecated. ${} placeholder can also be used as placeholder for Thread variables
        Replaces every placeholded element, enclosed in !{} with the corresponding attribute value in local Common class
        Parameters:
        element - element to be replaced
        pjp - JoinPoint
        Returns:
        String string
      • replaceEnvironmentPlaceholders

        protected static String replaceEnvironmentPlaceholders​(String element,
                                                               org.aspectj.lang.JoinPoint jp)
                                                        throws NonReplaceableException
        Replaces every placeholded element, enclosed in ${} with the corresponding java property
        Parameters:
        element - element to be replaced
        jp - JoinPoint
        Returns:
        String
        Throws:
        NonReplaceableException - exception