From 3e7b28ff4a91c94a9455a25ce88b36b3185d2d82 Mon Sep 17 00:00:00 2001 From: Jake Toronto Date: Sat, 16 Nov 2024 09:25:32 -0700 Subject: [PATCH 1/6] Make tests runnable in examples module --- sootup.examples/pom.xml | 15 ++++++++++++++- .../{BasicSetup.java => BasicSetupTest.java} | 2 +- ...yInterceptor.java => BodyInterceptorTest.java} | 2 +- ...raphExample.java => CallgraphExampleTest.java} | 12 +++++++++--- ...lassHierarchy.java => ClassHierarchyTest.java} | 2 +- ...gSootClass.java => MutatingSootClassTest.java} | 2 +- 6 files changed, 27 insertions(+), 8 deletions(-) rename sootup.examples/src/test/java/sootup/examples/basicSetup/{BasicSetup.java => BasicSetupTest.java} (98%) rename sootup.examples/src/test/java/sootup/examples/bodyInterceptor/{BodyInterceptor.java => BodyInterceptorTest.java} (98%) rename sootup.examples/src/test/java/sootup/examples/callgraph/{CallgraphExample.java => CallgraphExampleTest.java} (86%) rename sootup.examples/src/test/java/sootup/examples/classhierarchy/{ClassHierarchy.java => ClassHierarchyTest.java} (98%) rename sootup.examples/src/test/java/sootup/examples/mutatingSootClass/{MutatingSootClass.java => MutatingSootClassTest.java} (99%) diff --git a/sootup.examples/pom.xml b/sootup.examples/pom.xml index 0ac4edec49a..5ab90843d65 100644 --- a/sootup.examples/pom.xml +++ b/sootup.examples/pom.xml @@ -42,7 +42,12 @@ slf4j-simple test - + + org.junit.jupiter + junit-jupiter + 5.8.1 + test + @@ -55,6 +60,14 @@ true + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M9 + + + + diff --git a/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetup.java b/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetupTest.java similarity index 98% rename from sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetup.java rename to sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetupTest.java index 6d05d69125f..73185cc05ea 100644 --- a/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetup.java +++ b/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetupTest.java @@ -22,7 +22,7 @@ /** This example illustrates how to create and use a new Soot Project. */ @Tag("Java8") -public class BasicSetup { +public class BasicSetupTest { @Test public void createByteCodeProject() { diff --git a/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptor.java b/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptorTest.java similarity index 98% rename from sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptor.java rename to sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptorTest.java index 94bd87ab1a4..25e88994ef1 100644 --- a/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptor.java +++ b/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptorTest.java @@ -18,7 +18,7 @@ /** This example illustrates how to invoke body interceptors. */ @Tag("Java8") -public class BodyInterceptor { +public class BodyInterceptorTest { @Test public void test() { diff --git a/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExample.java b/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java similarity index 86% rename from sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExample.java rename to sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java index 9bdc89c6eac..ede26816223 100644 --- a/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExample.java +++ b/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; + import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import sootup.callgraph.CallGraph; @@ -18,7 +20,7 @@ import sootup.java.core.views.JavaView; @Tag("Java8") -public class CallgraphExample { +public class CallgraphExampleTest { @Test public void test() { @@ -46,12 +48,16 @@ public void test() { // Create type hierarchy and CHA final ViewTypeHierarchy typeHierarchy = new ViewTypeHierarchy(view); - System.out.println(typeHierarchy.subclassesOf(classTypeA)); + System.out.println("Subclasses of A: "); + typeHierarchy.subclassesOf(classTypeA).forEach(System.out::println); + CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(view); // Create CG by initializing CHA with entry method(s) CallGraph cg = cha.initialize(Collections.singletonList(entryMethodSignature)); - cg.callsFrom(entryMethodSignature).forEach(System.out::println); + System.out.println("Call Graph from B:"); + final Set calls = cg.callsFrom(entryMethodSignature); + calls.forEach(System.out::println); } } diff --git a/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java b/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchyTest.java similarity index 98% rename from sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java rename to sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchyTest.java index 6d7d631a106..3adbb97007e 100644 --- a/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java +++ b/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchyTest.java @@ -30,7 +30,7 @@ * This code example will show you how to build and examine a class hierarchy using sootup. */ @Tag("Java8") -public class ClassHierarchy { +public class ClassHierarchyTest { @Test public void test() { diff --git a/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClass.java b/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClassTest.java similarity index 99% rename from sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClass.java rename to sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClassTest.java index d4d607e99a5..2c8d7536a15 100644 --- a/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClass.java +++ b/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClassTest.java @@ -34,7 +34,7 @@ * @author Bastian Haverkamp */ @Tag("Java8") -public class MutatingSootClass { +public class MutatingSootClassTest { @Disabled public void test() { From fc047aac690fa05dd49564c6d94a46c63637a433 Mon Sep 17 00:00:00 2001 From: Jake Toronto Date: Sat, 16 Nov 2024 09:27:56 -0700 Subject: [PATCH 2/6] reformat examples pom --- sootup.examples/pom.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sootup.examples/pom.xml b/sootup.examples/pom.xml index 5ab90843d65..1dc1c740cc7 100644 --- a/sootup.examples/pom.xml +++ b/sootup.examples/pom.xml @@ -42,12 +42,12 @@ slf4j-simple test - - org.junit.jupiter - junit-jupiter - 5.8.1 - test - + + org.junit.jupiter + junit-jupiter + 5.8.1 + test + @@ -60,14 +60,14 @@ true - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M9 - - - - + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M9 + + + + From 3195695679175fccfd3f3d6a910543eb823eea74 Mon Sep 17 00:00:00 2001 From: Jake Toronto Date: Sat, 16 Nov 2024 09:25:32 -0700 Subject: [PATCH 3/6] Make tests runnable in examples module --- sootup.examples/pom.xml | 15 ++++++++++++++- .../{BasicSetup.java => BasicSetupTest.java} | 2 +- ...yInterceptor.java => BodyInterceptorTest.java} | 2 +- ...raphExample.java => CallgraphExampleTest.java} | 12 +++++++++--- ...lassHierarchy.java => ClassHierarchyTest.java} | 2 +- ...gSootClass.java => MutatingSootClassTest.java} | 2 +- 6 files changed, 27 insertions(+), 8 deletions(-) rename sootup.examples/src/test/java/sootup/examples/basicSetup/{BasicSetup.java => BasicSetupTest.java} (98%) rename sootup.examples/src/test/java/sootup/examples/bodyInterceptor/{BodyInterceptor.java => BodyInterceptorTest.java} (98%) rename sootup.examples/src/test/java/sootup/examples/callgraph/{CallgraphExample.java => CallgraphExampleTest.java} (86%) rename sootup.examples/src/test/java/sootup/examples/classhierarchy/{ClassHierarchy.java => ClassHierarchyTest.java} (98%) rename sootup.examples/src/test/java/sootup/examples/mutatingSootClass/{MutatingSootClass.java => MutatingSootClassTest.java} (99%) diff --git a/sootup.examples/pom.xml b/sootup.examples/pom.xml index 0ac4edec49a..5ab90843d65 100644 --- a/sootup.examples/pom.xml +++ b/sootup.examples/pom.xml @@ -42,7 +42,12 @@ slf4j-simple test - + + org.junit.jupiter + junit-jupiter + 5.8.1 + test + @@ -55,6 +60,14 @@ true + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M9 + + + + diff --git a/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetup.java b/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetupTest.java similarity index 98% rename from sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetup.java rename to sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetupTest.java index 6d05d69125f..73185cc05ea 100644 --- a/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetup.java +++ b/sootup.examples/src/test/java/sootup/examples/basicSetup/BasicSetupTest.java @@ -22,7 +22,7 @@ /** This example illustrates how to create and use a new Soot Project. */ @Tag("Java8") -public class BasicSetup { +public class BasicSetupTest { @Test public void createByteCodeProject() { diff --git a/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptor.java b/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptorTest.java similarity index 98% rename from sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptor.java rename to sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptorTest.java index 94bd87ab1a4..25e88994ef1 100644 --- a/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptor.java +++ b/sootup.examples/src/test/java/sootup/examples/bodyInterceptor/BodyInterceptorTest.java @@ -18,7 +18,7 @@ /** This example illustrates how to invoke body interceptors. */ @Tag("Java8") -public class BodyInterceptor { +public class BodyInterceptorTest { @Test public void test() { diff --git a/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExample.java b/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java similarity index 86% rename from sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExample.java rename to sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java index 9bdc89c6eac..ede26816223 100644 --- a/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExample.java +++ b/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; + import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import sootup.callgraph.CallGraph; @@ -18,7 +20,7 @@ import sootup.java.core.views.JavaView; @Tag("Java8") -public class CallgraphExample { +public class CallgraphExampleTest { @Test public void test() { @@ -46,12 +48,16 @@ public void test() { // Create type hierarchy and CHA final ViewTypeHierarchy typeHierarchy = new ViewTypeHierarchy(view); - System.out.println(typeHierarchy.subclassesOf(classTypeA)); + System.out.println("Subclasses of A: "); + typeHierarchy.subclassesOf(classTypeA).forEach(System.out::println); + CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(view); // Create CG by initializing CHA with entry method(s) CallGraph cg = cha.initialize(Collections.singletonList(entryMethodSignature)); - cg.callsFrom(entryMethodSignature).forEach(System.out::println); + System.out.println("Call Graph from B:"); + final Set calls = cg.callsFrom(entryMethodSignature); + calls.forEach(System.out::println); } } diff --git a/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java b/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchyTest.java similarity index 98% rename from sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java rename to sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchyTest.java index 6d7d631a106..3adbb97007e 100644 --- a/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java +++ b/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchyTest.java @@ -30,7 +30,7 @@ * This code example will show you how to build and examine a class hierarchy using sootup. */ @Tag("Java8") -public class ClassHierarchy { +public class ClassHierarchyTest { @Test public void test() { diff --git a/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClass.java b/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClassTest.java similarity index 99% rename from sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClass.java rename to sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClassTest.java index d4d607e99a5..2c8d7536a15 100644 --- a/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClass.java +++ b/sootup.examples/src/test/java/sootup/examples/mutatingSootClass/MutatingSootClassTest.java @@ -34,7 +34,7 @@ * @author Bastian Haverkamp */ @Tag("Java8") -public class MutatingSootClass { +public class MutatingSootClassTest { @Disabled public void test() { From 6d4fa6186fe8d7118c9043aec1bcc7aadc3bbd7c Mon Sep 17 00:00:00 2001 From: Jake Toronto Date: Sat, 16 Nov 2024 09:27:56 -0700 Subject: [PATCH 4/6] reformat examples pom --- sootup.examples/pom.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sootup.examples/pom.xml b/sootup.examples/pom.xml index 5ab90843d65..1dc1c740cc7 100644 --- a/sootup.examples/pom.xml +++ b/sootup.examples/pom.xml @@ -42,12 +42,12 @@ slf4j-simple test - - org.junit.jupiter - junit-jupiter - 5.8.1 - test - + + org.junit.jupiter + junit-jupiter + 5.8.1 + test + @@ -60,14 +60,14 @@ true - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M9 - - - - + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M9 + + + + From 77bde6d75a45b9973af11876c3e3c6f8313915ff Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Mon, 6 Jan 2025 10:48:17 +0100 Subject: [PATCH 5/6] make use of dependencyManagement, update to latest junit-jupiter version, style --- pom.xml | 10 ++++++++-- sootup.examples/pom.xml | 1 - .../examples/callgraph/CallgraphExampleTest.java | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3793711e98d..b19fc0073f0 100644 --- a/pom.xml +++ b/pom.xml @@ -441,16 +441,22 @@ + + org.junit.jupiter + junit-jupiter + 5.10.3 + test + org.junit.jupiter junit-jupiter-api - 5.10.2 + 5.10.3 test org.junit.jupiter junit-jupiter-engine - 5.10.2 + 5.10.3 test diff --git a/sootup.examples/pom.xml b/sootup.examples/pom.xml index 1dc1c740cc7..760b43d6455 100644 --- a/sootup.examples/pom.xml +++ b/sootup.examples/pom.xml @@ -45,7 +45,6 @@ org.junit.jupiter junit-jupiter - 5.8.1 test diff --git a/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java b/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java index ede26816223..12be8c8dae9 100644 --- a/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java +++ b/sootup.examples/src/test/java/sootup/examples/callgraph/CallgraphExampleTest.java @@ -4,7 +4,6 @@ import java.util.Collections; import java.util.List; import java.util.Set; - import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import sootup.callgraph.CallGraph; From f1bca76925f317258fc4128355fd2d276ae55d6f Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Mon, 6 Jan 2025 11:37:05 +0100 Subject: [PATCH 6/6] fix doc: include path --- docs/docguide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docguide.md b/docs/docguide.md index f19078db664..5540124542e 100644 --- a/docs/docguide.md +++ b/docs/docguide.md @@ -11,5 +11,5 @@ this enables that tutorial code can be tested and will fail if its not up to date anymore :) ``` -{{ include('basicSetup/BasicSetup.java')}} +{{ include('basicSetup/BasicSetupTest.java')}} ``` \ No newline at end of file