diff options
author | wisberg <wisberg> | 2002-12-16 17:58:19 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 17:58:19 +0000 |
commit | d842c4f1139629c1f062b74ba818d233b2c31043 (patch) | |
tree | 842d3871620bc0eb60edcd95e55804d67e0f61fa /ajde/testsrc | |
parent | 3ce247199704eae6b2c92c6e38c69584e3250c52 (diff) | |
download | aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.tar.gz aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.zip |
initial version
Diffstat (limited to 'ajde/testsrc')
22 files changed, 1467 insertions, 0 deletions
diff --git a/ajde/testsrc/AjdeModuleTests.java b/ajde/testsrc/AjdeModuleTests.java new file mode 100644 index 000000000..c26330ed9 --- /dev/null +++ b/ajde/testsrc/AjdeModuleTests.java @@ -0,0 +1,31 @@ +/* ******************************************************************* + * Copyright (c) 1999-2001 Xerox Corporation, + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +// default package + +import junit.framework.*; + +public class AjdeModuleTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AjdeModuleTests.class.getName()); + suite.addTest(org.aspectj.ajde.AjdeTests.suite()); + suite.addTest(org.aspectj.ajde.internal.AjdeInternalTests.suite()); + suite.addTest(org.aspectj.ajde.ui.AjdeUiTests.suite()); + return suite; + } + + public AjdeModuleTests(String name) { super(name); } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java new file mode 100644 index 000000000..8561f04d6 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java @@ -0,0 +1,65 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import java.io.*; +import junit.framework.TestCase; + +public class AjdeTestCase extends TestCase { + + private static final String TEST_DATA_PATH = "testdata"; + //private static final String TEST_DATA_PATH = "C:/Dev/aspectj/modules/ajde/testdata"; + + protected NullIdeManager ideManager = new NullIdeManager(); + protected TestBuildListener testerBuildListener = new TestBuildListener(); + protected String currTestDataPath; + + public AjdeTestCase(String name) { + super(name); + } + + protected File createFile(String path) { + return new File(currTestDataPath + File.separatorChar + path); + } + + /** + * Waits on the build complete. + */ + protected void doSynchronousBuild(String configFilePath) { + testerBuildListener.reset(); + File configFile = createFile(configFilePath); + Ajde.getDefault().getBuildManager().build(configFile.getAbsolutePath()); + while(!testerBuildListener.getBuildFinished()) { + try { + Thread.sleep(300); + } catch (InterruptedException ie) { } + } + } + + protected void setUp(String testDataPath) throws Exception { + currTestDataPath = TEST_DATA_PATH + File.separatorChar + testDataPath; + ideManager.init(currTestDataPath); + super.setUp(); + Ajde.getDefault().getBuildManager().addListener(testerBuildListener); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + protected String genStructureModelExternFilePath(String configFilePath) { + return configFilePath.substring(0, configFilePath.lastIndexOf(".lst")) + ".ajsym"; + } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java new file mode 100644 index 000000000..d2cd8fe9f --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -0,0 +1,34 @@ +/* ******************************************************************* + * Copyright (c) 1999-2001 Xerox Corporation, + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import junit.framework.*; + +public class AjdeTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AjdeTests.class.getName()); + //$JUnit-BEGIN$ + suite.addTestSuite(BuildOptionsTest.class); + suite.addTestSuite(StructureModelRegressionTest.class); + suite.addTestSuite(StructureModelTest.class); + suite.addTestSuite(VersionTest.class); + //$JUnit-END$ + return suite; + } + + public AjdeTests(String name) { super(name); } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java b/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java new file mode 100644 index 000000000..5f5df1329 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java @@ -0,0 +1,63 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import junit.framework.TestSuite; + +import org.aspectj.ajde.ui.UserPreferencesAdapter; +import org.aspectj.ajde.ui.internal.AjcBuildOptions; +import org.aspectj.ajde.ui.internal.UserPreferencesStore; + +public class BuildOptionsTest extends AjdeTestCase { + + private AjcBuildOptions buildOptions = null; + private UserPreferencesAdapter preferencesAdapter = null; + + public BuildOptionsTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(BuildOptionsTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(BuildOptionsTest.class); + return result; + } + + public void testCharacterEncoding() { + buildOptions.setCharacterEncoding("mumble"); + assertTrue("character encoding", buildOptions.getCharacterEncoding().equals("mumble")); + } + + public void testPortingMode() { + buildOptions.setPortingMode(true); + assertTrue("porting mode", buildOptions.getPortingMode()); + } + + protected void setUp() throws Exception { + super.setUp(); + preferencesAdapter = new UserPreferencesStore(); + buildOptions = new AjcBuildOptions(preferencesAdapter); + } + + protected void tearDown() throws Exception { + super.tearDown(); + buildOptions.setCharacterEncoding(""); + buildOptions.setPortingMode(true); + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java new file mode 100644 index 000000000..2269fcaba --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java @@ -0,0 +1,54 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import javax.swing.JFrame; + +import org.aspectj.ajde.ui.IdeUIAdapter; +import org.aspectj.ajde.ui.UserPreferencesAdapter; +import org.aspectj.ajde.ui.internal.UserPreferencesStore; +import org.aspectj.ajde.ui.swing.*; + +/** + * @author Mik Kersten + */ +public class NullIdeManager { + + public void init(String testProjectPath) { + try { + UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(); + ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath); + TaskListManager taskListManager = new NullIdeTaskListManager(); + BasicEditor ajdeEditor = new BasicEditor(); + IdeUIAdapter uiAdapter = new NullIdeUIAdapter(); + JFrame nullFrame = new JFrame(); + //configurationManager.setConfigFiles(getConfigFilesList(configFiles)); + + AjdeUIManager.getDefault().init( + ajdeEditor, + taskListManager, + browserProjectProperties, + preferencesAdapter, + uiAdapter, + new IconRegistry(), + nullFrame, + true); + } catch (Throwable t) { + t.printStackTrace(); + Ajde.getDefault().getErrorHandler().handleError( + "Null IDE failed to initialize.", + t); + } + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java new file mode 100644 index 000000000..0369954f8 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java @@ -0,0 +1,87 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import java.io.File; +import java.util.*; + +/** + * @author Mik Kersten + */ +public class NullIdeProperties implements ProjectPropertiesAdapter { + + private String testProjectPath = ""; + private List buildConfigFiles = new ArrayList(); + + public NullIdeProperties(String testProjectPath) { + this.testProjectPath = testProjectPath; + } + + public List getBuildConfigFiles() { + return buildConfigFiles; + } + + public String getLastActiveBuildConfigFile() { + return null; + } + + public String getDefaultBuildConfigFile() { + return null; + } + + public String getProjectName() { + return "test"; + } + + public String getRootProjectDir() { + return testProjectPath; + } + + public List getProjectSourceFiles() { + return null; + } + + public String getProjectSourcePath() { + return testProjectPath + "/src"; + } + + public String getClasspath() { + //XXX + return testProjectPath + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../../../runtime/bin"; + } + + public String getOutputPath() { + return testProjectPath + "/bin"; + } + + public String getAjcWorkingDir() { + return testProjectPath + "/ajworkingdir"; + } + + public String getBootClasspath() { + return null; + } + + public String getClassToExecute() { + return "figures.Main"; + } + + public String getExecutionArgs() { + return null; + } + + public String getVmArgs() { + return null; + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java new file mode 100644 index 000000000..44566ff32 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java @@ -0,0 +1,38 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import org.aspectj.bridge.*; + +/** + * Used for displaying tasks, such as compiler messages, to the user. + * + * @author Mik Kersten + */ +public class NullIdeTaskListManager implements TaskListManager { + + public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind) { + System.out.println("> added sourceline task: " + message + ", file: " + sourceLocation.getSourceFile().getAbsolutePath() + + ": " + sourceLocation.getLine()); + } + + public void addProjectTask(String message, IMessage.Kind kind) { + System.out.println("> added project task: " + message + ", kind: " + kind); + } + + public void clearTasks() { + System.out.println("> cleared tasks"); + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java b/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java new file mode 100644 index 000000000..78549b895 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java @@ -0,0 +1,27 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import org.aspectj.ajde.ui.*; + +public class NullIdeUIAdapter implements IdeUIAdapter { + + public void displayStatusInformation(String message) { + System.out.println("> status message: " + message); + } + + public void resetGUI() { + // not implemented + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java new file mode 100644 index 000000000..4acc5673e --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java @@ -0,0 +1,32 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + +package org.aspectj.ajde; + +public class SimpleStructureModelTest extends AjdeTestCase { + + private String CONFIG_FILE_PATH = "test.lst"; + + public SimpleStructureModelTest(String name) { + super(name); + } + + public void testModel() { + + } + + protected void setUp() throws Exception { + super.setUp("SimpleStructureModelTest"); + doSynchronousBuild(CONFIG_FILE_PATH); + } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java new file mode 100644 index 000000000..be06bdf20 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java @@ -0,0 +1,87 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import java.io.File; + +import junit.framework.TestSuite; + +import org.aspectj.asm.StructureModel; + +public class StructureModelRegressionTest extends AjdeTestCase { + + public StructureModelRegressionTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(StructureModelRegressionTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(StructureModelRegressionTest.class); + return result; + } + + public void test() { + String testLstFile = "StructureModelRegressionTest/example.lst"; + File f = new File(testLstFile); + assertTrue(testLstFile, f.canRead()); + assertTrue("saved model: " + testLstFile, verifyAgainstSavedModel(testLstFile)); + } + + public boolean verifyAgainstSavedModel(String lstFile) { + File modelFile = new File(genStructureModelExternFilePath(lstFile)); + StructureModel model = getModelForFile(lstFile); + System.out.println(">> model: " + model.getRoot()); + + if (modelFile.exists()) { + Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile); + StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getStructureModel(); + //System.err.println( savedModel.getRoot().getClass() + ", " + savedModel.getRoot()); + + return savedModel.getRoot().equals(model.getRoot()); + } else { + Ajde.getDefault().getStructureModelManager().writeStructureModel(lstFile); + return true; + } + //return true; + } + + private StructureModel getModelForFile(String lstFile) { + Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile); + Ajde.getDefault().getBuildManager().buildStructure(); + while(!testerBuildListener.getBuildFinished()) { + try { + Thread.sleep(300); + } catch (InterruptedException ie) { } + } + return Ajde.getDefault().getStructureModelManager().getStructureModel(); + } + + protected void setUp() throws Exception { + super.setUp("StructureModelRegressionTest"); + Ajde.getDefault().getStructureModelManager().setShouldSaveModel(false); + } + + public void testModelExists() { + assertTrue(Ajde.getDefault().getStructureModelManager().getStructureModel() != null); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java new file mode 100644 index 000000000..244a26b25 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java @@ -0,0 +1,145 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + +package org.aspectj.ajde; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import junit.framework.TestSuite; + +import org.aspectj.asm.*; + +/** + * @author Mik Kersten + */ +public class StructureModelTest extends AjdeTestCase { + + private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst"; + + public StructureModelTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(StructureModelTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(StructureModelTest.class); + return result; + } + + public void testFieldInitializerCorrespondence() throws IOException { + File testFile = createFile("../examples/figures-coverage/figures/Figure.java"); + StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + testFile.getCanonicalPath(), 28); + assertTrue("find result", node != null) ; + ProgramElementNode pNode = (ProgramElementNode)node; + ProgramElementNode foundNode = null; + final List list = pNode.getRelations(); + assertNotNull("pNode.getRelations()", list); + for (Iterator it = list.iterator(); it.hasNext(); ) { + RelationNode relation = (RelationNode)it.next(); + if (relation.getRelation().equals(AdviceAssociation.FIELD_ACCESS_RELATION)) { + for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) { + LinkNode linkNode = (LinkNode)it2.next(); + if (linkNode.getProgramElementNode().getName().equals("this.currVal = 0")) { + foundNode = linkNode.getProgramElementNode(); + } + } + } + } + + assertTrue("find associated node", foundNode != null) ; + + File pointFile = createFile("../examples/figures-coverage/figures/primitives/planar/Point.java"); + StructureNode fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + pointFile.getCanonicalPath(), 12); + assertTrue("find result", fieldNode != null); + + assertTrue("matches", foundNode.getParent() == fieldNode.getParent()); + } + + public void testFileNodeFind() throws IOException { + File testFile = createFile("../examples/figures-coverage/figures/Main.java"); + StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + testFile.getCanonicalPath(), 1); + assertTrue("find result", node != null) ; + ProgramElementNode pNode = (ProgramElementNode)node; + assertTrue("found node: " + pNode.getName(), pNode.getProgramElementKind().equals(ProgramElementNode.Kind.FILE_JAVA)); + } + + /** + * @todo add negative test to make sure things that aren't runnable aren't annotated + */ + public void testMainClassNodeInfo() throws IOException { + assertTrue("root exists", Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot() != null); + File testFile = createFile("../examples/figures-coverage/figures/Main.java"); + StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + testFile.getCanonicalPath(), 11); + assertTrue("find result", node != null); + + ProgramElementNode pNode = (ProgramElementNode)((ProgramElementNode)node).getParent(); + assertTrue("found node: " + pNode.getName(), pNode.isRunnable()); + } + + /** + * Integrity could be checked somewhere in the API. + */ + public void testModelIntegrity() { + StructureNode modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + assertTrue("root exists", modelRoot != null); + + try { + testModelIntegrityHelper(modelRoot); + } catch (Exception e) { + assertTrue(e.toString(), false); + } + } + + private void testModelIntegrityHelper(StructureNode node) throws Exception { + for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { + StructureNode child = (StructureNode)it.next(); + if (node == child.getParent()) { + testModelIntegrityHelper(child); + } else { + throw new Exception("parent-child check failed for child: " + child.toString()); + } + } + } + + public void testNoChildIsNull() { + ModelWalker walker = new ModelWalker() { + public void preProcess(StructureNode node) { + if (node.getChildren() == null) return; + for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { + if (it.next() == null) throw new NullPointerException("null child on node: " + node.getName()); + } + } + }; + Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot().walk(walker); + } + + protected void setUp() throws Exception { + super.setUp("StructureModelTest"); + doSynchronousBuild(CONFIG_FILE_PATH); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/TestBuildListener.java b/ajde/testsrc/org/aspectj/ajde/TestBuildListener.java new file mode 100644 index 000000000..c53feed45 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/TestBuildListener.java @@ -0,0 +1,45 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + + +public class TestBuildListener implements BuildListener { + + public boolean buildFinished = false; + public boolean buildSucceeded = false; + + public void reset() { + buildFinished = false; + } + + public void compileStarted(String buildConfigFile) { } + + public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) { + int timeInSeconds = buildTime/1000; + buildSucceeded = succeeded; + buildFinished = true; + } + + public void compileAborted(String buildConfigFile, String message) { } + + public boolean getBuildFinished() { + return buildFinished; + } + + public boolean getBuildSucceeded() { + return buildSucceeded; + } +} + + diff --git a/ajde/testsrc/org/aspectj/ajde/VersionTest.java b/ajde/testsrc/org/aspectj/ajde/VersionTest.java new file mode 100644 index 000000000..6e8617005 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/VersionTest.java @@ -0,0 +1,49 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde; + +import junit.framework.TestSuite; + +import org.aspectj.bridge.Version; + +/** + * @author Mik Kersten + */ +public class VersionTest extends AjdeTestCase { + + public VersionTest(String name) { + super(name); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(VersionTest.class); + return result; + } + + public void testVersionMatch() { + String ajdeVersion = Ajde.getDefault().getVersion(); + String compilerVersion = Version.text; + System.out.println("> ajde version: " + ajdeVersion + " <-> compiler version: " + compilerVersion); + assertTrue("version check", ajdeVersion.equals(compilerVersion)); + } + + protected void setUp() throws Exception { + super.setUp(""); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java b/ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java new file mode 100644 index 000000000..b910fd686 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java @@ -0,0 +1,32 @@ +/* ******************************************************************* + * Copyright (c) 1999-2001 Xerox Corporation, + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.internal; + +import junit.framework.*; + +public class AjdeInternalTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AjdeInternalTests.class.getName()); + //$JUnit-BEGIN$ + suite.addTestSuite(AspectJBuildManagerTest.class); + suite.addTestSuite(LstBuildConfigManagerTest.class); + //$JUnit-END$ + return suite; + } + + public AjdeInternalTests(String name) { super(name); } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/internal/AspectJBuildManagerTest.java b/ajde/testsrc/org/aspectj/ajde/internal/AspectJBuildManagerTest.java new file mode 100644 index 000000000..569fa6ef7 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/internal/AspectJBuildManagerTest.java @@ -0,0 +1,80 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.internal; + +import junit.framework.*; +import org.aspectj.ajde.*; +import java.io.*; + +/** + * @author Mik Kersten + */ +public class AspectJBuildManagerTest extends AjdeTestCase { + + public AspectJBuildManagerTest(String name) { + super(name); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(AspectJBuildManagerTest.class); + return result; + } + + public void testInit() { + assertTrue("initialization", ideManager != null); + } + + public void testCompileNonExistingConfig() { + assertTrue("compile of non-existing build config success", !testerBuildListener.getBuildSucceeded()); + } + + public void testCompileEmptyConfig() { + doSynchronousBuild("empty.lst"); + assertTrue("compile of empty build config success", testerBuildListener.getBuildSucceeded()); + } + + public void testCompileSuccess() { + doSynchronousBuild("../examples/figures-coverage/all.lst"); + assertTrue("compile success", testerBuildListener.getBuildSucceeded()); + } + + public void testCompileOutput() { + File classFile = new File(Ajde.getDefault().getProjectProperties().getOutputPath() + "/figures/Main.class"); + if (classFile != null) { + assertTrue("class file generated", classFile.exists()); + classFile.delete(); + } else { + assertTrue("class file generated", false); + } + } + + public void testSymbolFileGenerated() { + File symFile = createFile("../examples/figures-coverage/all.ajsym"); + if (symFile != null) { + assertTrue("sym file generated", symFile.exists()); + symFile.delete(); + } else { + assertTrue("sym file generated", false); + } + } + + protected void setUp() throws Exception { + super.setUp("AspectJBuildManagerTest"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java b/ajde/testsrc/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java new file mode 100644 index 000000000..5d9f78af8 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -0,0 +1,157 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.internal; + +import java.io.File; +import java.io.IOException; +import java.util.*; + +import junit.framework.TestSuite; + +import org.aspectj.ajde.AjdeTestCase; +import org.aspectj.ajde.BuildConfigManager; +import org.aspectj.ajde.ui.BuildConfigModel; +import org.aspectj.ajde.ui.internal.AjcBuildOptions; + +public class LstBuildConfigManagerTest extends AjdeTestCase { + + private AjcBuildOptions buildOptions = null; + private BuildConfigManager buildConfigManager = new LstBuildConfigManager(); + private LstBuildConfigFileUpdater fileUpdater = new LstBuildConfigFileUpdater(); + + public LstBuildConfigManagerTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(LstBuildConfigManagerTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(LstBuildConfigManagerTest.class); + return result; + } + + public void testNonExistentConfigFile() throws IOException { + File file = createFile("mumbleDoesNotExist.lst"); + assertTrue("valid non-existing file", !file.exists()); + BuildConfigModel model = buildConfigManager.buildModel(file.getCanonicalPath()); + System.err.println(model.getRoot().getChildren()); + assertTrue("root: " + model.getRoot(), model.getRoot() != null); + } + + public void testFileRelativePathSameDir() throws IOException { + File file = createFile("file-relPath-sameDir.lst"); + System.err.println("> " + file.getCanonicalPath()); + BuildConfigModel model = buildConfigManager.buildModel(file.getCanonicalPath()); + System.err.println("> " + model.getRoot()); + assertTrue("single file", true); + } + +// public void testWildcards() { +// verifyFile(WILDCARDS_FILE, WILDCARDS_FILE_CONTENTS); +// } +// +// public void testIncludes() { +// verifyFile(INCLUDES_FILE, INCLUDES_FILE_CONTENTS); +// } + + private void verifyFile(String configFile, String fileContents) { + StringTokenizer st = new StringTokenizer(fileContents, ";"); + BuildConfigModel model1 = buildConfigManager.buildModel(configFile); + File testFile = new File(configFile + "-test.lst"); + model1.setSourceFile(testFile.getPath()); + buildConfigManager.writeModel(model1); + List newList = fileUpdater.readConfigFile(testFile.getPath()); + testFile.delete(); + + assertTrue("contents: " + newList, verifyLists(st, newList)); + } + + private boolean verifyLists(StringTokenizer st, List list) { + Iterator it = list.iterator(); + while (st.hasMoreElements()) { + String s1 = (String)st.nextElement(); + System.out.print("comparing: " + s1 + " <-> "); + String s2 = (String)it.next(); + System.out.println(s2); + if (!s1.equals(s2)) return false; + } + if (it.hasNext()) { + return false; + } else { + return true; + } + } + + protected void setUp() throws Exception { + super.setUp("LstBuildConfigManagerTest"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + private static final String WILDCARDS_FILE = "C:/Dev/aspectj/tests/ajde/examples/figures-coverage/test-config.lst"; + private static final String BAD_PATHS_FILE = "C:/Dev/aspectj/tests/ajde/examples/figures-coverage/test-error.lst"; + private static final String INCLUDES_FILE = "C:/Dev/aspectj/tests/ajde/examples/spacewar/spacewar/demo.lst"; + + private static final String WILDCARDS_FILE_CONTENTS; + private static final String BAD_PATHS_FILE_CONTENTS; + private static final String INCLUDES_FILE_CONTENTS; + + static { + WILDCARDS_FILE_CONTENTS = + "figures/Debug.java;" + + "figures/Figure.java;" + + "figures/FigureElement.java;" + + "figures/Main.java;" + + "figures/composites/Line.java;" + + "figures/composites/Square.java;" + + "figures/primitives/planar/Point.java;" + + "figures/primitives/solid/SolidPoint.java;"; + + BAD_PATHS_FILE_CONTENTS = WILDCARDS_FILE_CONTENTS; + + INCLUDES_FILE_CONTENTS = + "../coordination/Condition.java;" + + "../coordination/CoordinationAction.java;" + + "../coordination/Coordinator.java;" + + "../coordination/Exclusion.java;" + + "../coordination/MethodState.java;" + + "../coordination/Mutex.java;" + + "../coordination/Selfex.java;" + + "../coordination/TimeoutException.java;" + + "Bullet.java;" + + "Display.java;" + + "Display1.java;" + + "Display2.java;" + + "EnergyPacket.java;" + + "EnergyPacketProducer.java;" + + "EnsureShipIsAlive.java;" + + "Game.java;" + + "GameSynchronization.java;" + + "Pilot.java;" + + "Player.java;" + + "Registry.java;" + + "RegistrySynchronization.java;" + + "Robot.java;" + + "SWFrame.java;" + + "Ship.java;" + + "SpaceObject.java;" + + "Timer.java;"; + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/ui/AjdeUiTests.java b/ajde/testsrc/org/aspectj/ajde/ui/AjdeUiTests.java new file mode 100644 index 000000000..d717a09e1 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ui/AjdeUiTests.java @@ -0,0 +1,33 @@ +/* ******************************************************************* + * Copyright (c) 1999-2001 Xerox Corporation, + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + +import junit.framework.*; + +public class AjdeUiTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AjdeUiTests.class.getName()); + //$JUnit-BEGIN$ + suite.addTestSuite(StructureModelUtilTest.class); + suite.addTestSuite(StructureSearchManagerTest.class); + suite.addTestSuite(StructureViewManagerTest.class); + //$JUnit-END$ + return suite; + } + + public AjdeUiTests(String name) { super(name); } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java new file mode 100644 index 000000000..5127387b7 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java @@ -0,0 +1,39 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + + +/** + * @author Mik Kersten + */ +public class NullIdeFileStructureView extends FileStructureView { + + private String sourceFilePath = null; + + public NullIdeFileStructureView(StructureViewProperties viewProperties) { + super(viewProperties); + } + public String getSourceFile() { + return sourceFilePath; + } + + public void setSourceFile(String sourceFile) { + this.sourceFilePath = sourceFile; + } + + public void setRootNode(StructureViewNode rootNode) { + super.setRootNode(rootNode); + notifyViewUpdated(); + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java new file mode 100644 index 000000000..d013e76d7 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java @@ -0,0 +1,44 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + + +/** + * @author Mik Kersten + */ +public class NullIdeStructureViewRenderer implements StructureViewRenderer { + + private boolean hasBeenNotified = false; + + public void updateView(StructureView structureView) { + hasBeenNotified = true; + } + + public void setActiveNode(StructureViewNode node) { + // ignored + } + + public void setActiveNode(StructureViewNode node, int lineOffset) { + // ignored + } + + public boolean getHasBeenNotified() { + return hasBeenNotified; + } + + public void setHasBeenNotified(boolean hasBeenNotified) { + this.hasBeenNotified = hasBeenNotified; + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java new file mode 100644 index 000000000..0a0ee544d --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java @@ -0,0 +1,78 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + +import java.util.*; + +import junit.framework.TestSuite; + +import org.aspectj.ajde.AjdeTestCase; +import org.aspectj.asm.ProgramElementNode; + +/** + * @author Mik Kersten + */ +public class StructureModelUtilTest extends AjdeTestCase { + + private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst"; + + public StructureModelUtilTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(StructureModelUtilTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(StructureModelUtilTest.class); + return result; + } + + public void testPackageViewUtil() { + List packages = StructureModelUtil.getPackagesInModel(); + assertTrue("packages list not null", packages != null); + System.err.println("> packages: " + packages); + + ProgramElementNode packageNode = (ProgramElementNode)((Object[])packages.get(0))[0]; + assertTrue("package node not null", packageNode != null); + System.err.println("> package node: " + packageNode); + + List files = StructureModelUtil.getFilesInPackage(packageNode); + assertTrue("fle list not null", files != null); + System.err.println("> file list: " + files); + + Map lineAdviceMap = StructureModelUtil.getLinesToAspectMap( + ((ProgramElementNode)files.get(0)).getSourceLocation().getSourceFile().getAbsolutePath() + ); + assertTrue("line->advice map not null", lineAdviceMap != null); + System.err.println("> line->advice map: " + lineAdviceMap); + + Set aspects = StructureModelUtil.getAspectsAffectingPackage(packageNode); + assertTrue("aspect list not null", aspects != null); + System.err.println("> aspects affecting package: " + aspects); + } + + + protected void setUp() throws Exception { + super.setUp("StructureModelUtilTest"); + doSynchronousBuild(CONFIG_FILE_PATH); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java new file mode 100644 index 000000000..418a4743b --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java @@ -0,0 +1,80 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + +import java.util.List; + +import junit.framework.TestSuite; + +import org.aspectj.ajde.Ajde; +import org.aspectj.ajde.AjdeTestCase; +import org.aspectj.asm.ProgramElementNode; + +/** + * @author Mik Kersten + */ +public class StructureSearchManagerTest extends AjdeTestCase { + + private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst"; + + public StructureSearchManagerTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(StructureSearchManagerTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(StructureSearchManagerTest.class); + return result; + } + + public void testFindPatternMatch() { + List matches = Ajde.getDefault().getStructureSearchManager().findMatches( + "Point", + null + ); + System.err.println(matches); + assertTrue("non existent node", true); + } + + public void testFindPatternAndKindMatch() { + List matches = Ajde.getDefault().getStructureSearchManager().findMatches( + "Point", + ProgramElementNode.Kind.CONSTRUCTOR + ); + System.err.println(matches); + assertTrue("non existent node", true); + } + + public void testFindNonExistent() { + List matches = Ajde.getDefault().getStructureSearchManager().findMatches( + "mumbleNodeDesNotExist", + null + ); + assertTrue("non existent", matches.isEmpty()); + } + + protected void setUp() throws Exception { + super.setUp("StructureSearchManagerTest"); + doSynchronousBuild(CONFIG_FILE_PATH); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} + diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java new file mode 100644 index 000000000..e6b7f8ae9 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java @@ -0,0 +1,167 @@ +/* ******************************************************************* + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + +import java.io.File; +import java.util.Iterator; + +import junit.framework.TestSuite; + +import org.aspectj.ajde.Ajde; +import org.aspectj.ajde.AjdeTestCase; +import org.aspectj.asm.StructureModelManager; +import org.aspectj.asm.StructureNode; + +/** + * @author Mik Kersten + */ +public class StructureViewManagerTest extends AjdeTestCase { + + private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst"; + private final String CONFIG_FILE_PATH_2 = "../examples/inheritance/inheritance.lst"; + + private FileStructureView currentView; + private NullIdeStructureViewRenderer renderer = new NullIdeStructureViewRenderer(); + private File testFile; + private StructureViewProperties properties; + + public StructureViewManagerTest(String name) { + super(name); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(StructureViewManagerTest.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(StructureViewManagerTest.class); + return result; + } + + public void testModelExists() { + assertTrue(Ajde.getDefault().getStructureModelManager().getStructureModel() != null); + } + + public void testNotificationAfterConfigFileChange() { + doSynchronousBuild(CONFIG_FILE_PATH_2); + renderer.setHasBeenNotified(false); + assertTrue("not yet notified", !renderer.getHasBeenNotified()); + Ajde.getDefault().getConfigurationManager().setActiveConfigFile(CONFIG_FILE_PATH_2); + assertTrue("notified", renderer.getHasBeenNotified()); + renderer.setHasBeenNotified(false); + Ajde.getDefault().getConfigurationManager().setActiveConfigFile("MumbleDoesNotExist.lst"); + assertTrue("notified", renderer.getHasBeenNotified()); + assertTrue( + "no structure", + currentView.getRootNode().getStructureNode().getChildren().get(0) + == StructureModelManager.INSTANCE.getStructureModel().NO_STRUCTURE + ); + } + + /** + * @todo this should be moved to a StructureModelManager test + */ + public void testFreshStructureModelCreation() { + renderer.setHasBeenNotified(false); + String modelPath = genStructureModelExternFilePath(CONFIG_FILE_PATH); + createFile(modelPath).delete(); + //System.err.println("> path: " + modelPath); + + Ajde.getDefault().getStructureModelManager().readStructureModel(CONFIG_FILE_PATH); + + assertTrue("notified", renderer.getHasBeenNotified()); + //System.err.println(">>>>>> " + currentView.getRootNode().getStructureNode()); + assertTrue( + "no structure", + currentView.getRootNode().getStructureNode().getChildren().get(0) + == StructureModelManager.INSTANCE.getStructureModel().NO_STRUCTURE + ); + } + + public void testModelIntegrity() { + doSynchronousBuild(CONFIG_FILE_PATH); + StructureNode modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + assertTrue("root exists", modelRoot != null); + + try { + testModelIntegrityHelper(modelRoot); + } catch (Exception e) { + assertTrue(e.toString(), false); + } + } + + private void testModelIntegrityHelper(StructureNode node) throws Exception { + for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { + StructureNode child = (StructureNode)it.next(); + if (node == child.getParent()) { + testModelIntegrityHelper(child); + } else { + throw new Exception("parent-child check failed for child: " + child.toString()); + } + } + } + + public void testNotificationAfterBuild() { + renderer.setHasBeenNotified(false); + doSynchronousBuild(CONFIG_FILE_PATH); + assertTrue("notified", renderer.getHasBeenNotified()); + } + + public void testViewCreationWithNullSourceFileAndProperties() { + currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(null, null); + assertTrue( + "no structure", + currentView.getRootNode().getStructureNode() + == StructureModelManager.INSTANCE.getStructureModel().NO_STRUCTURE + ); + } + + protected void setUp() throws Exception { + super.setUp("StructureViewManagerTest"); + doSynchronousBuild(CONFIG_FILE_PATH); + + properties = Ajde.getDefault().getStructureViewManager().getDefaultViewProperties(); + testFile = createFile("../examples/figures-coverage/figures/Figure.java"); + currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(testFile.getAbsolutePath(), properties); + currentView.setRenderer(renderer); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + +// public void testViewListenerRegistrations() { +// System.err.println("> starting..."); +// Ajde.getDefault().getBuildManager().build("C:/Dev/aspectj/tests/ajde/examples/coverage-figures/src/AllFiles.lst"); +// while(!testerBuildListener.getBuildFinished()) { +// try { +// Thread.sleep(300); +// } catch (InterruptedException ie) { } +// } +// List renderers = Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView().getRenderers(); +// System.err.println("> renderers (1): " + renderers); +// +// testerBuildListener.reset(); +// Ajde.getDefault().getBuildManager().build("C:/Dev/aspectj/tests/ajde/examples/coverage-figures/src/AllFiles.lst"); +// while(!testerBuildListener.getBuildFinished()) { +// try { +// Thread.sleep(300); +// } catch (InterruptedException ie) { } +// } +// System.err.println("> renderers (2): " + renderers); +// assertTrue("checking renderers", true); +// } +} + |