Class SutController
- java.lang.Object
-
- org.evomaster.client.java.controller.internal.SutController
-
- All Implemented Interfaces:
SutHandler
- Direct Known Subclasses:
EmbeddedSutController,ExternalSutController
public abstract class SutController extends Object implements SutHandler
Abstract class used to connect to the EvoMaster process, and that is responsible to start/stop/restart the tested application, ie the system under test (SUT)
-
-
Constructor Summary
Constructors Constructor Description SutController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ExtraHeuristicsDtocomputeExtraHeuristics()voidenableComputeSqlHeuristicsOrExtractExecution(boolean enableSqlHeuristics, boolean enableSqlExecution)voidexecInsertionsIntoDatabase(List<InsertionDto> insertions)Execute the given data insertions into the database (if any)abstract List<AdditionalInfo>getAdditionalInfoList()abstract ConnectiongetConnection()If the system under test (SUT) uses a SQL database, we need to have a configured connection to access it.StringgetControllerHost()intgetControllerPort()intgetControllerServerPort()abstract StringgetDatabaseDriverName()If the system under test (SUT) uses a SQL database, we need to specify the driver used to connect, eg.List<ExtraHeuristicsDto>getExtraHeuristics()abstract List<AuthenticationDto>getInfoForAuthentication()abstract StringgetPackagePrefixesToCover()a "," separated list of package prefixes or class names.abstract SutInfoDto.OutputFormatgetPreferredOutputFormat()abstract ProblemInfogetProblemInfo()Depending of which kind of SUT we are dealing with (eg, REST, GraphQL or SPA frontend), there is different info that must be providedDbSchemaDtogetSqlDatabaseSchema()Extra information about the SQL Database Schema, if any is present.abstract List<TargetInfo>getTargetInfos(Collection<Integer> ids)abstract UnitsInfoDtogetUnitsInfoDto()protected UnitsInfoDtogetUnitsInfoDto(UnitsInfoRecorder recorder)voidhandleSql(String sql)Calculate heuristics based on intercepted SQL commandsvoidinitSqlHandler()This is needed only during test generation (not execution), and it is automatically called by the EM controller after the SUT is started.abstract booleanisInstrumentationActivated()Check if bytecode instrumentation is on.abstract booleanisSutRunning()Check if the system under test (SUT) is running and fully initializedvoidnewAction(ActionDto dto)As some heuristics are based on which action (eg HTTP call, or click of button) in the test sequence is executed, and their order, we need to keep track of which action does cover what.abstract voidnewActionSpecificHandler(ActionDto dto)abstract voidnewSearch()Re-initialize all internal data to enable a completely new search phase which should be independent from previous onesvoidnewTest()Re-initialize some internal data needed before running a new testabstract voidnewTestSpecificHandler()voidresetExtraHeuristics()voidsetControllerHost(String controllerHost)voidsetControllerPort(int controllerPort)booleanstartTheControllerServer()Start the controller as a RESTful server.booleanstopTheControllerServer()booleanverifySqlConnection()Either there is no connection, or, if there is, then it must have P6Spy configured.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.evomaster.client.java.controller.SutHandler
resetStateOfSUT, setupForGeneratedTest, startSut, stopSut
-
-
-
-
Method Detail
-
startTheControllerServer
public final boolean startTheControllerServer()
Start the controller as a RESTful server. Use the setters of this class to change the default port and host.
This method is blocking until the server is initialized.- Returns:
- true if there was no problem in starting the controller
-
stopTheControllerServer
public final boolean stopTheControllerServer()
-
getControllerServerPort
public final int getControllerServerPort()
- Returns:
- the actual port in use (eg, if it was an ephemeral 0)
-
getControllerPort
public final int getControllerPort()
-
setControllerPort
public final void setControllerPort(int controllerPort)
-
getControllerHost
public final String getControllerHost()
-
setControllerHost
public final void setControllerHost(String controllerHost)
-
execInsertionsIntoDatabase
public void execInsertionsIntoDatabase(List<InsertionDto> insertions)
Description copied from interface:SutHandlerExecute the given data insertions into the database (if any)- Specified by:
execInsertionsIntoDatabasein interfaceSutHandler- Parameters:
insertions- DTOs for each insertion to execute
-
handleSql
public final void handleSql(String sql)
Calculate heuristics based on intercepted SQL commands- Parameters:
sql- command as a string
-
enableComputeSqlHeuristicsOrExtractExecution
public final void enableComputeSqlHeuristicsOrExtractExecution(boolean enableSqlHeuristics, boolean enableSqlExecution)
-
initSqlHandler
public final void initSqlHandler()
This is needed only during test generation (not execution), and it is automatically called by the EM controller after the SUT is started.
-
resetExtraHeuristics
public final void resetExtraHeuristics()
-
getExtraHeuristics
public final List<ExtraHeuristicsDto> getExtraHeuristics()
-
computeExtraHeuristics
public final ExtraHeuristicsDto computeExtraHeuristics()
-
getSqlDatabaseSchema
public final DbSchemaDto getSqlDatabaseSchema()
Extra information about the SQL Database Schema, if any is present. Note: this is extracted by querying the database itself. So the database must be up and running.- Returns:
- a DTO with the schema information
- See Also:
getConnection()
-
verifySqlConnection
public final boolean verifySqlConnection()
Either there is no connection, or, if there is, then it must have P6Spy configured. But this might not apply to all kind controllers- Returns:
- false if the verification failed
-
newSearch
public abstract void newSearch()
Re-initialize all internal data to enable a completely new search phase which should be independent from previous ones
-
newTest
public final void newTest()
Re-initialize some internal data needed before running a new test
-
newAction
public final void newAction(ActionDto dto)
As some heuristics are based on which action (eg HTTP call, or click of button) in the test sequence is executed, and their order, we need to keep track of which action does cover what.- Parameters:
dto- the DTO with the information about the action (eg its index in the test)
-
newTestSpecificHandler
public abstract void newTestSpecificHandler()
-
newActionSpecificHandler
public abstract void newActionSpecificHandler(ActionDto dto)
-
isInstrumentationActivated
public abstract boolean isInstrumentationActivated()
Check if bytecode instrumentation is on.- Returns:
- true if the instrumentation is on
-
isSutRunning
public abstract boolean isSutRunning()
Check if the system under test (SUT) is running and fully initialized- Returns:
- true if the SUT is running
-
getPackagePrefixesToCover
public abstract String getPackagePrefixesToCover()
a "," separated list of package prefixes or class names. For example, "com.foo.,com.bar.Bar". Note: be careful of using something as general as "com." or "org.", as most likely ALL your third-party libraries would be instrumented as well, which could have a severe impact on performance- Returns:
- a String representing the packages to cover
-
getInfoForAuthentication
public abstract List<AuthenticationDto> getInfoForAuthentication()
- Returns:
- a list of valid authentication credentials, or
nullif * none is necessary
-
getConnection
public abstract Connection getConnection()
If the system under test (SUT) uses a SQL database, we need to have a configured connection to access it.- Returns:
nullif the SUT does not use any SQL database
-
getDatabaseDriverName
public abstract String getDatabaseDriverName()
If the system under test (SUT) uses a SQL database, we need to specify the driver used to connect, eg.org.h2.Driver. This is needed for when we intercept SQL commands with P6Spy- Returns:
nullif the SUT does not use any SQL database
-
getTargetInfos
public abstract List<TargetInfo> getTargetInfos(Collection<Integer> ids)
-
getAdditionalInfoList
public abstract List<AdditionalInfo> getAdditionalInfoList()
- Returns:
- additional info for each action in the test. The list is ordered based on the action index.
-
getProblemInfo
public abstract ProblemInfo getProblemInfo()
Depending of which kind of SUT we are dealing with (eg, REST, GraphQL or SPA frontend), there is different info that must be provided- Returns:
- an instance of object with all the needed data for the specific addressed problem
-
getPreferredOutputFormat
public abstract SutInfoDto.OutputFormat getPreferredOutputFormat()
- Returns:
- the format in which the test cases should be generated
-
getUnitsInfoDto
public abstract UnitsInfoDto getUnitsInfoDto()
-
getUnitsInfoDto
protected UnitsInfoDto getUnitsInfoDto(UnitsInfoRecorder recorder)
-
-