From 7c9d27a39c17e765a4f59fffd52ff568b958d907 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 15 Jan 2007 08:44:55 +0000 Subject: [PATCH] 148190#32 --- .../ajde/internal/AjdeInternalTests.java | 32 ---- .../internal/AspectJBuildManagerTest.java | 35 ++--- .../internal/LstBuildConfigManagerTest.java | 139 +++--------------- 3 files changed, 36 insertions(+), 170 deletions(-) delete mode 100644 ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java diff --git a/ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java b/ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java deleted file mode 100644 index 6b716bab1..000000000 --- a/ajde/testsrc/org/aspectj/ajde/internal/AjdeInternalTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/* ******************************************************************* - * 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 Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-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 index 7d2fd7aa3..41c2aec9f 100644 --- a/ajde/testsrc/org/aspectj/ajde/internal/AspectJBuildManagerTest.java +++ b/ajde/testsrc/org/aspectj/ajde/internal/AspectJBuildManagerTest.java @@ -7,7 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Xerox/PARC initial implementation + * Xerox/PARC initial implementation + * Helen Hawkins Converted to new interface (bug 148190) * ******************************************************************/ @@ -24,10 +25,6 @@ import java.io.*; */ public class AspectJBuildManagerTest extends AjdeTestCase { - public AspectJBuildManagerTest(String name) { - super(name); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(AspectJBuildManagerTest.class); @@ -37,15 +34,17 @@ public class AspectJBuildManagerTest extends AjdeTestCase { public void testSequence() { AsmManager.dumpModelPostBuild=true; // or you wont get a .ajsym file try { - assertTrue("initialization", ideManager != null); - assertTrue("compile of non-existing build config success", !testerBuildListener.getBuildSucceeded()); // XXX should fail? empty configs fail b/c no sources specified - doSynchronousBuild("empty.lst"); - assertTrue("compile of empty build config", testerBuildListener.getBuildSucceeded()); + initialiseProject("AspectJBuildManagerTest"); + doBuild("empty.lst"); + assertTrue("Expected there to be no error messages from the build but found that" + + " there were some " + getErrorMessages("empty.lst"),getErrorMessages("empty.lst").isEmpty()); // TODO-path - doSynchronousBuild("../examples/figures-coverage/all.lst"); - assertTrue("compile success", testerBuildListener.getBuildSucceeded()); - File file = new File(Ajde.getDefault().getProjectProperties().getOutputPath() + "/figures/Main.class"); + initialiseProject("figures-coverage"); + doBuild("all.lst"); + assertTrue("Expected there to be no error messages from the build but found that" + + " there were some " + getErrorMessages("empty.lst"),getErrorMessages("empty.lst").isEmpty()); + File file = new File(getCompilerForConfigFileWithName("all.lst").getCompilerConfiguration().getOutputLocationManager().getDefaultOutputLocation() + "/figures/Main.class"); if (file.exists()) { file.delete(); } else { @@ -53,22 +52,14 @@ public class AspectJBuildManagerTest extends AjdeTestCase { } // TODO-path - file = openFile("../examples/figures-coverage/all.ajsym"); + file = openFile("all.ajsym"); if (file.exists()) { file.delete(); } else { - assertTrue("expected .ajsym" + file, false); + assertTrue("expected .ajsym: " + file, false); } } finally { AsmManager.dumpModelPostBuild=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 index 1154dd4f1..902c34d62 100644 --- a/ajde/testsrc/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java +++ b/ajde/testsrc/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -7,32 +7,26 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Xerox/PARC initial implementation + * Xerox/PARC initial implementation + * Helen Hawkins Converted to new interface (bug 148190) * ******************************************************************/ package org.aspectj.ajde.internal; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.IOException; +import java.util.List; import junit.framework.TestSuite; -import org.aspectj.ajde.*; -import org.aspectj.ajde.NullIdeTaskListManager.SourceLineTask; +import org.aspectj.ajde.AjdeTestCase; import org.aspectj.ajde.ui.BuildConfigModel; -//import org.aspectj.ajde.ui.internal.AjcBuildOptions; -//import org.aspectj.bridge.Message; +import org.aspectj.ajde.ui.utils.TestMessageHandler.TestMessage; 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); @@ -43,26 +37,32 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { result.addTestSuite(LstBuildConfigManagerTest.class); return result; } + + protected void setUp() throws Exception { + super.setUp(); + initialiseProject("LstBuildConfigManagerTest"); + } public void testConfigParserErrorMessages() { - doSynchronousBuild("dir-entry.lst"); - List messages = NullIdeManager.getIdeManager().getCompilationSourceLineTasks(); - NullIdeTaskListManager.SourceLineTask message = (NullIdeTaskListManager.SourceLineTask)messages.get(0); + doBuild("dir-entry.lst"); + List messages = getMessages("dir-entry.lst"); + TestMessage message = (TestMessage)messages.get(0); assertEquals(message.getContainedMessage().getSourceLocation().getSourceFile().getAbsolutePath(), openFile("dir-entry.lst").getAbsolutePath()); - doSynchronousBuild("bad-injar.lst"); - messages = NullIdeManager.getIdeManager().getCompilationSourceLineTasks(); - message = (NullIdeTaskListManager.SourceLineTask)messages.get(0); + doBuild("bad-injar.lst"); + messages = getMessages("bad-injar.lst"); + message = (TestMessage)messages.get(0); assertTrue(message.getContainedMessage().getMessage().indexOf("skipping missing, empty or corrupt inpath entry") != -1); } public void testErrorMessages() throws IOException { - doSynchronousBuild("invalid-entry.lst"); - assertTrue("compile failed", testerBuildListener.getBuildSucceeded()); + doBuild("invalid-entry.lst"); + assertFalse("expected there to be error messages because the build failed but didn't" + + " find any", getErrorMessages("invalid-entry.lst").isEmpty()); - List messages = NullIdeManager.getIdeManager().getCompilationSourceLineTasks(); - SourceLineTask message = (SourceLineTask)messages.get(0); + List messages = getMessages("invalid-entry.lst"); + TestMessage message = (TestMessage)messages.get(0); assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().indexOf("aaa.bbb") != -1); } @@ -80,98 +80,5 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { assertTrue("single file", true); } -// 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(); -// String s2 = (String)it.next(); -// 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; -// -// // TODO-path -// 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;"; - } } - -//public void testWildcards() { -// verifyFile(WILDCARDS_FILE, WILDCARDS_FILE_CONTENTS); -//} -// -//public void testIncludes() { -// verifyFile(INCLUDES_FILE, INCLUDES_FILE_CONTENTS); -//} - -- 2.39.5