]>
Commit | Line | Data |
---|---|---|
752f6dcc EK |
1 | package no.uio.ifi.refaktor.benchmark; |
2 | ||
3 | import java.io.File; | |
4 | ||
5 | import no.uio.ifi.refaktor.analyze.AnalysisStatistics; | |
6 | ||
7 | import org.eclipse.core.resources.IProject; | |
8 | import org.eclipse.core.resources.IProjectDescription; | |
21ccebe6 EK |
9 | import org.eclipse.core.resources.IWorkspace; |
10 | import org.eclipse.core.resources.IWorkspaceDescription; | |
11 | import org.eclipse.core.resources.ResourcesPlugin; | |
752f6dcc EK |
12 | import org.eclipse.core.runtime.CoreException; |
13 | import org.eclipse.core.runtime.Path; | |
14 | import org.junit.Before; | |
15 | ||
16 | public abstract class AbstractSearchBasedExtractAndMoveMethodBenchmark { | |
17 | ||
18 | private static final String REPOSITORY_FOLDER = createAbsolutePathName(System.getProperty("user.home"), "ifi-stolz-refaktor"); | |
19 | private static final String PROJECT_PATH = createAbsolutePathName(REPOSITORY_FOLDER, "eclipse_source_code/eclipse.jdt.ui/org.eclipse.jdt.ui"); | |
20 | private static final int DELAY_IN_SECONDS = Integer.parseInt(System.getProperty("refaktor.delay", "0")); | |
c04ea8eb EK |
21 | private IProject project; |
22 | private AnalysisStatistics statistics; | |
752f6dcc EK |
23 | |
24 | private static Path createAbsolutePath(String directoryName, String fileName) { | |
25 | return new Path(createAbsolutePathName(directoryName, fileName)); | |
26 | } | |
27 | ||
28 | private static String createAbsolutePathName(String directoryName, String fileName) { | |
29 | return new File(new File(directoryName), fileName).getAbsolutePath(); | |
30 | } | |
31 | ||
32 | public AbstractSearchBasedExtractAndMoveMethodBenchmark() { | |
33 | super(); | |
34 | } | |
35 | ||
36 | @Before | |
37 | public void before() throws CoreException { | |
38 | project = ProjectImporter.deepImportProjectToCurrentWorkspace( | |
39 | createAbsolutePath(System.getProperty("refaktor.jdt", PROJECT_PATH), IProjectDescription.DESCRIPTION_FILE_NAME)); | |
21ccebe6 | 40 | turnOffAutobuild(); |
752f6dcc EK |
41 | sleep(); |
42 | statistics = new AnalysisStatistics(); | |
43 | statistics.reset(); | |
44 | } | |
45 | ||
21ccebe6 EK |
46 | private void turnOffAutobuild() { |
47 | IWorkspace workspace = ResourcesPlugin.getWorkspace(); | |
48 | IWorkspaceDescription description = workspace.getDescription(); | |
49 | description.setAutoBuilding(false); | |
50 | try { | |
51 | workspace.setDescription(description); | |
52 | } catch (CoreException e) { | |
53 | assert false; | |
54 | } | |
55 | } | |
56 | ||
752f6dcc EK |
57 | private void sleep() { |
58 | try { | |
59 | Thread.sleep(DELAY_IN_SECONDS*1000); | |
60 | } catch(InterruptedException ex) { | |
61 | Thread.currentThread().interrupt(); | |
62 | } | |
63 | } | |
64 | ||
c04ea8eb EK |
65 | protected IProject getProject() { |
66 | return project; | |
67 | } | |
68 | ||
69 | protected AnalysisStatistics getStatistics() { | |
70 | return statistics; | |
71 | } | |
752f6dcc | 72 | } |