Class TestAppMojo
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 Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate booleanprivate Fileprivate Stringprivate org.apache.maven.shared.model.fileset.FileSetprivate List<TestProcessSpec> private Stringprivate intprivate intprivate Fileprivate Stringprivate Fileprivate booleanprivate intprivate Fileprivate Fileprivate Stringprivate booleanprivate Stringprivate Fileprivate intprivate org.apache.maven.project.MavenProjectprivate org.apache.maven.execution.MavenExecutionRequestprivate booleanprivate booleanprivate booleanprivate booleanprivate booleanprivate Stringprivate booleanprivate longprivate intprivate intprivate List<ProcessUnit> Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ProcessUnit.ProcessUnitBuilderaddMavenTestCall(ProcessUnit.ProcessUnitBuilder testBuilder) Adds the command line arguments for a maven call.private ProcessUnitBuilds the process unit ofbuilderand registers it for shutdown.private ProcessUnit.ProcessUnitBuildercreatePlatformBuilder(String description, File home, String scriptName, ProcessUnit.TerminationListener listener, String... args) Creates a process unit builder for a platform process.private voidDeploys an application via deployment descriptor if specified and case of atestCmd.private FileDetermines the probable broker directory from settings oroutputDirectory.voidexecute()voidImplements the test execution.extrapolate(List<String> args, List<TestProcessSpec> processes) Extrapolates the given arguments for the given processes.private booleanhandleTermination(ProcessUnit.TerminationReason reason, AtomicBoolean terminated, AtomicInteger testTerminatedCount) Handles a termination notification.private static booleanisValidFile(File file) Returns iffileis a valid file.private StringreplaceAsUri(String contents, String placeholder, String value, String info) Replaces a placeholder in the UI configuration template by a URI value.private StringreplacePlaceholder(String contents, String placeholder, String value) Replaces a placeholder in the UI configuration template by a String value.private de.iip_ecosphere.platform.support.iip_aas.config.RuntimeSetupstartPlatform(int brokerPort) Starts the platform processes depending on the selection in the attributes of this class.private ProcessUnitstartPlatformService(String description, File home, String scriptName, String... args) Starts a platform service and waits for startup completion.private voidStarts defined processes.private booleanStops all registered process units.private voidwriteMgtUiSetup(de.iip_ecosphere.platform.support.iip_aas.config.RuntimeSetup setup) Methods inherited from class de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
error, error, info, warnMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
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
-
appOffline
@Parameter(property="configuration.testApp.appOffline", required=false, defaultValue="true") private boolean appOffline -
appArgs
-
mvnArgs
-
mvnPluginArgs
-
logFile
@Parameter(property="configuration.testApp.logFile", required=false, defaultValue="") private File logFile -
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
-
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 ofbuilderand 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 processhome- the home directory of the scriptscriptName- the script name (without extension)listener- optional listener to be informed when the process terminates or a match happens, may be nullargs- 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 processhome- the home directory of the scriptscriptName- 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 viabuildAndRegister(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
Returns iffileis a valid file.- Parameters:
file- the file- Returns:
truefor 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 atestCmd. The resource in the deployment descriptor must bedeploymentResource.- Parameters:
deploy- deploy or undeployid- the undeployment id- Throws:
org.apache.maven.plugin.MojoExecutionException- if deployment/undeployment fails
-
startProcesses
private void startProcesses() throws org.apache.maven.plugin.MojoExecutionExceptionStarts defined processes.- Throws:
org.apache.maven.plugin.MojoExecutionException- if process execution fails
-
stopProcessUnits
private boolean stopProcessUnits()Stops all registered process units.- Returns:
truefor failed,falseelse
-
handleTermination
private boolean handleTermination(ProcessUnit.TerminationReason reason, AtomicBoolean terminated, AtomicInteger testTerminatedCount) Handles a termination notification.- Parameters:
reason- the termination reasonterminated- the terminated flag to change as a side effecttestTerminatedCount- 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.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
addMavenTestCall
Adds the command line arguments for a maven call.- Parameters:
testBuilder- the process unit builder for the call- Returns:
testBuilder, builder style
-
replacePlaceholder
Replaces a placeholder in the UI configuration template by a String value.- Parameters:
contents- the contents to apply the replacement onplaceholder- the placeholder namevalue- the value to replace the placeholder with- Returns:
- the modified contents
-
replaceAsUri
Replaces a placeholder in the UI configuration template by a URI value.- Parameters:
contents- the contents to apply the replacement onplaceholder- the placeholder namevalue- the value to replace the placeholder withinfo- 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) - Parameters:
setup- the setup file
-
extrapolate
Extrapolates the given arguments for the given processes.- Parameters:
args- the command line arguments, may be nullprocesses- the processes, may be null- Returns:
- the extrapolated arguments
-
determineBrokerDir
Determines the probable broker directory from settings oroutputDirectory.- Returns:
- the broker directory
-
executeImpl
public void executeImpl() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionImplements the test execution.- Throws:
org.apache.maven.plugin.MojoExecutionException- if the Mojo execution failedorg.apache.maven.plugin.MojoFailureException- if the Mojo failed
-