The different kinds of transitions systems supported by VIBeS may be defined by redefining one of the following abstract classes and by implementing its define() method:
import be.unamur.transitionsystem.dsl.*; public class MyLTS extends LabelledTransitionSystemDefinition{ public MyLTS(){ super(); } @Override protected void define() { initial("initial"); from("initial").action("act1").to("s1"); from("s1").action("doX").to("s2"); from("s1").action("doXY").to("s3"); from("s2").action("doY").to("s3"); from("s3").action("exit").to("initial"); } public static void main(String[] args){ MyLTS def = new MyLTS(); LabelledTransitionSystem lts = def.getTransitionSystem(); } }
Feature expressions are boolean expressions defined over features. In VIBeS, feature expressions have to respect the following grammar:
FEXPRESSION: 'true' | 'false' | FEATURENAME | '!' FEXPRESSION | FEXPRESSION '&&' FEXPRESSION | FEXPRESSION '||' FEXPRESSION | '(' FEXPRESSION ')' FEATURENAME: LETTER (LETTER | DIGIT)* LETTER: 'A'..'Z' | 'a'..'z' | '_' DIGIT: '0'..'9'
The operators priority is defined as following : parenthesis ('(' FEXPRESSION ')') > not ('!') > and ('&&'), or ('||')
Various transition systems may be loaded/saved in XML files.
import static be.unamur.transitionsystem.dsl.TransitionSystemXmlLoaders.*; import static be.unamur.transitionsystem.dsl.TransitionSystemXmlPrinter.*; public Main{ public static void main(String[] args){ LabelledTransitionSystem lts = loadLabelledTransitionSystem("myLTS.xml"); // [...] print(lts, "otherLTS.xml"); } }
The class ConfiguredMutagen allows to easilly generate mutants using a configuration file specifying the mutation operators configuration:
import static be.unamur.transitionsystem.dsl.TransitionSystemXmlLoaders.*; import static be.unamur.transitionsystem.dsl.test.mutation.ConfiguredMutagen.*; public Main{ public static void main(String[] args){ LabelledTransitionSystem lts = new MyLTS().getTransitionSystem(); // Loads the mutation operators configuration // E.g., ennumerative mutants generation configure("operatorsConfig.xml") .outputDir("mutants/") // Generates mutants in the given folder .mutate(lts); // E.g., FMM generation configure("operatorsConfig.xml") .ftsMutant("fmm.fts") // Generates FMM's FTS with given name .tvlMutant("fmm.tvl") // Generates FMM's FD in TVL format .mutate(lts); // E.g., ennumerative and FMM generation (will generate the same mutants) configure("operatorsConfig.xml") .outputDir("mutants/") // Generates mutants in the given folder .ftsMutant("fmm.fts") // Generates FMM's FTS with given name .tvlMutant("fmm.tvl") // Generates FMM's FD in TVL format .mutate(lts); } }
Here is a exemple of configuration file (in XML):
<?xml version="1.0" encoding="UTF-8"?> <config> <mutantsSize>200</mutantsSize> <!-- Default mutant size (may be redefined) --> <!-- Default selection strategies for each operator (may be redefined) --> <actionSelection>be.unamur.transitionsystem.test.mutation.RandomSelectionStrategy</actionSelection> <stateSelection>be.unamur.transitionsystem.test.mutation.RandomSelectionStrategy</stateSelection> <transitionSelection>be.unamur.transitionsystem.test.mutation.RandomSelectionStrategy</transitionSelection> <unique>true</unique> <!-- Default uniqueness of each mutant (may be redefined) --> <!-- Operators --> <operators> <operator> <class>be.unamur.transitionsystem.test.mutation.ActionExchange</class> </operator> <operator> <class>be.unamur.transitionsystem.test.mutation.ActionMissing</class> </operator> <operator> <class>be.unamur.transitionsystem.test.mutation.StateMissing</class> </operator> <operator> <class>be.unamur.transitionsystem.test.mutation.TransitionAdd</class> </operator> <operator> <class>be.unamur.transitionsystem.test.mutation.TransitionDestinationExchange</class> </operator> <operator> <class>be.unamur.transitionsystem.test.mutation.TransitionMissing</class> </operator> <operator> <class>be.unamur.transitionsystem.test.mutation.WrongInitialState</class> <mutantsSize>100</mutantsSize> <actionSelection>be.unamur.transitionsystem.test.mutation.RandomSelectionStrategy</actionSelection> <stateSelection>be.unamur.transitionsystem.test.mutation.RandomSelectionStrategy</stateSelection> <transitionSelection>be.unamur.transitionsystem.test.mutation.RandomSelectionStrategy</transitionSelection> <unique>false</unique> </operator> </operators> </config>
It is also possible to configure a particular mutation operator for a given transition system using the Mutagen class:
import static be.unamur.transitionsystem.dsl.TransitionSystemXmlLoaders.*; import static be.unamur.transitionsystem.dsl.test.mutation.Mutagen.*; import be.unamur.transitionsystem.test.mutation.*; public Main{ public static void main(String[] args){ LabelledTransitionSystem lts = new MyLTS().getTransitionSystem(); FeaturedTransitionSystem fts = new F // Initialise the operatro for the given transition system MutationOperator op = transitionMissing(lts) .transitionSelectionStrategy(new RandomSelectionStrategy()) .done(); // Apply the operator op.apply(); // Get the mutant transition system (enumerative version) LabelledTransitionSystem mutant = (LabelledTransitionSystem) op.result(); // Enrich the FMM's FTS with the new mutant op.transpose(ftsFMM); // Get the feature ID used in the FMM's FTS (should be added to the used feature diagram) String mutantFeatureId = op.getFeatureId(); } }