java.lang.Object
org.apache.maven.plugin.AbstractMojo
de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
de.iip_ecosphere.platform.configuration.maven.TestAppMojo
All Implemented Interfaces:
de.iip_ecosphere.platform.tools.maven.python.Logger, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="testApp", defaultPhase=PACKAGE) public class TestAppMojo extends de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
A platform application testing MOJO. May start an entire (local) platform
Author:
Holger Eichelberger, SSE
  • Field Details

    • project

      @Parameter(defaultValue="${project}", readonly=true) private org.apache.maven.project.MavenProject project
    • offline

      @Parameter(defaultValue="${session.offline}") private boolean offline
    • request

      @Parameter(defaultValue="${session.request}") private org.apache.maven.execution.MavenExecutionRequest request
    • testCmd

      @Parameter(property="configuration.testApp.testCmd", required=false, defaultValue="") private String testCmd
    • testCmdAsScript

      @Parameter(property="configuration.testApp.testCmdAsScript", required=false, defaultValue="false") private boolean testCmdAsScript
    • appId

      @Parameter(property="configuration.testApp.appId", required=false, defaultValue="app") private String appId
    • appProfile

      @Parameter(property="configuration.testApp.appProfile", required=false, defaultValue="App") private String appProfile
    • appPom

      @Parameter(property="configuration.testApp.appPom", required=false) private File appPom
    • appOffline

      @Parameter(property="configuration.testApp.appOffline", required=false, defaultValue="true") private boolean appOffline
    • appArgs

      @Parameter(property="configuration.testApp.appArgs", required=false) private List<String> appArgs
    • mvnArgs

      @Parameter(property="configuration.testApp.mvnArgs", required=false) private List<String> mvnArgs
    • mvnPluginArgs

      @Parameter(property="configuration.testApp.mvnPluginArgs", required=false) private List<String> mvnPluginArgs
    • logFile

      @Parameter(property="configuration.testApp.logFile", required=false, defaultValue="") private File logFile
    • logRegExprs

      @Parameter(property="configuration.testApp.logRegExprs", required=false) private List<String> logRegExprs
    • logRegExConjunction

      @Parameter(property="configuration.testApp.logRegExConjunction", required=false, defaultValue="true") private boolean logRegExConjunction
    • logRegExMatchCount

      @Parameter(property="configuration.testApp.logRegExMatchCount", required=false, defaultValue="1") private int logRegExMatchCount
    • skip

      @Parameter(property="configuration.testApp.skip", required=false, defaultValue="false") private boolean skip
    • brokerDir

      @Parameter(property="configuration.testApp.brokerDir", required=false, defaultValue="") private String brokerDir
    • brokerPort

      @Parameter(property="configuration.testApp.brokerPort", required=false, defaultValue="-1") private int brokerPort
    • brokerWaitTime

      @Parameter(property="configuration.testApp.brokerWaitTime", required=true, defaultValue="3000") private int brokerWaitTime
    • testTime

      @Parameter(property="configuration.testApp.testTime", required=true, defaultValue="120000") private int testTime
    • testTimePlatform

      private int testTimePlatform
    • platformStartTimeout

      @Parameter(property="configuration.testApp.platformStartTimeout", required=true, defaultValue="120000") private int platformStartTimeout
    • outputDirectory

      @Parameter(property="configuration.outputDirectory", required=true, defaultValue="gen") private String outputDirectory
    • platformDir

      @Parameter(property="configuration.testApp.platformDir", required=false, defaultValue="") private File platformDir
    • startPlatform

      @Parameter(property="configuration.testApp.startPlatform", required=false, defaultValue="true") private boolean startPlatform
    • startEcsRuntime

      @Parameter(property="configuration.testApp.startEcsRuntime", required=false, defaultValue="false") private boolean startEcsRuntime
    • startServiceManager

      @Parameter(property="configuration.testApp.startServiceMgr", required=false, defaultValue="false") private boolean startServiceManager
    • startEcsServiceManager

      @Parameter(property="configuration.testApp.startEcsServiceMgr", required=false, defaultValue="true") private boolean startEcsServiceManager
    • deploymentPlan

      @Parameter(property="configuration.testApp.deploymentPlan", required=false) private File deploymentPlan
    • deploymentResource

      @Parameter(property="configuration.testApp.deploymentResource", required=false, defaultValue="local") private String deploymentResource
    • mgtUiSetupFileTemplate

      @Parameter(property="configuration.testApp.mgtUiSetupFileTemplate", required=false, defaultValue="") private File mgtUiSetupFileTemplate
    • mgtUiSetupFile

      @Parameter(property="configuration.testApp.mgtUiSetupFile", required=false, defaultValue="") private File mgtUiSetupFile
    • befores

      @Parameter(property="configuration.testApp.befores", required=false) private List<TestProcessSpec> befores
    • nodejs

      @Parameter(property="configuration.ngTest.nodejs", required=false, defaultValue="") private String nodejs
    • artifacts

      @Parameter(required=false) private org.apache.maven.shared.model.fileset.FileSet artifacts
    • units

      private List<ProcessUnit> units
    • testStart

      private long testStart
  • Constructor Details

    • TestAppMojo

      public TestAppMojo()
  • Method Details

    • buildAndRegister

      private ProcessUnit buildAndRegister(ProcessUnit.ProcessUnitBuilder builder) throws org.apache.maven.plugin.MojoExecutionException
      Builds the process unit of builder and registers it for shutdown.
      Parameters:
      builder - the builder
      Returns:
      the created process unit
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if creating the process fails
    • createPlatformBuilder

      private ProcessUnit.ProcessUnitBuilder createPlatformBuilder(String description, File home, String scriptName, ProcessUnit.TerminationListener listener, String... args)
      Creates a process unit builder for a platform process.
      Parameters:
      description - the description of the process
      home - the home directory of the script
      scriptName - the script name (without extension)
      listener - optional listener to be informed when the process terminates or a match happens, may be null
      args - additional optional arguments
      Returns:
      the process unit builder
    • startPlatformService

      private ProcessUnit startPlatformService(String description, File home, String scriptName, String... args) throws org.apache.maven.plugin.MojoExecutionException
      Starts a platform service and waits for startup completion.
      Parameters:
      description - the description of the process
      home - the home directory of the script
      scriptName - the script name (without extension)
      args - additional optional arguments
      Returns:
      the process unit builder
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if starting the service fails
    • startPlatform

      private de.iip_ecosphere.platform.support.iip_aas.config.RuntimeSetup startPlatform(int brokerPort) throws org.apache.maven.plugin.MojoExecutionException
      Starts the platform processes depending on the selection in the attributes of this class. Registers all created processes via buildAndRegister(ProcessUnitBuilder).
      Parameters:
      brokerPort - the port the broker is running on
      Returns:
      the runtime setup instance of the platform, may be null in case of failures
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if starting the service fails
      See Also:
    • isValidFile

      private static boolean isValidFile(File file)
      Returns if file is a valid file.
      Parameters:
      file - the file
      Returns:
      true for valid, false
    • deployApp

      private void deployApp(boolean deploy, String id) throws org.apache.maven.plugin.MojoExecutionException
      Deploys an application via deployment descriptor if specified and case of a testCmd. The resource in the deployment descriptor must be deploymentResource.
      Parameters:
      deploy - deploy or undeploy
      id - the undeployment id
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if deployment/undeployment fails
    • startProcesses

      private void startProcesses() throws org.apache.maven.plugin.MojoExecutionException
      Starts defined processes.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if process execution fails
    • stopProcessUnits

      private boolean stopProcessUnits()
      Stops all registered process units.
      Returns:
      true for failed, false else
    • handleTermination

      private boolean handleTermination(ProcessUnit.TerminationReason reason, AtomicBoolean terminated, AtomicInteger testTerminatedCount)
      Handles a termination notification.
      Parameters:
      reason - the termination reason
      terminated - the terminated flag to change as a side effect
      testTerminatedCount - how often was a termination indicated so far
      Returns:
      stop the process or not
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • addMavenTestCall

      private ProcessUnit.ProcessUnitBuilder addMavenTestCall(ProcessUnit.ProcessUnitBuilder testBuilder)
      Adds the command line arguments for a maven call.
      Parameters:
      testBuilder - the process unit builder for the call
      Returns:
      testBuilder, builder style
    • replacePlaceholder

      private String replacePlaceholder(String contents, String placeholder, String value)
      Replaces a placeholder in the UI configuration template by a String value.
      Parameters:
      contents - the contents to apply the replacement on
      placeholder - the placeholder name
      value - the value to replace the placeholder with
      Returns:
      the modified contents
    • replaceAsUri

      private String replaceAsUri(String contents, String placeholder, String value, String info)
      Replaces a placeholder in the UI configuration template by a URI value.
      Parameters:
      contents - the contents to apply the replacement on
      placeholder - the placeholder name
      value - the value to replace the placeholder with
      info - information on the placeholder/value for logging
      Returns:
      the modified contents
    • writeMgtUiSetup

      private void writeMgtUiSetup(de.iip_ecosphere.platform.support.iip_aas.config.RuntimeSetup setup)
      If setup is given, turn mgtUiSetupFileTemplate into mgtUiSetupFile by replacing ${aasRegistryUri}.
      Parameters:
      setup - the setup file
    • extrapolate

      private List<String> extrapolate(List<String> args, List<TestProcessSpec> processes)
      Extrapolates the given arguments for the given processes.
      Parameters:
      args - the command line arguments, may be null
      processes - the processes, may be null
      Returns:
      the extrapolated arguments
    • determineBrokerDir

      private File determineBrokerDir()
      Determines the probable broker directory from settings or outputDirectory.
      Returns:
      the broker directory
    • executeImpl

      public void executeImpl() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Implements the test execution.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the Mojo execution failed
      org.apache.maven.plugin.MojoFailureException - if the Mojo failed