Skip to content
Permalink
Browse files

[TestMutation] Adding the cruise.umple.mutation project, it should al…

…low for mutating the Umple model to evaluate the quality of the test suite. The co
  • Loading branch information...
SultanEid committed Sep 21, 2019
1 parent d2f6eda commit 524594450f66aa7a20951804e2217397a46ff316
Showing with 2,862 additions and 3 deletions.
  1. +18 −3 build/build.testgenerator.xml
  2. +28 −0 cruise.umple.mutation/model.ump
  3. +39 −0 cruise.umple.mutation/model2.ump
  4. +8 −0 cruise.umple.mutation/src/Master.ump
  5. +171 −0 cruise.umple.mutation/src/MutationConsoleMain.ump
  6. +46 −0 cruise.umple.mutation/src/MutationMetamodel.ump
  7. +1,623 −0 cruise.umple.mutation/src/MutationSuite_code.ump
  8. +1 −0 cruise.umple.mutation/src/evaluator.ump
  9. +1 −0 cruise.umple.mutation/src/mutant.ump
  10. +1 −0 cruise.umple.mutation/src/mutantClass.ump
  11. 0 cruise.umple.mutation/src/mutator.ump
  12. +480 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/MutationTest.java
  13. +39 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel.ump
  14. +12 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_float.ump
  15. +12 −0 ...umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_float_expectedDouble.ump.txt
  16. +12 −0 ...se.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_float_expectedInt.ump.txt
  17. +12 −0 ...umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_float_expectedString.ump.txt
  18. +12 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_int.ump
  19. +12 −0 ...e.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_int_expectedDouble.ump.txt
  20. +12 −0 ...se.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_int_expectedFloat.ump.txt
  21. +12 −0 ...e.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_int_expectedString.ump.txt
  22. +12 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_string.ump
  23. +12 −0 ...mple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_string_expectedDouble.ump.txt
  24. +12 −0 ...umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_string_expectedFloat.ump.txt
  25. +12 −0 ...e.umple.mutation/test/cruise/umple/mutation/test/uModel_attributeTyped_string_expectedInt.ump.txt
  26. +39 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_mutateAssert_model.ump
  27. +39 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_mutateAssert_model_identical.ump
  28. +39 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_mutateAssert_model_mutated.ump
  29. +10 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_mutateConstraint.ump
  30. +10 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_mutateConstraint.ump.txt
  31. +9 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_namespace.ump
  32. +9 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_namespace_expected.ump.txt
  33. +39 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_telephone.ump
  34. +43 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_useFiles.ump
  35. +15 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_useFiles1.ump
  36. +8 −0 cruise.umple.mutation/test/cruise/umple/mutation/test/uModel_useFiles2.ump
  37. +3 −0 cruise.umple/src/umple_classes.grammar
@@ -25,7 +25,7 @@
</java>
<java jar="${umple.stable.jar}" fork="true" failonerror="true">
<arg value="UmpleTToRubyUnit/UmpleTLTemplates/Master.ump"/>
</java>
</java>

</parallel>
</target>
@@ -55,11 +55,26 @@

</parallel>
</target>


<target name="CompilingUmpleTestParser">
<echo message="Compiling Umple Test Parser !"/>

</target>

<!--
Build
Compile Umple files for Mutation test generator
-->

<target name="GeneratingMutationTestGenerator">
<echo message="Generating Umple Mutation Test Generator !"/>
<parallel>
<java jar="${umple.stable.jar}" fork="true" failonerror="true">
<arg value="cruise.umple.mutation/src/Master.ump"/>
</java>
</parallel>
</target>



@@ -70,8 +85,7 @@
</copy>
<copy todir="cruise.umple.test-parser/src-gen/cruise/umple/testparser/" overwrite="true">
<fileset dir="cruise.umple.test-parser/src/src-gen/cruise/umple/testparser/" excludes=".git* UmpleTToRubyUnit.java" />
</copy>

</copy>
</target>


@@ -93,6 +107,7 @@
<antcall target="CopyingXUnitGenerators" />
<antcall target="GeneratingTestParser" />
<antcall target="CompilingUmpleTestParser" />
<antcall target="GeneratingMutationTestGenerator" />
<antcall target="CopyingTestParserFiles" />
<antcall target="testXUnitTemplateTest" />

@@ -0,0 +1,28 @@
use model2.ump;

class A {

String id;
Integer number;
Float number3;
Double numer2;

}

class B {

0..1 -- * A;

1 -- * C;

}


class C {

1 -- 2..4 D;


}

class D {}
@@ -0,0 +1,39 @@
/*
Telephone System- sample UML class diagram in Umple
Last updated: June 8, 2010
*/
//Namespace for core of the system.
namespace telesystem.core;

class PhoneCall{
String isOnHold;
String startTime;
duration;
0..1 call -- * TelephoneNumber originator;
0..1 -- * TelephoneNumber parties;
}
class TelephoneNumber{
digits;
0..1 number -- * TelephoneNumber voicemail;
}
class VoiceMailBox{
0..1 -- * VoiceMailMessage;
0..1 -- * TelephoneNumber;
}
class VoiceMailMessage {
Integer digitizedSound;
}
class Feature {
Integer description;
* -- * TelephoneNumber;
}
class Telephone {
model;
}
class PhoneLine {
double location;
double poCode;
Integer digOrAnalog;
* -- * TelephoneNumber;
1 -- 0..1 Telephone;
}
@@ -0,0 +1,8 @@
generate Java "../src-gen-umple";

namespace cruise.umple.mutation;

use Mutant.ump;
use MutationMetamodel.ump;
use MutationSuite_code.ump;
use MutationConsoleMain.ump;
@@ -0,0 +1,171 @@
namespace cruise.umple.mutation;




class MutationConsoleMain{
depend java.io.File;
depend java.net.URISyntaxException;
depend java.nio.file.Paths;
depend java.util.Arrays;

depend cruise.umple.UmpleConsoleMain;
depend joptsimple.*;

public static void main(String[] args) {


MutationSuite ms = new MutationSuite(null,0, "", "");
OptionParser parser = new OptionParser();
OptionSpec<Void> help = parser.acceptsAll(Arrays.asList("h","help"),"show help").forHelp();
OptionSpec<String> generate = parser.accepts("generate").withRequiredArg();
OptionSpec<String> mutant = parser.accepts("mutant").withOptionalArg();
OptionSpec<String> mutationType = parser.accepts("t").withRequiredArg();
OptionSpec<String> mutationOperator = parser.accepts("p").withRequiredArg();
OptionSpec<String> lang = parser.accepts("l").withRequiredArg();

//OptionSet options = parser.parse("generate", "-t", "random", "-p", "full");
OptionSet options = null;
try {
options = parser.parse(args);
}
catch(Exception e) {
if (e.toString().contains("generate"))
{
System.out.println(" Missing Umple model file! example: <umple_file>.ump");
return;
}

if (e.toString().contains("l"))
{
System.out.println(" Missing language ! example: Java, Php, Ruby ..etc");
return;
}

if (e.toString().contains("t"))
{
System.out.println(" Missing replacement type ! example: random, OneOptionalToMany, Integer ..etc , runy -h for more help !");
return;
}

if (e.toString().contains("p"))
{
System.out.println(" Missing mutation operator ! example: full, OneOptionalToMany, Integer ..etc , runy -h for more help !");
return;
}

}

try {
options.valueOf(generate).equals(null);

//System.out.println(" Missing Umple model file! example: <umple_file>.ump");
}
catch(Exception e) {
System.out.println(" Missing Umple model file! example: <umple_file>.ump");
}

try {
options.valueOf(lang).equals(null);

//System.out.println(" Missing Umple model file! example: <umple_file>.ump");
}
catch(Exception e) {
System.out.println(" Missing language ! example: Java, Php, Ruby ..etc");
return;
}

try {
options.valueOf(mutationType).equals(null);

//System.out.println(" Missing Umple model file! example: <umple_file>.ump");
}
catch(Exception e) {
System.out.println(" Missing replacement type ! example: random, OneOptionalToMany, Integer ..etc , runy -h for more help !");
return;
}


try {
options.valueOf(mutationOperator).equals(null);

//System.out.println(" Missing Umple model file! example: <umple_file>.ump");
}
catch(Exception e) {
System.out.println(" Missing mutation operator ! example: full, OneOptionalToMany, Integer ..etc , runy -h for more help !");
return;
}

//OptionSet options = parser.parse("-a", "apple", "-a", "berries", "-a", "mango");
/*System.out.println("model name: ");
System.out.println(options.valuesOf(generate));
System.out.println(options.has(generate));
System.out.println("Opetions: ");
System.out.println(options.valueOf(mutationType));
System.out.println(options.has(mutationType));
System.out.println("Operator: ");
System.out.println(options.valueOf(mutationOperator));
System.out.println(options.has(mutationOperator));
//# FIXME: improve commandline messages;
System.out.println("Language: ");
System.out.println(options.valueOf(lang));
System.out.println(options.has(lang));*/
if(options.has(help)) {
System.out.println("Please specify <umple_file> to process for mutation");
System.out.println("For more detailed information visit http://manual.umple.org");
System.out.println("#############################################################################################");
System.out.println("Example: java -jar umple.mutation.jar -generate model.ump -t random -p OneToMany -l Java ");
System.out.println("#############################################################################################");
System.out.println("Option Description");
System.out.println("------ -----------");
System.out.println("-help Print help message");
System.out.println("-t indicate the type of replacement for the \n" +
" mutation : random, specific element: OptionalOneToMany, OneToMany, OptionalOneToOne, ManyToMany,\n"+
" direction, Integer, String, Double, Float");
System.out.println("-p indicate the targeted element to be mutated: ‘full’ or specific element.");
System.out.println("-l the output language of the system to be generated: Java, ruby, Php (any system Umple accepts) ");


}

else {

String path = "";
path = Paths.get(".").toAbsolutePath().normalize().toString()+File.separator;
//path = System.getProperty("user.dir")+File.separator+"cruise/umple/mutation/";
//path=(MutationConsoleMain.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath();
String modelName =options.valueOf(generate);
String aLang=options.valueOf(lang);
String replacementType = "";
String muOperator = "";

replacementType = (options.valueOf(mutationType)).toString();
muOperator = (options.valueOf(mutationOperator)).toString();


System.out.println("Replacement type used: "+replacementType);
System.out.println("Targeted mutation operator : "+muOperator);
try {
ms.prepare(path, modelName, aLang,replacementType,muOperator);
System.out.println("Model mutated successfully !");

}
catch(Exception e) {
System.out.println("Failed to mutate: "+ e.getMessage());

}
/*****
// Run Diff on original model against the mutated one to find changes.
try {

Runtime.getRuntime().exec("diff " + modelName +" "+ mutationType+File.separator+mutationType+"Mutation_"+modelName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
}

}

}
@@ -0,0 +1,46 @@
//////class UmpleClass{}
//// Mutation model

class MutationSuite{
depend cruise.umple.compiler.*;
// attriute
UmpleModel originalModel;
int score;
String uFileName;
int unprocessedFiles = 0 ;
String path;
List<String> muFiles = new ArrayList<String>();
boolean hasMultipleFiles= false;
ArrayList<String> randomReplacements_association = new ArrayList<String>(Arrays.asList("OneToMany","OptionalOneToMany","OneToNN","ManyToMany")) ;
ArrayList<String> randomReplacements_typedAttribute = new ArrayList<String>(Arrays.asList("String","Integer","Float","Double")) ;
//private ArrayList<String> replacementsCode = new ArrayList<String>(Arrays.asList("1..*","0..1--*","1--2..4")) ;

0..1 -- * Replacement;
1 -- * Mutant;
}

class Mutant{
depend cruise.umple.compiler.*;
UmpleModel muModel;
type;

1--* MutationFragment mf;

}



class Replacement{
replacementCode;
replacementType;

}

class MutationFragment {
code;
location;
type;
}



0 comments on commit 5245944

Please sign in to comment.
You can’t perform that action at this time.