Permalink
Browse files

TestCases directory holds JDT projects for Ekeko tests.

  • Loading branch information...
1 parent 09c21d7 commit 3906db72bda52663a8a82ac7d18f6f9184796794 @cderoove committed Nov 7, 2012
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TestCase-JDT-CompositeVisitor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,11 @@
+package test.damp.ekeko.cases;
+
+public class Main {
+
+ public static void main(String[] args) {
+
+ test.damp.ekeko.cases.compositevisitor.TestCase.runTest();
+
+ }
+
+}
@@ -0,0 +1,9 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class Component {
+ public void addComponent(Component element) {
+ }
+
+ public void acceptVisitor(ComponentVisitor v) {
+ }
+}
@@ -0,0 +1,27 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class ComponentVisitor {
+ public void visitEmptyLeaf(Component c1) {
+ }
+
+ public void visitOnlyLoggingLeaf(Component c2) {
+
+ }
+
+ public void visitMustAliasLeaf(Component c3) {
+
+ }
+
+ public void visitMayAliasLeaf(Component c5) {
+
+ }
+
+ public void visitPrototypicalLeaf(Component c4) {
+
+ }
+
+ public void visitSuperLogLeaf(Component c4) {
+
+ }
+
+}
@@ -0,0 +1,27 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+public class Composite extends Component {
+
+ public List<Component> elements;
+
+ public Composite() {
+ elements = new LinkedList<Component>();
+ }
+
+ public void addComponent(Component element) {
+ elements.add(element);
+ }
+
+ public void acceptVisitor(ComponentVisitor v) {
+ Iterator<Component> i = elements.iterator();
+ while (i.hasNext()) {
+ Component comp = (Component) i.next();
+ comp.acceptVisitor(v);
+ }
+ }
+
+}
@@ -0,0 +1,5 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class EmptyLeaf extends Component {
+
+}
@@ -0,0 +1,22 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class MayAliasLeaf extends Component {
+
+ public int getInput() {
+ return 1;
+ }
+
+ public Object m(Object o) {
+ if(getInput() % 2 == 0)
+ return o;
+ else
+ return new MayAliasLeaf();
+ }
+
+ public void acceptVisitor(ComponentVisitor v) {
+ System.out.println("May alias.");
+ v.visitMayAliasLeaf((MayAliasLeaf)m(this));
+ }
+}
+
+
@@ -0,0 +1,9 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class MustAliasLeaf extends Component {
+ public void acceptVisitor(ComponentVisitor v) {
+ System.out.println("Must alias.");
+ Component temp = this;
+ v.visitMustAliasLeaf(temp);
+ }
+}
@@ -0,0 +1,7 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class OnlyLoggingLeaf extends Component {
+ public void acceptVisitor(ComponentVisitor v) {
+ System.out.println("Only logging.");
+ }
+}
@@ -0,0 +1,8 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class PrototypicalLeaf extends Component {
+ public void acceptVisitor(ComponentVisitor v) {
+ System.out.println("Prototypical.");
+ v.visitPrototypicalLeaf(this);
+ }
+}
@@ -0,0 +1,8 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class SuperLogLeaf extends OnlyLoggingLeaf {
+ public void acceptVisitor(ComponentVisitor v) {
+ super.acceptVisitor(v);
+ v.visitSuperLogLeaf(this);
+ }
+}
@@ -0,0 +1,16 @@
+package test.damp.ekeko.cases.compositevisitor;
+
+public class TestCase {
+ static public void runTest() {
+ Composite cs = new Composite();
+ cs.addComponent(new EmptyLeaf());
+ cs.addComponent(new MayAliasLeaf());
+ cs.addComponent(new MustAliasLeaf());
+ cs.addComponent(new OnlyLoggingLeaf());
+ cs.addComponent(new PrototypicalLeaf());
+ cs.addComponent(new SuperLogLeaf());
+ ComponentVisitor vstor = new ComponentVisitor();
+ cs.acceptVisitor(vstor);
+ System.out.println("done");
+ }
+}

0 comments on commit 3906db7

Please sign in to comment.