diff --git a/src/test/java/bytecode/simplifyalgo/CycleTest.java b/src/test/java/bytecode/simplifyalgo/CycleTest.java deleted file mode 100644 index f847eff4..00000000 --- a/src/test/java/bytecode/simplifyalgo/CycleTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * - */ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; -import de.dhbwstuttgart.bytecode.utilities.Simplify; - -/** - * @author Fayez Abu Alia - * - */ -public class CycleTest { - - private static TPHExtractor tphExtractor; - private static String methName; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - tphExtractor = new TPHExtractor(); - // A < B - TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS); - // B < C - TPHConstraint c2 = new ExtendsConstraint("B", "C", Relation.EXTENDS); - // C < D - TPHConstraint c3 = new ExtendsConstraint("C", "D", Relation.EXTENDS); - // D < A - TPHConstraint c4 = new ExtendsConstraint("D", "A", Relation.EXTENDS); - // name - methName = "m"; - MethodAndTPH mtph = new MethodAndTPH("m"); - mtph.getTphs().add("A"); - mtph.getTphs().add("B"); - mtph.getTphs().add("C"); - mtph.getTphs().add("D"); - tphExtractor.ListOfMethodsAndTph.add(mtph); - tphExtractor.allCons.add(c1); - tphExtractor.allCons.add(c2); - tphExtractor.allCons.add(c3); - tphExtractor.allCons.add(c4); - - } - - @Test - public void test() { - HashMap> result = new HashMap<>(); - HashSet equals = new HashSet<>(); - equals.add("A"); - equals.add("B"); - equals.add("C"); - equals.add("D"); - TPHConstraint k = new ExtendsConstraint("A", Type.getInternalName(Object.class), Relation.EXTENDS); - result.put(k, equals); - - HashMap> sim = Simplify.simplifyConstraints(methName, tphExtractor,new ArrayList<>()); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - -} diff --git a/src/test/java/bytecode/simplifyalgo/FinderTest.java b/src/test/java/bytecode/simplifyalgo/FinderTest.java deleted file mode 100644 index edf43605..00000000 --- a/src/test/java/bytecode/simplifyalgo/FinderTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.ConstraintsFinder; -import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; -import de.dhbwstuttgart.bytecode.utilities.Simplify; -import de.dhbwstuttgart.typedeployment.TypeInsertPlacer; - -/** - * - * @author Fayez Abu Alia - * - */ -public class FinderTest { - - @Test - public void testM1() { - List allCons = new ArrayList<>(); - // L < M - TPHConstraint c1 = new ExtendsConstraint("L", "M", Relation.EXTENDS); - // L < N - TPHConstraint c2 = new ExtendsConstraint("L", "N", Relation.EXTENDS); - // M < O - TPHConstraint c3 = new ExtendsConstraint("M", "O", Relation.EXTENDS); - // M < P - TPHConstraint c4 = new ExtendsConstraint("M", "P", Relation.EXTENDS); - - allCons.add(c1); - allCons.add(c2); - allCons.add(c3); - allCons.add(c4); - List> res = new ArrayList<>(); - List l1 = new ArrayList<>(); - List l2 = new ArrayList<>(); - - l1.add(c1); - l1.add(c2); - - l2.add(c3); - l2.add(c4); - - res.add(l1); - res.add(l2); - - ConstraintsFinder finder = new ConstraintsFinder(allCons); - - assertEquals(finder.findConstraints(), res); - } - -} diff --git a/src/test/java/bytecode/simplifyalgo/SameLeftSide.java b/src/test/java/bytecode/simplifyalgo/SameLeftSide.java deleted file mode 100644 index 69d50c63..00000000 --- a/src/test/java/bytecode/simplifyalgo/SameLeftSide.java +++ /dev/null @@ -1,102 +0,0 @@ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; -import de.dhbwstuttgart.bytecode.utilities.Simplify; -import de.dhbwstuttgart.typedeployment.TypeInsertPlacer; - -/** -* -* @author Fayez Abu Alia -* -*/ -public class SameLeftSide { - // Typeplaceholders können nicht definiert werden, da die Konstruktor - // private ist => Test geht nicht - private static TPHExtractor tphExtractor; - private static String methName; - private static String methName2; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - tphExtractor = new TPHExtractor(); - // A < B - TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS); - // A < C - TPHConstraint c2 = new ExtendsConstraint("A", "C", Relation.EXTENDS); - // B < D - TPHConstraint c3 = new ExtendsConstraint("B", "D", Relation.EXTENDS); - // C < E - TPHConstraint c4 = new ExtendsConstraint("C", "E", Relation.EXTENDS); - // name - methName = "m1"; - MethodAndTPH m1 = new MethodAndTPH("m1"); - - methName2 = "m2"; - MethodAndTPH m2 = new MethodAndTPH("m2"); - - m1.getTphs().add("A"); - m1.getTphs().add("B"); - m1.getTphs().add("D"); - - m2.getTphs().add("C"); - m2.getTphs().add("E"); - - tphExtractor.ListOfMethodsAndTph.add(m1); - tphExtractor.ListOfMethodsAndTph.add(m2); - - tphExtractor.allCons.add(c1); - tphExtractor.allCons.add(c2); - tphExtractor.allCons.add(c3); - tphExtractor.allCons.add(c4); - } - - @Test - public void testM1() { - HashMap> result = new HashMap<>(); - - TPHConstraint d = new ExtendsConstraint("D", Type.getInternalName(Object.class), Relation.EXTENDS); - TPHConstraint a = new ExtendsConstraint("A", "D", Relation.EXTENDS); - TPHConstraint b = new ExtendsConstraint("B", "D", Relation.EXTENDS); - result.put(d, new HashSet<>()); - result.put(a, new HashSet<>()); - HashSet hs = new HashSet<>(); - - result.put(b, hs); - - HashMap> sim = Simplify.simplifyConstraints(methName, tphExtractor,new ArrayList<>()); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - - @Test - public void testM2() { - HashMap> result = new HashMap<>(); - - TPHConstraint e = new ExtendsConstraint("E", Type.getInternalName(Object.class), Relation.EXTENDS); - TPHConstraint c = new ExtendsConstraint("C", "E", Relation.EXTENDS); - - result.put(e, new HashSet<>()); - HashSet hs = new HashSet<>(); - hs.add("B"); - result.put(c, hs); - - HashMap> sim = Simplify.simplifyConstraints(methName2, tphExtractor,new ArrayList<>()); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - -} diff --git a/src/test/java/bytecode/simplifyalgo/SimpleCycle.java b/src/test/java/bytecode/simplifyalgo/SimpleCycle.java deleted file mode 100644 index 545b0514..00000000 --- a/src/test/java/bytecode/simplifyalgo/SimpleCycle.java +++ /dev/null @@ -1,80 +0,0 @@ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.Simplify; -/** - * - * @author Fayez Abu Alia - * - */ -public class SimpleCycle { - private static TPHExtractor tphExtractor; - private static String methName; - @BeforeClass - public static void setUpBeforeClass() throws Exception { - tphExtractor = new TPHExtractor(); - // A < B - TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS); - // B < A - TPHConstraint c2 = new ExtendsConstraint("B", "A", Relation.EXTENDS); - // name - methName = "m"; - tphExtractor.allCons.add(c1); - tphExtractor.allCons.add(c2); - - } - - @Test - public void test() { - HashMap> result = new HashMap<>(); - HashSet equals = new HashSet<>(); - equals.add("A"); - equals.add("B"); - TPHConstraint k = new ExtendsConstraint("B", Type.getInternalName(Object.class), Relation.EXTENDS); - result.put(k, equals); - - HashMap> sim = Simplify.simplifyConstraints(methName, tphExtractor,new ArrayList<>()); - boolean areEquals = areMapsEqual(result, sim); - assertTrue(areEquals); - } - - public static boolean areMapsEqual(HashMap> m1, HashMap> m2) { - - for(TPHConstraint c : m1.keySet()) { - for(TPHConstraint c2 : m2.keySet()) { - if(c.getLeft().equals(c2.getLeft()) && c.getRight().equals(c2.getRight()) && c.getRel()==c2.getRel()) { - HashSet eq1 = m1.get(c); - HashSet eq2 = m2.get(c2); - - if((eq1 == null && eq2 != null) || (eq1 != null && eq2 == null)) - return false; - if(eq1 != null) { - if(eq1.size() != eq2.size()) - return false; - - for(String tph:eq1) { - if(!eq2.contains(tph)) - return false; - } - } - } - } - - } - return true; - } - -}