Search in sources :

Example 1 with TraceMethodReader

use of de.dagere.peass.dependency.traces.TraceMethodReader in project peass by DaGeRe.

the class TestTraceMethodReader method testTraceLengthSimpleFor.

@Test
public void testTraceLengthSimpleFor() throws ParseException, IOException {
    System.out.println("Searching: " + SLF4J_API_JAR + " " + new File(SLF4J_API_JAR).exists());
    System.out.println("Searching: " + SLF4J_IMPL_JAR + " " + new File(SLF4J_IMPL_JAR).exists());
    String jarPath = getJarPath();
    String agentPath = getAgentPath();
    final ProcessBuilder builder = new ProcessBuilder("java", "-javaagent:" + agentPath, "-Dorg.aspectj.weaver.loadtime.configuration=file:src" + File.separator + "test" + File.separator + "resources" + File.separator + "aop.xml", "-cp", jarPath, "de.peass.example.CallerSimpleFor");
    System.out.println("Command: " + builder.command());
    final Process process = builder.start();
    StreamGobbler.showFullProcess(process);
    final File[] kiekerFolders = tmpFolder.listFiles((FileFilter) new WildcardFileFilter("kieker-*"));
    final File traceFolder = kiekerFolders[0];
    // 
    final TraceMethodReader reader = new TraceMethodReader(new CalledMethodLoader(traceFolder, ModuleClassMapping.SINGLE_MODULE_MAPPING, new KiekerConfig()).getShortTrace(""), new File("src" + File.separator + "test" + File.separator + "java"));
    final TraceWithMethods trace = reader.getTraceWithMethods();
    System.out.println(trace.getWholeTrace());
    /*
       * Trace: 20 Methodenaufrufe -> 10 sonstige -> 10 mal Schleife callMe2 -> müsste auf 1 Eintrag (callMe2, *10 Aufrufe) zusammenfasst werden -> Ziel: 11 Aufrufe
       */
    Assert.assertEquals(11, trace.getLength());
}
Also used : TraceWithMethods(de.dagere.peass.dependency.traces.TraceWithMethods) File(java.io.File) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter) TraceMethodReader(de.dagere.peass.dependency.traces.TraceMethodReader) KiekerConfig(de.dagere.peass.config.KiekerConfig) CalledMethodLoader(de.dagere.peass.dependency.analysis.CalledMethodLoader) Test(org.junit.jupiter.api.Test)

Example 2 with TraceMethodReader

use of de.dagere.peass.dependency.traces.TraceMethodReader in project peass by DaGeRe.

the class TestTraceReading method testSimpleTraceReading.

@Test
public void testSimpleTraceReading() throws ParseException, IOException {
    final TraceMethodReader tmr = new TraceMethodReader(new File(EXAMPLE_TRACE_FOLDER, "simple"), ModuleClassMapping.SINGLE_MODULE_MAPPING, EXAMPLE_SOURCE_FOLDER);
    // The path to the kieker-trace-data (first argument) and the path to the classes must match
    final TraceWithMethods trace = tmr.getTraceWithMethods();
    LOG.info("Trace length: " + trace.getLength());
    for (int i = 0; i < trace.getLength(); i++) {
        LOG.info(trace.getTraceElement(i));
        LOG.info(trace.getMethod(i));
    }
    Assert.assertNull(trace.getMethod(1));
    Assert.assertEquals(trace.getMethod(0).substring(0, trace.getMethod(0).indexOf("\n")), "public static void main(final String[] args) {");
    Assert.assertEquals(trace.getMethod(5).substring(0, trace.getMethod(5).indexOf("\n")), "private void main(final int z) {");
    Assert.assertEquals(trace.getMethod(6).substring(0, trace.getMethod(6).indexOf("\n")), "private void main(final String z) {");
}
Also used : TraceWithMethods(de.dagere.peass.dependency.traces.TraceWithMethods) TraceMethodReader(de.dagere.peass.dependency.traces.TraceMethodReader) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with TraceMethodReader

use of de.dagere.peass.dependency.traces.TraceMethodReader in project peass by DaGeRe.

the class TestSequiturSerialization method testDeepRepetition3.

@Test
public void testDeepRepetition3() throws ParseException, IOException {
    final List<TraceElement> calls = new LinkedList<>();
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < 5; i++) {
            calls.add(new TraceElement("CalleeSimpleFor", "methodA", 0));
            calls.add(new TraceElement("CalleeSimpleFor", "methodB", 0));
            for (int k = 0; k < 5; k++) {
                calls.add(new TraceElement("CalleeSimpleFor", "method1", 0));
                calls.add(new TraceElement("CalleeSimpleFor", "method2", 0));
            }
            calls.add(new TraceElement("CalleeSimpleFor", "methodG", 0));
        }
        calls.add(new TraceElement("CalleeSimpleFor", "methodC", 0));
        calls.add(new TraceElement("CalleeSimpleFor", "methodD", 0));
    }
    calls.add(new TraceElement("CalleeSimpleFor", "methodE", 0));
    final TraceMethodReader reader = new TraceMethodReader(calls, new File("src/test/java/"));
    final TraceWithMethods trace = reader.getTraceWithMethods();
    testTrace(calls, trace);
}
Also used : TraceElement(de.dagere.peass.dependency.analysis.data.TraceElement) TraceWithMethods(de.dagere.peass.dependency.traces.TraceWithMethods) TraceMethodReader(de.dagere.peass.dependency.traces.TraceMethodReader) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 4 with TraceMethodReader

use of de.dagere.peass.dependency.traces.TraceMethodReader in project peass by DaGeRe.

the class TestTraceMinimization method testSimple4NestedLoop.

@Test
public void testSimple4NestedLoop() throws ParseException, IOException {
    final List<TraceElement> calls = new LinkedList<>();
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            calls.add(new TraceElement("CalleeSimpleFor", "methodA", 0));
            calls.add(new TraceElement("CalleeSimpleFor", "methodB", 0));
            calls.add(new TraceElement("CalleeSimpleFor", "methodC", 0));
            calls.add(new TraceElement("CalleeSimpleFor", "methodD", 0));
        }
        calls.add(new TraceElement("CalleeSimpleFor", "methodC", 0));
    }
    final TraceMethodReader reader = new TraceMethodReader(calls, new File("src/test/java/"));
    final TraceWithMethods trace = reader.getTraceWithMethods();
    System.out.println("trace");
    System.out.println(trace);
    Assert.assertEquals(" (6)", trace.getTraceElement(0).toString());
    Assert.assertEquals(3, trace.getTraceOccurences(0));
    Assert.assertEquals(" (4)", trace.getTraceElement(1).toString());
    Assert.assertEquals(3, trace.getTraceOccurences(1));
    Assert.assertEquals("CalleeSimpleFor#methodA", trace.getTraceElement(2).toString());
    Assert.assertEquals("CalleeSimpleFor#methodB", trace.getTraceElement(3).toString());
    Assert.assertEquals("CalleeSimpleFor#methodC", trace.getTraceElement(4).toString());
    Assert.assertEquals("CalleeSimpleFor#methodD", trace.getTraceElement(5).toString());
    Assert.assertEquals("CalleeSimpleFor#methodC", trace.getTraceElement(6).toString());
}
Also used : TraceElement(de.dagere.peass.dependency.analysis.data.TraceElement) TraceWithMethods(de.dagere.peass.dependency.traces.TraceWithMethods) TraceMethodReader(de.dagere.peass.dependency.traces.TraceMethodReader) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 5 with TraceMethodReader

use of de.dagere.peass.dependency.traces.TraceMethodReader in project peass by DaGeRe.

the class TestTraceMinimization method testTwoMethodLoop.

@Test
public void testTwoMethodLoop() throws ParseException, IOException {
    final List<TraceElement> calls = new LinkedList<>();
    calls.add(new TraceElement("CalleeSimpleFor", "methodA", 0));
    calls.add(new TraceElement("CalleeSimpleFor", "methodB", 0));
    calls.add(new TraceElement("CalleeSimpleFor", "methodC", 0));
    calls.add(new TraceElement("CalleeSimpleFor", "methodB", 0));
    calls.add(new TraceElement("CalleeSimpleFor", "methodC", 0));
    calls.add(new TraceElement("CalleeSimpleFor", "methodB", 0));
    calls.add(new TraceElement("CalleeSimpleFor", "methodC", 0));
    final TraceMethodReader reader = new TraceMethodReader(calls, new File("src/test/java/"));
    final TraceWithMethods trace = reader.getTraceWithMethods();
    System.out.println();
    System.out.println("Trace");
    System.out.println(trace);
    Assert.assertEquals("CalleeSimpleFor#methodA", trace.getTraceElement(0).toString());
    Assert.assertEquals(" (2)", trace.getTraceElement(1).toString());
    // Assert.assertEquals("#0 (2)", trace.getTraceElement(1).toString());
    Assert.assertEquals("CalleeSimpleFor#methodB", trace.getTraceElement(2).toString());
    Assert.assertEquals("CalleeSimpleFor#methodC", trace.getTraceElement(3).toString());
    // Assert.assertEquals("methodB", trace.getTraceElement(1).getMethod());
    // Assert.assertEquals("methodC", trace.getTraceElement(2).getMethod());
    Assert.assertEquals(3, trace.getTraceOccurences(1));
}
Also used : TraceElement(de.dagere.peass.dependency.analysis.data.TraceElement) TraceWithMethods(de.dagere.peass.dependency.traces.TraceWithMethods) TraceMethodReader(de.dagere.peass.dependency.traces.TraceMethodReader) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Aggregations

TraceMethodReader (de.dagere.peass.dependency.traces.TraceMethodReader)16 TraceWithMethods (de.dagere.peass.dependency.traces.TraceWithMethods)16 File (java.io.File)16 Test (org.junit.jupiter.api.Test)15 TraceElement (de.dagere.peass.dependency.analysis.data.TraceElement)12 LinkedList (java.util.LinkedList)11 KiekerConfig (de.dagere.peass.config.KiekerConfig)3 CalledMethodLoader (de.dagere.peass.dependency.analysis.CalledMethodLoader)3 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)2 FileWriter (java.io.FileWriter)1