Class VelocityTemplateEngine

java.lang.Object
org.mockserver.templates.engine.velocity.VelocityTemplateEngine
All Implemented Interfaces:
TemplateEngine

public class VelocityTemplateEngine extends Object implements TemplateEngine
Author:
jamesdbloom
  • Constructor Details

  • Method Details

    • executeTemplate

      public <T> T executeTemplate(String template, HttpRequest request, Class<? extends DTO<T>> dtoClass)
      Specified by:
      executeTemplate in interface TemplateEngine
    • executeTemplate

      public <T> T executeTemplate(String template, HttpRequest request, HttpResponse response, Class<? extends DTO<T>> dtoClass)
      Specified by:
      executeTemplate in interface TemplateEngine
    • renderTemplate

      public String renderTemplate(String template, HttpRequest request)
      Description copied from interface: TemplateEngine
      Renders a template against the request and returns the raw rendered text, without attempting to deserialize it into an HttpResponse / HttpRequest. Used to template the contents of a FileBody so an externally stored response body can contain template placeholders. Supported by the text-based engines (Velocity, Mustache).
      Specified by:
      renderTemplate in interface TemplateEngine
    • renderTemplate

      public String renderTemplate(String template, HttpRequest request, IterationContext iteration)
      Description copied from interface: TemplateEngine
      Renders a template against the request with an optional per-iteration load-scenario variable injected under the key "iteration", returning the raw rendered text. Used only by the load-generation executor to vary a request step's fields per iteration (e.g. $iteration.index). When iteration is null this is identical to TemplateEngine.renderTemplate(String, HttpRequest). The default delegates to that method so engines that do not support the iteration variable (JavaScript via this text path) still render the request context unchanged.
      Specified by:
      renderTemplate in interface TemplateEngine
      Parameters:
      template - the template text
      request - the request context
      iteration - the per-iteration variable, or null for no iteration context