]> git.uio.no Git - ifi-stolz-refaktor.git/commitdiff
Adding test using AspectJ for aliasing example
authorErlend Kristiansen <erlenkr@ifi.uio.no>
Tue, 18 Feb 2014 19:06:17 +0000 (20:06 +0100)
committerErlend Kristiansen <erlenkr@ifi.uio.no>
Tue, 18 Feb 2014 19:06:17 +0000 (20:06 +0100)
software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/.classpath [new file with mode: 0644]
software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/.project [new file with mode: 0644]
software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/src/no/uio/ifi/refaktor/aSimpleExampleAspectJ/example/C.java [new file with mode: 0644]
software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/src/no/uio/ifi/refaktor/aSimpleExampleAspectJ/example/X.java [new file with mode: 0644]
software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/test/no/uio/ifi/refaktor/aSimpleExampleAspectJ/test/ExampleTest.java [new file with mode: 0644]
software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/test/no/uio/ifi/refaktor/aSimpleExampleAspectJ/test/ExampleTestAspect.aj [new file with mode: 0644]

diff --git a/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/.classpath b/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/.classpath
new file mode 100644 (file)
index 0000000..f3cc2e5
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry excluding="src/|test/" kind="src" path=""/>
+       <classpathentry kind="src" path="test"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/no.uio.ifi.refaktor"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/.project b/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/.project
new file mode 100644 (file)
index 0000000..2d98b4c
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>no.uio.ifi.refaktor.aSimpleExampleAspectJ</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.ajdt.core.ajbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.ajdt.ui.ajnature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/src/no/uio/ifi/refaktor/aSimpleExampleAspectJ/example/C.java b/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/src/no/uio/ifi/refaktor/aSimpleExampleAspectJ/example/C.java
new file mode 100644 (file)
index 0000000..a2d9453
--- /dev/null
@@ -0,0 +1,10 @@
+package no.uio.ifi.refaktor.aSimpleExampleAspectJ.example;
+
+public class C {
+       public X x = new X();
+       
+       public void f() {
+               x.m(this);
+               x.n();
+       }
+}
diff --git a/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/src/no/uio/ifi/refaktor/aSimpleExampleAspectJ/example/X.java b/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/src/no/uio/ifi/refaktor/aSimpleExampleAspectJ/example/X.java
new file mode 100644 (file)
index 0000000..14fa8fc
--- /dev/null
@@ -0,0 +1,12 @@
+package no.uio.ifi.refaktor.aSimpleExampleAspectJ.example;
+
+public class X {
+
+       public void m(C c) {
+               c.x = new X();
+       }
+
+       public void n() {
+       }
+
+}
diff --git a/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/test/no/uio/ifi/refaktor/aSimpleExampleAspectJ/test/ExampleTest.java b/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/test/no/uio/ifi/refaktor/aSimpleExampleAspectJ/test/ExampleTest.java
new file mode 100644 (file)
index 0000000..55ee595
--- /dev/null
@@ -0,0 +1,17 @@
+package no.uio.ifi.refaktor.aSimpleExampleAspectJ.test;
+
+import static org.junit.Assert.assertTrue;
+import no.uio.ifi.refaktor.aSimpleExampleAspectJ.example.C;
+
+import org.junit.Test;
+
+public class ExampleTest {
+
+       @Test
+       public void test() {
+               new C().f();
+               boolean isOK = ExampleTestAspect.aspectOf().isOK();
+               assertTrue(isOK);
+       }
+
+}
diff --git a/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/test/no/uio/ifi/refaktor/aSimpleExampleAspectJ/test/ExampleTestAspect.aj b/software/no.uio.ifi.refaktor.aSimpleExampleAspectJ/test/no/uio/ifi/refaktor/aSimpleExampleAspectJ/test/ExampleTestAspect.aj
new file mode 100644 (file)
index 0000000..24c5abb
--- /dev/null
@@ -0,0 +1,26 @@
+package no.uio.ifi.refaktor.aSimpleExampleAspectJ.test;
+
+import no.uio.ifi.refaktor.aSimpleExampleAspectJ.example.C;
+import no.uio.ifi.refaktor.aSimpleExampleAspectJ.example.X;
+
+
+public aspect ExampleTestAspect {
+       private X xM;
+       private X xN;
+
+       pointcut f() : call(public void C.f());
+       pointcut m(C c) : cflow(f()) && call(public void X.m(C)) && args(c);
+       pointcut n(X x) : cflow(f()) && call(public void X.n()) && target(x);
+       
+       after(C c) returning() : m(c) {
+               xM = c.x;
+       }
+       
+       before(X x) : n(x) {
+               xN = x;
+       }
+       
+       public boolean isOK() {
+               return xM == xN ;
+       }
+}