diff options
author | aclement <aclement> | 2004-08-23 13:40:31 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-08-23 13:40:31 +0000 |
commit | f5035234ee878003515413fee5e7e6bfa7a2228d (patch) | |
tree | 076109c08757dec1961f3899afac0fa2498475ef /org.aspectj.ajdt.core/testsrc | |
parent | d0be7b851b7bcedce43ab31cc307f44ebf0a2f2e (diff) | |
download | aspectj-f5035234ee878003515413fee5e7e6bfa7a2228d.tar.gz aspectj-f5035234ee878003515413fee5e7e6bfa7a2228d.zip |
Matthews enhancement fix for Bugzilla Bug 72154 "Support for simple dump file"
+ Andy using it to capture 'cant find type' issues.
Diffstat (limited to 'org.aspectj.ajdt.core/testsrc')
2 files changed, 103 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java index 5dcc167df..d89573909 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java @@ -31,6 +31,7 @@ public class AjdtBatchTests extends TestCase { suite.addTestSuite(MultipleCompileTestCase.class); suite.addTestSuite(JavadocTest.class); suite.addTestSuite(PartiallyExposedHierarchyTestCase.class); + suite.addTestSuite(CompilerDumpTestCase.class); // XXX suite.addTestSuite(VerifyWeaveTestCase.class); //suite.addTestSuite(WorkingCommandTestCase.class); //$JUnit-END$ diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java new file mode 100644 index 000000000..6a1b7cfa9 --- /dev/null +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * 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: + * Matthew Webster - initial implementation + *******************************************************************************/ +package org.aspectj.ajdt.internal.compiler.batch; + +import java.io.File; + +import org.aspectj.bridge.IMessage; +import org.aspectj.tools.ajc.AjcTestCase; +import org.aspectj.tools.ajc.CompilationResult; +import org.aspectj.weaver.Dump; + +import junit.framework.TestCase; + +public class CompilerDumpTestCase extends AjcTestCase { + + public static final String PROJECT_DIR = "DumpTestCase"; + + private File baseDir; + private File dumpFile; + private IMessage.Kind savedDumpCondition; + + protected void setUp() throws Exception { + super.setUp(); + + baseDir = new File("../org.aspectj.ajdt.core/testdata",PROJECT_DIR); + dumpFile = null; + savedDumpCondition = Dump.getDumpOnExit(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + + if (dumpFile != null && dumpFile.exists()) { + boolean deleted = dumpFile.delete(); + assertTrue("Dump file '" + dumpFile.getPath() + "' could not be deleted",deleted); + } + Dump.setDumpOnExit(savedDumpCondition); + } + + /** + * Aim: Dump after successful compile to ensure it contains the command + * line information. + * + * Inputs to the compiler: + * HelloWorld.java Pointcuts.aj Aspect.aj + * + * Expected result = Compile succeeds. + */ + public void testDump () { + String[] args = new String[] { "src/HelloWorld.java", "src/Pointcuts.aj", "src/Aspect.aj" }; + CompilationResult result = ajc(baseDir,args); + assertNoMessages(result); + String fileName = Dump.dump("DumpTestCase.testDump()"); + dumpFile = new File(fileName); + org.aspectj.weaver.DumpTestCase.assertContents(dumpFile,"Command Line","HelloWorld.java"); + } + + /** + * Aim: Dump after successful compile to ensure it contains warning + * messages. + * + * Inputs to the compiler: + * HelloWorld.java Pointcuts.aj Aspect.aj DeclareWarning.aj + * + * Expected result = Compile succeeds. + */ + public void testDumpWithWarnings () { + String[] args = new String[] { "src/HelloWorld.java", "src/Pointcuts.aj", "src/DeclareWarning.aj" }; + CompilationResult result = ajc(baseDir,args); + String fileName = Dump.dump("DumpTestCase.testDumpWithWarnings()"); + dumpFile = new File(fileName); + org.aspectj.weaver.DumpTestCase.assertContents(dumpFile,"Compiler Messages","warning"); + } + + /** + * Aim: Dump due to errors. + * + * Inputs to the compiler: + * HelloWorld.java Pointcuts.aj Aspect.aj DeclareError.aj + * + * Expected result = Compile fails and dump file created. + */ + public void testWithErrors () { + Dump.setDumpOnExit(IMessage.ERROR); + String previousFileName = Dump.getLastDumpFileName(); + String[] args = new String[] { "src/HelloWorld.java", "src/Pointcuts.aj", "src/DeclareError.aj" }; + CompilationResult result = ajc(baseDir,args); + String fileName = Dump.getLastDumpFileName(); + assertTrue("Dump file should be created",!fileName.equals(previousFileName)); + dumpFile = new File(fileName); + org.aspectj.weaver.DumpTestCase.assertContents(dumpFile,"Compiler Messages","error"); + } + +} |