aboutsummaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
authormkersten <mkersten>2004-02-19 16:02:06 +0000
committermkersten <mkersten>2004-02-19 16:02:06 +0000
commit669cd7ce8634623c004cca5732c94a20fd7f57f7 (patch)
tree9053ca410a5e6e0352d89a08f6551cbb712b57f0 /ajde
parent4e4a50e91244deafc41ed5fc3c25c3848e4d1551 (diff)
downloadaspectj-669cd7ce8634623c004cca5732c94a20fd7f57f7.tar.gz
aspectj-669cd7ce8634623c004cca5732c94a20fd7f57f7.zip
Fixed bug#45489 "Structure model is wrong when re-opened"
Diffstat (limited to 'ajde')
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java104
2 files changed, 105 insertions, 0 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index a6c7b740d..22905ca8f 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -33,6 +33,7 @@ public class AjdeTests extends TestCase {
suite.addTestSuite(InpathTestcase.class);
suite.addTestSuite(ResourceCopyTestCase.class);
suite.addTestSuite(ModelPerformanceTest.class);
+ suite.addTestSuite(SavedModelConsistencyTest. class);
//$JUnit-END$
return suite;
diff --git a/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java b/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java
new file mode 100644
index 000000000..e74b2fc90
--- /dev/null
+++ b/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java
@@ -0,0 +1,104 @@
+
+
+/* *******************************************************************
+ * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+package org.aspectj.ajde;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.aspectj.asm.HierarchyWalker;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
+
+/**
+ * @author Mik Kersten
+ */
+public class SavedModelConsistencyTest extends AjdeTestCase {
+
+ private final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
+
+ public SavedModelConsistencyTest(String name) {
+ super(name);
+ }
+
+ public static void main(String[] args) {
+ junit.swingui.TestRunner.run(SavedModelConsistencyTest.class);
+ }
+
+ public void testInterfaceIsSameInBoth() {
+ File configFile = openFile(CONFIG_FILE_PATH);
+ Ajde.getDefault().getStructureModelManager().readStructureModel(configFile.getAbsolutePath());
+
+ IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
+ assertTrue("model exists", model != null);
+
+ assertTrue("root exists", model.getRoot() != null);
+ File testFile = openFile("../examples/coverage/ModelCoverage.java");
+ assertTrue(testFile.exists());
+
+ IProgramElement nodePreBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);
+// System.err.println(nodePreBuild.getKind());
+
+ doSynchronousBuild(CONFIG_FILE_PATH);
+
+ IProgramElement nodePostBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);
+// System.err.println(nodePostBuild.getKind());
+
+ assertTrue(nodePreBuild.getKind().equals(nodePostBuild.getKind()));
+
+ }
+
+ public void testModelIsSamePreAndPostBuild() {
+ File configFile = openFile(CONFIG_FILE_PATH);
+ Ajde.getDefault().getStructureModelManager().readStructureModel(configFile.getAbsolutePath());
+
+ IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
+ assertTrue("model exists", model != null);
+
+ final List preBuildKinds = new ArrayList();
+ HierarchyWalker walker = new HierarchyWalker() {
+ public void preProcess(IProgramElement node) {
+ preBuildKinds.add(node.getKind());
+ }
+ };
+ Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker);
+
+ doSynchronousBuild(CONFIG_FILE_PATH);
+
+ final List postBuildKinds = new ArrayList();
+ HierarchyWalker walker2 = new HierarchyWalker() {
+ public void preProcess(IProgramElement node) {
+ postBuildKinds.add(node.getKind());
+ }
+ };
+ Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker2);
+
+// System.err.println(preBuildKinds);
+// System.err.println(postBuildKinds);
+
+ assertTrue(preBuildKinds.equals(postBuildKinds));
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp("examples");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
+