Search in sources :

Example 1 with KiekerConfig

use of de.dagere.peass.config.KiekerConfig 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 KiekerConfig

use of de.dagere.peass.config.KiekerConfig in project peass by DaGeRe.

the class TestPeassFilter method testExecution.

@Test
public void testExecution() throws ViewNotFoundException, IOException, XmlPullParserException, InterruptedException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    Assume.assumeFalse(EnvironmentVariables.isWindows());
    PeassFolders folders = new PeassFolders(CURRENT);
    final KiekerResultManager manager = new KiekerResultManager(folders, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
    final TestSet testset = new TestSet();
    final TestCase testcase = new TestCase("defaultpackage.TestMe", "testMe", "");
    testset.addTest(testcase);
    final ModuleClassMapping mapping = new ModuleClassMapping(manager.getExecutor());
    final List<TraceElement> referenceTrace = regenerateTrace(manager, testset, testcase, mapping, 0);
    for (int i = 1; i <= 3; i++) {
        final List<TraceElement> compareTrace = regenerateTrace(manager, testset, testcase, mapping, i);
        checkRegeneratedTrace(referenceTrace, compareTrace);
    }
}
Also used : EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ModuleClassMapping(de.dagere.peass.dependency.analysis.ModuleClassMapping) TraceElement(de.dagere.peass.dependency.analysis.data.TraceElement) KiekerResultManager(de.dagere.peass.dependency.KiekerResultManager) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) KiekerConfig(de.dagere.peass.config.KiekerConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 3 with KiekerConfig

use of de.dagere.peass.config.KiekerConfig in project peass by DaGeRe.

the class TraceGettingIT method executeReading.

public static void executeReading(final TestCase testcase, final File clazzDir, final Map<String, List<File>> traceFileMap, final String githash, final File kiekerResultFolder) throws ParseException, IOException {
    final ArrayList<TraceElement> shortTrace = new CalledMethodLoader(kiekerResultFolder, ModuleClassMapping.SINGLE_MODULE_MAPPING, new KiekerConfig()).getShortTrace("");
    LOG.debug("Short Trace: {}", shortTrace.size());
    final TraceMethodReader traceMethodReader = new TraceMethodReader(shortTrace, new File(TestConstants.CURRENT_FOLDER, "src/main/java"), new File(TestConstants.CURRENT_FOLDER, "src/java"), new File(TestConstants.CURRENT_FOLDER, "src/test/java"), new File(TestConstants.CURRENT_FOLDER, "src/test"));
    final TraceWithMethods trace = traceMethodReader.getTraceWithMethods();
    List<File> traceFile = traceFileMap.get(testcase.getMethod());
    if (traceFile == null) {
        traceFile = new LinkedList<>();
        traceFileMap.put(testcase.getMethod(), traceFile);
    }
    if (!clazzDir.exists()) {
        clazzDir.mkdirs();
    }
    final File currentTraceFile = new File(clazzDir, testcase.getMethod() + "_hash_" + githash);
    traceFile.add(currentTraceFile);
    try (final FileWriter fw = new FileWriter(currentTraceFile)) {
        fw.write(trace.getWholeTrace());
    }
    final File methodTrace = new File(clazzDir, testcase.getMethod() + "_hash_" + githash + "_method");
    try (final FileWriter fw = new FileWriter(methodTrace)) {
        LOG.debug("Methoden: " + trace.getTraceMethods().length());
        fw.write(trace.getTraceMethods());
    }
}
Also used : FileWriter(java.io.FileWriter) TraceElement(de.dagere.peass.dependency.analysis.data.TraceElement) TraceWithMethods(de.dagere.peass.dependency.traces.TraceWithMethods) KiekerConfig(de.dagere.peass.config.KiekerConfig) TraceMethodReader(de.dagere.peass.dependency.traces.TraceMethodReader) File(java.io.File) CalledMethodLoader(de.dagere.peass.dependency.analysis.CalledMethodLoader)

Example 4 with KiekerConfig

use of de.dagere.peass.config.KiekerConfig in project peass by DaGeRe.

the class TestGenerateDependencies method testGenerateDependencies.

@Test
public void testGenerateDependencies() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
    final FakeFileIterator iterator = new FakeFileIterator(TestConstants.CURRENT_FOLDER, Arrays.asList(TraceGettingIT.REPETITION));
    ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
    final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, VersionKeeper.INSTANCE, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
    final boolean success = reader.readInitialVersion();
    Assert.assertTrue(success);
    iterator.goToNextCommit();
    final ChangeManager manager = Mockito.mock(ChangeManager.class);
    final HashMap<ChangedEntity, ClazzChangeData> value = new HashMap<>();
    ChangedEntity testMeEntity = new ChangedEntity("viewtest.TestMe", "");
    value.put(testMeEntity, new ClazzChangeData(testMeEntity, false));
    Mockito.when(manager.getChanges(Mockito.any())).thenReturn(value);
    final int tests = reader.analyseVersion(manager);
    LOG.debug(Constants.OBJECTMAPPER.writeValueAsString(reader.getDependencies()));
    Assert.assertEquals(1, tests);
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) HashMap(java.util.HashMap) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) ChangeManager(de.dagere.peass.dependency.ChangeManager) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ResultsFolders(de.dagere.peass.folders.ResultsFolders) KiekerConfig(de.dagere.peass.config.KiekerConfig) Test(org.junit.jupiter.api.Test)

Example 5 with KiekerConfig

use of de.dagere.peass.config.KiekerConfig in project peass by DaGeRe.

the class DependencyDetectorIT method testClassChange.

@Test
public void testClassChange() throws Exception {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "changed_class");
    final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
    changes.put(new ChangedEntity("defaultpackage.NormalDependency", ""), new ClazzChangeData("defaultpackage.NormalDependency", false));
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
    final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(DependencyTestConstants.CURRENT), DependencyTestConstants.NULL_RESULTS_FOLDERS, null, fakeIterator, changeManager, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
    final boolean success = reader.readInitialVersion();
    Assert.assertTrue(success);
    final StaticTestSelection dependencies = reader.getDependencies();
    System.out.println(dependencies);
    fakeIterator.goToNextCommit();
    reader.analyseVersion(changeManager);
    final TestSet testMe = DependencyDetectorTestUtil.findDependency(dependencies, "defaultpackage.NormalDependency", DependencyTestConstants.VERSION_1);
    System.out.println(testMe);
    final ChangedEntity change = dependencies.getVersions().get(DependencyTestConstants.VERSION_1).getChangedClazzes().keySet().iterator().next();
    Assert.assertEquals("defaultpackage.NormalDependency", change.toString());
    Assert.assertEquals("defaultpackage.TestMe#testMe", testMe.getTests().iterator().next().getExecutable());
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) TreeMap(java.util.TreeMap) PeassFolders(de.dagere.peass.folders.PeassFolders) ChangeManager(de.dagere.peass.dependency.ChangeManager) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) VersionIterator(de.dagere.peass.vcs.VersionIterator) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Aggregations

KiekerConfig (de.dagere.peass.config.KiekerConfig)34 PeassFolders (de.dagere.peass.folders.PeassFolders)22 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)21 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)21 File (java.io.File)21 Test (org.junit.jupiter.api.Test)18 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)9 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)7 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)7 ChangeManager (de.dagere.peass.dependency.ChangeManager)5 CalledMethodLoader (de.dagere.peass.dependency.analysis.CalledMethodLoader)5 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)5 TraceElement (de.dagere.peass.dependency.analysis.data.TraceElement)5 ResultsFolders (de.dagere.peass.folders.ResultsFolders)5 VersionIteratorGit (de.dagere.peass.vcs.VersionIteratorGit)5 MeasurementConfig (de.dagere.peass.config.MeasurementConfig)4 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)4 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)4 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)4 VersionIterator (de.dagere.peass.vcs.VersionIterator)4