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());
}
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);
}
}
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());
}
}
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);
}
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());
}
Aggregations