Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Template for testing AspectJ queries.

  • Loading branch information...
commit 78c6366967bd7cff6ce82388b37ac05fc89b91e8 1 parent 6305a05
@cderoove authored
View
1  EkekoAspectJ/.classpath
@@ -3,6 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
<classpathentry exported="true" kind="lib" path="lib/dorothy-0.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/guava-11.0.2.jar"/>
<classpathentry kind="output" path="bin"/>
View
29 EkekoAspectJ/src/damp/ekeko/aspectj/AspectJProjectModel.java
@@ -21,8 +21,10 @@
import org.eclipse.ajdt.core.model.AJProjectModelFacade;
import org.eclipse.ajdt.core.model.AJProjectModelFactory;
import org.eclipse.ajdt.core.model.AJWorldFacade;
+import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -60,7 +62,7 @@ public CompilationUnit getCompilationUnitForAJCompilationUnit(AJCompilationUnit
- private void updateAJBuildInformation() {
+ private void updateAJBuildInformation() throws CoreException {
updateAJProjectFacade();
updateAJWorldFacade();
updateAJWorldAsSeenByWeaver();
@@ -74,6 +76,8 @@ private void updateAJWorldFacade() {
private void updateAJWorldAsSeenByWeaver() {
IProject p = getProject();
AjCompiler compiler = AspectJPlugin.getDefault().getCompilerFactory().getCompilerForProject(p);
+ //causes a NPE in ajde internals
+ //compiler.buildFresh();
AjState state = IncrementalStateManager.retrieveStateFor(compiler.getId());
if (state != null)
ajWorld = state.getAjBuildManager().getWorld();
@@ -81,12 +85,33 @@ private void updateAJWorldAsSeenByWeaver() {
ajWorld = null;
}
- private void updateAJProjectFacade() {
+ private void updateAJProjectFacade() throws CoreException {
IProject p = getProject();
System.out.println("Updating AspectJ project model facade for:" + p.getName());
ajFacade = AJProjectModelFactory.getInstance().getModelForProject(getProject());
+ if(!ajFacade.hasModel()) {
+ System.out.println("Forcing AspectJ re-build of project:" + p.getName());
+ performCleanProjectBuild();
+ }
}
+ private void performCleanProjectBuild() throws CoreException {
+ //does not have intended effect...
+ getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ /*
+ IProject p = getProject();
+ IBuildConfiguration[] buildConfigs = p.getBuildConfigs();
+ for(IBuildConfiguration bc : buildConfigs) {
+ if(bc instanceof org.eclipse.ajdt.internal.buildconfig.BuildConfiguration)
+ p.build(bc,IncrementalProjectBuilder.FULL_BUILD, null);
+
+ }
+
+ */
+
+ }
+
public AJProjectModelFacade getAJProjectFacade() {
return ajFacade;
}
View
75 EkekoAspectJ/test/test/damp/ekeko/aspectj.clj
@@ -0,0 +1,75 @@
+(ns test.damp.ekeko.aspectj
+ (:refer-clojure :exclude [== type declare])
+ (:use [clojure.core.logic :exclude [is]] :reload)
+ (:use [damp.ekeko logic])
+ (:use [damp.ekeko])
+ (:require
+ [damp.ekeko.workspace
+ [workspace :as ws]]
+ [damp.ekeko.aspectj
+ [soot :as soot]
+ [ajdt :as ajdt]
+ [xcut :as xcut]
+ [weaverworld :as world]
+ [assumptions :as assumptions]
+ ])
+ (:use clojure.test))
+
+;NOTE: do not forget to clean all tested projects before running the tests
+;TODO: fix that :)
+
+;see http://richhickey.github.com/clojure/clojure.test-api.html for api
+;followed http://twoguysarguing.wordpress.com/2010/03/24/fixies/ to workaround limitations regarding setup/teardown of in
+
+(defn
+ with-ekeko-disabled
+ [f]
+ (println "Disabling Ekeko nature on all projects.")
+ (ws/workspace-disable-ekeko!)
+ (ws/workspace-wait-for-builds-to-finish)
+ (f))
+
+(defn
+ against-project
+ [p f]
+ (try
+ (println "Enabling Ekeko nature on project: " p)
+ (ws/workspace-project-enable-ekeko! p)
+ (ws/workspace-wait-for-builds-to-finish)
+ (f)
+ (finally
+ (println "Disabling Ekeko nature on project: " p)
+ (ws/workspace-project-disable-ekeko! p))))
+
+(defn
+ against-project-named
+ [n f]
+ (against-project (ws/workspace-project-named n) f))
+
+
+(deftest
+ aspect-test
+ (let [grounding
+ (ekeko [?aspect]
+ (world/aspect ?aspect))
+ grounding-and-checking
+ (ekeko [?aspect]
+ (world/aspect ?aspect)
+ (world/aspect ?aspect))]
+ (is (> (count grounding) 0))
+ (is (empty? (clojure.set/difference (set grounding) (set grounding-and-checking))))))
+
+(deftest
+ test-suite
+ (against-project-named "AJ-LMP-Precedence" aspect-test)
+ (against-project-named "AJ-LMP-Wormhole" aspect-test))
+
+(defn
+ test-ns-hook
+ []
+ (with-ekeko-disabled test-suite))
+
+
+(comment
+ (run-tests)
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.