]> source.dussan.org Git - aspectj.git/commitdiff
tests for the new options handling
authoracolyer <acolyer>
Tue, 8 Jun 2004 15:14:29 +0000 (15:14 +0000)
committeracolyer <acolyer>
Tue, 8 Jun 2004 15:14:29 +0000 (15:14 +0000)
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java [new file with mode: 0644]
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java

index dba44067976f00d25cfb028fa072fc9cc6c4b644..94f41ffba467afe13500dfb72287fcf8662b9d2f 100644 (file)
@@ -106,8 +106,7 @@ public class BuildArgParserTestCase extends TestCase {
        
                assertTrue(
                        "default options",
-                       config.getAjOptions().get(AjCompilerOptions.OPTION_Xlint).equals(
-                               CompilerOptions.GENERATE));                     
+                       config.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT));                     
        }
 
        public void testAspectpath() throws InvalidInputException {
@@ -136,9 +135,9 @@ public class BuildArgParserTestCase extends TestCase {
                        "-injars", SOURCE_JAR }, 
                        messageWriter);
                //XXX don't let this remain in both places in beta1                     
-               assertTrue(
-                       "" + config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs),  
-                       config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs).equals(CompilerOptions.PRESERVE));
+//             assertTrue(
+//                     "" + config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs),  
+//                     config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs).equals(CompilerOptions.PRESERVE));
                assertTrue(((File)config.getInJars().get(0)).getName(), ((File)config.getInJars().get(0)).getName().equals("testclasses.jar"));
 
                config = genBuildConfig(new String[] { 
@@ -286,9 +285,9 @@ public class BuildArgParserTestCase extends TestCase {
                        messageWriter);
 
                //XXX don't let this remain in both places in beta1
-               assertTrue(
-                       "will generate: " + config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR),  
-                       config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR).equals(CompilerOptions.GENERATE));
+//             assertTrue(
+//                     "will generate: " + config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR),  
+//                     config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR).equals(CompilerOptions.GENERATE));
                assertEquals(
                        getCanonicalPath(new File(OUT_JAR)),config.getOutputJar().getAbsolutePath()); 
        
@@ -305,16 +304,14 @@ public class BuildArgParserTestCase extends TestCase {
        
        //XXX shouldn't need -1.4 to get this to pass
        public void testCombinedOptions() throws InvalidInputException {
-               AjBuildConfig config = genBuildConfig(new String[] {  "-Xlint", "-target", "1.4", "-1.4" }, messageWriter);
-               String TARGET = "1.4";
+               AjBuildConfig config = genBuildConfig(new String[] {  "-Xlint:error", "-target", "1.4"}, messageWriter);
                assertTrue(
-                       "target set",  
-                       config.getJavaOptions().get(CompilerOptions.OPTION_TargetPlatform).equals(TARGET));
+                               "target set",  
+                               config.getOptions().targetJDK == CompilerOptions.JDK1_4); 
 
                assertTrue(
                        "Xlint option set",
-                       config.getAjOptions().get(AjCompilerOptions.OPTION_Xlint).equals(
-                               CompilerOptions.GENERATE));                     
+                       config.getLintMode().equals(AjBuildConfig.AJLINT_ERROR));                       
        }
        
        public void testOutputDirectorySetting() throws InvalidInputException {
@@ -393,10 +390,10 @@ public class BuildArgParserTestCase extends TestCase {
                AjBuildConfig config = genBuildConfig(new String[] {"-target", TARGET, "-source", TARGET}, messageWriter);
                assertTrue(
                        "target set",  
-                       config.getJavaOptions().get(CompilerOptions.OPTION_TargetPlatform).equals(TARGET));
+                       config.getOptions().targetJDK == CompilerOptions.JDK1_4);
                assertTrue(
                        "source set",  
-                       config.getJavaOptions().get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4));
+                       config.getOptions().sourceLevel == CompilerOptions.JDK1_4);
        }
        
        public void testLstFileExpansion() throws IOException, FileNotFoundException, InvalidInputException {
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java
new file mode 100644 (file)
index 0000000..2d50ff3
--- /dev/null
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * 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:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.ajdt.internal.core.builder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class AjCompilerOptionsTest extends TestCase {
+
+       private AjCompilerOptions options;
+       
+       /*
+        * @see TestCase#setUp()
+        */
+       protected void setUp() throws Exception {
+               super.setUp();
+               options = new AjCompilerOptions();
+       }
+       
+       public void testDefaultValues() {
+               assertFalse(options.noWeave);
+               assertFalse(options.xSerializableAspects);
+               assertFalse(options.xLazyThisJoinPoint);
+               assertFalse(options.xNoInline);
+               assertFalse(options.xReweavable);
+               assertFalse(options.xReweavableCompress);
+               assertFalse(options.generateModel);
+               assertFalse(options.generateJavaDocsInModel);
+               assertFalse(options.generateEmacsSymFiles);
+               
+               Map map = options.getMap();
+               assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName));
+               assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName));
+               assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember));
+               assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver));
+               assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportShadowNotInStructure));
+               assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall));
+               assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP));
+               assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField));
+               assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion));
+       }
+       
+       public void testDirectSet() {
+               options.noWeave = true;
+               options.xSerializableAspects = true;
+               options.xLazyThisJoinPoint = true;
+               options.xNoInline = true;
+               options.xReweavable = true;
+               options.xReweavableCompress = true;
+               options.generateModel = true;
+               options.generateJavaDocsInModel = true;
+               options.generateEmacsSymFiles = true;
+
+               Map map = options.getMap();
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_NoWeave));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_XSerializableAspects));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_XLazyThisJoinPoint));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_XNoInline));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_XReweavable));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_XReweavableCompress));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_GenerateModel));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_GenerateJavaDocsInModel));
+               assertEquals(CompilerOptions.ENABLED,map.get(AjCompilerOptions.OPTION_Emacssym));
+       }
+
+       
+       public void testMapSet() {
+               Map map = new HashMap();
+               map.put(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName,CompilerOptions.ERROR);
+               map.put(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName,CompilerOptions.ERROR);
+               map.put(AjCompilerOptions.OPTION_ReportUnresolvableMember,CompilerOptions.IGNORE);
+               map.put(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver,CompilerOptions.ERROR);
+               map.put(AjCompilerOptions.OPTION_ReportShadowNotInStructure,CompilerOptions.WARNING);
+               map.put(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall,CompilerOptions.ERROR);
+               map.put(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP,CompilerOptions.ERROR);
+               map.put(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField,CompilerOptions.WARNING);
+               map.put(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion,CompilerOptions.ERROR);
+               
+               map.put(AjCompilerOptions.OPTION_NoWeave,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_XSerializableAspects,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_XLazyThisJoinPoint,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_XNoInline,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_XReweavable,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_XReweavableCompress,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_GenerateModel,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_GenerateJavaDocsInModel,CompilerOptions.ENABLED);
+               map.put(AjCompilerOptions.OPTION_Emacssym,CompilerOptions.ENABLED);
+               
+               options.set(map);
+               
+               assertTrue(options.noWeave);
+               assertTrue(options.xSerializableAspects);
+               assertTrue(options.xLazyThisJoinPoint);
+               assertTrue(options.xNoInline);
+               assertTrue(options.xReweavable);
+               assertTrue(options.xReweavableCompress);
+               assertTrue(options.generateModel);
+               assertTrue(options.generateJavaDocsInModel);
+               assertTrue(options.generateEmacsSymFiles);
+               
+               Map newMap = options.getMap();
+               
+               assertEquals(CompilerOptions.ERROR,newMap.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName));
+               assertEquals(CompilerOptions.ERROR,newMap.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName));
+               assertEquals(CompilerOptions.IGNORE,newMap.get(AjCompilerOptions.OPTION_ReportUnresolvableMember));
+               assertEquals(CompilerOptions.ERROR,newMap.get(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver));
+               assertEquals(CompilerOptions.WARNING,newMap.get(AjCompilerOptions.OPTION_ReportShadowNotInStructure));
+               assertEquals(CompilerOptions.ERROR,newMap.get(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall));
+               assertEquals(CompilerOptions.ERROR,newMap.get(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP));
+               assertEquals(CompilerOptions.WARNING,newMap.get(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField));
+               assertEquals(CompilerOptions.ERROR,newMap.get(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion));
+       }
+       
+       /*
+        * Class to test for String toString()
+        */
+       public void testToString() {
+               String s = options.toString();
+               assertTrue("Should have info on AspectJ options",s.indexOf("AspectJ Specific Options:") > 0);
+       }
+
+}
index e17a5e54202772caa56e99cea87fa8f2fd9a5b8f..ddf0c10b77b3eb80b5f46a7464bbc372e41e3e39 100644 (file)
@@ -23,6 +23,7 @@ public class AjdtBuilderTests extends TestCase {
         //$JUnit-BEGIN$
         suite.addTestSuite(AjBuildManagerTest.class); 
                suite.addTestSuite(AsmBuilderTest.class); 
+               suite.addTestSuite(AjCompilerOptionsTest.class);
         //$JUnit-END$
         return suite;
     }