diff options
author | mkersten <mkersten> | 2003-01-25 01:25:30 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-01-25 01:25:30 +0000 |
commit | 85a827a7f269a18a0c80802811bbc2aa3766c2e4 (patch) | |
tree | 75acaa45c529c458122ee2a1e601474b925fc87d /ajde/testsrc | |
parent | e5660e9d2e962392ad1b3bcd1fc5cbe4725cf8ae (diff) | |
download | aspectj-85a827a7f269a18a0c80802811bbc2aa3766c2e4.tar.gz aspectj-85a827a7f269a18a0c80802811bbc2aa3766c2e4.zip |
Committed patches specified in:
http://bugs.eclipse.org/bugs/show_bug.cgi?id=29769
Diffstat (limited to 'ajde/testsrc')
8 files changed, 680 insertions, 7 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index d2cd8fe9f..4a0140e90 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -22,6 +22,7 @@ public class AjdeTests extends TestCase { TestSuite suite = new TestSuite(AjdeTests.class.getName()); //$JUnit-BEGIN$ suite.addTestSuite(BuildOptionsTest.class); + suite.addTestSuite(BuildConfigurationTests.class); suite.addTestSuite(StructureModelRegressionTest.class); suite.addTestSuite(StructureModelTest.class); suite.addTestSuite(VersionTest.class); diff --git a/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java b/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java new file mode 100644 index 000000000..a59320966 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java @@ -0,0 +1,506 @@ +/********************************************************************** +Copyright (c) 2003 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: +Adrian Colyer - initial version +... +**********************************************************************/ +package org.aspectj.ajde; + +import java.io.File; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.swing.JFrame; + +import junit.framework.TestSuite; + +import org.aspectj.ajde.internal.CompilerAdapter; +import org.aspectj.ajde.ui.IdeUIAdapter; +import org.aspectj.ajde.ui.UserPreferencesAdapter; +import org.aspectj.ajde.ui.internal.AjcBuildOptions; +import org.aspectj.ajde.ui.internal.UserPreferencesStore; +import org.aspectj.ajde.ui.swing.AjdeUIManager; +import org.aspectj.ajde.ui.swing.BasicEditor; +import org.aspectj.ajde.ui.swing.IconRegistry; +import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +/** + * Tests that a correctly populated AjBuildConfig object is created + * in reponse to the setting in BuildOptionsAdapter and + * ProjectPropretiesAdapter + */ +public class BuildConfigurationTests extends AjdeTestCase { + + private CompilerAdapter compilerAdapter; + private AjBuildConfig buildConfig = null; + private AjcBuildOptions buildOptions = null; + private UserPreferencesAdapter preferencesAdapter = null; + private NullIdeProperties projectProperties = null; + private static final String configFile = + "testdata/examples/figures-coverage/all.lst"; + + + public BuildConfigurationTests( String name ) { + super( name ); + } + + public static void main(String[] args) { + junit.swingui.TestRunner.run(BuildConfigurationTests.class); + } + + public static TestSuite suite() { + TestSuite result = new TestSuite(); + result.addTestSuite(BuildConfigurationTests.class); + return result; + } + + + // The tests... + public void testCharacterEncoding() { + buildOptions.setCharacterEncoding( "12345" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + String encoding = (String) options.get( CompilerOptions.OPTION_Encoding ); + assertEquals( "character encoding", "12345", encoding ); + } + + public void testComplianceLevel() { + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance); + assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); + } + + public void testSourceCompatibilityLevel() { + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13); + buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals( "compliance level", CompilerOptions.VERSION_1_3, compliance); + assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); + } + + public void testSourceIncompatibilityLevel() { + // this config should "fail" and leave source level at 1.4 + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14); + buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_13); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance); + assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); + } + + + public void testNullWarnings() { + buildOptions.setWarnings( null ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with the default warnings + assertOptionEquals( "report overriding package default", + options, + CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, + CompilerOptions.WARNING); + assertOptionEquals( "report method with cons name", + options, + CompilerOptions.OPTION_ReportMethodWithConstructorName, + CompilerOptions.WARNING); + assertOptionEquals( "report deprecation", + options, + CompilerOptions.OPTION_ReportDeprecation, + CompilerOptions.WARNING); + assertOptionEquals( "report hidden catch block", + options, + CompilerOptions.OPTION_ReportHiddenCatchBlock, + CompilerOptions.WARNING); + assertOptionEquals( "report unused local", + options, + CompilerOptions.OPTION_ReportUnusedLocal, + CompilerOptions.IGNORE); + assertOptionEquals( "report unused param", + options, + CompilerOptions.OPTION_ReportUnusedParameter, + CompilerOptions.IGNORE); + assertOptionEquals( "report synthectic access", + options, + CompilerOptions.OPTION_ReportSyntheticAccessEmulation, + CompilerOptions.IGNORE); + assertOptionEquals( "report non-externalized string literal", + options, + CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, + CompilerOptions.IGNORE); + assertOptionEquals( "report assert identifer", + options, + CompilerOptions.OPTION_ReportAssertIdentifier, + CompilerOptions.IGNORE); + } + + public void testEmptyWarnings() { + buildOptions.setWarnings( new HashSet() ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with the user specifiable warnings + // turned off + assertOptionEquals( "report overriding package default", + options, + CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, + CompilerOptions.IGNORE); + assertOptionEquals( "report method with cons name", + options, + CompilerOptions.OPTION_ReportMethodWithConstructorName, + CompilerOptions.IGNORE); + assertOptionEquals( "report deprecation", + options, + CompilerOptions.OPTION_ReportDeprecation, + CompilerOptions.IGNORE); + assertOptionEquals( "report hidden catch block", + options, + CompilerOptions.OPTION_ReportHiddenCatchBlock, + CompilerOptions.IGNORE); + assertOptionEquals( "report unused local", + options, + CompilerOptions.OPTION_ReportUnusedLocal, + CompilerOptions.IGNORE); + assertOptionEquals( "report unused param", + options, + CompilerOptions.OPTION_ReportUnusedParameter, + CompilerOptions.IGNORE); + assertOptionEquals( "report synthectic access", + options, + CompilerOptions.OPTION_ReportSyntheticAccessEmulation, + CompilerOptions.IGNORE); + assertOptionEquals( "report non-externalized string literal", + options, + CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, + CompilerOptions.IGNORE); + assertOptionEquals( "report assert identifer", + options, + CompilerOptions.OPTION_ReportAssertIdentifier, + CompilerOptions.IGNORE); + } + + public void testSetOfWarnings() { + HashSet warnings = new HashSet(); + warnings.add( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ); + warnings.add( BuildOptionsAdapter.WARN_CONSTRUCTOR_NAME ); + warnings.add( BuildOptionsAdapter.WARN_DEPRECATION ); + warnings.add( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ); + warnings.add( BuildOptionsAdapter.WARN_PACKAGE_DEFAULT_METHOD ); + warnings.add( BuildOptionsAdapter.WARN_SYNTHETIC_ACCESS ); + warnings.add( BuildOptionsAdapter.WARN_UNUSED_ARGUMENTS ); + warnings.add( BuildOptionsAdapter.WARN_UNUSED_IMPORTS ); + warnings.add( BuildOptionsAdapter.WARN_UNUSED_LOCALS ); + warnings.add( BuildOptionsAdapter.WARN_NLS ); + + buildOptions.setWarnings( warnings ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with all the user specifiable warnings + // turned on + assertOptionEquals( "report overriding package default", + options, + CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, + CompilerOptions.WARNING); + assertOptionEquals( "report method with cons name", + options, + CompilerOptions.OPTION_ReportMethodWithConstructorName, + CompilerOptions.WARNING); + assertOptionEquals( "report deprecation", + options, + CompilerOptions.OPTION_ReportDeprecation, + CompilerOptions.WARNING); + assertOptionEquals( "report hidden catch block", + options, + CompilerOptions.OPTION_ReportHiddenCatchBlock, + CompilerOptions.WARNING); + assertOptionEquals( "report unused local", + options, + CompilerOptions.OPTION_ReportUnusedLocal, + CompilerOptions.WARNING); + assertOptionEquals( "report unused param", + options, + CompilerOptions.OPTION_ReportUnusedParameter, + CompilerOptions.WARNING); + assertOptionEquals( "report synthectic access", + options, + CompilerOptions.OPTION_ReportSyntheticAccessEmulation, + CompilerOptions.WARNING); + assertOptionEquals( "report non-externalized string literal", + options, + CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, + CompilerOptions.WARNING); + assertOptionEquals( "report assert identifer", + options, + CompilerOptions.OPTION_ReportAssertIdentifier, + CompilerOptions.WARNING); + } + + public void testNoDebugOptions() { + buildOptions.setDebugLevel( null ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with the default debug settings + assertOptionEquals( "debug source", + options, + CompilerOptions.OPTION_SourceFileAttribute, + CompilerOptions.DO_NOT_GENERATE); + assertOptionEquals( "debug lines", + options, + CompilerOptions.OPTION_LineNumberAttribute, + CompilerOptions.DO_NOT_GENERATE); + assertOptionEquals( "debug vars", + options, + CompilerOptions.OPTION_LocalVariableAttribute, + CompilerOptions.DO_NOT_GENERATE); + } + + public void testEmptyDebugOptions() { + buildOptions.setDebugLevel( new HashSet() ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with the debug off + assertOptionEquals( "debug source", + options, + CompilerOptions.OPTION_SourceFileAttribute, + CompilerOptions.DO_NOT_GENERATE); + assertOptionEquals( "debug lines", + options, + CompilerOptions.OPTION_LineNumberAttribute, + CompilerOptions.DO_NOT_GENERATE); + assertOptionEquals( "debug vars", + options, + CompilerOptions.OPTION_LocalVariableAttribute, + CompilerOptions.DO_NOT_GENERATE); + } + + public void testDebugAll() { + HashSet debugOpts = new HashSet(); + debugOpts.add( BuildOptionsAdapter.DEBUG_ALL ); + buildOptions.setDebugLevel( debugOpts ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with all debug on + assertOptionEquals( "debug source", + options, + CompilerOptions.OPTION_SourceFileAttribute, + CompilerOptions.GENERATE); + assertOptionEquals( "debug lines", + options, + CompilerOptions.OPTION_LineNumberAttribute, + CompilerOptions.GENERATE); + assertOptionEquals( "debug vars", + options, + CompilerOptions.OPTION_LocalVariableAttribute, + CompilerOptions.GENERATE); + + } + + public void testDebugSet() { + HashSet debugOpts = new HashSet(); + debugOpts.add( BuildOptionsAdapter.DEBUG_SOURCE ); + debugOpts.add( BuildOptionsAdapter.DEBUG_VARS ); + buildOptions.setDebugLevel( debugOpts ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + + // this should leave us with all debug on + assertOptionEquals( "debug source", + options, + CompilerOptions.OPTION_SourceFileAttribute, + CompilerOptions.GENERATE); + assertOptionEquals( "debug lines", + options, + CompilerOptions.OPTION_LineNumberAttribute, + CompilerOptions.DO_NOT_GENERATE); + assertOptionEquals( "debug vars", + options, + CompilerOptions.OPTION_LocalVariableAttribute, + CompilerOptions.GENERATE); + } + + public void testNoImport() { + buildOptions.setNoImportError( true ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + String noImport = (String) options.get( CompilerOptions.OPTION_ReportInvalidImport ); + assertEquals( "no import", CompilerOptions.WARNING, noImport ); + buildOptions.setNoImportError( false ); + } + + public void testPreserveAllLocals() { + buildOptions.setPreserveAllLocals( true ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + Map options = buildConfig.getJavaOptions(); + String preserve = (String) options.get( CompilerOptions.OPTION_PreserveUnusedLocal ); + assertEquals( "preserve unused", CompilerOptions.PRESERVE, preserve ); + } + + public void testNonStandardOptions() { + buildOptions.setNonStandardOptions( "-XnoWeave" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue( "XnoWeave", buildConfig.isNoWeave() ); + buildOptions.setNonStandardOptions( "-XserializableAspects" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue( "XserializableAspects", buildConfig.isXserializableAspects() ); + buildOptions.setNonStandardOptions( "-XnoInline" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue( "XnoInline", buildConfig.isXnoInline()); + buildOptions.setNonStandardOptions( "-Xlint" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertEquals( "Xlint", AjBuildConfig.AJLINT_DEFAULT, + buildConfig.getLintMode()); + buildOptions.setNonStandardOptions( "-Xlint:error" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertEquals( "Xlint", AjBuildConfig.AJLINT_ERROR, + buildConfig.getLintMode()); + buildOptions.setNonStandardOptions( "-Xlintfile testdata/AspectJBuildManagerTest/lint.properties" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertEquals( "Xlintfile", new File( "testdata/AspectJBuildManagerTest/lint.properties" ).getAbsolutePath(), + buildConfig.getLintSpecFile().toString()); + // and a few options thrown in at once + buildOptions.setNonStandardOptions( "-Xlint -XnoInline -XserializableAspects" ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertEquals( "Xlint", AjBuildConfig.AJLINT_DEFAULT, + buildConfig.getLintMode()); + assertTrue( "XnoInline", buildConfig.isXnoInline()); + assertTrue( "XserializableAspects", buildConfig.isXserializableAspects() ); + } + + public void testSourceRoots() { + Set roots = new HashSet(); + projectProperties.setSourceRoots( roots ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List configRoots = buildConfig.getSourceRoots(); + assertTrue( "no source dirs", configRoots.isEmpty() ); + + File f = new File( "testdata/examples/figures/figures-coverage" ); + roots.add( f ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List configRoots2 = buildConfig.getSourceRoots(); + assertTrue( "one source dir", configRoots2.size() == 1 ); + assertTrue( "source dir", configRoots2.contains(f) ); + + + File f2 = new File( "testdata/examples/figures/figures-demo" ); + roots.add( f2 ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List configRoots3 = buildConfig.getSourceRoots(); + assertTrue( "two source dirs", configRoots3.size() == 2 ); + assertTrue( "source dir 1", configRoots3.contains(f) ); + assertTrue( "source dir 2", configRoots3.contains(f2) ); + } + + public void testInJars() { + Set jars = new HashSet(); + projectProperties.setInJars( jars ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List inJars = buildConfig.getInJars(); + assertTrue( "no in jars", inJars.isEmpty() ); + + File f = new File( "jarone.jar" ); + jars.add( f ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List inJars2 = buildConfig.getInJars(); + assertTrue( "one in jar", inJars2.size() == 1 ); + assertTrue( "in jar", inJars2.contains(f) ); + + + File f2 = new File( "jartwo.jar" ); + jars.add( f2 ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List inJars3 = buildConfig.getInJars(); + assertTrue( "two in jars", inJars3.size() == 2 ); + assertTrue( "in jar 1", inJars3.contains(f) ); + assertTrue( "in jar 2", inJars3.contains(f2) ); + } + + public void testAspectPath() { + Set aspects = new HashSet(); + projectProperties.setAspectPath( aspects ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List aPath = buildConfig.getAspectpath(); + assertTrue( "no aspect path", aPath.isEmpty() ); + + File f = new File( "jarone.jar" ); + aspects.add( f ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List aPath2 = buildConfig.getAspectpath(); + assertTrue( "one jar in path", aPath2.size() == 1 ); + assertTrue( "1 aspectpath", aPath2.contains(f) ); + + + File f2 = new File( "jartwo.jar" ); + aspects.add( f2 ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + List aPath3 = buildConfig.getAspectpath(); + assertTrue( "two jars in path", aPath3.size() == 2 ); + assertTrue( "1 aspectpath", aPath3.contains(f) ); + assertTrue( "2 aspectpath", aPath3.contains(f2) ); + } + + public void testOutJar() { + String outJar = "mybuild.jar"; + projectProperties.setOutJar( outJar ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertEquals( "out jar", outJar, buildConfig.getOutputJar().toString() ); + } + + protected void setUp() throws Exception { + preferencesAdapter = new UserPreferencesStore(); + buildOptions = new AjcBuildOptions(preferencesAdapter); + compilerAdapter = new CompilerAdapter(); + projectProperties = new NullIdeProperties( "" ); + init(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + buildOptions.setCharacterEncoding(""); + } + + public void init() { + try { + Ajde.init( + null, + null, + null, + projectProperties, + buildOptions, + null, + null, + null); + + //Ajde.getDefault().enableLogging( System.out ); + } catch (Throwable t) { + t.printStackTrace(); + Ajde.getDefault().getErrorHandler().handleError( + "Ajde failed to initialize.", + t); + } + } + + private void assertOptionEquals( String reason, Map options, String optionName, String value) { + String mapValue = (String) options.get(optionName); + assertEquals( reason, value, mapValue ); + } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java b/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java index 5f5df1329..f30b4f308 100644 --- a/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java +++ b/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java @@ -8,11 +8,16 @@ * * Contributors: * Xerox/PARC initial implementation + * AMC 01.21.2003 extended to cover new AspectJ1.1 options * ******************************************************************/ package org.aspectj.ajde; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import junit.framework.TestSuite; import org.aspectj.ajde.ui.UserPreferencesAdapter; @@ -47,6 +52,97 @@ public class BuildOptionsTest extends AjdeTestCase { buildOptions.setPortingMode(true); assertTrue("porting mode", buildOptions.getPortingMode()); } + + public void testVerboseMode() { + buildOptions.setVerboseMode(true); + assertTrue("verbose mode", buildOptions.getVerboseMode()); + } + + public void testNonStandardOptions() { + buildOptions.setNonStandardOptions( "-Xlint" ); + assertEquals( "non std options", "-Xlint", + buildOptions.getNonStandardOptions()); + } + + public void testComplianceLevel() { + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 ); + assertEquals( "compliance level", + BuildOptionsAdapter.VERSION_14, + buildOptions.getComplianceLevel()); + } + + public void testSourceCompatibilityLevel() { + buildOptions.setSourceCompatibilityLevel(BuildOptionsAdapter.VERSION_13); + assertEquals( "source level", + BuildOptionsAdapter.VERSION_13, + buildOptions.getSourceCompatibilityLevel()); + } + + public void testWarnings() { + buildOptions.setWarnings( null ); + assertNull( "null warning set", buildOptions.getWarnings()); + HashSet s = new HashSet(); + buildOptions.setWarnings( s ); + Set s2 = buildOptions.getWarnings(); + assertTrue( "empty warning set", s2.isEmpty() ); + s.add( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ); + s.add( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ); + buildOptions.setWarnings( s ); + s2 = buildOptions.getWarnings(); + assertTrue( "two warnings", s2.size() == 2 ); + boolean warn_assert_found = false; + boolean warn_catch_found = false; + Iterator it = s2.iterator(); + while (it.hasNext()) { + String option = (String) it.next(); + if ( option.equals( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ) ) { + warn_assert_found = true; + } + if ( option.equals( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ) ) { + warn_catch_found = true; + } + } + assertTrue( "assert warning found", warn_assert_found ); + assertTrue( "catch waning found", warn_catch_found ); + } + + public void testDebugLevel() { + buildOptions.setDebugLevel( null ); + assertNull( "null debug set", buildOptions.getDebugLevel()); + HashSet s = new HashSet(); + buildOptions.setDebugLevel( s ); + Set s2 = buildOptions.getDebugLevel(); + assertTrue( "empty debug set", s2.isEmpty() ); + s.add( BuildOptionsAdapter.DEBUG_LINES ); + s.add( BuildOptionsAdapter.DEBUG_SOURCE ); + buildOptions.setDebugLevel( s ); + s2 = buildOptions.getDebugLevel(); + assertTrue( "two warnings", s2.size() == 2 ); + boolean debug_lines_found = false; + boolean debug_source_found = false; + Iterator it = s2.iterator(); + while (it.hasNext()) { + String option = (String) it.next(); + if ( option.equals( BuildOptionsAdapter.DEBUG_LINES ) ) { + debug_lines_found = true; + } + if ( option.equals( BuildOptionsAdapter.DEBUG_SOURCE ) ) { + debug_source_found = true; + } + } + assertTrue( "debug lines found", debug_lines_found ); + assertTrue( "debug source found", debug_source_found ); + } + + public void testNoImportError() { + buildOptions.setNoImportError(true); + assertTrue("no import error", buildOptions.getNoImportError()); + } + + public void testPreserveLocals() { + buildOptions.setPreserveAllLocals(true); + assertTrue("preserve all locals", buildOptions.getPreserveAllLocals()); + } protected void setUp() throws Exception { super.setUp(); diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java index 2269fcaba..c3a09e8dc 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java @@ -44,6 +44,8 @@ public class NullIdeManager { new IconRegistry(), nullFrame, true); + + //Ajde.getDefault().enableLogging( System.out ); } catch (Throwable t) { t.printStackTrace(); Ajde.getDefault().getErrorHandler().handleError( diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java index 0369954f8..03173f33b 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java @@ -8,6 +8,7 @@ * * Contributors: * Xerox/PARC initial implementation + * AMC 01.20.2003 extended to support AspectJ 1.1 options * ******************************************************************/ @@ -24,6 +25,11 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { private String testProjectPath = ""; private List buildConfigFiles = new ArrayList(); + private Set inJars; + private Set sourceRoots; + private Set aspectPath; + private String outJar; + public NullIdeProperties(String testProjectPath) { this.testProjectPath = testProjectPath; } @@ -58,7 +64,10 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { public String getClasspath() { //XXX - return testProjectPath + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../../../runtime/bin"; + // AMC - added in path separator since absence was causing + // build failures with invalid classpath + return testProjectPath + File.pathSeparator + + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../runtime/bin"; } public String getOutputPath() { @@ -84,4 +93,28 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { public String getVmArgs() { return null; } + + public void setInJars( Set jars ) { this.inJars = jars; } + + public Set getInJars( ) { + return inJars; + } + + public void setOutJar( String jar ){ this.outJar = jar; } + + public String getOutJar() { + return outJar; + } + + public void setSourceRoots( Set roots ) { this.sourceRoots = roots; } + + public Set getSourceRoots() { + return sourceRoots; + } + + public void setAspectPath( Set path ) { this.aspectPath = path; } + + public Set getAspectPath() { + return aspectPath; + } } diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java index be06bdf20..d3c4b1041 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java @@ -14,10 +14,12 @@ package org.aspectj.ajde; import java.io.File; +import java.util.List; import junit.framework.TestSuite; import org.aspectj.asm.StructureModel; +import org.aspectj.asm.StructureNode; public class StructureModelRegressionTest extends AjdeTestCase { @@ -36,7 +38,7 @@ public class StructureModelRegressionTest extends AjdeTestCase { } public void test() { - String testLstFile = "StructureModelRegressionTest/example.lst"; + String testLstFile = "testdata/StructureModelRegressionTest/example.lst"; File f = new File(testLstFile); assertTrue(testLstFile, f.canRead()); assertTrue("saved model: " + testLstFile, verifyAgainstSavedModel(testLstFile)); @@ -52,7 +54,14 @@ public class StructureModelRegressionTest extends AjdeTestCase { StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getStructureModel(); //System.err.println( savedModel.getRoot().getClass() + ", " + savedModel.getRoot()); - return savedModel.getRoot().equals(model.getRoot()); + // AMC This test will not pass as written until StructureNode defines + // equals. The equals loic is commented out in the StructureNode + // class - adding it back in could have unforeseen system-wide + // consequences, so I've defined a structureNodesEqual( ) helper + // method here instead. + StructureNode rootNode = model.getRoot(); + StructureNode savedRootNode = savedModel.getRoot(); + return structureNodesEqual( rootNode, savedRootNode ); } else { Ajde.getDefault().getStructureModelManager().writeStructureModel(lstFile); return true; @@ -60,6 +69,30 @@ public class StructureModelRegressionTest extends AjdeTestCase { //return true; } + private boolean structureNodesEqual( StructureNode s1, StructureNode s2 ) { + final boolean equal = true; + if ( s1 == s2 ) return equal; + if ( null == s1 || null == s2 ) return !equal; + + if (!s1.getName( ).equals(s2.getName())) return !equal; + if (!s1.getKind( ).equals(s2.getKind())) return !equal; + + // check child nodes + List s1Kids = s1.getChildren(); + List s2Kids = s2.getChildren(); + + if ( s1Kids != null && s2Kids != null ) { + if (s1Kids == null || s2Kids == null) return !equal; + if (s1Kids.size() != s2Kids.size() ) return !equal; + for ( int k=0; k<s1Kids.size(); k++ ) { + StructureNode k1 = (StructureNode) s1Kids.get(k); + StructureNode k2 = (StructureNode) s2Kids.get(k); + if (!structureNodesEqual( k1, k2 )) return !equal; + } + } + return equal; + } + private StructureModel getModelForFile(String lstFile) { Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile); Ajde.getDefault().getBuildManager().buildStructure(); diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java index 244a26b25..cd3e3db57 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java @@ -8,6 +8,7 @@ * * Contributors: * Xerox/PARC initial implementation + * AMC 21.01.2003 fixed for new source location in eclipse.org * ******************************************************************/ package org.aspectj.ajde; @@ -43,7 +44,7 @@ public class StructureModelTest extends AjdeTestCase { } public void testFieldInitializerCorrespondence() throws IOException { - File testFile = createFile("../examples/figures-coverage/figures/Figure.java"); + File testFile = createFile("testdata/examples/figures-coverage/figures/Figure.java"); StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( testFile.getCanonicalPath(), 28); assertTrue("find result", node != null) ; @@ -65,7 +66,7 @@ public class StructureModelTest extends AjdeTestCase { assertTrue("find associated node", foundNode != null) ; - File pointFile = createFile("../examples/figures-coverage/figures/primitives/planar/Point.java"); + File pointFile = createFile("testdata/examples/figures-coverage/figures/primitives/planar/Point.java"); StructureNode fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( pointFile.getCanonicalPath(), 12); assertTrue("find result", fieldNode != null); @@ -74,7 +75,7 @@ public class StructureModelTest extends AjdeTestCase { } public void testFileNodeFind() throws IOException { - File testFile = createFile("../examples/figures-coverage/figures/Main.java"); + File testFile = createFile("testdata/examples/figures-coverage/figures/Main.java"); StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( testFile.getCanonicalPath(), 1); assertTrue("find result", node != null) ; @@ -87,7 +88,7 @@ public class StructureModelTest extends AjdeTestCase { */ public void testMainClassNodeInfo() throws IOException { assertTrue("root exists", Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot() != null); - File testFile = createFile("../examples/figures-coverage/figures/Main.java"); + File testFile = createFile("testdata/examples/figures-coverage/figures/Main.java"); StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( testFile.getCanonicalPath(), 11); assertTrue("find result", node != null); diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java index e6b7f8ae9..4c3351f57 100644 --- a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java @@ -83,6 +83,7 @@ public class StructureViewManagerTest extends AjdeTestCase { assertTrue("notified", renderer.getHasBeenNotified()); //System.err.println(">>>>>> " + currentView.getRootNode().getStructureNode()); + StructureNode n = currentView.getRootNode().getStructureNode(); assertTrue( "no structure", currentView.getRootNode().getStructureNode().getChildren().get(0) |