From 2b24e7377da7c849fe7f9f4fa06a701664f9d27d Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Wed, 30 Jan 2019 16:55:38 -0800 Subject: mavenizing tests - wip --- .../test/java/org/aspectj/systemtest/AllTests.java | 61 + .../java/org/aspectj/systemtest/AllTests14.java | 30 + .../java/org/aspectj/systemtest/AllTests15.java | 49 + .../java/org/aspectj/systemtest/AllTests16.java | 45 + .../java/org/aspectj/systemtest/AllTests17.java | 32 + .../java/org/aspectj/systemtest/AllTests18.java | 52 + .../java/org/aspectj/systemtest/AllTests19.java | 34 + .../org/aspectj/systemtest/ajc10x/Ajc10xTests.java | 1176 ++++ .../org/aspectj/systemtest/ajc10x/ajc10x-tests.xml | 2013 +++++++ .../java/org/aspectj/systemtest/ajc10x/ajc10x.xml | 9 + .../org/aspectj/systemtest/ajc11/Ajc11Tests.java | 485 ++ .../org/aspectj/systemtest/ajc11/ajc11-tests.xml | 850 +++ .../java/org/aspectj/systemtest/ajc11/ajc11.xml | 10 + .../org/aspectj/systemtest/ajc120/Ajc120Tests.java | 252 + .../org/aspectj/systemtest/ajc120/ajc120-tests.xml | 482 ++ .../java/org/aspectj/systemtest/ajc120/ajc120.xml | 11 + .../org/aspectj/systemtest/ajc121/Ajc121Tests.java | 345 ++ .../org/aspectj/systemtest/ajc121/ajc121-tests.xml | 494 ++ .../java/org/aspectj/systemtest/ajc121/ajc121.xml | 12 + .../systemtest/ajc150/AccBridgeMethods.java | 67 + .../org/aspectj/systemtest/ajc150/Ajc150Tests.java | 1035 ++++ .../systemtest/ajc150/AllTestsAspectJ150.java | 63 + .../systemtest/ajc150/AnnotationBinding.java | 402 ++ .../ajc150/AnnotationPointcutsTests.java | 53 + .../systemtest/ajc150/AnnotationRuntimeTests.java | 60 + .../org/aspectj/systemtest/ajc150/Annotations.java | 171 + .../ajc150/AnnotationsBinaryWeaving.java | 56 + .../org/aspectj/systemtest/ajc150/Autoboxing.java | 94 + .../aspectj/systemtest/ajc150/CovarianceTests.java | 166 + .../systemtest/ajc150/DeclareAnnotationTests.java | 331 + .../java/org/aspectj/systemtest/ajc150/Enums.java | 72 + .../systemtest/ajc150/GenericITDsDesign.java | 254 + .../aspectj/systemtest/ajc150/GenericsTests.java | 996 ++++ .../org/aspectj/systemtest/ajc150/HasMember.java | 58 + .../aspectj/systemtest/ajc150/MigrationTests.java | 64 + .../systemtest/ajc150/PerTypeWithinTests.java | 104 + .../systemtest/ajc150/RuntimeAnnotations.java | 138 + .../aspectj/systemtest/ajc150/SCCSFixTests.java | 73 + .../aspectj/systemtest/ajc150/StaticImports.java | 33 + .../systemtest/ajc150/SuppressedWarnings.java | 53 + .../aspectj/systemtest/ajc150/VarargsTests.java | 80 + .../java/org/aspectj/systemtest/ajc150/ajc150.xml | 6308 ++++++++++++++++++++ .../ajc150/ataspectj/AtAjAnnotationGenTests.java | 160 + .../systemtest/ajc150/ataspectj/AtAjLTWTests.java | 237 + .../ajc150/ataspectj/AtAjMisuseTests.java | 68 + .../ajc150/ataspectj/AtAjSyntaxTests.java | 145 + .../systemtest/ajc150/ataspectj/annotationgen.xml | 187 + .../ajc150/ataspectj/coverage/CoverageTests.java | 43 + .../ajc150/ataspectj/coverage/coverage.xml | 320 + .../aspectj/systemtest/ajc150/ataspectj/ltw.xml | 349 ++ .../aspectj/systemtest/ajc150/ataspectj/misuse.xml | 146 + .../aspectj/systemtest/ajc150/ataspectj/syntax.xml | 202 + .../systemtest/ajc150/ltw/LTWServerTests.java | 27 + .../aspectj/systemtest/ajc150/ltw/LTWTests.java | 213 + .../aspectj/systemtest/ajc150/ltw/ltw-tests.xml | 670 +++ .../java/org/aspectj/systemtest/ajc150/ltw/ltw.xml | 11 + .../org/aspectj/systemtest/ajc150/tests/.cvsignore | 1 + .../org/aspectj/systemtest/ajc151/Ajc151Tests.java | 282 + .../systemtest/ajc151/AllTestsAspectJ151.java | 28 + .../aspectj/systemtest/ajc151/AtAroundTests.java | 89 + .../systemtest/ajc151/NewarrayJoinpointTests.java | 136 + .../systemtest/ajc151/SerialVersionUIDTests.java | 37 + .../java/org/aspectj/systemtest/ajc151/ajc151.xml | 414 ++ .../org/aspectj/systemtest/ajc151/ataround.xml | 379 ++ .../systemtest/ajc151/newarray_joinpoint.xml | 165 + .../aspectj/systemtest/ajc151/serialversionuid.xml | 51 + .../org/aspectj/systemtest/ajc152/Ajc152Tests.java | 384 ++ .../systemtest/ajc152/AllTestsAspectJ152.java | 27 + .../systemtest/ajc152/SynchronizationTests.java | 261 + .../ajc152/SynchronizationTransformTests.java | 310 + .../java/org/aspectj/systemtest/ajc152/ajc152.xml | 777 +++ .../aspectj/systemtest/ajc152/synchronization.xml | 650 ++ .../org/aspectj/systemtest/ajc153/Ajc153Tests.java | 508 ++ .../systemtest/ajc153/AllTestsAspectJ153.java | 28 + .../ajc153/JDTLikeHandleProviderTests.java | 553 ++ .../systemtest/ajc153/LTWServer153Tests.java | 23 + .../aspectj/systemtest/ajc153/PipeliningTests.java | 89 + .../java/org/aspectj/systemtest/ajc153/ajc153.xml | 886 +++ .../systemtest/ajc153/jdtlikehandleprovider.xml | 256 + .../org/aspectj/systemtest/ajc153/pipelining.xml | 72 + .../org/aspectj/systemtest/ajc154/Ajc154Tests.java | 442 ++ .../systemtest/ajc154/AllTestsAspectJ154.java | 28 + .../ajc154/CustomMungerExtensionTest.java | 137 + .../java/org/aspectj/systemtest/ajc154/ajc154.xml | 491 ++ .../org/aspectj/systemtest/ajc160/Ajc160Tests.java | 154 + .../systemtest/ajc160/AllTestsAspectJ160.java | 30 + .../ajc160/AnnotationValueMatchingTests.java | 55 + .../org/aspectj/systemtest/ajc160/NewFeatures.java | 35 + .../ajc160/ParameterAnnotationMatchingTests.java | 98 + .../org/aspectj/systemtest/ajc160/SanityTests.java | 163 + .../java/org/aspectj/systemtest/ajc160/ajc160.xml | 187 + .../systemtest/ajc160/annotationValueMatching.xml | 148 + .../systemtest/ajc160/newfeatures-tests.xml | 37 + .../systemtest/ajc160/parameterAnnotations.xml | 149 + .../org/aspectj/systemtest/ajc160/sanity-tests.xml | 76 + .../org/aspectj/systemtest/ajc161/Ajc161Tests.java | 204 + .../systemtest/ajc161/AllTestsAspectJ161.java | 26 + .../ajc161/OptimizedAnnotationFieldBinding.java | 72 + .../java/org/aspectj/systemtest/ajc161/ajc161.xml | 321 + .../systemtest/ajc161/annotationFieldBinding.xml | 127 + .../aspectj/systemtest/ajc1610/Ajc1610Tests.java | 67 + .../systemtest/ajc1610/AllTestsAspectJ1610.java | 26 + .../aspectj/systemtest/ajc1610/NewFeatures.java | 152 + .../org/aspectj/systemtest/ajc1610/ajc1610.xml | 76 + .../systemtest/ajc1610/newfeatures-tests.xml | 113 + .../aspectj/systemtest/ajc1611/Ajc1611Tests.java | 129 + .../systemtest/ajc1611/AllTestsAspectJ1611.java | 26 + .../aspectj/systemtest/ajc1611/NewFeatures.java | 77 + .../org/aspectj/systemtest/ajc1611/ajc1611.xml | 172 + .../systemtest/ajc1611/newfeatures-tests.xml | 139 + .../aspectj/systemtest/ajc1612/Ajc1612Tests.java | 420 ++ .../systemtest/ajc1612/AllTestsAspectJ1612.java | 25 + .../org/aspectj/systemtest/ajc1612/ajc1612.xml | 755 +++ .../org/aspectj/systemtest/ajc162/Ajc162Tests.java | 223 + .../systemtest/ajc162/AllTestsAspectJ162.java | 25 + .../java/org/aspectj/systemtest/ajc162/ajc162.xml | 336 ++ .../org/aspectj/systemtest/ajc163/Ajc163Tests.java | 320 + .../systemtest/ajc163/AllTestsAspectJ163.java | 25 + .../java/org/aspectj/systemtest/ajc163/ajc163.xml | 354 ++ .../org/aspectj/systemtest/ajc164/Ajc164Tests.java | 443 ++ .../systemtest/ajc164/AllTestsAspectJ164.java | 27 + .../systemtest/ajc164/DeclareMixinTests.java | 157 + .../systemtest/ajc164/JointpointIdTests.java | 39 + .../java/org/aspectj/systemtest/ajc164/ajc164.xml | 278 + .../org/aspectj/systemtest/ajc164/declareMixin.xml | 173 + .../org/aspectj/systemtest/ajc164/joinpointid.xml | 19 + .../org/aspectj/systemtest/ajc165/Ajc165Tests.java | 124 + .../systemtest/ajc165/AllTestsAspectJ165.java | 25 + .../org/aspectj/systemtest/ajc165/WorldTests.java | 44 + .../java/org/aspectj/systemtest/ajc165/ajc165.xml | 117 + .../java/org/aspectj/systemtest/ajc165/world.xml | 5 + .../org/aspectj/systemtest/ajc166/Ajc166Tests.java | 105 + .../systemtest/ajc166/AllTestsAspectJ166.java | 25 + .../java/org/aspectj/systemtest/ajc166/ajc166.xml | 147 + .../org/aspectj/systemtest/ajc167/Ajc167Tests.java | 89 + .../systemtest/ajc167/AllTestsAspectJ167.java | 26 + .../aspectj/systemtest/ajc167/IntertypeTests.java | 77 + .../systemtest/ajc167/OverweavingTests.java | 84 + .../java/org/aspectj/systemtest/ajc167/ajc167.xml | 143 + .../org/aspectj/systemtest/ajc167/intertype.xml | 41 + .../org/aspectj/systemtest/ajc167/overweaving.xml | 198 + .../org/aspectj/systemtest/ajc169/Ajc169Tests.java | 253 + .../systemtest/ajc169/AllTestsAspectJ169.java | 27 + .../aspectj/systemtest/ajc169/IntertypeTests.java | 214 + .../systemtest/ajc169/TransparentWeavingTests.java | 244 + .../java/org/aspectj/systemtest/ajc169/ajc169.xml | 413 ++ .../org/aspectj/systemtest/ajc169/intertype.txt | 5 + .../org/aspectj/systemtest/ajc169/intertype.xml | 249 + .../systemtest/ajc169/transparentweaving.xml | 68 + .../org/aspectj/systemtest/ajc170/Ajc170Tests.java | 309 + .../systemtest/ajc170/AllTestsAspectJ170.java | 25 + .../org/aspectj/systemtest/ajc170/IndyTests.java | 56 + .../java/org/aspectj/systemtest/ajc170/ajc170.xml | 398 ++ .../java/org/aspectj/systemtest/ajc170/indy.xml | 59 + .../org/aspectj/systemtest/ajc171/Ajc171Tests.java | 75 + .../systemtest/ajc171/Ajc171Tests_need17jre.java | 43 + .../systemtest/ajc171/AllTestsAspectJ171.java | 28 + .../org/aspectj/systemtest/ajc171/NewFeatures.java | 73 + .../java/org/aspectj/systemtest/ajc171/ajc171.xml | 116 + .../systemtest/ajc171/newfeatures-tests.xml | 41 + .../org/aspectj/systemtest/ajc172/Ajc172Tests.java | 210 + .../systemtest/ajc172/AllTestsAspectJ172.java | 25 + .../java/org/aspectj/systemtest/ajc172/ajc172.xml | 204 + .../org/aspectj/systemtest/ajc173/Ajc173Tests.java | 84 + .../systemtest/ajc173/AllTestsAspectJ173.java | 25 + .../java/org/aspectj/systemtest/ajc173/ajc173.xml | 90 + .../org/aspectj/systemtest/ajc174/Ajc174Tests.java | 96 + .../systemtest/ajc174/AllTestsAspectJ174.java | 25 + .../java/org/aspectj/systemtest/ajc174/ajc174.xml | 212 + .../org/aspectj/systemtest/ajc175/Ajc175Tests.java | 45 + .../systemtest/ajc175/AllTestsAspectJ175.java | 25 + .../java/org/aspectj/systemtest/ajc175/ajc175.xml | 19 + .../org/aspectj/systemtest/ajc180/Ajc180Tests.java | 59 + .../systemtest/ajc180/AllTestsAspectJ180.java | 25 + .../java/org/aspectj/systemtest/ajc180/ajc180.xml | 55 + .../org/aspectj/systemtest/ajc181/Ajc181Tests.java | 62 + .../systemtest/ajc181/AllTestsAspectJ181.java | 27 + .../java/org/aspectj/systemtest/ajc181/ajc181.xml | 34 + .../aspectj/systemtest/ajc1810/Ajc1810Tests.java | 177 + .../systemtest/ajc1810/AllTestsAspectJ1810.java | 25 + .../org/aspectj/systemtest/ajc1810/ajc1810.xml | 110 + .../aspectj/systemtest/ajc1811/Ajc1811Tests.java | 90 + .../systemtest/ajc1811/AllTestsAspectJ1811.java | 25 + .../org/aspectj/systemtest/ajc1811/ajc1811.xml | 46 + .../org/aspectj/systemtest/ajc182/Ajc182Tests.java | 50 + .../systemtest/ajc182/AllTestsAspectJ182.java | 25 + .../java/org/aspectj/systemtest/ajc182/tests.xml | 18 + .../org/aspectj/systemtest/ajc183/Ajc183Tests.java | 99 + .../systemtest/ajc183/AllTestsAspectJ183.java | 25 + .../java/org/aspectj/systemtest/ajc183/ajc183.xml | 182 + .../org/aspectj/systemtest/ajc184/Ajc184Tests.java | 120 + .../systemtest/ajc184/AllTestsAspectJ184.java | 25 + .../java/org/aspectj/systemtest/ajc184/ajc184.xml | 198 + .../org/aspectj/systemtest/ajc185/Ajc185Tests.java | 68 + .../systemtest/ajc185/AllTestsAspectJ185.java | 25 + .../java/org/aspectj/systemtest/ajc185/ajc185.xml | 34 + .../org/aspectj/systemtest/ajc186/Ajc186Tests.java | 162 + .../systemtest/ajc186/AllTestsAspectJ186.java | 25 + .../java/org/aspectj/systemtest/ajc186/ajc186.xml | 25 + .../org/aspectj/systemtest/ajc187/Ajc187Tests.java | 63 + .../systemtest/ajc187/AllTestsAspectJ187.java | 25 + .../java/org/aspectj/systemtest/ajc187/ajc187.xml | 67 + .../org/aspectj/systemtest/ajc188/Ajc188Tests.java | 55 + .../systemtest/ajc188/AllTestsAspectJ188.java | 25 + .../java/org/aspectj/systemtest/ajc188/ajc188.xml | 44 + .../org/aspectj/systemtest/ajc189/Ajc189Tests.java | 73 + .../systemtest/ajc189/AllTestsAspectJ189.java | 25 + .../org/aspectj/systemtest/ajc189/ajc189.out.xml | 0 .../java/org/aspectj/systemtest/ajc189/ajc189.xml | 102 + .../org/aspectj/systemtest/ajc190/Ajc190Tests.java | 57 + .../systemtest/ajc190/AllTestsAspectJ190.java | 29 + .../org/aspectj/systemtest/ajc190/Annotations.java | 176 + .../systemtest/ajc190/EfficientTJPTests.java | 126 + .../org/aspectj/systemtest/ajc190/ModuleTests.java | 179 + .../aspectj/systemtest/ajc190/SanityTests19.java | 153 + .../java/org/aspectj/systemtest/ajc190/ajc190.xml | 216 + .../aspectj/systemtest/ajc190/ajc190_from150.xml | 6290 +++++++++++++++++++ .../org/aspectj/systemtest/ajc190/features190.xml | 172 + .../aspectj/systemtest/ajc190/sanity-tests-19.xml | 70 + .../org/aspectj/systemtest/ajc191/Ajc191Tests.java | 48 + .../systemtest/ajc191/AllTestsAspectJ191.java | 26 + .../systemtest/ajc191/SanityTestsJava10.java | 98 + .../java/org/aspectj/systemtest/ajc191/ajc191.xml | 36 + .../aspectj/systemtest/ajc191/sanity-tests-10.xml | 70 + .../org/aspectj/systemtest/ajc192/Ajc192Tests.java | 98 + .../systemtest/ajc192/AllTestsAspectJ192.java | 26 + .../systemtest/ajc192/SanityTestsJava11.java | 99 + .../java/org/aspectj/systemtest/ajc192/ajc192.xml | 140 + .../aspectj/systemtest/ajc192/sanity-tests-11.xml | 69 + .../org/aspectj/systemtest/ajc193/Ajc193Tests.java | 144 + .../systemtest/ajc193/AllTestsAspectJ193.java | 25 + .../java/org/aspectj/systemtest/ajc193/ajc193.xml | 326 + .../org/aspectj/systemtest/apt/AllTestsApt.java | 25 + .../java/org/aspectj/systemtest/apt/AptTests.java | 65 + .../java/org/aspectj/systemtest/apt/apt-spec.xml | 101 + .../systemtest/aspectpath/AspectPathTests.java | 112 + .../systemtest/aspectpath/aspectpath-tests.xml | 192 + .../aspectj/systemtest/aspectpath/aspectpath.xml | 12 + .../org/aspectj/systemtest/base/BaseTests.java | 188 + .../aspectj/systemtest/bringup/BringUpTests.java | 39 + .../org/aspectj/systemtest/bringup/bringup.xml | 14 + .../org/aspectj/systemtest/design/DesignTests.java | 84 + .../java/org/aspectj/systemtest/design/design.xml | 11 + .../org/aspectj/systemtest/design/designtest.xml | 106 + .../systemtest/incremental/IncrementalTests.java | 309 + .../incremental/incremental-junit-tests.xml | 409 ++ .../systemtest/incremental/incremental-tests.xml | 185 + .../aspectj/systemtest/incremental/incremental.xml | 10 + .../incremental/model/IncrementalModelTests.java | 187 + .../incremental/model/incremental-model-tests.xml | 98 + .../incremental/model/incremental-model.xml | 10 + ...tiProjectIncrementalAjdeInteractionTestbed.java | 284 + .../incremental/tools/AjdeInteractionTestbed.java | 559 ++ .../tools/AjdeInteractionTestbedLauncher.java | 47 + .../tools/AnnotationProcessingTests.java | 169 + .../incremental/tools/CompilerFactory.java | 58 + .../tools/IncrementalCompilationTests.java | 994 +++ .../IncrementalOutputLocationManagerTests.java | 106 + .../tools/IncrementalPerformanceTests.java | 174 + .../tools/MoreOutputLocationManagerTests.java | 382 ++ .../tools/MultiProjTestBuildProgressMonitor.java | 91 + .../tools/MultiProjTestCompilerConfiguration.java | 275 + .../tools/MultiProjTestMessageHandler.java | 133 + .../tools/MultiProjTestOutputLocationManager.java | 120 + .../tools/MultiProjectIncrementalTests.java | 4038 +++++++++++++ .../tools/OutputLocationManagerTests.java | 165 + .../org/aspectj/systemtest/inpath/InPathTests.java | 97 + .../org/aspectj/systemtest/inpath/inpath-tests.xml | 297 + .../java/org/aspectj/systemtest/inpath/inpath.xml | 11 + .../org/aspectj/systemtest/java14/Java14Tests.java | 127 + .../org/aspectj/systemtest/java14/java14-tests.xml | 153 + .../java/org/aspectj/systemtest/java14/java14.xml | 11 + .../knownfailures/KnownfailuresTests.java | 37 + .../systemtest/knownfailures/knownfailures.xml | 13 + .../knownlimitations/KnownLimitationsTests.java | 144 + .../knownlimitations/knownLimitations-tests.xml | 297 + .../knownlimitations/knownLimitations.xml | 11 + .../org/aspectj/systemtest/model/Model5Tests.java | 93 + .../aspectj/systemtest/model/ModelTestCase.java | 218 + .../org/aspectj/systemtest/model/ModelTests.java | 114 + .../java/org/aspectj/systemtest/model/model.xml | 115 + .../aspectj/systemtest/options/OptionsTests.java | 44 + .../aspectj/systemtest/options/options-tests.xml | 37 + .../org/aspectj/systemtest/options/options.xml | 10 + .../aspectj/systemtest/pre10x/AjcPre10xTests.java | 316 + .../org/aspectj/systemtest/pre10x/pre10x-tests.xml | 638 ++ .../java/org/aspectj/systemtest/pre10x/pre10x.xml | 10 + .../aspectj/systemtest/purejava/PureJavaTests.java | 992 +++ .../aspectj/systemtest/purejava/pureJava-tests.xml | 1894 ++++++ .../org/aspectj/systemtest/purejava/pureJava.xml | 10 + .../aspectj/systemtest/serialVerUID/SUIDTests.java | 96 + .../systemtest/serialVerUID/serialVerUID-tests.xml | 169 + .../systemtest/serialVerUID/serialVerUID.xml | 10 + .../java/org/aspectj/systemtest/tests/.cvsignore | 1 + .../aspectj/systemtest/tracing/TracingTests.java | 57 + .../org/aspectj/systemtest/tracing/tracing.xml | 99 + .../org/aspectj/systemtest/xlint/XLint5Tests.java | 36 + .../org/aspectj/systemtest/xlint/XLintTests.java | 169 + .../org/aspectj/systemtest/xlint/xlint-tests.xml | 267 + .../java/org/aspectj/systemtest/xlint/xlint.xml | 10 + .../src/test/java/org/aspectj/testing/Harness.java | 39 + tests/src/test/java/org/aspectj/testing/Utils.java | 83 + .../java/org/aspectj/tests/TestsModuleTests.java | 51 + 303 files changed, 66435 insertions(+) create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests14.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests15.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests16.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests17.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests18.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/AllTests19.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc10x/Ajc10xTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc120/Ajc120Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/AccBridgeMethods.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationBinding.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationPointcutsTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/Annotations.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationsBinaryWeaving.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/Autoboxing.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/CovarianceTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/Enums.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/HasMember.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/MigrationTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/PerTypeWithinTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/RuntimeAnnotations.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/SCCSFixTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/StaticImports.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/SuppressedWarnings.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/VarargsTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ajc150.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjMisuseTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/CoverageTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/misuse.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWServerTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/Ajc151Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/AtAroundTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/ajc151.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/ataround.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc151/serialversionuid.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc152/AllTestsAspectJ152.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc152/ajc152.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc152/synchronization.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/Ajc153Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/AllTestsAspectJ153.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/LTWServer153Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/PipeliningTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/ajc153.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc153/pipelining.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc154/AllTestsAspectJ154.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc154/ajc154.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/Ajc160Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/AllTestsAspectJ160.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/AnnotationValueMatchingTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/NewFeatures.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/ajc160.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/annotationValueMatching.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/newfeatures-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/parameterAnnotations.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc160/sanity-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc161/AllTestsAspectJ161.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc161/OptimizedAnnotationFieldBinding.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc161/ajc161.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc161/annotationFieldBinding.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1610/Ajc1610Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1610/NewFeatures.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1610/ajc1610.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1611/Ajc1611Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1611/AllTestsAspectJ1611.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1611/NewFeatures.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1611/ajc1611.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1612/Ajc1612Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1612/AllTestsAspectJ1612.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1612/ajc1612.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc162/Ajc162Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc162/AllTestsAspectJ162.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc162/ajc162.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/AllTestsAspectJ164.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/DeclareMixinTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/JointpointIdTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/ajc164.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/declareMixin.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc164/joinpointid.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc165/AllTestsAspectJ165.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc165/WorldTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc165/ajc165.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc165/world.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc166/Ajc166Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc166/AllTestsAspectJ166.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc166/ajc166.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/Ajc167Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/AllTestsAspectJ167.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/IntertypeTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/OverweavingTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/ajc167.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/intertype.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc167/overweaving.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/Ajc169Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/AllTestsAspectJ169.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/TransparentWeavingTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/ajc169.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.txt create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc169/transparentweaving.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc170/Ajc170Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc170/AllTestsAspectJ170.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc170/IndyTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc170/ajc170.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc170/indy.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc171/NewFeatures.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc171/ajc171.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc171/newfeatures-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc172/Ajc172Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc172/ajc172.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc173/Ajc173Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc173/AllTestsAspectJ173.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc173/ajc173.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc174/Ajc174Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc174/ajc174.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc175/Ajc175Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc175/AllTestsAspectJ175.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc175/ajc175.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc180/Ajc180Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc180/ajc180.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc181/Ajc181Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc181/AllTestsAspectJ181.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc181/ajc181.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1810/ajc1810.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1811/ajc1811.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc182/Ajc182Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc182/tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc183/Ajc183Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc183/ajc183.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc184/Ajc184Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc184/ajc184.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc185/Ajc185Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc185/AllTestsAspectJ185.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc185/ajc185.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc186/ajc186.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc187/Ajc187Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc187/ajc187.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc188/Ajc188Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc188/ajc188.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc189/Ajc189Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.out.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/Ajc190Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/Annotations.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190_from150.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/features190.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc190/sanity-tests-19.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc191/Ajc191Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc191/ajc191.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc191/sanity-tests-10.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc192/Ajc192Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc192/ajc192.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc192/sanity-tests-11.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc193/Ajc193Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc193/ajc193.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/apt/AllTestsApt.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/apt/AptTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/apt/apt-spec.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/aspectpath/AspectPathTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/base/BaseTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/bringup/BringUpTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/bringup/bringup.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/design/DesignTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/design/design.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/design/designtest.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/incremental-junit-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/incremental-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/incremental.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbedLauncher.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/CompilerFactory.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestBuildProgressMonitor.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/inpath/InPathTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/inpath/inpath-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/inpath/inpath.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/java14/java14-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/java14/java14.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/knownfailures/KnownfailuresTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/knownfailures/knownfailures.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/knownlimitations/KnownLimitationsTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/model/Model5Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/model/ModelTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/model/model.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/options/OptionsTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/options/options-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/options/options.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/pre10x/AjcPre10xTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/purejava/PureJavaTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/purejava/pureJava-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/purejava/pureJava.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/serialVerUID/SUIDTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore create mode 100644 tests/src/test/java/org/aspectj/systemtest/tracing/TracingTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/tracing/tracing.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/xlint/XLint5Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/xlint/XLintTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/xlint/xlint-tests.xml create mode 100644 tests/src/test/java/org/aspectj/systemtest/xlint/xlint.xml create mode 100644 tests/src/test/java/org/aspectj/testing/Harness.java create mode 100644 tests/src/test/java/org/aspectj/testing/Utils.java create mode 100644 tests/src/test/java/org/aspectj/tests/TestsModuleTests.java (limited to 'tests/src/test/java') diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests.java b/tests/src/test/java/org/aspectj/systemtest/AllTests.java new file mode 100644 index 000000000..a4aec7d68 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests.java @@ -0,0 +1,61 @@ +/* + * Created on 03-Aug-2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.aspectj.systemtest; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.ajc10x.Ajc10xTests; +import org.aspectj.systemtest.ajc11.Ajc11Tests; +import org.aspectj.systemtest.ajc120.Ajc120Tests; +import org.aspectj.systemtest.ajc121.Ajc121Tests; +import org.aspectj.systemtest.aspectpath.AspectPathTests; +import org.aspectj.systemtest.base.BaseTests; +import org.aspectj.systemtest.design.DesignTests; +import org.aspectj.systemtest.incremental.IncrementalTests; +import org.aspectj.systemtest.incremental.model.IncrementalModelTests; +import org.aspectj.systemtest.incremental.tools.OutputLocationManagerTests; +import org.aspectj.systemtest.inpath.InPathTests; +import org.aspectj.systemtest.model.ModelTests; +import org.aspectj.systemtest.options.OptionsTests; +import org.aspectj.systemtest.pre10x.AjcPre10xTests; +import org.aspectj.systemtest.serialVerUID.SUIDTests; +import org.aspectj.systemtest.tracing.TracingTests; +import org.aspectj.systemtest.xlint.XLintTests; + +/** + * @author colyer + */ +public class AllTests { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.3"); + //$JUnit-BEGIN$ + suite.addTest(Ajc121Tests.suite()); + suite.addTest(Ajc120Tests.suite()); + suite.addTest(Ajc11Tests.suite()); + suite.addTest(Ajc10xTests.suite()); + suite.addTest(AspectPathTests.suite()); + suite.addTest(InPathTests.suite()); + suite.addTest(BaseTests.suite()); + suite.addTest(DesignTests.suite()); + suite.addTest(IncrementalTests.suite()); + suite.addTestSuite(OutputLocationManagerTests.class); + suite.addTest(IncrementalModelTests.suite()); + //suite.addTest(KnownLimitationsTests.class); + suite.addTest(OptionsTests.suite()); + suite.addTest(AjcPre10xTests.suite()); + //suite.addTest(PureJavaTests.class); + suite.addTest(SUIDTests.suite()); + suite.addTest(XLintTests.suite()); + suite.addTest(TracingTests.suite()); + suite.addTest(ModelTests.suite()); + //$JUnit-END$ + + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests14.java b/tests/src/test/java/org/aspectj/systemtest/AllTests14.java new file mode 100644 index 000000000..da97c7337 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests14.java @@ -0,0 +1,30 @@ +/* + * Created on 03-Aug-2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.aspectj.systemtest; + +import org.aspectj.systemtest.java14.Java14Tests; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author colyer + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class AllTests14 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.4"); + //$JUnit-BEGIN$ + suite.addTest(AllTests.suite()); + suite.addTest(Java14Tests.suite()); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests15.java b/tests/src/test/java/org/aspectj/systemtest/AllTests15.java new file mode 100644 index 000000000..8b19ef23b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests15.java @@ -0,0 +1,49 @@ +/* + * Created on 19-01-2005 + */ +package org.aspectj.systemtest; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.ajc150.AllTestsAspectJ150; +import org.aspectj.systemtest.ajc150.ataspectj.AtAjAnnotationGenTests; +import org.aspectj.systemtest.ajc151.AllTestsAspectJ151; +import org.aspectj.systemtest.ajc152.AllTestsAspectJ152; +import org.aspectj.systemtest.ajc153.AllTestsAspectJ153; +import org.aspectj.systemtest.ajc154.AllTestsAspectJ154; +import org.aspectj.systemtest.incremental.tools.IncrementalCompilationTests; +import org.aspectj.systemtest.incremental.tools.IncrementalOutputLocationManagerTests; +import org.aspectj.systemtest.incremental.tools.IncrementalPerformanceTests; +import org.aspectj.systemtest.incremental.tools.MoreOutputLocationManagerTests; +import org.aspectj.systemtest.incremental.tools.MultiProjectIncrementalTests; +import org.aspectj.systemtest.model.Model5Tests; +import org.aspectj.systemtest.xlint.XLint5Tests; + +public class AllTests15 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.5"); + // $JUnit-BEGIN$ + suite.addTest(AllTests14.suite()); + suite.addTest(AllTestsAspectJ150.suite()); + suite.addTest(AllTestsAspectJ151.suite()); + suite.addTest(AllTestsAspectJ152.suite()); + suite.addTest(AllTestsAspectJ153.suite()); + suite.addTest(AllTestsAspectJ154.suite()); + suite.addTest(AtAjAnnotationGenTests.suite()); + suite.addTest(Model5Tests.suite()); + /* + * FIXME maw Many of these tests do not depend on Java 5 but they cannot be executed in Eclipse with 1.3 because of XML + * issues and are excluded on the build machine so moving them here loses nothing for the moment. + */ + suite.addTestSuite(MultiProjectIncrementalTests.class); + suite.addTestSuite(IncrementalCompilationTests.class); + suite.addTestSuite(IncrementalPerformanceTests.class); + suite.addTestSuite(MoreOutputLocationManagerTests.class); + suite.addTestSuite(IncrementalOutputLocationManagerTests.class); + suite.addTest(XLint5Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests16.java b/tests/src/test/java/org/aspectj/systemtest/AllTests16.java new file mode 100644 index 000000000..f1f7b4a14 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests16.java @@ -0,0 +1,45 @@ +/* + * Created on 19-01-2005 + */ +package org.aspectj.systemtest; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.ajc160.AllTestsAspectJ160; +import org.aspectj.systemtest.ajc161.AllTestsAspectJ161; +import org.aspectj.systemtest.ajc1610.AllTestsAspectJ1610; +import org.aspectj.systemtest.ajc1611.AllTestsAspectJ1611; +import org.aspectj.systemtest.ajc1612.AllTestsAspectJ1612; +import org.aspectj.systemtest.ajc162.AllTestsAspectJ162; +import org.aspectj.systemtest.ajc163.AllTestsAspectJ163; +import org.aspectj.systemtest.ajc164.AllTestsAspectJ164; +import org.aspectj.systemtest.ajc165.AllTestsAspectJ165; +import org.aspectj.systemtest.ajc166.AllTestsAspectJ166; +import org.aspectj.systemtest.ajc167.AllTestsAspectJ167; +import org.aspectj.systemtest.ajc169.AllTestsAspectJ169; +import org.aspectj.systemtest.incremental.tools.AnnotationProcessingTests; + +public class AllTests16 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.6"); + // $JUnit-BEGIN$ + // These 16X tests do not require 1.6 jre to run + suite.addTest(AllTestsAspectJ160.suite()); + suite.addTest(AllTestsAspectJ161.suite()); + suite.addTest(AllTestsAspectJ162.suite()); + suite.addTest(AllTestsAspectJ163.suite()); + suite.addTest(AllTestsAspectJ164.suite()); + suite.addTest(AllTestsAspectJ165.suite()); + suite.addTest(AllTestsAspectJ166.suite()); + suite.addTest(AllTestsAspectJ167.suite()); + suite.addTest(AllTestsAspectJ169.suite()); + suite.addTest(AllTestsAspectJ1610.suite()); + suite.addTest(AllTestsAspectJ1611.suite()); + suite.addTest(AllTestsAspectJ1612.suite()); + suite.addTestSuite(AnnotationProcessingTests.class); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests17.java b/tests/src/test/java/org/aspectj/systemtest/AllTests17.java new file mode 100644 index 000000000..9feebfb1e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests17.java @@ -0,0 +1,32 @@ +/* + * Created on 19-01-2005 + */ +package org.aspectj.systemtest; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.ajc170.AllTestsAspectJ170; +import org.aspectj.systemtest.ajc171.AllTestsAspectJ171; +import org.aspectj.systemtest.ajc172.AllTestsAspectJ172; +import org.aspectj.systemtest.ajc173.AllTestsAspectJ173; +import org.aspectj.systemtest.ajc174.AllTestsAspectJ174; +import org.aspectj.systemtest.ajc175.AllTestsAspectJ175; + +public class AllTests17 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.7"); + // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ175.suite()); + suite.addTest(AllTestsAspectJ174.suite()); + suite.addTest(AllTestsAspectJ173.suite()); + suite.addTest(AllTestsAspectJ172.suite()); + suite.addTest(AllTestsAspectJ171.suite()); + suite.addTest(AllTestsAspectJ170.suite()); + suite.addTest(AllTests16.suite()); + suite.addTest(AllTests15.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests18.java b/tests/src/test/java/org/aspectj/systemtest/AllTests18.java new file mode 100644 index 000000000..9c2387b0d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests18.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest; + +import org.aspectj.systemtest.ajc180.AllTestsAspectJ180; +import org.aspectj.systemtest.ajc181.AllTestsAspectJ181; +import org.aspectj.systemtest.ajc1810.AllTestsAspectJ1810; +import org.aspectj.systemtest.ajc1811.AllTestsAspectJ1811; +import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; +import org.aspectj.systemtest.ajc183.AllTestsAspectJ183; +import org.aspectj.systemtest.ajc184.AllTestsAspectJ184; +import org.aspectj.systemtest.ajc185.AllTestsAspectJ185; +import org.aspectj.systemtest.ajc186.AllTestsAspectJ186; +import org.aspectj.systemtest.ajc187.AllTestsAspectJ187; +import org.aspectj.systemtest.ajc188.AllTestsAspectJ188; +import org.aspectj.systemtest.ajc189.AllTestsAspectJ189; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests18 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8"); + // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ1811.suite()); + suite.addTest(AllTestsAspectJ1810.suite()); + suite.addTest(AllTestsAspectJ189.suite()); + suite.addTest(AllTestsAspectJ188.suite()); + suite.addTest(AllTestsAspectJ187.suite()); + suite.addTest(AllTestsAspectJ186.suite()); + suite.addTest(AllTestsAspectJ185.suite()); + suite.addTest(AllTestsAspectJ184.suite()); + suite.addTest(AllTestsAspectJ183.suite()); + suite.addTest(AllTestsAspectJ182.suite()); + suite.addTest(AllTestsAspectJ181.suite()); + suite.addTest(AllTestsAspectJ180.suite()); + suite.addTest(AllTests17.suite()); +// suite.addTest(AllTests16.suite()); +// suite.addTest(AllTests15.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java new file mode 100644 index 000000000..c2c798c32 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest; + +import org.aspectj.systemtest.ajc190.AllTestsAspectJ190; +import org.aspectj.systemtest.ajc191.AllTestsAspectJ191; +import org.aspectj.systemtest.ajc192.AllTestsAspectJ192; +import org.aspectj.systemtest.ajc193.AllTestsAspectJ193; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests19 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.9"); + // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ190.suite()); + suite.addTest(AllTestsAspectJ191.suite()); + suite.addTest(AllTestsAspectJ192.suite()); + suite.addTest(AllTestsAspectJ193.suite()); + suite.addTest(AllTests18.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc10x/Ajc10xTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc10x/Ajc10xTests.java new file mode 100644 index 000000000..1fb6b7045 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc10x/Ajc10xTests.java @@ -0,0 +1,1176 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.ajc10x; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc10xTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc10xTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc10x.xml"); + } + + public void test001() { + runTest("properly make choice between cast and parenthesis in parser"); + } + + public void test002() { + runTest("field from implemented interface not found in advice"); + } + + public void test003() { + runTest("make sure advice affects introduced methods and constructors"); + } + + public void test004() { + runTest("new around construct"); + } + + public void test005() { + runTest("aspect redefines a parameter"); + } + + public void test006() { + runTest("introducing extends and implements"); + } + + public void test007() { + runTest("(related) aspect on interface"); + } + + public void test008() { + runTest("advice and package visibility"); + } + + public void test009() { + runTest("advice and package visibility"); + } + + public void test010() { + runTest("advice on implied empty constructor"); + } + + public void test011() { + runTest("advice on * *(..) not mapping to initializers"); + } + + public void test012() { + runTest("three type declarations in the scope of an advice"); + } + + public void test013() { + runTest("introduction fails on class with an inner class that extends or implements something"); + } + + public void test014() { + runTest("checks that methods are introduced on the topmost class implemented"); + } + + public void test015() { + runTest("a couple different returns from around advice"); + } + + public void test016() { + runTest("member finally advice paired with signature advice"); + } + + public void test017() { + runTest("aspect of eachobject(instanceof(Interface))"); + } + + public void test018() { + runTest("final member initialization broken with JDK before 1.1.8"); + } + + public void test019() { + runTest("same package and var name clash in preprocessed code when aspectOf is used"); + } + + public void test020() { + runTest("and PR#201 advice on static methods fails javac compile with this"); + } + + public void test021() { + runTest("non-static advice on inner class defined inside of method body"); + } + + public void test022() { + runTest("simple single-threaded eachcflow test (includes aspectOf)"); + } + + public void test023() { + runTest("bad type resolution when var reassigned in same scope"); + } + + public void test024() { + runTest("generating the right throws clause for call-site advice (and around)"); + } + + public void test025() { + runTest("advice on calls to static methods using several syntax"); + } + + public void test026() { + runTest(", PR#249, PR#250 advice on constructor sites"); + } + + public void test027() { + runTest("test after throwing advice in several ways"); + } + + public void test028() { + runTest("fancy name patterns for method names"); + } + + public void test029() { + runTest("calls: calls(...)"); + } + + public void test030() { + runTest("throws Exception clause is unnecessarily added to Driver.main method"); + } + + public void test031() { + runTest("javac fails when this is referenced in the static main method"); + } + + public void test032() { + runTest("and 276 cast error generated by ajc when type not in signature"); + } + + public void test033() { + runTest("calls to methods to which we don't have source"); + } + + public void test034() { + runTest("more aspect inheritance"); + } + + public void test035() { + runTest("around and calls with both calling and called this params"); + } + + public void test036() { + runTest("compiler crashes with eachobject and named pointcuts with parameters"); + } + + public void test037() { + runTest("lookup rules for unqualified pointcut names"); + } + + public void test038() { + runTest("eachcflow only instantiated if the aspect has some advice in it"); + } + + public void test039() { + runTest("(DESIGN QUESTION) aspect of eachJVM advising its own initializer"); + } + + public void test040() { + runTest("after returning advice on calls to constructors"); + } + + public void test041() { + runTest("Does annotating 'new' with a type work as desired?"); + } + + public void test042() { + runTest("Referring to inner classes as {super}.{inner} confused ajc."); + } + + public void test043() { + runTest("Advice on advice"); + } + + public void test044() { + runTest("Introductions on other introductions"); + } + + public void test045() { + runTest("Putting advice on array constructors."); + } + + public void test046() { + runTest("call points within block inner classes are doubled"); + } + + public void test047() { + runTest("Gets and sets with other advice"); + } + + public void test048() { + runTest("Compiler can compile correct strictfp modifiers"); + } + + public void test049() { + runTest("basic test of callsto pointcuts"); + } + + public void test050() { + runTest("package wildcards in packages"); + } + + public void test051() { + runTest("around advice on calls and receptions with lots of context"); + } + + public void test052() { + runTest("! modifier and char in pointcut (no longer an error)"); + } + + public void test053() { + runTest("right number of aspect instances per cflow"); + } + + public void test054() { + runTest("many this's into around advice on calls"); + } + + public void test055() { + runTest("Ensures introduction methods can have advice placed on them"); + } + + public void test056() { + runTest("No boolean appearing in the 'if' clause for around advice with eachJVM()"); + } + + public void test057() { + runTest("Order of super introductions."); + } + + public void test058() { + runTest("Ensuring backdoor methods are produced."); + } + + public void test059() { + runTest("no duplicate advice methods in abstract aspects"); + } + + public void test060() { + runTest("no duplicate advice methods in abstract aspects extended"); + } + + public void test061() { + runTest("Putting after-constructor advice on the wrong types implementing the same interface."); + } + + public void test062() { + runTest("Instantiating non-static inner classes in advice."); + } + + public void test063() { + runTest("Referring to pointcut in of clauses"); + } + + public void test064() { + runTest("Confused referring to instance variables and locals"); + } + + public void test065() { + runTest("Parsing C+ expressions without parens in super introductions."); + } + + public void test066() { + runTest("Introducing methods on classes that implements inner-interfaces with +implements."); + } + + public void test067() { + runTest("Methods with the same name are generated when abstract aspects extend another abstract aspect."); + } + + public void test068() { + runTest("Making sure final variables stay final."); + } + + public void test069() { + runTest("Problem resolving meta-joinpoint names with around advice on methods called from around advice."); + } + + public void test070() { + runTest("Make sure that names of lifted local classes are right when referenced in call-site advice"); + } + + public void test071() { + runTest("matching for throws clause"); + } + + public void test072() { + runTest("basic test of declare soft"); + } + + public void test073() { + runTest("advice on calls to constructors of anonymous inners and access to context"); + } + + public void test074() { + runTest("inner aspects can't access outer pointcuts"); + } + + public void test075() { + runTest("implements and extends are introduced before methods and fields"); + } + + public void test076() { + runTest("a static/inner aspect of a inner class of an aspect is pulled to the top level as static"); + } + + public void test077() { + runTest("Crashes with privileged aspect."); + } + + public void test078() { + runTest("join points exist in the execution of field initializers"); + } + + public void test079() { + try { + runTest("privileged aspects"); + } finally { + System.out.println(ajc.getLastCompilationResult().getStandardError()); + System.out.println(ajc.getLastCompilationResult().getStandardOutput()); + } + } + + public void test080() { + runTest("advice on field gets in privileged aspects"); + } + + public void test081() { + runTest("Two anonymous classes in the same scope"); + } + + public void test082() { + runTest("basic tests for initializer and staticinitializer PCDs"); + } + + public void test083() { + runTest("introduction of an initializer into a class"); + } + + public void test084() { + runTest("some method accessibility tests, particularly package-protected and inheritance"); + } + + public void test085() { + runTest("fairly monotonous (and non-covering) tests for expanded dot patterns"); + } + + public void test086() { + runTest("field patterns and subtyping"); + } + + public void test087() { + runTest("Checking formal matching as in Roeder's bug in 0.7b10"); + } + + public void test088() { + runTest("Introducing synchronized methods on interfaces."); + } + + public void test089() { + runTest("The pointcut params (..,int..) is not recognizing (Object,int,Object)."); + } + + public void test090() { + runTest("calls advice on array objects causes error in code generation"); + } + + public void test091() { + runTest("join points in field initializers aren't showing up."); + } + + public void test092() { + runTest("Handlers problem"); + } + + public void test093() { + runTest("work nicely with inner class method look-up rules and call-site advice"); + } + + public void test094() { + runTest("strictfp modifier allowed on advice"); + } + + public void test095() { + runTest("No argthis was being created for calls advice."); + } + + public void test096() { + runTest("Ensuring no advice with instanceof(..) is run on static methods."); + } + + public void test097() { + runTest("Null pointer on gets advice showing the case causing the error"); + } + + public void test098() { + runTest("try to make sure that dynamic JoinPoint objects aren't generated when used inside of if (false) { ... }"); + } + + public void test099() { + runTest("within and withincode (doesn't all work due to local class name issues)"); + } + + public void test100() { + runTest("around advice on calls within inner classes (including protected method calls)"); + } + + public void test101() { + runTest("around advice on calls within inner classes (including protected method calls)"); + } + + public void test102() { + runTest("Arguments to runNext should be final when needed"); + } + + public void test103() { + runTest("Method introductions"); + } + + public void test104() { + runTest("Putting an introduced method on each interface"); + } + + public void test105() { + runTest("Extending interfaces"); + } + + public void test106() { + runTest("Introducing private methods on interfaces"); + } + + public void test107() { + runTest("Issuing errors for assigning variables thisJoinPoint -- not assigning thisJoinPoint."); + } + + public void test108() { + runTest("Static references inside of introduced bodies get bound correctly."); + } + + public void test109() { + runTest("cflow and object creations [of eachcflow]"); + } + + public void test110() { + runTest("Doesn't import MightHaveAspect when compiling with more than 1 file. [eachobject]"); + } + + public void test111() { + runTest("test binding to formals in calls to constructors (binding to null) (eachobject !!! now misnamed)"); + } + + public void test112() { + runTest("After advice isn't being woven into after throwing advice"); + } + + public void test113() { + runTest("Throwing an EmptyStackException."); + } + + public void test114() { + runTest("check that MightHaveAspect interface is created correctly for an aspect in deep package"); + } + + public void test115() { + runTest("Defines clfow$ajc0 more once. [eachcflow]"); + } + + public void test116() { + runTest("Various calls, receptions, and callsto tests [callsto]"); + } + + public void test117() { + runTest("Was throwing exception, now just an error. [eachobject]"); + } + + public void test118() { + runTest("different version of aspect inheritance, particularly empty pointcuts and abstract cflows [eachcflow]"); + } + + public void test119() { + runTest("set advice on member initing throwing exception [eachobject]"); + } + + public void test120() { + runTest("Testing class names with same name's with difference case as package. [eachobject]"); + } + + public void test121() { + runTest("Null pointer on gets advice with coverage [painful]"); + } + + public void test122() { + runTest("Basic test for cflow pointcuts [eachcflow]"); + } + + public void test123() { + runTest("Crashing when looking up the type of array members."); + } + + public void test124() { + runTest("PostfixExprs to various synthetic things are fixed correctly [eachobject]"); + } + + public void test125() { + runTest("Dave Binkley's problem with eachcflowroot. [eachcflow]"); + } + + public void test126() { + runTest("advice on an inherited method"); + } + + public void test127() { + runTest(", PR#115 checks the ordering of catch clauses"); + } + + public void test128() { + runTest("various declared exception permutations"); + } + + public void test129() { + runTest("ordering of advice kinds as well as cflow and dominates"); + } + + public void test130() { + runTest("advice on default constructor for a class only referenced via reflection"); + } + + public void test131() { + runTest("calling and called this params in calls points"); + } + + public void test132() { + runTest("primitive parameters coercable to Object just like return values are"); + } + + public void test133() { + runTest("join points in static/dynamic initializers aren't showing up."); + } + + public void test134() { + runTest("Gets and sets on a number of variables (field access ???)"); + } + + public void test135() { + runTest("Joinpoints are showing up on intermediate call sites"); + } + + public void test136() { + runTest("Reception based on strictfp modifier"); + } + + public void test137() { + runTest("Subclasses that do not redefine a method are not being handled correctly"); + } + + public void test138() { + runTest("making sure that super calls are bound to the right methods"); + } + + public void test139() { + runTest("inheritance, around advice and abstract pointcuts [eachobject] (still)"); + } + + public void test140() { + runTest("Priviledged aspect methods are missing for privates. [eachobject]"); + } + + public void test141() { + runTest("exceptions thrown and caught in advice, particularly try+proceed"); + } + + public void test142() { + runTest("Not and And operators in pointcuts not working"); + } + + public void test143() { + runTest("Member initializers should run before the current class constructor"); + } + + public void test144() { + runTest("Coverage tests for Member initializers should run before the current class constructor and after super"); + } + + public void test145() { + runTest("thisJoinPoint{Static} not visible in if() pcd of named pointcut"); + } + + public void test146() { + runTest("pcd if() expression visibility at compile-time (minimal operation)"); + } + + public void test147() { + runTest("pcd if() NPE in compiler when unwinding assignment in pcd if(expr)"); + } + + public void test148() { + runTest("pcd if() dup methods produced when pointcut after advice etc (javac)"); + } + + public void test149() { + runTest("pcd if() variants: [anonymous, named] x [execution, call, callTyped, get, set, initializations] x [before, after, around]"); + } + + // moved to ajcTestsFailing.xml + // public void test150(){ + // runTest("advice on advice in usejavac mode"); + // } + + public void test151() { + runTest("initialization order with this"); + } + + public void test152() { + runTest("!within and !this handling for callee-side call points"); + } + + public void test153() { + runTest("private inner interfaces and bytecode visibility"); + } + + public void test154() { + runTest("elaborated into testing of around on all join points"); + } + + public void test155() { + runTest("type name hygiene when code comes from aspects in different packages"); + } + + public void test156() { + runTest("cflowbelow dependencies (from Chris Dutchyn)"); + } + + public void test157() { + runTest("Compiler incorrectly flagging *1 (non-alphabetic start to signature pattern)"); + } + + public void test158() { + runTest("Unable to bind privately-introduced field name from introduced method in the same aspect"); + } + + public void test159() { + runTest("anonymous inner class with aspect"); + } + + public void test160() { + runTest("Arguments are not being passed in to calls advice"); + } + + public void test161() { + runTest("interfaces as mixins with introduction"); + } + + public void test161b() { + runTest("interfaces as mixins with introduction b"); + } + + public void test162() { + runTest("functional modifiers work correctly with introduced members"); + } + + public void test163() { + runTest("ExceptionInInitializerError accessing cflow in aspect initialization - before variants"); + } + + public void test164() { + runTest("NoClassDefFoundError accessing cflow in aspect initialization - after variants"); + } + + public void test165() { + runTest("InternalCompilerError in JpPlan when args alone"); + } + + public void test166() { + runTest("compile error using pcd if() with advice on introduced methods."); + } + + public void test167() { + runTest("compile errors boolean using cflow and unimplemented method using around advice on methods introduced by interface"); + } + + public void test168() { + runTest("aspect as member of interface"); + } + + public void test169() { + runTest("missing method name to synthetic invocation"); + } + + public void test170() { + runTest("protected subclass impl of superclass method with default access and variants"); + } + + public void test171() { + runTest("Exception planning advice"); + } + + public void test172() { + runTest("unreproduced bug with advice - probably UTR"); + } + + public void test173() { + runTest("introduced inner interfaces accessible inside aspect"); + } + + public void test174() { + runTest("validate (enclosing) join point and source locations"); + } + + public void test175() { + runTest("advice formals are just like method formals"); + } + + public void test176() { + runTest("advice formals produce errors just like method formals"); + } + + public void test177() { + runTest("advice throws clauses must be compatible with joinpoints they apply to"); + } + + public void test178() { + runTest("potential method conflicts with introductions and interfaces and PR#561"); + } + + public void test179() { + runTest("illegal method conflicts with introductions and interfaces and PR#561"); + } + + public void test180() { + runTest("AspectOf available for different aspect types"); + } + + public void test181() { + runTest("access to all members of class and inner class from privileged aspect"); + } + + public void test182() { + runTest("cflow alone with around produces compiler bcg StackOverflowError"); + } + + public void test183() { + runTest("get/set join points run for complex assignment operators (+=, etc.) (working)"); + } + + public void test184() { + runTest("this available in introduced field initializers"); + } + + public void test185() { + runTest("Introduced type unavailable to cast expressions in introduced methods"); + } + + public void test186() { + runTest("Introduced type unavailable to qualified new expressions in introduced methods"); + } + + public void test187() { + runTest("Introduced type unavailable to cast expressions in introduced field initializers"); + } + + public void test188() { + runTest("Aspect type unavailable to qualified new expressions in body of introduced methods"); + } + + public void test189() { + runTest("Introduced type unavailable to qualified new expressions in introduced field initializers"); + } + + public void test190() { + runTest("variable slots and finally/catch causing verify errors"); + } + + public void test191() { + runTest("after advice on static method with pcd if() using result"); + } + + public void test192() { + runTest("after advice on static method with pcd if() using result through pointcut"); + } + + public void test193() { + runTest("AbstractMethodError for introduced methods (order 1)"); + } + + public void test194() { + runTest("AbstractMethodError for introduced methods (order 2)"); + } + + public void test195() { + runTest("AbstractMethodError for introduced methods (order 3)"); + } + + public void test196() { + runTest("AbstractMethodError for introduced methods (order 4)"); + } + + public void test197() { + runTest("AbstractMethodError for introduced methods (order 5)"); + } + + public void test198() { + runTest("declare error and abstract pointcuts"); + } + + public void test199() { + runTest("Exercise runtime classes (optionally in 1.1 VM)"); + } + + public void test200() { + runTest("VerifyError after around advice falls off end of tryCatch"); + } + + public void test201() { + runTest("Named within pointcuts failing"); + } + + public void test202() { + runTest("aspect with private abstract pointcut"); + } + + public void test203() { + runTest("concrete aspect unable to access abstract package-private pointcut in parent for overriding"); + } + + public void test204() { + runTest("inner, outer, and outside-package subaspects of an aspect with abstract protected-, public-, and default-access pointcuts"); + } + + public void test205() { + runTest("inner subaspects of an aspect with private pointcut"); + } + + public void test206() { + runTest("outer subaspects of an aspect with private pointcut"); + } + + public void test207() { + runTest("abstract aspect used statically should not cause instantiation of advice or pointcut"); + } + + public void test208() { + runTest("private inner interface accessible in scope when declared on outer class"); + } + + public void test209() { + runTest("accessing protected superclass members in and outside CCC from body of method introduction"); + } + + public void test210() { + runTest("accessing private superclass members from body of method introduction"); + } + + public void test211() { + runTest("simple test for around and casting"); + } + + public void test212() { + runTest("aroundInner 1 - around advice inner Thread subclass running proceed but not writing field"); + } + + public void test213() { + runTest("aroundInner 2 - around advice inner Runnable running proceed and writing method-final proxy"); + } + + public void test214() { + runTest("aroundInner 3 - around advice inner class running proceed and writing field"); + } + + public void test215() { + runTest("aroundInner 4 - around advice inner Thread subclass running proceed and writing field"); + } + + public void test216() { + runTest("aroundInner 5 - around advice inner Runnable (subinterface) running proceed and writing field introduced on subinterface"); + } + + public void test217() { + runTest("Named local class closing over proceed invocation"); + } + + public void test218() { + runTest("beautiful recursive computation of factorial with around is now supported"); + } + + public void test219() { + runTest("multi-dispatch not used for named pcd references"); + } + + public void test220() { + runTest("multi-dispatch implemented through around + args"); + } + + public void test221() { + runTest("unrecognized aspect should not net Cloneable and Serializable warnings"); + } + + public void test222() { + // FIXME AV - infinite loop on JRockit in m5 advice - don't know why + runTest("unreachable code generated by around advice on the execution of void methods"); + } + + public void test223() { + runTest("Overriding method implementations using introduction on interfaces"); + } + + public void test224() { + runTest("more coverage for around and concrete methods on interfaces"); + } + + public void test225() { + runTest("invalid number and type of proceed arguments"); + } + + public void test226() { + runTest("after returning advice order"); + } + + public void test227() { + runTest("after returning advice param"); + } + + public void test228() { + runTest("! and declaring types with callee-side call join points"); + } + + public void test229() { + runTest(". Binding the wrong arguments in withincode(..)."); + } + + public void test230() { + runTest(". Matching arguments in cflow correctly."); + } + + public void test231() { + runTest(". Binding variables with numbers in their name with pertarget(..)'s."); + } + + public void test232() { + runTest("second arg in formal on shared joinpoint with pcd if() causes verify error ??"); + } + + public void test233() { + runTest("access to private members from privileged aspect"); + } + + public void test234() { + runTest("inner classes of privileged aspects cannot see target class private members"); + } + + public void test235() { + runTest("aspects should get package access outside the file"); + } + + public void test236() { + runTest("subclass advice not run for join points selected by superclass cflow-based pointcuts"); + } + + public void test237() { + runTest("more issues with abstract aspects and cflow pointcuts"); + } + + public void test238() { + runTest("compile fails for aspect derived from percflow base aspect unless pointcut excludes base aspect and subaspects"); + } + + public void test239() { + runTest("pertarget stack overflow getting name of anonymous (Interface) class"); + } + + public void test240() { + runTest("pertarget stack overflow getting name of anonymous (Object) class"); + } + + public void test241() { + runTest("pertarget runtime stack overflow (getting name of anonymous (Object) class?)"); + } + + public void test242() { + runTest("subaspect method declaration on superaspect inner interface (names)"); + } + + public void test243() { + runTest("subaspect method declaration on superaspect inner interface (access)"); + } + + public void test244() { + runTest("subaspect method declaration on superaspect inner interface (types)"); + } + + public void test245() { + runTest("around AST type XXX"); + } + + public void test246() { + runTest("around all execution with double assignment in initializer (simple)"); + } + + public void test247() { + runTest("around all execution with double assignment in initializer (coverage)"); + } + + public void test248() { + runTest("changing this in around's proceed reported by Rich Price"); + } + + public void test249() { + runTest("default package for aspect introductions is not the current package"); + } + + public void test250() { + runTest("anon class written to wrong directory"); + } + + public void test251() { + runTest("unqualified transitive pointcut references not resolved"); + } + + public void test252() { + runTest("unqualified transitive pointcut references not resolved - 2"); + } + + public void test253() { + runTest("direct use outside aspect of defined abstract pointcut"); + } + + public void test254() { + runTest("direct use outside aspect of undefined abstract pointcut"); + } + + public void test255() { + runTest("indirect use outside aspect of undefined abstract pointcut"); + } + + public void test256() { + runTest("simple call join point tests for JoinPoint SourceLocation context"); + } + + public void test257() { + runTest("!target with second advice on casted call"); + } + + public void test258() { + runTest("name binding in around cflow"); + } + + public void test259() { + runTest("name binding in around cflow - 2"); + } + + public void test260() { + runTest("around name-binding in cflows using factorial"); + } + + public void test261() { + runTest("replacing this or target in around advice"); + } + + public void test262() { + runTest("after returning from initialization and after executing constructor"); + } + + public void test263() { + runTest("after returning from initialization causes ExceptionInInitializer in aspect"); + } + + public void test264() { + runTest("name binding in before cflow containing cflowbelow"); + } + + public void test265() { + runTest("file order in type searching"); + } + + public void test266() { + runTest("simple declare warning (NPE)"); + } + + public void test267() { + runTest("ajc dies on cflow into field init anon class see knownbugs.txt"); + } + + public void test268() { + runTest("Incrementing interface-introduced field"); + } + + public void test269() { + runTest("The dynamic type, not the static one, should be used in if pcds"); + } + + public void test270() { + runTest("bad interaction with after returning, around and void methods (from Rich Price)"); + } + + public void test271() { + runTest("type pattern matching for inner classes (from Ken Horn)"); + } + + public void test272() { + runTest("static initializer member name"); + } + + public void test273() { + runTest("cflow pcd syntax error"); + } + + public void test274() { + runTest("binding args with indeterminate prefix and suffix"); + } + + public void test275() { + runTest("check arg types with indeterminate prefix and suffix"); + } + + public void test276() { + runTest("testing and binding args with single indeterminate prefix and suffix"); + } + + public void test277() { + runTest("binding handler args with indeterminate prefix and suffix"); + } + + public void test278() { + runTest("Compiling java.lang.Object with ajc yields non-verifying bytecode"); + } + + public void test279() { + runTest("method-local class defined in around return statement"); + } + + public void test280() { + runTest("CE expected for assignment to arg in if pcd"); + } + + public void test281() { + runTest("advising field get/sets when accessing via super"); + } + + public void test282() { + runTest("accessing private members in outer types"); + } + + public void test283() { + runTest("can't apply around advice to the execution of around advice"); + } + + public void test284() { + runTest("incompatible advice throws clause are a compile-time error"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml new file mode 100644 index 000000000..56ee8f6e4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml @@ -0,0 +1,2013 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x.xml b/tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x.xml new file mode 100644 index 000000000..90198331d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc10x/ajc10x.xml @@ -0,0 +1,9 @@ + +]> + + + + +&tests; + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java new file mode 100644 index 000000000..ff19e7954 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java @@ -0,0 +1,485 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.ajc11; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.LangUtil; + +public class Ajc11Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc11Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc11.xml"); + } + + public void test001() { + runTest("declare interface extends class"); + } + + public void test002() { + runTest("declare interface implements class"); + } + + public void test003() { + runTest("declaring a private method on an inner interface"); + } + + public void test004() { + runTest("CE expected when declaring fields on arrays"); + } + + public void test005() { + runTest("signature of handler join point"); + } + + public void test006() { + runTest("source locations within expressions"); + } + + public void test007() { + runTest("crashes given method in declared method"); + } + + public void test008() { + runTest("after returning advice on interface constructor"); + } + + public void test009() { + runTest("after returning advice on interface constructor - error"); + } + + public void test010() { + runTest("after advice on static call join point"); + } + + public void test011() { + runTest("incompatible class change error"); + } + + public void test012() { + runTest("simple cflow of method execution"); + } + + public void test013() { + runTest("using instance as class reference to constant field"); + } + + public void test014() { + runTest("interface self-reference in anonymous instance"); + } + + public void test015() { + runTest("self-reference from (aspect-declared) method-local class"); + } + + public void test016() { + runTest("expect CE for unterminated declare error"); + } + + public void test017() { + runTest("expect CE for declaration collision between subaspects instead of domination order"); + } + + public void test018() { + runTest("subtype pattern in dominates should pick out aspect subtypes"); + } + + public void test019() { + runTest("subtype pattern in dominates will conflict with type pattern"); + } + + public void test020() { + runTest("after returning advice on interface and implementation constructor"); + } + + public void test021() { + runTest("after throwing advice with non-throwable formal"); + } + + public void test022() { + runTest("declare array field using postfix"); + } + + public void test023() { + runTest("prohibit declaring new aspect constructor with arguments"); + } + + public void test024() { + runTest("prohibit declaring only aspect constructor with arguments"); + } + + public void test025() { + runTest("declare class extends interface"); + } + + public void test026() { + runTest("declare class implements class"); + } + + public void test027() { + runTest("declare interface implements interface"); + } + + public void test028() { + runTest("if and cflow arg binding"); + } + + public void test029() { + runTest("circularity in declare dominates"); + } + + public void test030() { + runTest("percflow code hangs compiler"); + } + + public void test031() { + runTest("Verification error tracing constructor that takes arguments"); + } + + public void test032() { + runTest("declared exceptions in inter-type decls"); + } + + public void test033() { + runTest("Verify error on non-Throwable in declare soft"); + } + + public void test034() { + runTest("inter-type fields with array types"); + } + + public void test035() { + runTest("checking around join point for advice return type - numeric"); + } + + public void test036() { + runTest("void around advice without proceed"); + } + + public void test037() { + runTest("declaring method on superclass and subclass"); + } + + public void test038() { + runTest("introducing final fields (simple)"); + } + + public void test039() { + runTest("introducing final fields and using as constants"); + } + + public void test040() { + runTest("introducing final fields and checking errors"); + } + + public void test041() { + runTest("Static inner aspects cannot reference user defined pointcuts"); + } + + public void test042() { + runTest("Static inner aspects cannot reference user defined pointcuts"); + } + + public void test043() { + runTest("Declare precedence should not allow multiple * patterns"); + } + + public void test044() { + runTest("VerifyError on accessing objects not accessible to the weaver"); + } + + public void test045() { + runTest("aspect static initializers should run before instance constructed"); + } + + public void test046() { + runTest("super call in intertype method declaration body causes VerifyError"); + } + + public void test047() { + runTest("Error with certain combination of advice"); + } + + public void test048() { + runTest("Pointcut adviceexecution() does not work"); + } + + public void test049() { + runTest("problems with finalize call"); + } + + public void test050() { + runTest("Negation of if pointcut does not work"); + } + + public void test051() { + runTest("ajc reports error when encountering static declaration of nested classes"); + } + + public void test052() { + runTest("can't use pointcuts defined in inner aspects "); + } + + public void test053() { + runTest("can't resolve nested public interfaces (also PR#32399)"); + } + + public void test054() { + runTest("thisJoinPoint.getArgs() causes IncompatibleClassChangeError"); + } + + public void test055() { + runTest("inter-type declaration of void field"); + } + + public void test056() { + runTest("no such constructor for proceed argument (error)"); + } + + public void test057() { + runTest("omnibus declare warning context with no initializer/constructor"); + } + + public void test058() { + runTest("omnibus declare warning context"); + } + + public void test059() { + runTest("cflow binding issues with ignoring state"); + } + + public void test060() { + runTest("cflow binding -- original weaver crash"); + } + + public void test061() { + runTest("type not imported in around advice"); + } + + public void test062() { + runTest("type not imported in aspect"); + } + + public void test063() { + runTest("class extending abstract aspect"); + } + + public void test064() { + runTest("declare soft and throw statements"); + } + + public void test065() { + runTest("inter-type declaration bug with abstract classes"); + } + + public void test066() { + runTest("Inter type declaration to base class not seen by derived class"); + } + + public void test067() { + runTest("Declare parents with intermediate ancestor"); + } + + public void test068() { + runTest("Declare parents removing ancestor"); + } + + public void test069() { + runTest("IllegalAccessError while accessing introduced variable / 1.1rc1"); + } + + public void test070() { + runTest("implemented abstract pointcut"); + } + + public void test071() { + runTest("privileged aspect main verify error"); + } + + public void test072() { + runTest("Internal compiler error with thisJoinPoint.getStaticPart()"); + } + + public void test073() { + runTest("Inconsistant stack height with around"); + } + + public void test074() { + runTest("Ajc 1.1 rc1 java.lang.VerifyError with messy arounds"); + } + + public void test075() { + runTest("try/finally in around advice (same as ...messy arounds?)"); + } + + public void test076() { + runTest("advise join points in subclass of empty interface"); + } + + public void test077() { + runTest("can't put around advice on interface static initializer"); + } + + public void test078() { + runTest("cflow concretization causing assertion failure"); + } + + public void test079() { + runTest("lame error message: negation doesn't allow binding"); + } + + public void test080() { + runTest("Error when introducing members of type Class"); + } + + // public void test081(){ + // runTest("arrays via Class.forName()"); + // } + + public void test082() { + runTest("perthis and inline arounds"); + } + + public void test083() { + runTest("Weaver fails with NPE for very large source files "); + } + + public void test084() { + runTest("CLE: no sources"); + } + + public void test085() { + runTest("CLE: bad filename"); + } + + public void test086() { + runTest("CLE: no dir specified for sourceroots"); + } + + public void test087() { + runTest("CLE: no sourceroot specified for incremental"); + } + + public void test088() { + runTest("CLE: file specified with incremental"); + } + + public void test089() { + runTest("public static fields being ignored"); + } + + public void test090() { + runTest("can not resolve this member warning"); + } + + public void test091() { + runTest("try switch VerifyError, InconsistentStackHeight"); + } + + public void test092() { + if (LangUtil.is17VMOrGreater()) { + runTest("Compiler crash in ajc 1.1 - terrible error for inaccessible constructor - 1.7"); + } else { + runTest("Compiler crash in ajc 1.1 - terrible error for inaccessible constructor"); + } + } + + public void test093() { + runTest("Missing import crashes compiler"); + } + + public void test094() { + runTest("NPE in bcel.LazyMethodGen when delegating from one ctor to a second that includes a switch"); + } + + public void test095() { + runTest("switch statement in aspects crashes weaving"); + } + + public void test096() { + runTest("ajc stack trace on declaring hashcode() method in aspect"); + } + + public void test097() { + runTest("using super in method introduced on interface with multiple supertypes"); + } + + public void test098() { + runTest("Compiler crashes in jar and cflow (with no .jar)"); + } + + public void test099() { + runTest("Compiler crashes in jar and cflow (with .jar)"); + } + + public void test100() { + runTest("Default method impl for interface causes internal exception."); + } + + public void test102() { + runTest("compile error expected for abstract pointcut outside abstract aspect"); + } + + public void test103() { + runTest("subtype-qualified pointcut reference"); + } + + public void test104() { + runTest("weaver trace on mis-qualified pointcut reference"); + } + + public void test105() { + runTest("compile error expected for interface pointcuts"); + } + + public void test106() { + runTest("interface call signatures when declaring method in aspect"); + } + + public void test107() { + runTest("reflective check of declared exceptions from aspect-declared methods"); + } + + public void test108() { + runTest("throw derivative pointcuts not advised"); + } + + public void test109() { + runTest("perthis and signature bad interaction"); + } + + public void test110() { + runTest("declare error fails on pointcuts composed from multiple classes"); + } + + public void test111() { + runTest("declare error fails on pointcuts composed from multiple classes"); + } + + public void test112() { + runTest("Interaction between pointcut binding and declare parents"); + } + + public void test113() { + runTest("Non-functional concretezation of ReferencePointcut"); + } + + public void test114() { + runTest("zip and jar suffixes for extdirs entries"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11-tests.xml new file mode 100644 index 000000000..02b422bb8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11-tests.xml @@ -0,0 +1,850 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11.xml b/tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11.xml new file mode 100644 index 000000000..899dfe725 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc11/ajc11.xml @@ -0,0 +1,10 @@ + +]> + + + + +&tests; + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc120/Ajc120Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc120/Ajc120Tests.java new file mode 100644 index 000000000..8e1ef8789 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc120/Ajc120Tests.java @@ -0,0 +1,252 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.ajc120; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc120Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc120Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc120.xml"); + } + + + public void test001(){ + runTest("NPE in concretization error path"); + } + + public void test002(){ + runTest("priviledged aspects calling methods from advice"); + } + + public void test003(){ + runTest("No error on overloaded pointcuts in class"); + } + + public void test004(){ + runTest("No error on overloaded pointcuts unless binding variables"); + } + + public void test005(){ + runTest("Declare soft softening other exception types"); + } + + public void test006(){ + runTest("static method introduction on interfaces, should not be allowed"); + } + + public void test007(){ + runTest("External pointcut refs not resolved if named pointcut used by declare"); + } + + public void test008(){ + runTest("Appropriate message for 'after() thowing(Throwable th)' syntax error"); + } + + public void test009(){ + runTest("Ensure we don't look for source on the classpath when binary not found"); + } + + public void test010(){ + runTest("inner aspect containing declare soft"); + } + + public void test011(){ + runTest("Bad parser error recovery in advice"); + } + + public void test012(){ + runTest("Bad parser error recovery in java source"); + } + + public void test013(){ + runTest("compiler issues error on inner aspects when privilieged"); + } + + public void test014(){ + runTest("After throwing advice on ctors doesn't execute for inter-type decl field inits"); + } + + public void test015(){ + runTest("Introduced abstract method on abstract class not implemented by subtype (single source file)"); + } + + public void test016(){ + runTest("Introduced abstract method on abstract class with introduced concrete method (single source file)"); + } + + public void test017(){ + runTest("Introduced abstract method on abstract class with existing concrete method (single source file)"); + } + + public void test018(){ + runTest("aspect declares interface method (no modifiers)"); + } + + public void test019(){ + runTest("aspect declares interface method (abstract)"); + } + + public void test020(){ + runTest("aspect declares interface method (public abstract)"); + } + + public void test021(){ + runTest("Use class implementing interface via aspect (not woven together)"); + } + + public void test022(){ + runTest("Use class implementing interface via aspect (weave all together)"); + } + + public void test023(){ + runTest("Use class implementing interface via aspect (only one implementer)"); + } + + public void test024(){ + runTest("Erroneous exception conversion"); + } + + public void test025(){ + runTest("before():execution(new(..)) does not throw NoAspectBoundException"); + } + + public void test026(){ + runTest("Anomalous handling of inter-type declarations to abstract base classes in aspectj 1.1"); + } + + public void test027(){ + runTest("NPE When compiling intertype declaration"); + } + + public void test028(){ + runTest("declare warning on subtype constructor"); + } + + public void test029(){ + runTest("CatchClauseSignature has broken operation"); + } + + public void test030(){ + runTest("after returning with parameter: matching rules"); + } + + public void test031(){ + runTest("binary compatibility of advice method names - expect no error"); + } + + public void test032(){ + runTest("binary compatibility of advice method names - expect error"); + } + + public void test033(){ + runTest("binary compatibility of advice method names - expect no error"); + } + + public void test034(){ + runTest("mail list VerifyError with protected access"); + } + + public void test035(){ + runTest("Polymorphic ITD fails in CVS HEAD (From ajdt 1.1.6)"); + } + + public void test036(){ + runTest("ClasscastException on concretization of if(false)"); + } + + public void test037(){ + runTest("ClasscastException on concretization of if(false)"); + } + + public void test038(){ + runTest("Introduced abstract method on interface not implemented by subtype (weave altogether)"); + } + + public void test039(){ + runTest("declare String field on interface"); + } + + public void test040(){ + runTest("declare int field on interface"); + } + + public void test041(){ + runTest("declare Object field on interface"); + } + + public void test042(){ + runTest("fail in compiling aspect with overriding method introduction with different throws clause "); + } + + public void test043(){ + runTest("super call in anonymous class created in around advice"); + } + + public void test044(){ + runTest("retitle warning to circular {advice} dependency at ..."); + } + + public void test045(){ + runTest("Introduce Unknown Type to class causes Null pointer exception"); + } + + public void test046(){ + runTest("Private members introduced via an interface are visible to the class"); + } + + public void test047(){ + runTest("declare precedence on a class should be a compile-time error"); + } + + public void test048(){ + runTest("declare precedence on a class should be a compile-time error"); + } + + public void test049(){ + runTest("NPE when binary weaving a ctor ITD"); + } + + public void test050(){ + runTest("NPE in compiler when using (an unusual) declare warning against a ctor ITD"); + } + + public void test051(){ + runTest("InterTypeMethodDeclaration.java:104"); + } + + public void test052(){ + runTest("nested uses of this() inside constructors not handled properly for initialization and preinitialization pointcuts"); + } + + public void test053(){ + runTest("wrong variable binding in || pointcuts"); + } + + public void test054(){ + runTest("error message for constructor-execution pcd"); + } + + public void test055(){ + runTest("weaving using an empty jar in -injars"); + } + + public void test056(){ + runTest("weaving using an empty jar in -aspectpath"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120-tests.xml new file mode 100644 index 000000000..4b51a98dd --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120-tests.xml @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120.xml b/tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120.xml new file mode 100644 index 000000000..dade07154 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc120/ajc120.xml @@ -0,0 +1,11 @@ + +]> + + + + + +&tests; + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java new file mode 100644 index 000000000..e1ae534bf --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java @@ -0,0 +1,345 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.ajc121; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + + + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc121Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc121.xml"); + } + + + public void test001(){ + runTest("false ambiguous binding error (introduced in 1.2rc2)"); + } + + public void test002(){ + runTest("An if() pointcut inside a perthis() clauses an ABORT - null pointer exception in ajc"); + } + + public void test003(){ + runTest("An if() pointcut inside a perthis() clauses an ABORT - null pointer exception in ajc"); + } + + public void test004(){ + runTest("An if() pointcut inside a perthis() clauses an ABORT - null pointer exception in ajc"); + } + + public void test005(){ + runTest("compiler aborts with 'conflicting dominates orders' with circular declare precedences"); + } + + public void test006(){ + runTest("'can't bind type' message has $ for . in type name for declare soft"); + } + + public void test007(){ + runTest("Hiding of Instance Methods by static methods"); + } + + public void test008(){ + runTest("if(false) optimisation"); + } + + public void test009(){ + runTest("if(true) optimisation"); + } + + public void test010(){ + runTest("java.lang.NullPointerException in WeaverMessageHandler class"); + } + + public void test011(){ + runTest("ClassCastException at BcelRenderer.java:169"); + } + + public void test012(){ + runTest("Front-end bug, shouldn't allow patterns of the form foo.., should be foo..*"); + } + + public void test013() { + runTest("Nullpointer-Exception when defining a withincode() pointcut"); + } + + public void test014() { + runTest("NPE, Incorrect XLint:unmatchedSuperTypeInCall warning"); + } + + public void test015_invalidXlint() { // keywords: "laurie hendren" + runTest("invalid warning indicating no match when a match really occurs"); + } + + public void test016_ByteConversionInstructions() { + runTest("RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I"); + String output = getLastRunResult().getStdErr(); + assertTrue("Expected to find [b2] in this output but didn't:"+output,output.indexOf("[b2]")!=-1); + assertTrue("Expected to find [b127] in this output but didn't:"+output,output.indexOf("[b127]")!=-1); + assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); + + assertTrue("Expected to find [c65] in this output but didn't:"+output,output.indexOf("[c65]")!=-1); + assertTrue("Expected to find [c66] in this output but didn't:"+output,output.indexOf("[c66]")!=-1); + assertTrue("Expected to find [c67] in this output but didn't:"+output,output.indexOf("[c67]")!=-1); + + assertTrue("Expected to find [s1] in this output but didn't:"+output,output.indexOf("[s1]")!=-1); + assertTrue("Expected to find [s32767] in this output but didn't:"+output,output.indexOf("[s32767]")!=-1); + assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); + } + + public void test017_PrivateMethodCallsInAroundAdvice() { + runTest("Cannot advise private method call in around advice"); + System.err.println(getLastRunResult().getStdErr()); + } + + public void test018_PrivateFieldSetsInAroundAdvice() { + runTest("Cannot advise private field sets in around advice"); + System.err.println(getLastRunResult().getStdErr()); + } + + public void test019_PrivateFieldGetsInAroundAdvice() { + runTest("Cannot advise private field gets in around advice"); + System.err.println(getLastRunResult().getStdErr()); + } + +// test takes over 5 minutes to run, so not included in normal suite run +// public void test020_branchTargetOffsetTooLargeForShort() { +// runTest("Branch target offset too large for short"); +// } + +// public void test021_BcelFailureWithVeryLargeClasses() { +// runTest("Weaver fails in BCEL for large classes"); +// } +// +// public void test022_BcelFailureWithVeryLargeClasses_Binary() { +// runTest("Weaver fails in BCEL for large classes (binary)"); +// } + + public void test023_proceedInAround1() { + runTest("proceed used as method name in around advice (1)"); + } + + public void test024_proceedInAround2() { + runTest("proceed used as method name in around advice (2)"); + } + + public void test025_proceedInAround3() { + runTest("proceed used as method name in around advice (3)"); + } + + public void test026_bindingThisAndTargetToTheSameFormal() { + runTest("ajc crashes when compiling the following program (binding this() and target())"); + } + + public void test027_itdsOnInnerClassesAsStatic() { + runTest("ITDs on inner classes should be static context"); + } + + public void test028_itdsAndInitializers() { + runTest("resolution of IT field inits"); + } + + public void test029_falseInvalidAbsoluteTypeName() { + runTest("Valid but inaccessible type names should not be flagged by XLint:invalidAbsoluteTypeName"); + } + + public void test030_privateITDinitialisersBeingMatched() { + runTest("intertype initialisers should match field set pointcuts"); + } + + public void test031_privateITDinitialisersBeingMatched_OxfordTest() { + runTest("intertype initialisers should match field set pointcuts (oxford testcase)"); + //System.err.println(">"+getLastRunResult().getStdErr()); + String exp = ":set field set(int C.n):set field set(int C.m):get field get(int C.n):set field set(int C.n)"; + assertTrue("Expected output '"+exp+"' but got "+getLastRunResult().getStdErr(), + getLastRunResult().getStdErr().equals(exp)); + } + + public void test032_stringConcatForDEOW() { + runTest("Compile time declarations (warning and error) do not accept string concatenation (with +)"); + } + + public void test033_stringConcatForDEOWErrorCase() { + runTest("Compile time declarations (warning and error) do not accept string concatenation (with +) (2)"); + } + + public void test034_scopeForITDS_pr61768() { + runTest("scope for inter-type methods"); + } + + public void test035_innerAspectCallsPrivateMethod_pr71372() { + runTest("NoSuchMethodError calling private method from around advice in inner aspect"); + String s = getLastRunResult().getStdErr(); + assertTrue("Expected ':before:around' but got "+s, + s.equals(":before:around")); + } + + public void test036_innerAspectCallsPrivateMethod_pr71372_2() { + runTest("NoSuchMethodError calling private method from around advice in inner aspect (2)"); + String s = getLastRunResult().getStdErr(); + assertTrue("Expected ':before:around' but got "+s, + s.equals(":before:around")); + } + + public void test037_innerAspectCallsPrivateMethod_pr71372_3() { + runTest("NoSuchMethodError calling private method from around advice in inner aspect (3)"); + String s = getLastRunResult().getStdErr(); + assertTrue("Expected ':before:around' but got "+s, + s.equals(":before:around")); + } + + public void test038_innerAspectCallsPrivateMethod_pr71372_4() { + runTest("NoSuchMethodError calling private method from around advice in inner aspect (4)"); + String s = getLastRunResult().getStdErr(); + assertTrue("Expected ':before:around' but got "+s, + s.equals(":before:around")); + } + + public void test039_privilegedAspectAccessingPrivateMethods_pr67579() { + runTest("NPE on privileged aspect error"); + } + + public void test040_privilegedAspectAccessingPrivateMethods_pr67579_2() { + runTest("NPE on privileged aspect error (2)"); + } + + public void test041_ITDaccessingPrivateMethod_pr67578() { + runTest("Privileged Aspect Access Problem Across Packages"); + } + + public void test042_ITDaccessingPrivateMethod_pr67578_2() { + runTest("Privileged Aspect Access Problem Across Packages (2)"); + } + + public void test043_pr62642_ExceptionInInitializerError() { + runTest("proper handling of ExceptionInIntializer inside clinit in presence of after throwing advice"); + String s = getLastRunResult().getStdErr(); + assertTrue("Output should contain java.lang.ExceptionInInitializerError but is '"+s+"'", + s.indexOf("java.lang.ExceptionInInitializerError")!=-1); + // No getCause on 1.3 JVMs +// assertTrue("Output should contain 'CAUSE=org.aspectj.lang.NoAspectBoundException' but is '"+s+"'", +// s.indexOf("CAUSE=org.aspectj.lang.NoAspectBoundException")!=-1); + } + + public void test044_ITDnameClashes() { + runTest("ITD name clashes with private members"); + } + + public void test045_ITDprotectedVisibility() { + runTest("Inconsistency in scoping of protected members in ITDs"); + } + + public void test045_wrongLineForExecutionJoinPoint() { + runTest("wrong line for method execution join point"); + } + + public void test046_interfaceITD_pr70794_1() { + runTest("The introduction on interface causes the interface implementation class error (1)"); + } + + public void test047_interfaceITD_pr70794_2() { + runTest("The introduction on interface causes the interface implementation class error (2)"); + } + + public void test048_interfaceITD_pr70794_3() { + runTest("The introduction on interface causes the interface implementation class error (3)"); + } + + public void test049_interfaceITD_pr70794_4() { + runTest("The introduction on interface causes the interface implementation class error (4)"); + } + + public void test050_typePatternMatchingWithArrays() { + runTest("declare warning warns at wrong points"); + } + + public void test052_bogusMessage1() { + runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (1)"); + } + + public void test053_bogusMessage2() { + runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (2)"); + } + + public void test054_cnfe() { + runTest("passing null to array arguments confuzes static join point signature. (1)"); + } + + public void test055_cnfe() { + runTest("passing null to array arguments confuzes static join point signature. (2)"); + } + + public void test056_arrayCloning() { + runTest("around advice throws java.lang.VerifyError at runtime"); + } + + public void test057_decSoftWithSuper() { + runTest("declare soft can cause programs with invalid exception behaviour to be generated"); + } + + public void test058_npeOnTJPerror() { + runTest("NPE on thisJoinPoint mistake"); + } + + public void test059_cflowOptimization_counters() { + runTest("Optimization of cflow - counters (1)"); + } + + public void test060_cflowOptimization_counters() { + runTest("Optimization of cflow - shared counters (2)"); + } + + public void test061_cflowOptimization_counters() { + runTest("Optimization of cflow - shared stacks (3)"); + } + + public void test062_cflowOptimization_counters() { + runTest("Optimization of cflow - counters (4)"); + } + + public void test063_cflowOptimization_countersWithAbstractPcuts() { + runTest("Optimization of cflow - counters with abstract pointcuts (5)"); + } + + public void test064() { + runTest("Anonymous classes unaware of introductions into abstract classes"); + } + + private int countLines(String s) { + int lines = 0; + int idx = 0; + while (s.indexOf("\n",idx)!=-1) { + lines++; + idx = s.indexOf("\n",idx)+1; + } + return lines; + } + + public void test065() { + runTest("before,after not (cflow(within(Trace*))) prints nothing"); + String s = getLastRunResult().getStdErr(); + int lines = countLines(s); + assertTrue("The actual output does not match the expected output. Expected 102 lines but got "+ + lines+" lines. Actual output =\n"+s,lines==102); + // IF YOU WANT TO SEE THE EXPECTED OUTPUT, LOOK IN THE TEST PROGRAM bugs/WhatsGoingOn.java + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121-tests.xml new file mode 100644 index 000000000..1d65dc3e1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121-tests.xml @@ -0,0 +1,494 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121.xml b/tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121.xml new file mode 100644 index 000000000..8ad54bf32 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc121/ajc121.xml @@ -0,0 +1,12 @@ + +]> + + + + + +&tests; + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/AccBridgeMethods.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/AccBridgeMethods.java new file mode 100644 index 000000000..e9348f49c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/AccBridgeMethods.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +/** + * These tests check binary weaving of code compiled with the 1.5 compiler. If you need to rebuild + * the class files then you will have to run tests/java5/bridgeMethods/build.xml. + * + *

Bridge methods are generated when a type extends or implements a parameterized class or interface and + * type erasure changes the signature of any inherited method. + * + *

They impact AspectJ in two ways: + *

    + *
  1. They exist as a method execution join point, and their 'body' exists as a set of new join points + * (although their body is normally coded simply to delegate to the method they are bridging too). + *
  2. They create a potential call join point where a call can be made to the bridge method. + *
+ * + *

The principal things we have to do are avoid weaving their body and ignore their existence + * as a method execution join point. Their existence as a potential target for a call join point are + * more complicated. Although they exist in the code, a 1.5 compiler will prevent a call to them with + * an error like this: + * + * M.java:3: compareTo(Number) in Number cannot be applied to (java.lang.String) + * new Number(5).compareTo("abc"); + * + * Our problem is that a Java 1.4 or earlier compiler will allow you to write calls to this bridge method + * and it will let them through. + */ +public class AccBridgeMethods extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AccBridgeMethods.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + + /** + * AspectX attempts to weave call and execution of the method for which a 'bridge method' is also created. + * If the test works then only two weaving messages come out. If it fails then usually 4 messages come out + * and we have incorrectly woven the bridge method (the 3rd message is execution of the bridge method and + * the 4th message is the call within the bridge method to the real method). + */ + public void test001_bridgeMethodIgnored() { + runTest("Ignore bridge methods"); + } + + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java new file mode 100644 index 000000000..c9998d6c9 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -0,0 +1,1035 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.asm.AsmManager; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.LangUtil; + +public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc150Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + public void testMixingCodeStyles_pr121385() { + runTest("mixing aspect styles"); + } + + public void testTypeVars_pr121575() { + runTest("different numbers of type vars"); + } + + public void testTypeVars_pr121575_2() { + runTest("different numbers of type vars - 2"); + } + + public void testTypeVars_pr121575_3() { + runTest("different numbers of type vars - 3"); + } + + public void testTypeVars_pr121575_4() { + runTest("different numbers of type vars - 4"); + } + + public void testDecps1() { + runTest("decps - 1"); + } + + public void testDecps1b() { + runTest("decps - 1b"); + } + + public void testDecps2() { + runTest("decps - 2"); + } + + public void testDecps2b() { + runTest("decps - 2b"); + } + + public void testDecps3() { + runTest("decps - 3"); + } + + public void testDecps3b() { + runTest("decps - 3b"); + } + + public void testDecps3c() { + runTest("decps - 3c"); + } + + public void testVarargsNPE_pr120826() { + runTest("varargs NPE"); + } + + public void testNamedPointcutPertarget_pr120521() { + runTest("named pointcut not resolved in pertarget pointcut"); + } + + public void testDollarClasses_pr120474() { + runTest("Dollar classes"); + } + + public void testGenericPTW_pr119539_1() { + runTest("generic pertypewithin aspect - 1"); + } + + public void testGenericPTW_pr119539_2() { + runTest("generic pertypewithin aspect - 2"); + } + + public void testGenericPTW_pr119539_3() { + runTest("generic pertypewithin aspect - 3"); + } + + /* + * public void testBrokenDispatchByITD_pr72834() { runTest("broken dispatch");} public void testMissingAccessor_pr73856() { + * runTest("missing accessor");} public void testCunningDeclareParents_pr92311() { runTest("cunning declare parents");} public + * void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");} + */ + public void testIncorrectSignatureMatchingWithExceptions_pr119749() { + runTest("incorrect exception signature matching"); + } + + public void testGeneratingCodeForAnOldRuntime_pr116679_1() { + runTest("generating code for a 1.2.1 runtime - 1"); + } + + public void testGeneratingCodeForAnOldRuntime_pr116679_2() { + runTest("generating code for a 1.2.1 runtime - 2"); + } + + public void testAmbiguousMethod_pr118599_1() { + runTest("ambiguous method when binary weaving - 1"); + } + + public void testAmbiguousMethod_pr118599_2() { + runTest("ambiguous method when binary weaving - 2"); + } + + public void testAroundAdviceArrayAdviceSigs_pr118781() { + runTest("verify error with around advice array sigs"); + } + + public void testAtDeclareParents_pr117681() { + runTest("at declare parents"); + } + + public void testPrivilegeProblem_pr87525() { + runTest("privilege problem with switch"); + } + + public void testRangeProblem_pr109614() { + runTest("Range problem"); + } + + public void testGenericAspects_pr115237() { + runTest("aspectOf and generic aspects"); + } + + public void testClassFormatError_pr114436() { + runTest("ClassFormatError binary weaving perthis"); + } + + public void testParserException_pr115788() { + runTest("parser exception"); + } + + public void testPossibleStaticImports_pr113066_1() { + runTest("possible static imports bug - 1"); + } + + public void testPossibleStaticImports_pr113066_2() { + runTest("possible static imports bug - 2"); + } + + public void testPossibleStaticImports_pr113066_3() { + runTest("possible static imports bug - 3"); + } + + public void testITDCtor_pr112783() { + runTest("Problem with constructor ITDs"); + } + + public void testAnnotatedITDFs_pr114005_1() { + runTest("Annotated ITDFs - 1"); + } + + public void testAnnotatedITDFs_pr114005_2() { + runTest("Annotated ITDFs - 2"); + } + + public void testCantCallSuperMethods_pr90143() { + runTest("cant call super methods"); + } + + public void testBrokenDecp_pr112476() { + runTest("binary weaving decp broken"); + } + + public void testUnboundFormal_pr112027() { + runTest("unexpected error unboundFormalInPC"); + } + + public void testNPEScopeSetup_pr115038() { + runTest("NPE in ensureScopeSetup"); + } + + public void testCCEGenerics_pr113445() { + runTest("Generics ClassCastException"); + } + + public void testMatthewsAspect_pr113947_1() { + runTest("maws generic aspect - 1"); + } + + public void testMatthewsAspect_pr113947_2() { + runTest("maws generic aspect - 2"); + } + + public void testFieldGet_pr114343() { + runTest("field-get, generics and around advice"); + } + + public void testFieldGet_pr114343_2() { + runTest("field-get, generics and around advice - 2"); + } + + public void testFieldGet_pr114343_3() { + runTest("field-get, generics and around advice - 3"); + } + + public void testCaptureBinding_pr114744() { + runTest("capturebinding wildcard problem"); + } + + public void testAutoboxingAroundAdvice_pr119210_1() { + runTest("autoboxing around advice - 1"); + } + + public void testAutoboxingAroundAdvice_pr119210_2() { + runTest("autoboxing around advice - 2"); + } + + public void testAutoboxingAroundAdvice_pr119210_3() { + runTest("autoboxing around advice - 3"); + } + + public void testBadDecp_pr110788_1() { + runTest("bad generic decp - 1"); + } + + public void testBadDecp_pr110788_2() { + runTest("bad generic decp - 2"); + } + + public void testBadDecp_pr110788_3() { + runTest("bad generic decp - 3"); + } + + public void testBadDecp_pr110788_4() { + runTest("bad generic decp - 4"); + } + + // public void testSimplifiedGenericAspectITDTest() { runTest("spurious override method warning - 3");} + // public void testSpuriousOverrideMethodWarning_pr119570_1() { runTest("spurious override method warning");} + // public void testSpuriousOverrideMethodWarning_pr119570_2() { runTest("spurious override method warning - 2");} + + public void testBrokenSwitch_pr117854() { + runTest("broken switch transform"); + } + + public void testVarargsITD_pr110906() { + runTest("ITD varargs problem"); + } + + public void testBadRenderer_pr86903() { + runTest("bcelrenderer bad"); + } + + // public void testIllegalInitialization_pr118326_1() { runTest("illegal initialization - 1");} + // public void testIllegalInitialization_pr118326_2() { runTest("illegal initialization - 2");} + public void testLintForAdviceSorting_pr111667() { + runTest("lint for advice sorting"); + } + + public void testIncompatibleClassChangeError_pr113630_1() { + runTest("IncompatibleClassChangeError - errorscenario"); + } + + public void testIncompatibleClassChangeError_pr113630_2() { + runTest("IncompatibleClassChangeError - workingscenario"); + } + + public void testFieldGetProblemWithGenericField_pr113861() { + runTest("field-get problems with generic field"); + } + + public void testAccesstoPrivateITDInNested_pr118698() { + runTest("access to private ITD from nested type"); + } + + public void testDeclareAnnotationOnNonExistentType_pr99191_1() { + runTest("declare annotation on non existent type - 1"); + } + + public void testDeclareAnnotationOnNonExistentType_pr99191_2() { + runTest("declare annotation on non existent type - 2"); + } + + public void testDeclareAnnotationOnNonExistentType_pr99191_3() { + runTest("declare annotation on non existent type - 3"); + } + + public void testDeclareAnnotationOnNonExistentType_pr99191_4() { + runTest("declare annotation on non existent type - 4"); + } + + public void testDeclareAnnotationOnNonExistentType_pr99191_5() { + runTest("declare annotation on non existent type - 5"); + } + + public void testBadGenericSigAttribute_pr110927() { + runTest("cant create signature attribute"); + Signature sig = GenericsTests.getClassSignature(ajc, "I"); + if (sig == null) + fail("Couldn't find signature attribute for type I"); + String sigString = sig.getSignature(); + if (!(sigString.equals("Ljava/lang/Object;LIE2;LIE1;") || sigString + .equals("Ljava/lang/Object;LIE1;LIE2;"))) { + fail("Signature was " + sigString + + " when should have been something like Ljava/lang/Object;LIE1;LIE2;"); + } + } + + public void test_typeProcessingOrderWhenDeclareParents() { + runTest("Order of types passed to compiler determines weaving behavior"); + } + + public void test_aroundMethod() { + runTest("method called around in class"); + } + + public void test_aroundMethodAspect() { + runTest("method called around in aspect"); + } + + public void test_ambiguousBindingsDetection() { + runTest("Various kinds of ambiguous bindings"); + } + + public void test_ambiguousArgsDetection() { + runTest("ambiguous args"); + } + + public void testIncorrectExceptionTableWhenBreakInMethod_pr78021() { + runTest("Injecting exception into while loop with break statement causes catch block to be ignored"); + } + + public void testIncorrectExceptionTableWhenReturnInMethod_pr79554() { + runTest("Return in try-block disables catch-block if final-block is present"); + } + + public void testMissingDebugInfoForGeneratedMethods_pr82570() throws ClassNotFoundException { + runTest("Weaved code does not include debug lines"); + boolean f = false; + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "PR82570_1"); + Method[] meths = jc.getMethods(); + for (int i = 0; i < meths.length; i++) { + Method method = meths[i]; + if (f) + System.err.println("Line number table for " + method.getName() + method.getSignature() + " = " + + method.getLineNumberTable()); + assertTrue("Didn't find a line number table for method " + method.getName() + method.getSignature(), + method.getLineNumberTable() != null); + } + + // This test would determine the info isn't there if you pass -g:none ... + // cR = ajc(baseDir,new String[]{"PR82570_1.java","-g:none"}); + // assertTrue("Expected no compile problem:"+cR,!cR.hasErrorMessages()); + // System.err.println(cR.getStandardError()); + // jc = getClassFrom(ajc.getSandboxDirectory(),"PR82570_1"); + // meths = jc.getMethods(); + // for (int i = 0; i < meths.length; i++) { + // Method method = meths[i]; + // assertTrue("Found a line number table for method "+method.getName(), + // method.getLineNumberTable()==null); + // } + } + + public void testCanOverrideProtectedMethodsViaITDandDecp_pr83303() { + runTest("compiler error when mixing inheritance, overriding and polymorphism"); + } + + public void testPerTypeWithin_pr106554() { + runTest("Problem in staticinitialization with pertypewithin aspect"); + } + + public void testPerTypeWithinMissesNamedInnerTypes() { + runTest("pertypewithin() handing of inner classes (1)"); + } + + public void testPerTypeWithinMissesAnonymousInnerTypes() { + runTest("pertypewithin() handing of inner classes (2)"); + } + + public void testPerTypeWithinIncorrectlyMatchingInterfaces() { + runTest("pertypewithin({interface}) illegal field modifier"); + } + + public void test051_arrayCloningInJava5() { + runTest("AJC possible bug with static nested classes"); + } + + public void testBadASMforEnums() throws IOException { + runTest("bad asm for enums"); + + if (LangUtil.is15VMOrGreater()) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = new PrintWriter(baos); + AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); + pw.flush(); + String tree = baos.toString(); + assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.indexOf("Red [enumvalue]") != -1); + } + } + + public void npeOnTypeNotFound() { + runTest("structure model npe on type not found"); + } + + public void testNoRuntimeExceptionSoftening() { + runTest("declare soft of runtime exception"); + } + + public void testRuntimeNoSoftenWithHandler() { + runTest("declare soft w. catch block"); + } + + public void testSyntaxError() { + runTest("invalid cons syntax"); + } + + public void testVarargsInConsBug() { + runTest("varargs in constructor sig"); + } + + public void testAspectpathdirs() { + runTest("dirs on aspectpath"); + } + + public void testIntroSample() { + runTest("introduction sample"); + } + + public void testPTWInterface() { + runTest("pertypewithin({interface}) illegal field modifier"); + } + + public void testEnumCalledEnumEtc() { + runTest("enum called Enum, annotation called Annotation, etc"); + } + + public void testInternalCompilerError_pr86832() { + runTest("Internal compiler error"); + } + + public void testCloneMethod_pr83311() { + runTest("overriding/polymorphism error on interface method introduction"); + } + + // IfPointcut.findResidueInternal() was modified to make this test complete in a short amount + // of time - if you see it hanging, someone has messed with the optimization. + public void testIfEvaluationExplosion_pr94086() { + runTest("Exploding compile time with if() statements in pointcut"); + } + + public void testReflectNPE_pr94167() { + runTest("NPE in reflect implementation"); + } + + public void testStaticImports_pr84260() { + runTest("static import failures"); + } + + public void testGenerics_pr99089() { + runTest("ArrayIndexOutOfBoundsException - Generics in privileged aspects"); + } + + public void testGenerics_pr95993() { + runTest("NPE at ClassScope.java:660 when compiling generic class"); + } + + public void testItdGenerics_pr99228() { + runTest("ITD of a field into a generic class"); + } + + public void testItdGenerics_pr98320() { + runTest("intertype with nested generic type"); + } + + public void testItdGenerics_pr100227() { + runTest("inner class with generic enclosing class"); + } + + public void testItdGenerics_pr100260() { + runTest("methods inherited from a generic parent"); + } + + public void testSyntaxErrorNPE_pr103266() { + runTest("NPE on syntax error"); + } + + public void testFinalAbstractClass_pr109486() { + runTest("Internal compiler error (ClassParser.java:242)"); + } + + public void testComplexBinding_pr102210() { + runTest("NullPointerException trying to compile"); + } + + public void testIllegalStateExceptionOnNestedParameterizedType_pr106634() { + runTest("IllegalStateException unpacking signature of nested parameterized type"); + } + + public void testParseErrorOnAnnotationStarPlusPattern() { + runTest("(@Foo *)+ type pattern parse error"); + } + + public void test_pr106130_tooManyLocals() { + runTest("test weaving with > 256 locals"); + } + + public void testMissingNamePattern_pr106461() { + runTest("missing name pattern"); + } + + public void testMissingNamePattern_pr107059() { + runTest("parser crashes on call(void (@a *)(..)"); + } + + public void testIntermediateAnnotationMatching() { + runTest("intermediate annotation matching"); + } + + public void testBadRuntimeTestGeneration() { + runTest("target(@Foo *)"); + } + + // ONE_EIGHT remove for now, needs some grammar changes to ensure empty type annotations are put in place for later consumption +// public void testErrorMessageOnITDWithTypePatterns() { +// runTest("clear error message on itd with type pattern"); +// } + + public void testAjKeywordsAsIdentifiers() { + runTest("before and after are valid identifiers in classes"); + } + + public void testAjKeywordsAsIdentifiers2() { + runTest("before and after are valid identifiers in classes, part 2"); + } + + public void testNoBeforeReturningAdvice() { + runTest("before returning advice not allowed!"); + } + + public void testDetectVoidFieldType() { + runTest("void field type in pointcut expression"); + } + + public void testPointcutOverriding() { + runTest("overriding final pointcut from super-aspect"); + } + + public void testAtSuppressWarnings() { + runTest("@SuppressWarnings should suppress"); + } + + public void testDEOWWithBindingPointcut() { + runTest("declare warning : foo(str) : ...;"); + } + + public void testAroundAdviceAndInterfaceInitializer() { + runTest("around advice on interface initializer"); + } + + public void testGoodErrorMessageOnUnmatchedMemberSyntax() { + runTest("good error message for unmatched member syntax"); + } + + public void testITDWithNoExceptionAndIntermediary() { + runTest("itd override with no exception clause"); + } + + public void testAnonymousInnerClasses() { + runTest("anonymous inner classes"); + } + + public void testMultipleAnonymousInnerClasses() { + runTest("multiple anonymous inner classes"); + } + + public void testPrivilegedMethodAccessorsGetRightExceptions_pr82989() { + runTest("Compiler error due to a wrong exception check in try blocks"); + } + + public void testAnonymousInnerClassWithMethodReturningTypeParameter_pr107898() { + runTest("anonymous inner class with method returning type parameter"); + } + + public void testMatchingOfObjectArray() { + runTest("matching against Object[]"); + } + + public void testMultipleAnonymousInnerClasses_pr108104() { + runTest("multiple anonymous inner classes 2"); + } + + public void testSignatureMatchingInMultipleOverrideScenario() { + runTest("signature matching in override scenario"); + } + + public void testWildcardAnnotationMatching_pr108245() { + runTest("wildcard annotation matching - pr108245"); + } + + public void testInnerTypesAndTypeVariables() { + runTest("inner types and type variables"); + } + + public void testAtAfterThrowingWithNoFormal() { + runTest("@AfterThrowing with no formal specified"); + } + + public void testParameterizedVarArgsMatch() { + runTest("varargs with type variable"); + } + + public void testFieldAccessInsideITDM() { + runTest("itd field access inside itd method"); + } + + public void testTypeVarWithTypeVarBound() { + runTest("type variable with type variable bound"); + } + + public void testEnumSwitchInITD() { + runTest("switch on enum inside ITD method"); + } + + public void testInnerTypeOfGeneric() { + runTest("inner type of generic interface reference from parameterized type"); + } + + public void testDeclareParentsIntroducingCovariantReturnType() { + runTest("declare parents introducing override with covariance"); + } + + public void testInnerClassPassedToVarargs() { + runTest("inner class passed as argument to varargs method"); + } + + public void testInlinedFieldAccessInProceedCall() { + runTest("inlined field access in proceed call"); + } + + public void testVisibiltyInSignatureMatchingWithOverridesPart1() { + runTest("visibility in signature matching with overrides - 1"); + } + + public void testVisibiltyInSignatureMatchingWithOverridesPart2() { + runTest("visibility in signature matching with overrides - 2"); + } + + public void testVisibiltyInSignatureMatchingWithOverridesPart3() { + runTest("visibility in signature matching with overrides - 3"); + } + + public void testArgsGeneratedCorrectlyForAdviceExecution() { + runTest("args generated correctly for advice execution join point"); + } + + public void testNoUnusedWarningsOnAspectTypes() { + runTest("no unused warnings on aspect types"); + } + + public void testSyntheticArgumentsOnITDConstructorsNotUsedInMatching() { + runTest("synthetic arguments on itd cons are not used in matching"); + } + + public void testParsingOfGenericTypeSignature() { + runTest("parse generic type signature with parameterized type in interface"); + } + + public void testOverrideAndCovarianceWithDecPRuntime() { + runTest("override and covariance with decp - runtime"); + } + + public void testOverrideAndCovarianceWithDecPRuntimeMultiFiles() { + runTest("override and covariance with decp - runtime separate files"); + } + + public void testOverrideAndCovarianceWithDecPRuntimeMultiFilesBinaryWeaving() { + runTest("override and covariance with decp - binary weaving"); + } + + public void testAbstractSynchronizedITDMethods() { + runTest("abstract synchronized itdms not detected"); + } + + public void testSynchronizedITDInterfaceMethods() { + runTest("synchronized itd interface methods"); + } + + public void testNoWarningOnUnusedPointcut() { + runTest("unused private pointcuts"); + } + + public void testITDOnInterfaceWithExistingMember() { + runTest("itd interface method already existing on interface"); + } + + public void testFinalITDMOnInterface() { + runTest("final itd methods on interfaces"); + } + + public void testPrivatePointcutOverriding() { + runTest("can't override private pointcut in abstract aspect"); + } + + public void testAdviceOnCflow() { + runTest("advising cflow advice execution"); + } + + public void testNoTypeMismatchOnSameGenericTypes() { + runTest("no type mismatch on generic types in itds"); + } + + public void testSuperCallInITD() { + runTest("super call in ITD"); + } + + public void testSuperCallInITDPart2() { + runTest("super call in ITD - part 2"); + } + + public void testAtAnnotationBadTest_pr103740() { + runTest("Compiler failure on at_annotation"); + } + + public void testNoUnusedParameterWarningsForSyntheticAdviceArgs() { + runTest("no unused parameter warnings for synthetic advice args"); + } + + public void testNoVerifyErrorWithSetOnInnerType() { + runTest("no verify error with set on inner type"); + } + + public void testCantFindTypeErrorWithGenericReturnTypeOrParameter() { + runTest("cant find type error with generic return type or parameter"); + } + + public void testNoVerifyErrorOnGenericCollectionMemberAccess() { + runTest("no verify error on generic collection member access"); + } + + public void testRawAndGenericTypeConversionITDCons() { + runTest("raw and generic type conversion with itd cons"); + } + + public void testAtAnnotationBindingWithAround() { + runTest("@annotation binding with around advice"); + } + + public void testUnableToBuildShadows_pr109728() { + runTest("Unable to build shadows"); + } + + public void testMessageOnMissingTypeInDecP() { + runTest("declare parents on a missing type"); + } + + public void testParameterizedGenericMethods() { + runTest("parameterized generic methods"); + } + + public void testIllegalChangeToPointcutDeclaration_pr111915() { + runTest("test illegal change to pointcut declaration"); + } + + public void testCantProvideDefaultImplViaITD_pr110307_1() { + runTest("Cant provide default implementation via ITD - 1"); + } + + public void testCantProvideDefaultImplViaITD_pr110307_2() { + runTest("Cant provide default implementation via ITD - 2"); + } + + public void testCantProvideDefaultImplViaITD_pr110307_3() { + runTest("Cant provide default implementation via ITD - 3"); + } + + public void testCantProvideDefaultImplViaITD_pr110307_4() { + runTest("Cant provide default implementation via ITD - 4"); + } + + public void testCantProvideDefaultImplViaITD_pr110307_5() { + runTest("Cant provide default implementation via ITD - 5"); + } + + // Needs a change in the compiler so that getType() can be overridden in the intertype scope - thats + // where we can police whether a type variable has been used without being specified appropriately. + // public void testCantProvideDefaultImplViaITD_pr110307_6() {runTest("Cant provide default implementation via ITD - 6");} + + public void testCantProvideDefaultImplViaITD_pr110307_7() { + runTest("Cant provide default implementation via ITD - 7"); + } + + public void testCallJoinPointsInAnonymousInnerClasses() { + runTest("call join points in anonymous inner classes"); + } + + public void testNoRequirementForUnwovenTypesToBeExposedToWeaver() { + runTest("default impl of Runnable"); + } + + public void testArrayCloneCallJoinPoints() { + runTest("array clone call join points in 1.4 vs 1.3"); + } + + public void testDebugInfoForAroundAdvice() { + runTest("debug info in around advice inlining"); + } + + public void testCCEWithGenericWildcard_pr112602() { + runTest("ClassCastException with generic wildcard"); + } + + public void testVarArgsIITDInConstructor() { + runTest("ITD varargs in constructor"); + } + + public void testWeaveInfoMessageForDeclareAtMethodOnITDdMethod() { + runTest("weaveinfo message for declare at method on an ITDd method"); + } + + public void testITDCWithNoExplicitConsCall() { + runTest("ITDC with no explicit cons call"); + } + + public void testJava5SpecificFeaturesUsedAtJava14OrLower() { + if (LangUtil.is17VMOrGreater()) { + runTest("java 5 pointcuts and declares at pre-java 5 compliance levels - 1.7"); + } else { + runTest("java 5 pointcuts and declares at pre-java 5 compliance levels"); + } + } + + public void testAnonymousTypes() { + runTest("Anonymous types and nome matching"); + } + + public void testAdviceExecutionJPToStringForms() { + runTest("adviceexecution join point toString forms"); + } + + public void testAssertWithinPointcutExpression() { + runTest("pointcut expression containing 'assert'"); + } + + public void testNoVerifyErrorWithTwoThisPCDs_pr113447() { + runTest("no verify error with two this pcds"); + } + + public void testNoVerifyErrorWithTwoAtThisPCDs_pr113447() { + runTest("no verify error with two at this pcds"); + } + + public void testNoVerifyErrorWithAtWithinPCDs_pr113447() { + runTest("no verify error with at within pcds"); + } + + public void testNoVerifyErrorWithAtWithincodePCDs_pr113447() { + runTest("no verify error with at withincode pcds"); + } + + public void testNoVerifyErrorWithAtAnnotationPCDs_pr113447() { + runTest("no verify error with at annotation pcds"); + } + + public void testNoVerifyErrorWithTwoArgsPCDs_pr113447() { + runTest("no verify error with two args pcds"); + } + + public void testNoStackOverflowWithCircularPCDInGenericAspect() { + runTest("no StackOverflowError with circular pcd in generic aspect"); + } + + public void testNoStackOverflowWithCircularPCDInGenericAspect2() { + runTest("no StackOverflowError with circular pcd in generic aspect - 2"); + } + + public void testNPEInThisJoinPointStaticPart() { + runTest("thisJoinPointStaticPart in if test"); + } + + public void testPointcutParsingOfCompiledPointcuts() { + runTest("pointcut parsing with ajc compiled pointcut references"); + } + + public void testReflectionOfAbstractITDs() { + runTest("reflection on abstract ITDs (Billing example)"); + } + + public void testDeclareSoftWithAdviceExecution() { + runTest("declare soft and adviceexecution"); + } + + public void testDeclareSoftWithExclusions() { + runTest("declare soft and exclusions"); + } + + public void testReturningObjectBinding() { + runTest("returning(Object) binding"); + } + + public void testPerTargetAndNegation() { + runTest("pertarget and negated pointcut"); + } + + public void testParameterizedPointcutAndAdvice() { + runTest("parameterized pointcut and advice"); + } + + public void testDoublyParameterizedAbstractType() { + runTest("double parameter generic abstract type"); + } + + public void testArgNamesInAdviceAnnotations() { + runTest("arg names in advice annotations"); + } + + /* + * Load-time weaving bugs + */ + public void testNPEinWeavingAdaptor_pr116626() { + runTest("NPE in WeavingAdaptor"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_Exact() { + runTest("xlint message for improper exact annotation type"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_OR() { + runTest("xlint message for improper annotation type inside OR"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_AND() { + runTest("xlint message for improper annotation type inside AND"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_Return() { + runTest("xlint message for improper annotated return type"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_Declaring() { + runTest("xlint message for improper annotated declaring type"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_Parameter() { + runTest("xlint message for improper annotated parameter type"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_Throws() { + runTest("xlint message for improper annotated throws pattern"); + } + + public void testXlintMessageForImproperAnnotationType_pr115252_MoreThanOne() { + runTest("xlint message for more than one improper annotated parameter type"); + } + + public void testNoNPEWhenInaccessibleMethodIsCalledWithinITD_pr119019() { + runTest("no NPE when inaccessible method is called within itd"); + } + + public void testNoNPEWithOrPointcutAndMoreThanOneArgs_pr118149() { + runTest("no NPE with or pointcut and more than one args"); + } + + public void testNoSOBWithGenericInnerAspects_pr119543() { + runTest("no StringOutOfBoundsException with generic inner aspects"); + } + + public void testIllegalAccessErrorWithAroundAdvice_pr119657() { + runTest("IllegalAccessError with around advice on interface method call"); + } + + public void testIllegalAccessErrorWithAroundAdviceNotSelf_pr119657() { + runTest("IllegalAccessError with around advice on interface method call not self"); + } + + public void testIllegalAccessErrorWithAroundAdviceTerminateAfterCompilationLTW_pr119657() { + runTest("IllegalAccessError with around advice on interface method call using -XterminateAfterCompilation and LTW"); + } + + public void testIllegalAccessErrorWithAroundAdviceLTW_pr119657() { + runTest("IllegalAccessError with around advice on interface method call using LTW"); + } + + public void testIllegalAccessErrorWithAroundAdviceNotSelfLTW_pr119657() { + runTest("IllegalAccessError with around advice on interface method call not self using LTW"); + } + + public void testIllegalAccessErrorWithAroundAdviceSelfAndNotSelfLTW_pr119657() { + runTest("IllegalAccessError with around advice on interface method call self and not self using LTW"); + } + + public void testIllegalAccessErrorWithAroundAdviceLTWNoInline_pr119657() { + runTest("IllegalAccessError with around advice on interface method call using LTW and -XnoInline"); + } + + public void testReflectOnCodeStyleITDs() { + runTest("reflection on itds"); + } + + public void testReflectOnAtAspectJDecP() { + runTest("reflection on @DeclareParents"); + } + + public void testModifierOverrides() { + runTest("modifier overrides"); + } + + public void testAbstractPerThisInAtAspectJ() { + runTest("abstract perthis in @AspectJ"); + } + + public void testNPEInBcelAdviceWithConcreteAspect_pr121385() { + runTest("override protected pointcut in aop.xml concrete aspect"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java new file mode 100644 index 000000000..1d750bb94 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.ajc150.ataspectj.AtAjLTWTests; +import org.aspectj.systemtest.ajc150.ataspectj.AtAjMisuseTests; +import org.aspectj.systemtest.ajc150.ataspectj.AtAjSyntaxTests; +import org.aspectj.systemtest.ajc150.ltw.LTWServerTests; +import org.aspectj.systemtest.ajc150.ltw.LTWTests; + +/** + * This pulls together tests we have written for AspectJ 1.5.0 that don't need Java 1.5 to run + */ +public class AllTestsAspectJ150 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ1.5.0 tests"); + // $JUnit-BEGIN$ + suite.addTestSuite(MigrationTests.class); + suite.addTest(Ajc150Tests.suite()); + suite.addTestSuite(SCCSFixTests.class); + + suite.addTest(AccBridgeMethods.suite()); + suite.addTestSuite(CovarianceTests.class); + suite.addTestSuite(Enums.class); + suite.addTest(AnnotationsBinaryWeaving.suite()); + suite.addTest(AnnotationPointcutsTests.suite()); + suite.addTestSuite(VarargsTests.class); + suite.addTestSuite(StaticImports.class); + suite.addTest(AnnotationRuntimeTests.suite()); + suite.addTestSuite(PerTypeWithinTests.class); + + suite.addTest(Autoboxing.suite()); + suite.addTest(Annotations.suite()); + suite.addTest(AnnotationBinding.suite()); + suite.addTest(RuntimeAnnotations.suite()); + + suite.addTest(SuppressedWarnings.suite()); + suite.addTest(DeclareAnnotationTests.suite()); + suite.addTest(GenericsTests.suite()); + suite.addTest(GenericITDsDesign.suite()); + suite.addTest(AtAjSyntaxTests.suite()); + suite.addTest(AtAjMisuseTests.suite()); + suite.addTest(AtAjLTWTests.suite()); + suite.addTest(HasMember.suite()); + + suite.addTestSuite(LTWTests.class); + suite.addTestSuite(LTWServerTests.class); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationBinding.java new file mode 100644 index 000000000..466567641 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationBinding.java @@ -0,0 +1,402 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; +import org.aspectj.asm.internal.Relationship; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class AnnotationBinding extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AnnotationBinding.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // /////////////////////////////////// @ANNOTATION and CALL + + // Very simple annotation binding for 'call() && @annotation()' + public void testCallAnnotationBinding1() { + runTest("call annotation binding 1"); + } + + // 'call() && @annotation()' when the called method has multiple arguments + public void testCallAnnotationBinding2() { + runTest("call annotation binding 2"); + } + + // 'call() && @annotation()' when the called method takes primitive arguments (YUCK!) + public void testCallAnnotationBinding3() { + runTest("call annotation binding 3"); + } + + // 'call() && @annotation()' when runtime type will exhibit different annotation (due to interface implementing) + public void testCallAnnotationBinding4() { + runTest("call annotation binding 4"); + } + + // 'call() && @annotation()' when target doesnt have an annotation ! + public void testCallAnnotationBinding5() { + runTest("call annotation binding 5"); + } + + // 'call() && @annotation()' when runtime type will exhibit different annotation (due to subclassing) + public void testCallAnnotationBinding6() { + runTest("call annotation binding 6"); + } + + // 'call() && @annotation()' using named pointcut + public void testCallAnnotationBinding7() { + runTest("call annotation binding 7"); + } + + // /////////////////////////////////// @TARGET + + // 'call() && @target()' + public void testAtTargetAnnotationBinding1() { + runTest("@target annotation binding 1"); + } + + // 'call() && @target() && @target' + public void testAtTargetAnnotationBinding2() { + runTest("@target annotation binding 2"); + } + + // 'call() && @target()' - using a type hierarchy where some levels are missing annotations + public void testAtTargetAnnotationBinding3() { + runTest("@target annotation binding 3"); + } + + // 'call() && @target()' - using a type hierarchy where some levels are missing annotations + // but the annotation is inherited + public void testAtTargetAnnotationBinding4() { + runTest("@target annotation binding 4"); + } + + // @target() with an annotation in a package + public void testAtTargetAnnotationBinding5() { + runTest("@target annotation binding 5"); + } + + // /////////////////////////////////// @THIS + + // 'call() && @this()' + public void testAtThisAnnotationBinding1() { + runTest("@this annotation binding 1"); + } + + // 'call() && @this() && @this' + public void testAtThisAnnotationBinding2() { + runTest("@this annotation binding 2"); + } + + // 'call() && @this()' - using a type hierarchy where some levels are missing annotations + public void testAtThisAnnotationBinding3() { + runTest("@this annotation binding 3"); + } + + // 'call() && @this()' - using a type hierarchy where some levels are missing annotations + // but the annotation is inherited + public void testAtThisAnnotationBinding4() { + runTest("@this annotation binding 4"); + } + + // '@this() and @target()' used together + public void testAtThisAtTargetAnnotationBinding() { + runTest("@this annotation binding 5"); + } + + // /////////////////////////////////// @ARGS + + // complex case when there are 3 parameters + public void testAtArgs1() { + runTest("@args annotation binding 1"); + } + + // simple case when there is only one parameter + public void testAtArgs2() { + runTest("@args annotation binding 2"); + } + + // simple case when there is only one parameter and no binding + public void testAtArgs3() { + runTest("@args annotation binding 3"); + } + + // complex case binding different annotation kinds + public void testAtArgs4() { + runTest("@args annotation binding 4"); + } + + // check @args and execution() + public void testAtArgs5() { + runTest("@args annotation binding 5"); + } + + // /////////////////////////////////// @ANNOTATION and EXECUTION + + // 'execution() && @annotation()' + public void testExecutionAnnotationBinding1() { + runTest("execution and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and SET + + // 'set() && @annotation()' + public void testFieldAnnotationBinding1() { + runTest("set and @annotation"); + } + + // 'get() && @annotation()' + public void testFieldAnnotationBinding2() { + runTest("get and @annotation"); + } + + // 'get() && @annotation()' when using array fields + public void testFieldAnnotationBinding3() { + runTest("get and @annotation with arrays"); + } + + // /////////////////////////////////// @ANNOTATION and CTOR-CALL + + // 'ctor-call(new) && @annotation()' + public void testCtorCallAnnotationBinding1() { + runTest("cons call and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and CTOR-CALL + + // 'ctor-execution() && @annotation()' + public void testCtorExecAnnotationBinding1() { + runTest("cons exe and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and STATICINITIALIZATION + + // 'staticinitialization() && @annotation()' + public void testStaticInitAnnotationBinding1() { + runTest("staticinit and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and PREINITIALIZATION + + // 'preinitialization() && @annotation()' + public void testPreInitAnnotationBinding1() { + runTest("preinit and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and INITIALIZATION + + // 'initialization() && @annotation()' + public void testInitAnnotationBinding1() { + runTest("init and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and ADVICEEXECUTION + + // 'adviceexecution() && @annotation()' + public void testAdviceExecAnnotationBinding1() { + runTest("adviceexecution and @annotation"); + } + + // /////////////////////////////////// @ANNOTATION and HANDLER + + // 'handler() && @annotation()' + public void testHandlerAnnotationBinding1() { + runTest("handler and @annotation"); + } + + // /////////////////////////////////// @WITHIN + + // '@within()' + public void testWithinBinding1() { + runTest("@within"); + } + + // '@within()' but multiple types around (some annotated) + public void testWithinBinding2() { + runTest("@within - multiple types"); + } + + // /////////////////////////////////// @WITHINCODE + + // '@withincode() && call(* println(..))' + public void testWithinCodeBinding1() { + runTest("@withincode() and call(* println(..))"); + } + + // /////////////////////////////////// @ANNOTATION complex tests + + // Using package names for the types (including the annotation) - NO BINDING + public void testPackageNamedTypesNoBinding() { + runTest("packages and no binding"); + } + + // Using package names for the types (including the annotation) - INCLUDES BINDING + public void testPackageNamedTypesWithBinding() { + runTest("packages and binding"); + } + + // declare parents: @Color * implements Serializable + public void testDeclareParentsWithAnnotatedAnyPattern() { + runTest("annotated any pattern"); + } + + // Should error (in a nice way!) on usage of an annotation that isnt imported + public void testAnnotationUsedButNotImported() { + runTest("annotation not imported"); + } + + // Binding with calls/executions of static methods + public void testCallsAndExecutionsOfStaticMethods() { + runTest("binding with static methods"); + } + + // /////////////////////////////////////////////////////////////////////////////// + // annotation binding with ITDs + + public void testAnnotationBindingAndITDs1() { + runTest("simple binding annotation values where itd method is annotated"); + } + + public void testAnnotationBindingAndITDs2() { + runTest("simple binding annotation values where itd field is annotated"); + } + + public void testAnnotationBindingAndITDs3() { + runTest("simple binding annotation values where itd ctor is annotated"); + } + + public void testAnnotationBindingAndITDs4() { + runTest("simple binding annotation values where itd method is annotated via declare"); + } + + public void testAnnotationBindingAndITDs5() { + runTest("simple binding annotation values where itd field is annotated via declare"); + } + + public void testAnnotationBindingAndITDs6() { + runTest("simple binding annotation values where itd field is annotated multiple times via declare"); + } + + public void testAnnotationBindingAndITDs7() { + runTest("simple binding annotation values where itd ctor is annotated via declare"); + } + + public void testAnnotationBindingAndITDs4_asmtest() { + // AsmManager.setReporting("c:/debug.txt",true,true,true,true); + runTest("simple binding annotation values where itd method is annotated via declare"); + + if (getCurrentTest().canRunOnThisVM()) { + AsmManager asm = AsmManager.lastActiveStructureModel; + IHierarchy top = asm.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD, + "declare @method: int A.m() : @Fruit(\"orange\")"); + assertTrue("Couldn't find 'declare @method' element in the tree", ipe != null); + + List l = asm.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD, + "declare @method: int A.n() : @Fruit(\"banana\")"); + assertTrue("Couldn't find 'declare @method element in the tree", ipe != null); + + l = asm.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + Relationship rel = (Relationship) l.get(0); + assertTrue("Should have 1 target but has " + rel.getTargets().size(), rel.getTargets().size() == 1); + String tgt = (String) rel.getTargets().get(0); + int lineNumber = asm.getHandleProvider().getLineNumberForHandle(tgt); + assertTrue("Should point to line 10 but doesnt: " + lineNumber, lineNumber == 10); + } + } + + public void testAnnotationBindingAndITDs5_asmtest() { + // AsmManager.setReporting("c:/debug.txt",true,true,true,true); + runTest("simple binding annotation values where itd field is annotated via declare"); + + if (getCurrentTest().canRunOnThisVM()) { + AsmManager asm = AsmManager.lastActiveStructureModel; + IHierarchy top = asm.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD, + "declare @field: int A.i : @Fruit(\"orange\")"); + assertTrue("Couldn't find 'declare @type' element in the tree", ipe != null); + + List l = asm.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD, + "declare @field: java.lang.String A.j : @Fruit(\"banana\")"); + assertTrue("Couldn't find 'declare @field element in the tree", ipe != null); + + l = asm.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + Relationship rel = (Relationship) l.get(0); + assertTrue("Should have 1 target but has " + rel.getTargets().size(), rel.getTargets().size() == 1); + String tgt = (String) rel.getTargets().get(0); + int lineNumber = asm.getHandleProvider().getLineNumberForHandle(tgt); + assertTrue("Should point to line 10 but doesnt: " + lineNumber, lineNumber == 10); + + } + } + + public void testAnnotationBindingAndITDs7_asmtest() { + // AsmManager.setReporting("c:/debug.txt",true,true,true,true); + runTest("simple binding annotation values where itd ctor is annotated via declare"); + + if (getCurrentTest().canRunOnThisVM()) { + + AsmManager asm = AsmManager.lastActiveStructureModel; + IHierarchy top = asm.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR, + "declare @constructor: A.new(java.lang.String) : @Fruit(\"pear\")"); + assertTrue("Couldn't find 'declare @constructor' element in the tree", ipe != null); + + List l = asm.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR, + "declare @constructor: A.new(int) : @Fruit(\"orange\")"); + assertTrue("Couldn't find 'declare @constructor element in the tree", ipe != null); + + l = asm.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + Relationship rel = (Relationship) l.get(0); + assertTrue("Should have 1 target but has " + rel.getTargets().size(), rel.getTargets().size() == 1); + String tgt = (String) rel.getTargets().get(0); + int lineNumber = asm.getHandleProvider().getLineNumberForHandle(tgt); + assertTrue("Should point to line 10 but doesnt: " + lineNumber, lineNumber == 10); + + } + } + + public void testAnnotationBindingArgsVerifyError_pr92053() { + runTest("AtArgs causes a VerifyError: Unable to pop operand off an empty stack"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationPointcutsTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationPointcutsTests.java new file mode 100644 index 000000000..4301a44c0 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationPointcutsTests.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +/** + * Tests the use of Annotations in pointcuts + */ +public class AnnotationPointcutsTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AnnotationPointcutsTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // before(): call(@SimpleAnnotation * *(..)) { } + public void test001_usingAnnotationsInPointcuts() { + runTest("annotation matching on call"); + } + + public void test002_AtAnnotationMatching() { + runTest("at annotation matching"); + } + + public void test003_Within_Code() { + runTest("annotations and within(code)"); + } + + public void test004_Within() { + runTest("annotations and within"); + } + + // TODO extra tests + // 3) @annotation on the different join point kinds, matches with inherited annotation + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java new file mode 100644 index 000000000..e1d83a6cc --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** +* Tests for @this, @target, @args +*/ +public class AnnotationRuntimeTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AnnotationRuntimeTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + +// No longer a limitation ASC 31Jan05 +// public void test001_BindingWithAtTargetAllowed() { +// CompilationResult cR = binaryWeave("TestingAnnotations.jar","BindingWithAtTarget.aj",0,0); +// List errors = cR.getErrorMessages(); +// RunResult rR = run("TestingAnnotations"); +// System.err.println(rR.getStdErr()); +// } + + public void test002_MustHaveRuntimeRetention() { + runTest("must have runtime retention"); + } + + public void test003_InheritableOrNot() { + runTest("inheritable or not"); + } + + public void test004_CantUseinDecEoW() { + runTest("use of @this/target in deow"); + } + + public void test005_ArgsSuite() { + runTest("@args tests"); + } + + public void test006_CantUseinDecEoW() { + runTest("use of @args in deow"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Annotations.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Annotations.java new file mode 100644 index 000000000..f6cea64cb --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Annotations.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Annotations extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Annotations.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); + } + + public void testCompilingAnnotation() { + runTest("compiling an annotation"); + } + + public void testCompilingAnnotatedFile() { + runTest("compiling annotated file"); + } + + public void testCompilingUsingWithinAndAnnotationTypePattern() { + runTest("annotations and within (src)"); + } + + /** + * We had a bug where annotations were not present in the output class file for methods + * that got woven. This was due to unpacking bugs in LazyMethodGen. This test compiles + * a simple program then checks the annotations were copied across. + */ + public void testBugWithAnnotationsLostOnWovenMethods() throws ClassNotFoundException { + runTest("losing annotations..."); + if (getCurrentTest().canRunOnThisVM()) { + + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Program"); + Method[] meths = jc.getMethods(); + for (int i = 0; i < meths.length; i++) { + Method method = meths[i]; + if (method.getName().equals("m1")) { + assertTrue("Didn't have annotations - were they lost? method="+method.getName(),method.getAnnotations().length==1); + } + } + } + } + + public void testAnnotatedAnnotations() { + runTest("annotated annotations (@Target)"); + } + + public void testSimpleAnnotatedAspectMembers() { + runTest("simple annotated aspect members"); + } + + public void testAnnotatedAspectMembersWithWrongAnnotationType() { + runTest("simple annotated aspect members with bad target"); + } + + // more implementation work needed before this test passes + public void testAnnotatedITDs() { + runTest("annotated itds"); + } + + public void testAnnotatedITDs2() { + runTest("annotated public itds"); + } + + public void testAnnotatedITDs3() { + runTest("annotated public itds - values"); + } + + public void testAnnotatedITDs4() { + runTest("annotated public itds - multiple complex annotations"); + } + + public void testAnnotatedITDsWithWrongAnnotationType() { + runTest("annotated itds with bad target"); + } + + public void testAnnotatedAdvice() { + runTest("annotated advice"); + } + + public void testAnnotatedAdviceWithWrongAnnotationType() { + runTest("annotated advice with bad target"); + } + + public void testAnnotatedPointcut() { + runTest("annotated pointcut"); + } + + // FIXME asc uncomment this test when parser is opened up +// public void testAnnotatedDeclareStatements() { +// runTest("annotated declare statements"); +// } + + public void testBasicDeclareAnnotation() { + runTest("basic declare annotation parse test"); + } + + public void testAJDKAnnotatingAspects() { + runTest("ajdk: annotating aspects chapter"); + } + + public void testAJDKAnnotatingAspects2() { + runTest("ajdk: annotating aspects chapter, ex 2"); + } + + public void testAnnotationPatterns() { + runTest("ajdk: annotation pattern matching"); + } + + public void testAnnotationTypePatterns() { + runTest("ajdk: annotation type pattern matching"); + } + + public void testAnnotationSigPatterns() { + runTest("ajdk: annotations in sig patterns"); + } + + public void testAnnotationRuntimeMatching() { + runTest("ajdk: runtime annotations"); + } + + public void testAnnotationRetentionChecking() { + runTest("ajdk: @retention checking"); + } + + public void testAnnotationInheritance() { + runTest("ajdk: @inherited"); + } + + public void testAnnotationDEOW() { + runTest("ajdk: deow-ann"); + } + + public void testAnnotationDecp() { + runTest("ajdk: decp-ann"); + } + + public void testAnnotationDecPrecedence() { + runTest("ajdk: dec precedence"); + } + + public void testAnnotationDecAnnotation() { + runTest("ajdk: dec annotation"); + } + + public void testAnnotationsAndITDs() { + runTest("nasty annotation and itds test"); + } + + // helper methods..... + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationsBinaryWeaving.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationsBinaryWeaving.java new file mode 100644 index 000000000..cec4665a7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/AnnotationsBinaryWeaving.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +/** + * Annotations, the rules/tests: + * + * 1. cannot make ITD (C,M or F) on an annotation + * 2. cannot use declare parents to change the super type of an annotation + * 3. cannot use decp to make an annotation type implement an interface + * 4. cannot use decp to dec java.lang.annotation.Annotation as the parent of any type + * 5. cannot extend set of values in an annotation via an ITD like construct + * 6. Compilation error if you explicitly identify an Annotation type. + * 7. Lint warning if a non-explicit type pattern would match an annotation type. + */ +public class AnnotationsBinaryWeaving extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AnnotationsBinaryWeaving.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // Cannot make ITD (c/m/f) on an annotation + public void test001_itdsOnAnnotationsNotAllowed() { + runTest("no itds on annotation types"); + } + + // Deals with the cases where an explicit type is specified and it is an annotation type + public void test002_decpOnAnnotationNotAllowed_errors() { + runTest("no declare parents on annotation types"); + } + + //Deals with the cases where an wild type pattern is specified and it hits an annotation type + public void test004_decpOnAnnotationNotAllowed_xlints() { + runTest("declare parents wildcards matching annotation types"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Autoboxing.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Autoboxing.java new file mode 100644 index 000000000..46a261e24 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Autoboxing.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** +This test must be run under a Java5 VM - so it is *not* currently +in the test suite !!! +*/ +public class Autoboxing extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Autoboxing.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + public void testSimpleBoxing() { + runTest("simple boxing test"); + } + + public void testIntegerBoxing() { + runTest("integer boxing"); + } + + public void testCharacterBoxing() { + runTest("char boxing"); + } + + public void testDoubleBoxing() { + runTest("double boxing"); + } + + public void testFloatBoxing() { + runTest("float boxing"); + } + + public void testShortBoxing() { + runTest("short boxing"); + } + + public void testLongBoxing() { + runTest("long boxing"); + } + + public void testBooleanBoxing() { + runTest("boolean boxing"); + } + + public void testByteBoxing() { + runTest("byte boxing"); + } + + public void testBoxingAfterReturning() { + runTest("boxing in after returning"); + } +// CompilationResult cR = binaryWeave("testcode.jar","AspectAfterReturning.aj",0,0,"-1.5"); +// //System.err.println(cR.getStandardError()); +// assertTrue("Expected six weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), +// getWeavingMessages(cR.getInfoMessages()).size()==6); +// RunResult rR = run("AspectAfterReturning"); +// int lines = countLines(rR.getStdErr()); +// assertTrue("Expected 6 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==6); +// } +// +// public int countLines(String s) { +// int count = 0; +// while (s.indexOf("\n")!=-1) { +// count++; +// s = s.substring(s.indexOf("\n")+1); +// } +// return count; +// } +// +// protected void verify(String output,String lookingFor) { +// assertTrue("Didn't find expected string '"+lookingFor+"' in:\n"+output,output.indexOf(lookingFor)!=-1); +// } +// +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/CovarianceTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/CovarianceTests.java new file mode 100644 index 000000000..662394969 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/CovarianceTests.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/* + +class Car {} + +class FastCar extends Car {} + +class Super { + Car getCar() { + return new Car(); + } +} + +class Sub extends Super { + FastCar getCar() { + return new FastCar(); + } +} + +public class CovBaseProgram01 { + public static void main(String[] argv) { + new CovBaseProgram01().run(); + } + + public void run() { + Super instance_super = new Super(); + Sub instance_sub = new Sub(); + + Car c1 = instance_super.getCar(); // Line 26 + Car c2 = instance_sub.getCar(); // Line 27 + } +} + +// Line26: callJPs: call(Car Super.getCar()) +// Line27: callJPs: call(FastCar Sub.getCar()) call(Car Super.getCar()) + + */ + +/** + * Covariance is simply where a type overrides some inherited implementation and narrows the return type. + */ +public class CovarianceTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(CovarianceTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + private boolean verbose = false; + + + /** + * call(* getCar()) should match both + */ + public void testCOV001() { + runTest("covariance 1"); + } + + + /** + * call(* Super.getCar()) should match both + * + * This test required a change to the compiler. When we are looking at signatures and comparing them we walk up + * the hierarchy looking for supertypes that declare the same method. The problem is that in the comparison for + * whether to methods are compatible we were including the return type - this meant 'Car getCar()' on Super was + * different to 'FastCar getCar()' on Sub - it thought they were entirely different methods. In fact the return + * type is irrelevant here, we just want to make sure the names and the parameter types are the same - so I + * added a parameterSignature to the Member class that looks like '()' where the full signature looks like + * '()LFastCar;' (which includes the return type). If the full signature comparison fails then it looks at the + * parameter signature - I did it that way to try and preserve some performance. I haven't changed the + * definition of 'signature' for a member as trimming the return type off it seems rather serious ! + * + * What might break: + * - 'matches' can now return true for things that have different return types - I guess whether this is a problem + * depends on what the caller of matches is expecting, their code will have been written before covariance was + * a possibility. All the tests pass so I'll leave it like this for now. + */ + public void testCOV002() { + runTest("covariance 2"); + } + + /** + * call(Car getCar()) should match both + * + * Had to implement proper covariance support here... + */ + public void testCOV003() { + runTest("covariance 3"); + } + + /** + * *** Different base program, where Sub does not extend Super. + * call(Car Super.getCar()) should only match first call to getCar() + */ + public void testCOV004() { + runTest("covariance 4"); + } + + /** + * *** Original base program + * call(Car Super.getCar()) should match both + */ + public void testCOV005() { + runTest("covariance 5"); + } + + /** + * call(Car Sub.getCar()) should not match anything + */ + public void testCOV006() { + runTest("covariance 6"); + } + + /** + * call(Car+ Sub.getCar()) should match 2nd call with xlint for the 1st call + */ + public void testCOV007() { + runTest("covariance 7"); + } + + /** + * *** aspect now contains two pointcuts and two pieces of advice + * call(FastCar getCar()) matches on 2nd call + * call(FastCar Sub.getCar()) matches on 2nd call + */ + public void testCOV008() { + runTest("covariance 8"); + } + + /** + * call(FastCar Super.getCar()) matches nothing + */ + public void testCOV009() { + runTest("covariance 9"); + } + + /** + * call(Car+ getCar()) matches both + */ + public void testCOV010() { + runTest("covariance 10"); + } + + public void testAJDKExamples() { + runTest("ajdk: covariance"); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java new file mode 100644 index 000000000..28d48c6ca --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java @@ -0,0 +1,331 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM + * 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: + * Andy Clement initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class DeclareAnnotationTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(DeclareAnnotationTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // parsing the various forms of declare @ + public void testDeclareAnnotationParsing() { + runTest("basic declare annotation parse test"); + } + + // declare @type + + // declare @type for one simple annotation on one specific type + public void testAtType_OneAnnotationHittingOneType_Src() { + runTest("declare @type 1"); + } + + // declare @type for one simple annotation to multiple types + public void testAtType_OneAnnotationHittingMultipleTypes_Src() { + runTest("declare @type 2"); + } + + // declare @type for one simple annotation and a pointcut that matches on it + public void testAtType_PointcutMatchingOnDeclaredAnnotation() { + runTest("declare @type - with matching pointcut"); + } + + // binary weaving declare @type, one annotation on one type + public void testAtType_OneAnnotationHittingOneType_Bin() { + runTest("declare @type - binary weaving"); + } + + // an annotation with multiple values (all the primitives and string) + // is declared upon a single type + public void testAtType_ComplexAnnotation_BinWeaving() { + runTest("declare @type - complex annotation - binary weaving"); + } + + public void testAtType_ComplexAnnotation_SrcWeaving() { + runTest("declare @type - complex annotation - source weaving"); + } + + // two annotations are declared on a type + public void testAtType_TwoAnnotationsOnOneType_BinWeaving() { + runTest("declare @type - two annotations hit one type - binary weaving"); + } + + public void testAtType_TwoAnnotationsOnOneType_SrcWeaving() { + runTest("declare @type - two annotations hit one type - source weaving"); + } + + // decp and deca can interact, let's try some variants that should + // result in the same thing + public void testAtType_InteractingWithDeclareParents1_BinWeaving() { + runTest("declare @type - declare parents interactions (order 1) - binary weaving"); + } + + public void testAtType_InteractingWithDeclareParents1_SrcWeaving() { + runTest("declare @type - declare parents interactions (order 1) - source weaving"); + } + + public void testAtType_InteractingWithDeclareParents2_BinWeaving() { + runTest("declare @type - declare parents interactions (order 2) - binary weaving"); + } + + public void testAtType_InteractingWithDeclareParents2_SrcWeaving() { + runTest("declare @type - declare parents interactions (order 2) - source weaving"); + } + + public void testAtType_InteractingWithDeclareParents3_BinWeaving() { + runTest("declare @type - declare parents interactions (order 3) - binary weaving"); + } + + public void testAtType_InteractingWithDeclareParents3_SrcWeaving() { + runTest("declare @type - declare parents interactions (order 3) - source weaving"); + } + + public void testAtType_InteractingWithDeclareParents4_BinWeaving() { + runTest("declare @type - declare parents interactions (order 4) - binary weaving"); + } + + public void testAtType_InteractingWithDeclareParents4_SrcWeaving() { + runTest("declare @type - declare parents interactions (order 4) - source weaving"); + } + + public void testAtType_AnnotatingAlreadyAnnotatedType_BinWeaving() { + runTest("declare @type - annotating an already annotated type - binary weaving"); + } + + public void testAtType_AnnotatingAlreadyAnnotatedType_SrcWeaving() { + runTest("declare @type - annotating an already annotated type - source weaving"); + } + + // testing for error messages when exact type patterns used + // public void testAtType_UsingWrongAnnotationOnAType_BinWeaving() + // runTest("declare @type - annotations with different targets - binary weaving"); + // } + public void testAtType_UsingWrongAnnotationOnAType_SrcWeaving() { + runTest("declare @type - annotations with different targets - source weaving"); + } + + // testing for the lint message when non exact patterns used + // public void testAtType_UsingWrongAnnotationOnAType_TypeSpecifiedByPattern_BinWeaving() { + // runTest("declare @type - annotations with different targets (using type patterns) - binary weaving"); + // } + public void testAtType_UsingWrongAnnotationOnAType_TypeSpecifiedByPattern_SrcWeaving() { + runTest("declare @type - annotations with different targets (using type patterns) - source weaving"); + } + + // testing how multiple decAtType/decps interact when they rely on each other + public void testAtType_ComplexDecpDecAtTypeInteractions_BinWeaving() { + runTest("declare @type - complex decp decAtType interactions - binary weaving"); + } + + public void testAtType_ComplexDecpDecAtTypeInteractions_SrcWeaving() { + runTest("declare @type - complex decp decAtType interactions - source weaving"); + } + + public void testAtType_PuttingIncorrectAnnosOnTypes_SrcWeaving() { + runTest("declare @type - trying to put annotation targetting annos on normal types - source weaving"); + } + + public void testAtType_PuttingIncorrectAnnosOnTypes_BinWeaving() { + runTest("declare @type - trying to put annotation targetting annos on normal types - binary weaving"); + } + + public void testAtType_PuttingIncorrectAnnosOnTypesWithPatterns_SrcWeaving() { + runTest("declare @type - trying to put annotation targetting annos on normal types (uses pattern) - source weaving"); + } + + public void testAtType_PuttingIncorrectAnnosOnTypesWithPatterns_BinWeaving() { + runTest("declare @type - trying to put annotation targetting annos on normal types (uses pattern) - binary weaving"); + } + + // I think this fails because of a freaky JDT compiler bug ... + // public void testAtType_UsingClassOrEnumElementValuesInAnnotations_SrcWeaving() { + // runTest("declare @type - covering enum and class element values - source weaving"); + // } + + public void testAtType_UsingClassOrEnumElementValuesInAnnotations_BinWeaving() { + runTest("declare @type - covering enum and class element values - binary weaving"); + } + + // /////////////////////////////////////////////////////////////////////////////// + // declare @field + + public void testAtField_SimpleSource() { + runTest("declare @field - simple source weaving"); + } + + public void testAtField_SimpleBinary() { + runTest("declare @field - simple binary weaving"); + } + + // lint warning + public void testAtField_TwoTheSameOnOneSource() { + runTest("declare @field - two the same on one - source weaving"); + } + + // lint warning + public void testAtField_TwoTheSameOnOneBinary() { + runTest("declare @field - two the same on one - binary weaving"); + } + + public void testAtField_TwoDifferentOnOneSource() { + runTest("declare @field - two different on one - source weaving"); + } + + public void testAtField_TwoDifferentOnOneBinary() { + runTest("declare @field - two different on one - binary weaving"); + } + + public void testAtField_WrongTargetSource() { + runTest("declare @field - wrong target - source weaving"); + } + + // Can't do a test like this - as verification of the declare @ is + // done when the aspect is first compiled. + // public void testAtField_WrongTargetBinary() { + // runTest("declare @field - wrong target - binary weaving"); + // } + + public void testAtField_RightTargetSource() { + runTest("declare @field - right target - source weaving"); + } + + public void testAtField_RightTargetBinary() { + runTest("declare @field - right target - binary weaving"); + } + + public void testAtField_RecursiveSource() { + runTest("declare @field - recursive application - source weaving"); + } + + public void testAtField_RecursiveBinary() { + runTest("declare @field - recursive application - binary weaving"); + } + + public void testAtField_RecursiveOtherOrderSource() { + runTest("declare @field - recursive application (other order) - source weaving"); + } + + public void testAtField_RecursiveOtherOrderBinary() { + runTest("declare @field - recursive application (other order) - binary weaving"); + } + + // /////////////////////////////////////////////////////////////////////////////// + // declare @method + + public void testAtMethod_SimpleSource() { + runTest("declare @method - simple source weaving"); + } + + public void testAtMethod_SimpleBinary() { + runTest("declare @method - simple binary weaving"); + } + + // /////////////////////////////////////////////////////////////////////////////// + // declare @constructor + + public void testAtCtor_SimpleSource() { + runTest("declare @constructor - simple source weaving"); + } + + public void testAtCtor_SimpleBinary() { + runTest("declare @constructor - simple binary weaving"); + } + + // /////////////////////////////////////////////////////////////////////////////// + // declare @method @constructor + + public void testAtMethodCtor_WrongTargetSource() { + runTest("declare @method @ctor - wrong target - source weaving"); + } + + public void testAtMethodCtor_RightTargetSource() { + runTest("declare @method @ctor - right target - source weaving"); + } + + public void testAtMethodCtor_RightTargetBinary() { + runTest("declare @method @ctor - right target - binary weaving"); + } + + // lint warning + public void testAtMethodCtor_TwoTheSameOnOneSource() { + runTest("declare @method @ctor - two the same on one - source weaving"); + } + + // lint warning + public void testAtMethodCtor_TwoTheSameOnOneBinary() { + runTest("declare @method @ctor - two the same on one - binary weaving"); + } + + public void testAtMethodCtor_TwoDifferentOnOneSource() { + runTest("declare @method @ctor - two different on one - source weaving"); + } + + public void testAtMethodCtor_TwoDifferentOnOneBinary() { + runTest("declare @method @ctor - two different on one - binary weaving"); + } + + // to debug this test, uncomment the first line which will give you a nice + // dump of the structure model in c:/debug.txt + public void testStructureModel() { + // AsmManager.setReporting("c:/debug.txt",true,true,true,true); + runTest("declare all annotations on one class - source weaving"); + + if (getCurrentTest().canRunOnThisVM()) { + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE, + "declare @type: p.q.DeathByAnnotations : @Colored(\"red\")"); + assertTrue("Couldn't find 'declare @type' element in the tree", ipe != null); + + List l = AsmManager.lastActiveStructureModel.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l != null && l.size() > 0); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD, + "declare @method: * m*(..) : @Fruit(\"tomato\")"); + assertTrue("Couldn't find 'declare @method element in the tree", ipe != null); + + l = AsmManager.lastActiveStructureModel.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR, + "declare @constructor: p.q.DeathByAnnotations.new(..) : @Fruit(\"tomato\")"); + assertTrue("Couldn't find 'declare @constructor element in the tree", ipe != null); + l = AsmManager.lastActiveStructureModel.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD, + "declare @field: * p.q.DeathByAnnotations.* : @Material(\"wood\")"); + assertTrue("Couldn't find 'declare @field element in the tree", ipe != null); + l = AsmManager.lastActiveStructureModel.getRelationshipMap().get(ipe); + assertTrue("Should have a relationship but does not ", l.size() > 0); + } + } + + public void testDeclareTypeMisspelled() { + runTest("declare @Type (should be @type)"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Enums.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Enums.java new file mode 100644 index 000000000..7f7f8bac4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Enums.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +/** + * Enums, the rules/tests: + * + * 1. cannot make ITDC on an enum + * 2. cannot make ITDM or ITDF on an enum + * 3. cannot use declare parents to change the super type of an enum + * 4. cannot use decp to make an enum type implement an interface + * 5. cannot use decp to dec java.lang.Enum as the parent of any type + * 6. cannot extend set of values in an enum via an ITD like construct + * 7. Compilation error if you explicitly identify an Enum type. + * 8. Lint warning if a non-explicit type pattern would match an enum type. + * + */ +public class Enums extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Enums.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // Cannot make ITDC on an enum + public void test001_itdcsOnEnumNotAllowed() { + runTest("cant itd constructor on enum"); + } + + // Cannot make ITDM or ITDF on an enum + public void test002_itdFieldOrMethodOnEnumNotAllowed() { + runTest("cant itd field or method on enum"); + } + + // Deals with the cases where an explicit type is specified and it is an enum type + public void test003_decpOnEnumNotAllowed_errors() { + runTest("declare parents and enums"); + } + + //Deals with the cases where an wild type pattern is specified and it hits an enum type + public void test004_decpOnEnumNotAllowed_xlints() { + runTest("wildcard enum match in itd"); + } +// CompilationResult cR = binaryWeave("testcode.jar","EnumAspect04.aj",0,2,false); +// IMessage msg = (IMessage)cR.getWarningMessages().get(0); +// assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg, +// msg.toString().indexOf("matches a declare parents type pattern")!=-1); +// msg = (IMessage)cR.getWarningMessages().get(1); +// assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg, +// msg.toString().indexOf("matches a declare parents type pattern")!=-1); +// verifyWeavingMessagesOutput(cR,new String[]{}); +// } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java new file mode 100644 index 000000000..6209298c1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java @@ -0,0 +1,254 @@ +package org.aspectj.systemtest.ajc150; + +import java.io.File; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.Field; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.apache.bcel.util.ClassPath; +import org.aspectj.apache.bcel.util.SyntheticRepository; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.tools.ajc.Ajc; +import org.aspectj.weaver.ConcreteTypeMunger; +import org.aspectj.weaver.CrosscuttingMembers; +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.ResolvedTypeMunger; +import org.aspectj.weaver.TypeVariable; +import org.aspectj.weaver.TypeVariableReference; +import org.aspectj.weaver.World; +import org.aspectj.weaver.bcel.BcelTypeMunger; +import org.aspectj.weaver.bcel.BcelWorld; + +public class GenericITDsDesign extends XMLBasedAjcTestCase { + + private World recentWorld; + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(GenericITDsDesign.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + private void verifyDebugString(ResolvedMember theMember, String string) { + assertTrue("Expected '" + string + "' but found " + theMember.toDebugString(), theMember.toDebugString().equals(string)); + } + + public static JavaClass getClassFromDisk(Ajc ajc, String classname) { + try { + ClassPath cp = new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path")); + SyntheticRepository sRepos = SyntheticRepository.getInstance(cp); + return sRepos.loadClass(classname); + } catch (ClassNotFoundException e) { + fail("Couldn't find class " + classname + " in the sandbox directory."); + } + return null; + } + + public static Signature getClassSignature(Ajc ajc, String classname) { + JavaClass clazz = getClassFromDisk(ajc, classname); + Signature sigAttr = null; + Attribute[] attrs = clazz.getAttributes(); + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals("Signature")) { + sigAttr = (Signature) attribute; + } + } + return sigAttr; + } + + // Check the signature attribute on a class is correct + public static void verifyClassSignature(Ajc ajc, String classname, String sig) { + Signature sigAttr = getClassSignature(ajc, classname); + assertTrue("Failed to find signature attribute for class " + classname, sigAttr != null); + assertTrue("Expected signature to be '" + sig + "' but was '" + sigAttr.getSignature() + "'", sigAttr.getSignature() + .equals(sig)); + } + + public List getTypeMunger(String classname) { + ClassPath cp = new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path")); + recentWorld = new BcelWorld(cp.toString()); + ReferenceType resolvedType = (ReferenceType) recentWorld.resolve(classname); + CrosscuttingMembers cmembers = resolvedType.collectCrosscuttingMembers(true); + List tmungers = cmembers.getTypeMungers(); + return tmungers; + } + + private BcelTypeMunger getMungerFromLine(String classname, int linenumber) { + List allMungers = getTypeMunger(classname); + for (Iterator iter = allMungers.iterator(); iter.hasNext();) { + BcelTypeMunger element = (BcelTypeMunger) iter.next(); + if (element.getMunger().getSourceLocation().getLine() == linenumber) { + return element; + } + } + for (Iterator iter = allMungers.iterator(); iter.hasNext();) { + BcelTypeMunger element = (BcelTypeMunger) iter.next(); + System.err.println("Line: " + element.getMunger().getSourceLocation().getLine() + " > " + element); + } + fail("Couldn't find a type munger from line " + linenumber + " in class " + classname); + return null; + } + + public Hashtable getMeTheFields(String classname) { + JavaClass theClass = getClassFromDisk(ajc, classname); + Hashtable retval = new Hashtable<>(); + org.aspectj.apache.bcel.classfile.Field[] fs = theClass.getFields(); + for (int i = 0; i < fs.length; i++) { + Field field = fs[i]; + retval.put(field.getName(), field); + } + return retval; + } + + /* + * test plan: 1. Serializing and recovering 'default bounds' type variable info: a. methods b. fields c. ctors 2. Serializing + * and recovering 'extends' with a class bounded type variable info: a. methods b. fields c. ctors 3. Serializing and recovering + * 'extends' with an interface bounded type variable info: a. methods b. fields c. ctors 4. Multiple interface bounds a. methods + * b. fields c. ctors 5. wildcard bounds '? extends/? super' a. methods b. fields c. ctors 6. using type variables in an ITD + * from the containing aspect, no bounds a. methods b. fields c. ctors + */ + + // Verify: a) After storing it in a class file and recovering it (through deserialization), we can see the type + // variable and that the parameter refers to the type variable. + public void testDesignA() { + runTest("generic itds - design A"); + BcelTypeMunger theBcelMunger = getMungerFromLine("X", 5); + ResolvedType typeC = recentWorld.resolve("C"); + ResolvedTypeMunger rtMunger = theBcelMunger.getMunger(); + ResolvedMember theMember = rtMunger.getSignature(); + // Let's check all parts of the member + assertTrue("Declaring type should be C: " + theMember, theMember.getDeclaringType().equals(typeC)); + + TypeVariable tVar = theMember.getTypeVariables()[0]; + TypeVariableReference tvrt = (TypeVariableReference) theMember.getParameterTypes()[0]; + + theMember.resolve(recentWorld); // resolution will join the type variables together (i.e. make them refer to the same + // instance) + + tVar = theMember.getTypeVariables()[0]; + tvrt = (TypeVariableReference) theMember.getParameterTypes()[0]; + + assertTrue( + "Post resolution, the type variable in the parameter should be identical to the type variable declared on the member", + tVar == tvrt.getTypeVariable()); + } + + // Verify: bounds are preserved and accessible after serialization + public void testDesignB() { + runTest("generic itds - design B"); + BcelTypeMunger theBcelMunger = getMungerFromLine("X", 7); + ResolvedTypeMunger rtMunger = theBcelMunger.getMunger(); + ResolvedMember theMember = rtMunger.getSignature(); + verifyDebugString(theMember, " void C.m0(T)"); + + theBcelMunger = getMungerFromLine("X", 9); + rtMunger = theBcelMunger.getMunger(); + theMember = rtMunger.getSignature(); + verifyDebugString(theMember, " void C.m1(Q)"); + + theBcelMunger = getMungerFromLine("X", 11); + rtMunger = theBcelMunger.getMunger(); + theMember = rtMunger.getSignature(); + verifyDebugString(theMember, " void C.m2(R)"); + } + + // Verify: a) multiple type variables work. + // b) type variables below the 'top level' (e.g. List) are preserved. + public void testDesignC() { + runTest("generic itds - design C"); + BcelTypeMunger theBcelMunger = getMungerFromLine("X", 9); + // System.err.println(theBcelMunger.getMunger().getSignature().toDebugString()); + verifyDebugString(theBcelMunger.getMunger().getSignature(), " void C.m0(T, Q)"); + + theBcelMunger = getMungerFromLine("X", 11); + // System.err.println(theBcelMunger.getMunger().getSignature().toDebugString()); + verifyDebugString(theBcelMunger.getMunger().getSignature(), " java.util.List C.m1(B, java.util.Collection)"); + } + + // Verify: a) sharing type vars with some target type results in the correct variable names in the serialized form + public void testDesignD() { + runTest("generic itds - design D"); + BcelTypeMunger theBcelMunger = getMungerFromLine("X", 9); + // System.err.println(theBcelMunger.getMunger().getSignature().toDebugString()); + verifyDebugString(theBcelMunger.getMunger().getSignature(), "void C.m0(R)"); + + theBcelMunger = getMungerFromLine("X", 11); + // System.err.println(theBcelMunger.getMunger().getSignature().toDebugString()); + verifyDebugString(theBcelMunger.getMunger().getSignature(), + "java.util.List C.m0(Q, int, java.util.List>)"); + } + + // Verify: a) for fields, sharing type vars with some target type results in the correct entries in the class file + public void testDesignE() { + runTest("generic itds - design E"); + BcelTypeMunger theBcelMunger = getMungerFromLine("X", 9); + verifyDebugString(theBcelMunger.getMunger().getSignature(), "java.util.List C.ln"); + assertTrue("Expected to find \"Z\": " + theBcelMunger.getTypeVariableAliases(), theBcelMunger.getTypeVariableAliases() + .contains("Z")); + + theBcelMunger = getMungerFromLine("X", 11); + verifyDebugString(theBcelMunger.getMunger().getSignature(), "Q C.n"); + assertTrue("Expected to find \"Q\": " + theBcelMunger.getTypeVariableAliases(), theBcelMunger.getTypeVariableAliases() + .contains("Q")); + } + + // Verifying what gets into a class targetted with a field ITD + public void testDesignF() { + runTest("generic itds - design F"); + Hashtable fields = getMeTheFields("C"); + + // Declared in src as: List C.list1; and List C.list2; + Field list1 = (Field) fields.get("list1");// ajc$interField$$list1"); + assertTrue("Field list1 should be of type 'Ljava/util/List;' but is " + list1.getSignature(), list1.getSignature().equals( + "Ljava/util/List;")); + Field list2 = (Field) fields.get("list2");// ajc$interField$$list1"); + assertTrue("Field list2 should be of type 'Ljava/util/List;' but is " + list2.getSignature(), list2.getSignature().equals( + "Ljava/util/List;")); + + // Declared in src as: String C.field1; and Q C.field2; + // bound for second field collapses to Object + Field field1 = (Field) fields.get("field1");// ajc$interField$$field1"); + assertTrue("Field list1 should be of type 'Ljava/lang/String;' but is " + field1.getSignature(), field1.getSignature() + .equals("Ljava/lang/String;")); + Field field2 = (Field) fields.get("field2");// ajc$interField$$field2"); + assertTrue("Field list2 should be of type 'Ljava/lang/Object;' but is " + field2.getSignature(), field2.getSignature() + .equals("Ljava/lang/Object;")); + } + + // Verifying what gets into a class when an interface it implements was targetted with a field ITD + public void testDesignG() { + runTest("generic itds - design G"); + Hashtable fields = getMeTheFields("C"); + + // The ITDs are targetting an interface. That interface is generic and is parameterized with + // 'String' when implemented in the class C. This means the fields that make it into C should + // be parameterized with String also. + + // List I.ln; and Q I.n; + // Field field1 = (Field)fields.get("ajc$interField$X$I$ln"); + // assertTrue("Field list1 should be of type 'Ljava/util/List;' but is "+field1.getSignature(), + // field1.getSignature().equals("Ljava/util/List;")); + // Field field2 = (Field)fields.get("ajc$interField$X$I$n"); + // assertTrue("Field list2 should be of type 'Ljava/lang/String;' but is "+field2.getSignature(), + // field2.getSignature().equals("Ljava/lang/String;")); + } + + // // Verify: a) sharing type vars with some target type results in the correct variable names in the serialized form + // public void testDesignE() { + // runTest("generic itds - design E"); + // + // } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java new file mode 100644 index 000000000..907e3d7a5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -0,0 +1,996 @@ +package org.aspectj.systemtest.ajc150; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.HashSet; +import java.util.Set; + +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.apache.bcel.util.ClassPath; +import org.aspectj.apache.bcel.util.SyntheticRepository; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.tools.ajc.Ajc; +import org.aspectj.util.LangUtil; + +import junit.framework.Test; + +public class GenericsTests extends XMLBasedAjcTestCase { + + /*========================================== + * Generics test plan for pointcuts. + * + * handler PASS + * - does not permit type var spec + * - does not permit generic type (fail with type not found) + * - does not permit parameterized types + * if PASS + * - does not permit type vars + * cflow PASS + * - does not permit type vars + * cflowbelow PASS + * - does not permit type vars + * @this PASS + * - does not permit type vars PASS + * - does not permit parameterized type PASS + * @target PASS + * - does not permit type vars PASS + * - does not permit parameterized type PASS + * @args PASS + * - does not permit type vars PASS + * - does not permit parameterized type PASS + * @annotation PASS + * - does not permit type vars PASS + * - does not permit parameterized type PASS + * @within, @within code - as above PASS + * annotation type pattern with generic and parameterized types PASS + * - just make sure that annotation interfaces can never be generic first! VERIFIED + * - @Foo should fail PASS + * - @Foo should fail PASS + * - @(Foo || Bar) should fail DEFERRED (not critical) + * staticinitialization PASS + * - error on parameterized type PASS N/A + * - permit parameterized type + PASS N/A + * - matching with parameterized type + N/A + * - wrong number of parameters in parameterized type PASS N/A + * - generic type with one type parameter N/A + * - generic type with n type parameters N/A + * - generic type with bounds [extends, extends + i/f's] N/A + * - generic type with wrong number of type params N/A + * - wildcards in bounds N/A + * within PASS + * - as above, but allows parameterized type (disallowed in simplified plan) + * - wildcards in type parameters N/A + * this PASS + * - no type vars + * - parameterized types - disallowed in simplification plan + * - implements + * - instanceof + * target PASS + * - as this + * args + * - args(List) matches List, List, List PASS + * - args(List) -> invalid absolute type T + * - args(List) matches List but not List PASS + * - args(List) matches List with unchecked warning PASS + * - args(List) matches List with unchecked warning PASS + * - args(List) matches List, List, List with unchecked warning PASS + * matches List PASS, List PASS(with warning) + * - args(List) matches List, List, List, ... PASS + * - args(List, List, not List PASS + * matches List, List with unchecked warning PASS + * - args(List) matches List, List + * does not match List + * matches List, List with unchecked warning + * matches List + * matches List with unchecked warning + * matches List with unchecked warning + * get & set PASS + * - parameterized declaring type PASS + * - generic declaring type PASS + * - field type is type variable PASS + * - field type is parameterized PASS + * initialization, preinitialization PASS + * - generic declaring type PASS + * - type variables as params PASS + * - parameterized types as params PASS + * - no join points for init, preinit of parameterized types (as per staticinit) PASS + * withincode PASS + * - no generic or parameterized declaring type patterns PASS + * - no parameterized throws patterns PASS + * - return type as type variable PASS + * - return type as parameterized type PASS + * - parameter as type variable PASS + * - parameter as parameterized type PASS + * - no join points within bridge methods PASS + * execution PASS + * - no generic or parameterized declaring type patterns PASS + * - no parameterized throws patterns PASS + * - return type as type variable PASS + * - return type as parameterized type PASS + * - parameter as type variable PASS + * - parameter as parameterized type PASS + * - no join points for bridge methods PASS + * call PASS + * - no generic or parameterized declaring type patterns PASS + * - no parameterized throws patterns PASS + * - return type as type variable PASS + * - return type as parameterized type PASS + * - parameter as type variable PASS + * - parameter as parameterized type PASS + * - calls to a bridge methods PASS + * after throwing - can't use parameterized type pattern + * after returning - same as for args + */ + + /* ========================================== + * Generics test plan for ITDs. + * + * think about: + * - 'visibility' default/private/public + * - static/nonstatic + * - parameterized ITDs (methods/ctors/fields) + * - ITD target: interface/class/aspect + * - multiple type variables + * - constructor ITDs, method ITDs + * - ITDs sharing type variables with generic types + * - relating to above point, this makes generic ITD fields possible + * - signature attributes for generic ITDs (required? required only for public ITDs?) + * - binary weaving when target type changes over time (might start out 'simple' then sometime later be 'generic') + * - bridge methods - when to create them + * - multiple 'separate' ITDs in a file that share a type variable by 'name' + * - wildcards '?' 'extends' 'super' '&' + * - do type variables assigned to members need to persist across serialization + * - recursive type variable definitions eg. > + * - super/extends with parameterized types > + * - multiple ITDs defined in one type that reuse type variable letters, specifying different bounds + * - generic aspects + * + * PASS parsing generic ITDs + * PASS generic methods + * PASS generic constructors + * PASS ITD visibility + * PASS static/nonstatic + * PASS parameterizedITDs + * PASS differing targets (interface/class/aspect) + * PASS multiple type variables in an ITD + * PASS parsing ITDs that share type variables with target type + * PASS using type variables from the target type in your field ITD + * PASS using type variables from the target type in your method ITD (but no type vars of your own) + * PASS using type variables from the target type in your ctor ITD (but no type vars of your own) + * PASS using type variables from the target type and having your own too (methods) + * PASS using type variables from the target type and having your own too (ctors) + * PASS reusing type variable letter but differing spec across multiple ITDs in one aspect + * PASS wildcards + * PASS recursive type variable definitions + * PASS generic aspects + * PASS parameterizing ITDs with type variables + * PASS using type variables from the target type in your *STATIC* ITD (field/method/ctor) (error scenario) + * PASS basic binary weaving of generic itds + * + * TODO generic aspect binary weaving (or at least multi source file weaving) + * TODO binary weaving with changing types (moving between generic and simple) + * TODO bridge method creation (also relates to covariance overrides..) + * TODO exotic class/interface bounds ('? extends List','? super anything') + * TODO signature attributes for generic ITDs (public only?) + * + */ + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(GenericsTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + public void testITDReturningParameterizedType() { + runTest("ITD with parameterized type"); + } + + public void testPR91267_1() { + runTest("NPE using generic methods in aspects 1"); + } + + public void testParameterizedTypeAndAroundAdvice_PR115250() { + runTest("parameterized type and around advice"); + } + + public void testParameterizedTypeAndAroundAdvice_PR115250_2() { + runTest("parameterized type and around advice - 2"); + } + + public void testPR91267_2() { + runTest("NPE using generic methods in aspects 2"); + } + + public void testPR91053() { + runTest("Generics problem with Set"); + } + + public void testPR87282() { + runTest("Compilation error on generic member introduction"); + } + + public void testGenericsOverrides_1() { runTest("generics and ITD overrides - 1"); } + public void testGenericsOverrides_2() { runTest("generics and ITD overrides - 2"); } + public void testGenericsOverrides_3() { runTest("generics and ITD overrides - 3"); } + public void testGenericsOverrides_4() { runTest("generics and ITD overrides - 4"); } + + + public void testSelfBoundGenerics_pr117296() { + runTest("self bounding generic types"); + } + + public void testPR88606() { + runTest("Parameterized types on introduced fields not correctly recognized"); + } + + public void testPR97763() { + runTest("ITD method with generic arg"); + } + + public void testGenericsBang_pr95993() { + runTest("NPE at ClassScope.java:660 when compiling generic class"); + } + + + // generic aspects + public void testPR96220_GenericAspects1() {runTest("generic aspects - 1");} + public void testPR96220_GenericAspects2() {runTest("generic aspects - 2");} + public void testPR96220_GenericAspects3() {runTest("generic aspects - 3");} + public void testGenericAspects4() {runTest("generic aspects - 4");} + public void testGenericAspects5() {runTest("generic aspects - 5 (ajdk)");} // in separate files + public void testGenericAspects6() {runTest("generic aspects - 6 (ajdk)");} // all in one file + public void testTypeVariablesInDeclareWarning() { runTest("generic aspect with declare warning using type vars");} + public void testTypeVariablesInExecutionAdvice() { runTest("generic aspect with execution advice using type vars");} + public void testTypeVariablesInAnonymousPointcut() { runTest("generic aspect with anonymous pointcut");} + public void testDeclareParentWithParameterizedInterface() { + runTest("generic aspect declare parents"); + } + public void testDeclareSoftInGenericAspect() { + runTest("generic aspect declare soft"); + } + + ////////////////////////////////////////////////////////////////////////////// + // Generic/Parameterized ITDs - includes scenarios from developers notebook // + ////////////////////////////////////////////////////////////////////////////// + + + // parsing of generic ITD members + public void testParseItdNonStaticMethod() {runTest("Parsing generic ITDs - 1");} + public void testParseItdStaticMethod() {runTest("Parsing generic ITDs - 2");} + public void testParseItdCtor() {runTest("Parsing generic ITDs - 3");} + public void testParseItdComplexMethod() {runTest("Parsing generic ITDs - 4");} + public void testParseItdSharingVars1() {runTest("Parsing generic ITDs - 5");} + public void testParseItdSharingVars2() {runTest("Parsing generic ITDs - 6");} + + + // non static + public void testGenericMethodITD1() {runTest("generic method itd - 1");} // ... (List) + public void testGenericMethodITD2() {runTest("generic method itd - 2");} // ... (List) called incorrectly + public void testGenericMethodITD3() {runTest("generic method itd - 3");} // ... (List,List) + public void testGenericMethodITD4() {runTest("generic method itd - 4");} // ... (List,List) + public void testGenericMethodITD5() {runTest("generic method itd - 5");} // ... (List,List) called incorrectly + public void testGenericMethodITD6() {runTest("generic method itd - 6");} // ... (List) + public void testGenericMethodITD7() {runTest("generic method itd - 7"); } // ... (List,List) + public void testGenericMethodITD8() {runTest("generic method itd - 8"); } // ... (List,List) called incorrectly + public void testGenericMethodITD9() {runTest("generic method itd - 9"); } // > ... (List) + public void testGenericMethodITD10() {runTest("generic method itd - 10");} // > ... (List) called incorrectly + public void testGenericMethodITD11() {runTest("generic method itd - 11");} // > ... (List) + public void testGenericMethodITD12() {runTest("generic method itd - 12");} // > ... (List) called incorrectly + public void testGenericMethodITD13() {runTest("generic method itd - 13");} // > ... (List) called correctly in a clever way ;) + public void testGenericMethodITD14() {runTest("generic method itd - 14");} // > ... (List) called incorrectly in a clever way + public void testGenericMethodITD15() {runTest("generic method itd - 15");} // > ... (List) called correctly in a clever way + + + + // generic ctors + public void testGenericCtorITD1() {runTest("generic ctor itd - 1");} // new(List) + public void testGenericCtorITD2() {runTest("generic ctor itd - 2");} // new(List,List) + public void testGenericCtorITD3() {runTest("generic ctor itd - 3");} // new(List,Comparator) + + + // parameterized ITDs + public void testParameterizedMethodITD1() {runTest("parameterized method itd - 1");} // (List) + public void testParameterizedMethodITD2() {runTest("parameterized method itd - 2");} // (List) called incorrectly + public void testParameterizedMethodITD3() {runTest("parameterized method itd - 3");} // (List) called incorrectly + public void testParameterizedMethodITD4() {runTest("parameterized method itd - 4");} // (List) + + + // differing visibilities + public void testPublicITDs() {runTest("public itds");} + public void testPublicITDsErrors() {runTest("public itds with errors");} + public void testPrivateITDs() {runTest("private itds");} + public void testPackageITDs() {runTest("package itds");} + + + // targetting different types (interface/class/aspect) + public void testTargettingInterface() {runTest("targetting interface");} + public void testTargettingAspect() {runTest("targetting aspect");} + public void testTargettingClass() {runTest("targetting class");} + + + + // using a type variable from the target generic type in your ITD + public void testFieldITDsUsingTargetTypeVars1() {runTest("field itd using type variable from target type - 1");} + public void testFieldITDsUsingTargetTypeVars2() {runTest("field itd using type variable from target type - 2");} + public void testFieldITDsUsingTargetTypeVars3() {runTest("field itd using type variable from target type - 3");} + public void testFieldITDsUsingTargetTypeVars4() {runTest("field itd using type variable from target type - 4");} + public void testFieldITDsUsingTargetTypeVars5() {runTest("field itd using type variable from target type - 5");} + public void testFieldITDsUsingTargetTypeVars6() {runTest("field itd using type variable from target type - 6");} + public void testFieldITDsUsingTargetTypeVars7() {runTest("field itd using type variable from target type - 7");} + public void testFieldITDsUsingTargetTypeVars8() {runTest("field itd using type variable from target type - 8");} + public void testFieldITDsUsingTargetTypeVars9() {runTest("field itd using type variable from target type - 9");} + public void testFieldITDsUsingTargetTypeVars10(){runTest("field itd using type variable from target type -10");} + public void testFieldITDsUsingTargetTypeVars11(){runTest("field itd using type variable from target type -11");} + public void testFieldITDsUsingTargetTypeVars12(){runTest("field itd using type variable from target type -12");} + public void testFieldITDsUsingTargetTypeVars13(){runTest("field itd using type variable from target type -13");} + public void testFieldITDsUsingTargetTypeVars14(){runTest("field itd using type variable from target type -14");} + public void testFieldITDsUsingTargetTypeVars15(){runTest("field itd using type variable from target type -15");} + public void testFieldITDsUsingTargetTypeVars16(){runTest("field itd using type variable from target type -16");} + public void testFieldITDsUsingTargetTypeVars17(){runTest("field itd using type variable from target type -17");} + + + public void testMethodITDsUsingTargetTypeVarsA1() {runTest("method itd using type variable from target type - A1");} + public void testMethodITDsUsingTargetTypeVarsA2() {runTest("method itd using type variable from target type - A2");} + public void testMethodITDsUsingTargetTypeVarsA3() {runTest("method itd using type variable from target type - A3");} + public void testMethodITDsUsingTargetTypeVarsA4() {runTest("method itd using type variable from target type - A4");} + public void testMethodITDsUsingTargetTypeVarsB1() {runTest("method itd using type variable from target type - B1");} + public void testMethodITDsUsingTargetTypeVarsC1() {runTest("method itd using type variable from target type - C1");} + public void testMethodITDsUsingTargetTypeVarsD1() {runTest("method itd using type variable from target type - D1");} + public void testMethodITDsUsingTargetTypeVarsE1() {runTest("method itd using type variable from target type - E1");} + public void testMethodITDsUsingTargetTypeVarsF1() {runTest("method itd using type variable from target type - F1");} + public void testMethodITDsUsingTargetTypeVarsG1() {runTest("method itd using type variable from target type - G1");} + public void testMethodITDsUsingTargetTypeVarsH1() {runTest("method itd using type variable from target type - H1");} + public void testMethodITDsUsingTargetTypeVarsI1() {runTest("method itd using type variable from target type - I1");} + public void testMethodITDsUsingTargetTypeVarsI2() {runTest("method itd using type variable from target type - I2");} + public void testMethodITDsUsingTargetTypeVarsJ1() {runTest("method itd using type variable from target type - J1");} + public void testMethodITDsUsingTargetTypeVarsK1() {runTest("method itd using type variable from target type - K1");} + public void testMethodITDsUsingTargetTypeVarsL1() {runTest("method itd using type variable from target type - L1");} + public void testMethodITDsUsingTargetTypeVarsM1() {runTest("method itd using type variable from target type - M1");} + public void testMethodITDsUsingTargetTypeVarsM2() {runTest("method itd using type variable from target type - M2");} + public void testMethodITDsUsingTargetTypeVarsN1() {runTest("method itd using type variable from target type - N1");} + public void testMethodITDsUsingTargetTypeVarsO1() {runTest("method itd using type variable from target type - O1");} + public void testMethodITDsUsingTargetTypeVarsO2() {runTest("method itd using type variable from target type - O2");} + public void testMethodITDsUsingTargetTypeVarsP1() {runTest("method itd using type variable from target type - P1");} + public void testMethodITDsUsingTargetTypeVarsQ1() {runTest("method itd using type variable from target type - Q1");} + + public void testCtorITDsUsingTargetTypeVarsA1() {runTest("ctor itd using type variable from target type - A1");} + public void testCtorITDsUsingTargetTypeVarsB1() {runTest("ctor itd using type variable from target type - B1");} + public void testCtorITDsUsingTargetTypeVarsC1() {runTest("ctor itd using type variable from target type - C1");} + public void testCtorITDsUsingTargetTypeVarsD1() {runTest("ctor itd using type variable from target type - D1");} + public void testCtorITDsUsingTargetTypeVarsE1() {runTest("ctor itd using type variable from target type - E1");} + public void testCtorITDsUsingTargetTypeVarsF1() {runTest("ctor itd using type variable from target type - F1");} + public void testCtorITDsUsingTargetTypeVarsG1() {runTest("ctor itd using type variable from target type - G1");} + public void testCtorITDsUsingTargetTypeVarsH1() {runTest("ctor itd using type variable from target type - H1");} + public void testCtorITDsUsingTargetTypeVarsI1() {runTest("ctor itd using type variable from target type - I1");} + + public void testSophisticatedAspectsA() {runTest("uberaspects - A");} + public void testSophisticatedAspectsB() {runTest("uberaspects - B");} + public void testSophisticatedAspectsC() {runTest("uberaspects - C");} + public void testSophisticatedAspectsD() {runTest("uberaspects - D");} + public void testSophisticatedAspectsE() {runTest("uberaspects - E");} + public void testSophisticatedAspectsF() {runTest("uberaspects - F");} + public void testSophisticatedAspectsG() {runTest("uberaspects - G");} + public void testSophisticatedAspectsH() {runTest("uberaspects - H");} + public void testSophisticatedAspectsI() {runTest("uberaspects - I");} + public void testSophisticatedAspectsJ() {runTest("uberaspects - J");} + //public void testSophisticatedAspectsK() {runTest("uberaspects - K");} // FIXME asc bounds testing is tough! + public void testSophisticatedAspectsK2(){runTest("uberaspects - K2");} + public void testSophisticatedAspectsL() {runTest("uberaspects - L");} + public void testSophisticatedAspectsM() {runTest("uberaspects - M");} + public void testSophisticatedAspectsN() {runTest("uberaspects - N");} + public void testSophisticatedAspectsO() {runTest("uberaspects - O");} + public void testSophisticatedAspectsP() {runTest("uberaspects - P");} + public void testSophisticatedAspectsQ() {runTest("uberaspects - Q");} + public void testSophisticatedAspectsR() {runTest("uberaspects - R");} + public void testSophisticatedAspectsS() {runTest("uberaspects - S");} + public void testSophisticatedAspectsT() {runTest("uberaspects - T");} + public void testSophisticatedAspectsU() {runTest("uberaspects - U");} // includes nasty casts + public void testSophisticatedAspectsV() {runTest("uberaspects - V");} // casts are gone + public void testSophisticatedAspectsW() {runTest("uberaspects - W");} + public void testSophisticatedAspectsX() {runTest("uberaspects - X");} // from the AJDK + public void testSophisticatedAspectsY() {runTest("uberaspects - Y");} // pointcut matching + public void testSophisticatedAspectsZ() {runTest("uberaspects - Z");} + + // FIXME asc these two tests have peculiar error messages - generic aspect related +// public void testItdUsingTypeParameter() {runTest("itd using type parameter");} +// public void testItdIncorrectlyUsingTypeParameter() {runTest("itd incorrectly using type parameter");} + + + public void testUsingSameTypeVariable() {runTest("using same type variable in ITD");} + + public void testBinaryWeavingITDsA() {runTest("binary weaving ITDs - A");} + public void testBinaryWeavingITDsB() {runTest("binary weaving ITDs - B");} + public void testBinaryWeavingITDs1() {runTest("binary weaving ITDs - 1");} + public void testBinaryWeavingITDs2() {runTest("binary weaving ITDs - 2");} + public void testBinaryWeavingITDs3() {runTest("binary weaving ITDs - 3");} + public void testGenericITFSharingTypeVariable() {runTest("generic intertype field declaration, sharing type variable");} + + + // general tests ... usually just more complex scenarios + public void testReusingTypeVariableLetters() {runTest("reusing type variable letters");} + public void testMultipleGenericITDsInOneFile() {runTest("multiple generic itds in one file");} + public void testItdNonStaticMember() {runTest("itd of non static member");} + public void testItdStaticMember() {runTest("itd of static member");} + public void testStaticGenericMethodITD() {runTest("static generic method itd");} + + + public void testAtOverride0() {runTest("atOverride used with ITDs");} + public void testAtOverride1() {runTest("atOverride used with ITDs - 1");} + public void testAtOverride2() {runTest("atOverride used with ITDs - 2");} + public void testAtOverride3() {runTest("atOverride used with ITDs - 3");} + public void testAtOverride4() {runTest("atOverride used with ITDs - 4");} + public void testAtOverride5() {runTest("atOverride used with ITDs - 5");} + public void testAtOverride6() {runTest("atOverride used with ITDs - 6");} + public void testAtOverride7() {runTest("atOverride used with ITDs - 7");} + + + // bridge methods + public void testITDBridgeMethodsCovariance1() {runTest("bridging with covariance 1 - normal");} + public void testITDBridgeMethodsCovariance2() {runTest("bridging with covariance 1 - itd");} + public void testITDBridgeMethods1Normal() {runTest("basic bridging with type vars - 1 - normal");} + public void testITDBridgeMethods1Itd() {runTest("basic bridging with type vars - 1 - itd");} + public void testITDBridgeMethods2Normal() {runTest("basic bridging with type vars - 2 - normal");} + public void testITDBridgeMethods2Itd() {runTest("basic bridging with type vars - 2 - itd");} + public void testITDBridgeMethodsPr91381() {runTest("Abstract intertype method and covariant returns");} + + + // Just normal source compile of two types with a method override between them + public void testGenericITDsBridgeMethods1() { + runTest("bridge methods - 1"); + checkMethodsExist("Sub1",new String[]{ + "java.lang.Integer Sub1.m()", + "java.lang.Object Sub1.m() [BridgeMethod]"}); + } + // Now the same thing but the aspect (which doesn't do much!) is binary woven in. + public void testGenericITDsBridgeMethods1binary() { + runTest("bridge methods - 1 - binary"); + checkMethodsExist("Sub1",new String[]{ + "java.lang.Integer Sub1.m()", + "java.lang.Object Sub1.m() [BridgeMethod]"}); + } + // Now the method is put into the superclass via ITD - there should be a bridge method in the subclass + public void testGenericITDsBridgeMethods2() { + runTest("bridge methods - 2"); + checkMethodsExist("Sub2",new String[]{ + "java.lang.Integer Sub2.m()", + "java.lang.Object Sub2.m() [BridgeMethod]"}); + } + // Now the superclass ITD is done with binary weaving so the weaver (rather than compiler) has to create the bridge method + public void testGenericITDsBridgeMethods2binary() { + runTest("bridge methods - 2 - binary"); + checkMethodsExist("Sub2",new String[]{ + "java.lang.Integer Sub2.m()", + "java.lang.Object Sub2.m() [BridgeMethod]"}); + } + // Now the method is put into the subclass via ITD - there should be a bridge method alongside it in the subclass + public void testGenericITDsBridgeMethods3() { + runTest("bridge methods - 3"); + checkMethodsExist("Sub3",new String[]{ + "java.lang.Integer Sub3.m()", + "java.lang.Object Sub3.m() [BridgeMethod]"}); + } + // Now the subclass ITD is done with binary weaving - the weaver should create the necessary bridge method + public void testGenericITDsBridgeMethods3binary() { + runTest("bridge methods - 3 - binary"); + checkMethodsExist("Sub3",new String[]{ + "java.lang.Integer Sub3.m()", + "java.lang.Object Sub3.m() [BridgeMethod]"}); + } + // Now the two types are disconnected until the aspect supplies a declare parents relationship - + // the bridge method should still be created in the subtype + public void testGenericITDSBridgeMethods4() { + runTest("bridge methods - 4"); + checkMethodsExist("Sub4",new String[]{ + "java.lang.Integer Sub4.m()", + "java.lang.Object Sub4.m() [BridgeMethod]"}); + } + // now the aspect doing the decp between the types is applied via binary weaving - weaver should create the bridge method + public void testGenericITDSBridgeMethods4binary() { + runTest("bridge methods - 4 - binary"); + checkMethodsExist("Sub4",new String[]{ + "java.lang.Integer Sub4.m()", + "java.lang.Object Sub4.m() [BridgeMethod]"}); + } + + public void testBinaryBridgeMethodsOne() { + runTest("binary bridge methods - one"); + checkMethodsExist("OneB",new String[]{ + "java.lang.Number OneB.firstMethod() [BridgeMethod]", + "java.lang.Integer OneB.firstMethod()", + "void OneB.secondMethod(java.lang.Number) [BridgeMethod]", + "void OneB.secondMethod(java.lang.Integer)", + "void OneB.thirdMethod(java.lang.Number,java.lang.Number) [BridgeMethod]", + "void OneB.thirdMethod(java.lang.Integer,java.lang.Integer)", + "void OneB.fourthMethod(java.util.List)", + "java.lang.Number OneB.fifthMethod(java.lang.Number,java.util.List) [BridgeMethod]", + "java.lang.Integer OneB.fifthMethod(java.lang.Integer,java.util.List)" + }); + } + public void testBinaryBridgeMethodsTwo() { + runTest("binary bridge methods - two"); + checkMethodsExist("TwoB",new String[]{ + "java.lang.Number TwoB.firstMethod(java.io.Serializable) [BridgeMethod]", + "java.lang.Integer TwoB.firstMethod(java.lang.String)" + }); + } + public void testBinaryBridgeMethodsThree() { + runTest("binary bridge methods - three"); + checkMethodsExist("ThreeB",new String[]{ + "java.lang.Number ThreeB.m() [BridgeMethod]", + "java.lang.Double ThreeB.m()" + }); + } + + + public void testGenericITDsBridgeMethodsPR91381() {runTest("abstract intertype methods and covariant returns");} + public void testGenericITDsBridgeMethodsPR91381_2() {runTest("abstract intertype methods and covariant returns - error");} + + // ---------------------------------------------------------------------------------------- + // generic declare parents tests + // ---------------------------------------------------------------------------------------- + + public void testPR96220_GenericDecp() { + runTest("generic decp - simple"); + checkOneSignatureAttribute(ajc,"Basic"); + verifyClassSignature(ajc,"Basic","Ljava/lang/Object;LJ;LI;"); + } + + // Both the existing type decl and the one adding via decp are parameterized + public void testGenericDecpMultipleVariantsOfAParameterizedType1() { + runTest("generic decp - implementing two variants #1"); + } + + // Existing type decl is raw and the one added via decp is parameterized + public void testGenericDecpMultipleVariantsOfAParameterizedType2() { + runTest("generic decp - implementing two variants #2"); + } + + // Existing type decl is parameterized and the one added via decp is raw + public void testGenericDecpMultipleVariantsOfAParameterizedType3() { + runTest("generic decp - implementing two variants #3"); + } + + // decp is parameterized but it does match the one already on the type + public void testGenericDecpMultipleVariantsOfAParameterizedType4() { + runTest("generic decp - implementing two variants #4"); + } + + // same as above four tests for binary weaving + public void testGenericDecpMultipleVariantsOfAParameterizedType1_binaryWeaving() { + runTest("generic decp binary - implementing two variants #1"); + } + + public void testGenericDecpMultipleVariantsOfAParameterizedType2_binaryWeaving() { + runTest("generic decp binary - implementing two variants #2"); + } + + // Existing type decl is parameterized and the one added via decp is raw + public void testGenericDecpMultipleVariantsOfAParameterizedType3_binaryWeaving() { + runTest("generic decp binary - implementing two variants #3"); + } + + // decp is parameterized but it does match the one already on the type + public void testGenericDecpMultipleVariantsOfAParameterizedType4_binaryWeaving() { + runTest("generic decp binary - implementing two variants #4"); + } + + public void testGenericDecpParameterized() { + runTest("generic decp - with parameterized on the target"); + checkOneSignatureAttribute(ajc,"Basic6"); + verifyClassSignature(ajc,"Basic6","Ljava/lang/Object;LI;LK;"); + } + + public void testGenericDecpIncorrectNumberOfTypeParams() { + runTest("generic decp - incorrect number of type parameters"); + } + + public void testGenericDecpSpecifyingBounds() { + runTest("generic decp - specifying bounds"); + } + + public void testGenericDecpViolatingBounds() { + runTest("generic decp - specifying bounds but breaking them"); + } + + // need separate compilation test to verify signatures are ok +// +// public void testIllegalGenericDecp() { +// runTest("illegal generic decp"); +// } +// +// public void testPR95992_TypeResolvingProblemWithGenerics() { +// runTest("Problems resolving type name inside generic class"); +// } + + + // -- Pointcut tests... + + public void testHandlerWithGenerics() { + runTest("handler pcd and generics / type vars"); + } + + public void testPointcutsThatDontAllowTypeVars() { + runTest("pointcuts that dont allow type vars"); + } + + public void testParameterizedTypesInAtPCDs() { + runTest("annotation pcds with parameterized types"); + } + + public void testAnnotationPatternsWithParameterizedTypes() { + runTest("annotation patterns with parameterized types"); + } + + public void testStaticInitializationWithParameterizedTypes() { + runTest("staticinitialization and parameterized types"); + } + + // no longer a valid test with generics simplication +// public void testStaticInitializationMatchingWithParameterizedTypes() { +// runTest("staticinitialization and parameterized type matching"); +// } + +// no longer a valid test in simplified design +// public void testStaticInitializationWithGenericTypes() { +// runTest("staticinitialization with generic types"); +// } + +// no longer a valid test in simplified design +// public void testStaticInitializationWithGenericTypesAdvanced() { +// runTest("staticinitialization with generic types - advanced"); +// } + + public void testWithinPointcutErrors() { + runTest("within pcd with various parameterizations and generic types - errors"); + } + + public void testWithinPointcutWarnings() { + runTest("within pcd with various parameterizations and generic types - warnings"); + } + + public void testThisTargetPointcutErrors() { + runTest("this and target with various parameterizations and generic types - errors"); + } + + public void testThisTargetPointcutRuntime() { + runTest("this and target with various parameterizations and generic types - runtime"); + } + + public void testInitAndPreInitPointcutErrors() { + runTest("init and preinit with parameterized declaring types"); + } + + public void testInitAndPreInitPointcutMatchingWithGenericDeclaringTypes() { + runTest("init and preinit with raw declaring type pattern"); + } + + public void testInitAndPreInitPointcutMatchingWithParameterizedParameterTypes() { + runTest("init and preinit with parameterized parameter types"); + } + + public void testWithinCodePointcutErrors() { + runTest("withincode with various parameterizations and generic types - errors"); + } + + public void testWithinCodeMatching() { + runTest("withincode with various parameterizations and generic types - matching"); + } + + public void testWithinCodeOverrideMatchingWithGenericMembers() { + runTest("withincode with overriding of inherited generic members"); + } + + public void testExecutionWithRawType() { + runTest("execution pcd with raw type matching"); + } + + public void testExecutionWithRawSignature() { + runTest("execution pcd with raw signature matching"); + } + + public void testExecutionPointcutErrors() { + runTest("execution with various parameterizations and generic types - errors"); + } + + public void testExecutionMatching() { + runTest("execution with various parameterizations and generic types - matching"); + } + + public void testExecutionOverrideMatchingWithGenericMembers() { + runTest("execution with overriding of inherited generic members"); + } + + public void testCallPointcutErrors() { + runTest("call with various parameterizations and generic types - errors"); + } + + public void testCallMatching() { + runTest("call with various parameterizations and generic types - matching"); + } + + public void testCallOverrideMatchingWithGenericMembers() { + runTest("call with overriding of inherited generic members"); + } + + public void testCallWithBridgeMethods() { + runTest("call with bridge methods"); + } + + public void testGetAndSetPointcutErrors() { + runTest("get and set with various parameterizations and generic types - errors"); + } + + public void testGetAndSetPointcutMatchingWithGenericAndParameterizedTypes() { + runTest("get and set with various parameterizations and generic declaring types"); + } + + public void testGetAndSetPointcutMatchingWithGenericAndParameterizedFieldTypes() { + runTest("get and set with various parameterizations and generic field types"); + } + + public void testArgsWithRawType() { + runTest("args with raw type and generic / parameterized sigs"); + } + + public void testArgsParameterizedType() { + runTest("args with parameterized type and generic / parameterized sigs"); + } + + public void testArgsParameterizedAndWildcards() { + runTest("args with parameterized type and wildcards"); + } + + public void testArgsWithWildcardVar() { + runTest("args with generic wildcard"); + } + + public void testArgsWithWildcardExtendsVar() { + runTest("args with generic wildcard extends"); + } + + public void testArgsWithWildcardSuperVar() { + runTest("args with generic wildcard super"); + } + + public void testGenericMethodMatching() { + runTest("generic method matching"); + } + + public void testGenericWildcardsInSignatureMatching() { + runTest("generic wildcards in signature matching"); + } + + public void testAfterThrowing() { + runTest("after throwing with parameterized throw type"); + } + + public void testAfterReturningWithRawType() { + runTest("after returning with raw type and generic / parameterized sigs"); + } + + public void testAfterReturningParameterizedType() { + runTest("after returning with parameterized type and generic / parameterized sigs"); + } + + public void testAfterReturningParameterizedAndWildcards() { + runTest("after returning with parameterized type and wildcards"); + } + + public void testAfterReturningWithWildcardVar() { + if (LangUtil.is19VMOrGreater()) { + // See ReferenceType.isCoerceableFrom comments + return; + } + // Something to investigate here. The implementation of isCoerceable + runTest("after returning with generic wildcard"); + } + + public void testAfterReturningWithWildcardExtendsVar() { + runTest("after returning with generic wildcard extends"); + } + + public void testAfterReturningWithWildcardSuperVar() { + runTest("after returning with generic wildcard super"); + } + + public void testAJDKErasureMatchingExamples() { + runTest("ajdk notebook: erasure matching examples"); + } + + public void testAJDKParameterizedMatchingSimpleExamples() { + runTest("ajdk notebook: simple parameterized type matching examples"); + } + + public void testAJDKMixedTypeVarsAndParametersExample() { + runTest("ajdk notebook: mixed parameterized types and generic methods"); + } + + public void testAJDKSignatureAndWildcardExamples() { + runTest("ajdk notebook: signature matching with generic wildcards"); + } + + // had to remove at e37 level - although pointcuts are likely to work, we can't compile the code + // that invokes the bridge methods - seems the compiler is too smart and won't let them through. +// public void testAJDKBridgeMethodExamples() { +// runTest("ajdk notebook: bridge method examples"); +// } + + public void testAJDKArgsExamples() { + runTest("ajdk notebook: args examples"); + } + + public void testAJDKArgsAndWildcardsExamples() { + runTest("ajdk notebook: args and wildcards examples"); + } + + public void testAJDKAfterReturningExamples() { + runTest("ajdk notebook: after returning examples"); + } + + public void testAJDKPointcutInGenericClassExample() { + runTest("ajdk notebook: pointcut in generic class example"); + } + + // TESTS for generic abstract aspects that get extended and parameterized... + + public void testStaticPointcutParameterization() { + runTest("static pointcut parameterization suite"); + } + + public void testDynamicPointcutParameterization() { + runTest("dynamic pointcut parameterization suite"); + } + + public void testReferenceToPointcutInGenericClass() { + runTest("reference to pointcut in generic class"); + } + + public void testReferenceToPointcutInGenericClass2() { + runTest("reference to non-parameterized pointcut in generic class"); + } + + public void testDeclareParentsParameterized() { + runTest("declare parents parameterized"); + } + + public void testDeclarePrecedenceParameterized() { + runTest("declare precedence parameterized"); + } + + public void testDeclareAnnotationParameterized() { + runTest("declare annotation parameterized"); + } + + public void testMultiLevelGenericAspects() { + runTest("multi-level generic abstract aspects"); + } + + // --- helpers + + /** + * When a class has been written to the sandbox directory, you can ask this method to + * verify it contains a particular set of methods. Typically this is used to verify that + * bridge methods have been created. + */ + public void checkMethodsExist(String classname,String[] methods) { + Set methodsFound = new HashSet<>(); + StringBuffer debugString = new StringBuffer(); + try { + ClassLoader cl = new URLClassLoader(new URL[]{ajc.getSandboxDirectory().toURL()}); + Class clz = Class.forName(classname,false,cl); + java.lang.reflect.Method[] ms = clz.getDeclaredMethods(); + if (ms!=null) { + for (int i =0;i "+debugString); + } + } + StringBuffer unexpectedMethods = new StringBuffer(); + if (!methodsFound.isEmpty()) { + for (String element: methodsFound) { + unexpectedMethods.append("[").append(element).append("]"); + } + fail("These methods weren't expected: "+unexpectedMethods); + } + + } + + /** + * Use 1.5 API isBridge if available. + * See JLS3 15.12.4.5 Create Frame, Synchronize, Transfer Control + */ + public static boolean isBridge(java.lang.reflect.Method m) { + // why not importing java.lang.reflect.Method? No BCEL clash? + if (!LangUtil.is15VMOrGreater()) { + return false; + } + try { + final Class[] noparms = new Class[0]; + java.lang.reflect.Method isBridge + = java.lang.reflect.Method.class.getMethod("isBridge", noparms); + Boolean result = (Boolean) isBridge.invoke(m, new Object[0]); + return result.booleanValue(); + } catch (Throwable t) { + return false; + } + } + public static JavaClass getClass(Ajc ajc, String classname) { + try { + ClassPath cp = + new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path")); + SyntheticRepository sRepos = SyntheticRepository.getInstance(cp); + JavaClass clazz = sRepos.loadClass(classname); + return clazz; + } catch (ClassNotFoundException e) { + fail("Couldn't find class "+classname+" in the sandbox directory."); + } + return null; + } + + public static Signature getClassSignature(Ajc ajc,String classname) { + JavaClass clazz = getClass(ajc,classname); + Signature sigAttr = null; + Attribute[] attrs = clazz.getAttributes(); + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals("Signature")) sigAttr = (Signature)attribute; + } + return sigAttr; + } + + public static void checkOneSignatureAttribute(Ajc ajc,String classname) { + JavaClass clazz = getClass(ajc,classname); + Attribute[] attrs = clazz.getAttributes(); + int signatureCount = 0; + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals("Signature")) { + signatureCount++; + sb.append("\n"+((Signature)attribute).getSignature()); + } + } + if (signatureCount>1) fail("Should be only one signature attribute but found "+signatureCount+sb.toString()); + } + + // Check the signature attribute on a class is correct + public static void verifyClassSignature(Ajc ajc,String classname,String sig) { + Signature sigAttr = getClassSignature(ajc,classname); + assertTrue("Failed to find signature attribute for class "+classname,sigAttr!=null); + assertTrue("Expected signature to be '"+sig+"' but was '"+sigAttr.getSignature()+"'", + sigAttr.getSignature().equals(sig)); + } + + private static String stringify(Class[] clazzes) { + if (clazzes==null) return ""; + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < clazzes.length; i++) { + if (i>0) sb.append(","); + sb.append(clazzes[i].getName()); + } + return sb.toString(); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/HasMember.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/HasMember.java new file mode 100644 index 000000000..57e053b9b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/HasMember.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Adrian Colyer - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class HasMember extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(HasMember.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + public void testSimpleDecPHasMethod() { + runTest("declare parents : hasmethod(..) - 1"); + } + + public void testSimpleDecPHasMethodInherited() { + runTest("declare parents : hasmethod(..) - 2"); + } + + public void testSimpleDecPHasMethodInheritedPrivate() { + runTest("declare parents : hasmethod(..) - 3"); + } + + // this test not passing yet, ITD integration not implemented +// public void testDecPHasMethodViaITD() { +// runTest("declare parents : hasmethod(..) - 4"); +// } + + public void testSimpleDecPHasField() { + runTest("declare parents : hasfield(..) - 1"); + } + + public void testSimpleDecPHasFieldInherited() { + runTest("declare parents : hasfield(..) - 2"); + } + + public void testSimpleDecPHasFieldInheritedPrivate() { + runTest("declare parents : hasfield(..) - 3"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/MigrationTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/MigrationTests.java new file mode 100644 index 000000000..a9322b086 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/MigrationTests.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +/** + * Checks if we are obeying migration rules. + */ +public class MigrationTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(MigrationTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + /** + * Compile a simple java class with an aspect library built with aspectj 1.2.1 - this + * checks that we can load in attributes (especially pointcuts) that were written out + * in the 'old way' + * + */ + public void testMigrationFrom121_pointcutsAndAdvice() { + runTest("load aspectj 1.2.1 aspects in aspectj 5"); +// CompilationResult cR = ajc(baseDir,new String[]{"-aspectpath","aspects121.jar","Program.java"}); +// System.err.println(cR.getStandardError()); +// assertTrue("Should not coredump: "+cR.getStandardError(),cR.getStandardError().indexOf("Dumping to ajcore")==-1); +// assertTrue("Should be no error messages: \n"+cR.getErrorMessages(),cR.getErrorMessages().size()==0); +// File f = new File(ajc.getSandboxDirectory()+File.separator+"Program.class"); +// assertTrue("Missing class file",f.exists()); +// run("Program"); + } + +// /** +// * We cannot support all aspects built prior to AspectJ 1.2.1 - so we don't support any. +// * There are probably many reasons but the first one I've hit is: +// * - Changes for cflow optimizations (counters instead of stacks where we can) mean that an aspect +// * compiled at AspectJ1.2.0 will contain stack cases but AspectJ1.5.0 will look for counter +// * fields in some cases. +// * +// * This means we should get a reasonable failure message in this case. +// */ +// public void testMigrationFrom120_pointcutsAndAdvice() { +// CompilationResult cR = ajc(baseDir,new String[]{"-aspectpath","aspects120.jar","Program.java"}); +// assertTrue("Should have failed",cR.getFailMessages().size()>0); +// assertTrue("Should have produced nice message",cR.getFailMessages().get(0).toString().indexOf("Unable to continue")!=-1); +// } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/PerTypeWithinTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/PerTypeWithinTests.java new file mode 100644 index 000000000..84b014392 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/PerTypeWithinTests.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.tools.ajc.CompilationResult; + + + +public class PerTypeWithinTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(PerTypeWithinTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + /** + * First few tests: + * + * Five types p.A, p.B, p.C, q.D, q.E and an aspect a.X. + * + * The aspect is pertypewithin(p..*) - this should match A,B,C but not D,E. + * + * Aspect instances should be accessible for A,B,C but not D,E. + * The aspect instances for A,B,C should be different. + * + * hasAspect(), aspectOf() should work. + * + * We test these assumptions in A,B,C,D,E. + */ + public void testDoesItWorkAtAll() { + runTest("basic ptw test"); + } + + public void testCheckHasAspectWorks() { + runTest("ptw hasAspect"); + } + + public void testCheckAspectOfWorks() { + runTest("ptw aspectOf"); + } + /** + * Aspects Q and R match P with a pertypewithin() - they shouldn't clash in any way + * + */ + public void testTwoAspectsHittingOneType() { + runTest("ptw multi-aspects"); + } + + /** + * Checks the use of pertypewithin() doesn't result in extra join points (i.e. the + * infrastructure is properly hidden in ajc$ or synthetic members) + */ + public void testPervasivenessOfWeaving() { + CompilationResult cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"U.java","-showWeaveInfo"}); + int weavingMessagesFromNormalDeploymentModel = cR.getWeaveMessages().size(); + + cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"V.java","-showWeaveInfo"}); + int weavingMessagesFromPerTypeWithin = cR.getWeaveMessages().size(); + + assertEquals("Expected same number of messages regardless of perclause", + weavingMessagesFromNormalDeploymentModel,weavingMessagesFromPerTypeWithin); + } + + + public void testBinaryWeaving_ClassesAreBinary() { + runTest("ptw binary"); + } + + public void testBinaryWeaving_AspectsAreBinary() { + runTest("ptw binary aspect"); + } + + public void testAJDKExamples() { + runTest("ajdk: ptw"); + } +// // Compile the aspect H.java into classes3 +// CompilationResult cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"H.java","-outjar","aspects.jar"}); +// setShouldEmptySandbox(false); +// // Compile the class with H.class as aspectpath, should be binary woven correctly +// cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"G.java","-aspectpath","aspects.jar"}); +// RunResult rR = run("G"); +// assertTrue("Expected aspect related message 'advice running' in output from G", +// rR.getStdErr().indexOf("advice running")!=-1); +// setShouldEmptySandbox(true); +// } +// +// // binary weaving case ... +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/RuntimeAnnotations.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/RuntimeAnnotations.java new file mode 100644 index 000000000..676c2b014 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/RuntimeAnnotations.java @@ -0,0 +1,138 @@ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Checking that runtime visible annotations are visible at runtime (they get into the class file) + */ +public class RuntimeAnnotations extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(RuntimeAnnotations.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + public void test01() { + runTest("public method with declare @method"); + } + + public void test02() { + runTest("public method on the aspect that declares @method on it"); + } + + public void test03() { + runTest("public annotated method"); + } + + public void test04() { + runTest("public ITD method with declare @method"); + } + + public void test05() { + runTest("public annotated ITD method"); + } + + public void test06() { + runTest("public ITD-on-itself method with declare @method"); + } + + public void test07() { + runTest("public annotated ITD-on-itself method"); + } + + public void test08() { + runTest("public method on an Interface with declare @method"); + } + + public void test09() { + runTest("public annotated method on an Interface"); + } + + public void test10() { + runTest("public ITD method onto an Interface with declare @method"); + } + + public void test11() { + runTest("public annotated ITD method onto an Interface"); + } + + public void test12() { + runTest("public abstract method with declare @method"); + } + + public void test13() { + runTest("public abstract method on the aspect that declares @method on it"); + } + + public void test14() { + runTest("public abstract annotated method"); + } + + public void test15() { + runTest("public abstract ITD method with declare @method"); + } + + public void test16() { + runTest("public abstract annotated ITD method"); + } + + public void test17() { + runTest("public abstract ITD-on-itself method with declare @method"); + } + + public void test18() { + runTest("public abstract annotated ITD-on-itself method"); + } + + public void test19() { + runTest("public abstract method on an Interface with declare @method"); + } + + public void test20() { + runTest("public abstract annotated method on an Interface"); + } + + public void test21() { + runTest("public abstract ITD method onto an Interface with declare @method"); + } + + public void test22() { + runTest("public abstract annotated ITD method onto an Interface"); + } + + public void test23() { + runTest("public field with declare @field"); + } + + public void test24() { + runTest("public field on the aspect that declares @field on it"); + } + + public void test25() { + runTest("public annotated field"); + } + + public void test26() { + runTest("public ITD field with declare @field"); + } + + public void test27() { + runTest("public annotated ITD field"); + } + + public void test28() { + runTest("public ITD-on-itself field with declare @field"); + } + + public void test29() { + runTest("public annotated ITD-on-itself field"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/SCCSFixTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/SCCSFixTests.java new file mode 100644 index 000000000..30dba129f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/SCCSFixTests.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * 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: + * Wes Isberg - initial implementation + *******************************************************************************/ + +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import org.aspectj.tools.ajc.AjcTestCase; +import org.aspectj.tools.ajc.CompilationResult; +import org.aspectj.util.FileUtil; + +/** + * SCCS/CVS directory fix. + * Would add to Ajc150TestsNoHarness, but can't share basedir/setup, etc. + */ +public class SCCSFixTests extends AjcTestCase { + File baseDir; + File sourceroot; + + public void setUp() throws Exception { + super.setUp(); + baseDir = FileUtil.getTempDir("BugFixTests"); + sourceroot = new File(baseDir, "sourceroot"); + sourceroot.mkdirs(); + } + public void tearDown() { + FileUtil.deleteContents(baseDir); + } + /** + * @see org/aspectj/util/FileUtil.java 1.17 + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48650 + */ + public void testSkipCVS() { + doTestSkip("CVS"); + } + + /** + * @see org/aspectj/util/FileUtil.java 1.17 + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48650 + */ + public void testSkipSCCS() { + doTestSkip("SCCS"); + } + + /** + * Can't check in "CVS" or "SCCS" directories, + * so construct for each test. + */ + private void doTestSkip(String name) { + File dir = new File(sourceroot, name); + sourceroot.mkdirs(); + File file = new File(dir, "Error.java"); + FileUtil.writeAsString(file, "public class Error { here }"); + file = new File(sourceroot, "Main.java"); + FileUtil.writeAsString(file, MAIN); + String[] args = { "-sourceroots", sourceroot.getPath() }; + CompilationResult result = ajc(baseDir, args); + assertNoMessages(result); + RunResult r = run("Main"); + String m = r.getStdOut().trim(); + assertEquals("I ran", m); + } + private static final String MAIN = + "public class Main { public static void main(String[] a) {System.out.println(\"I ran\");}}"; +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/StaticImports.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/StaticImports.java new file mode 100644 index 000000000..71b82f4e4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/StaticImports.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors + * 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: + * Andrew Huff - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class StaticImports extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(StaticImports.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + public void testImportStaticSystemDotOut() { + runTest("import static java.lang.System.out"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/SuppressedWarnings.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/SuppressedWarnings.java new file mode 100644 index 000000000..0a830018e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/SuppressedWarnings.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class SuppressedWarnings extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SuppressedWarnings.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // Check basic suppression + public void testSuppression1() { + runTest("suppressing non-matching advice warnings"); + } + + // Checks source contexts aren't put out incorrectly + // NOTE: Source contexts only come out if the primary source location in a message + // matches the file currently being dealt with. Because advice not matching + // messages come out at the last stage of compilation, you currently only + // get sourcecontext for advice not matching messages that point to places in + // the last file being processed. You do get source locations in all cases - + // you just don't always get context, we could revisit this sometime... + // (see bug 62073 reference in WeaverMessageHandler.handleMessage()) + public void testSuppression2() { + runTest("suppressing non-matching advice warnings when multiple source files involved"); + } + + public void testSuppressionWithCflow_pr93345() { + runTest("XLint warning for advice not applied with cflow(execution)"); + } + + public void testSuppressionOfMessagesIssuedDuringMatching() { + runTest("SuppressAjWarnings raised during matching"); + } +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/VarargsTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/VarargsTests.java new file mode 100644 index 000000000..7592f7c6d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/VarargsTests.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +/** + * Varargs, the rules/tests: + * + * 1. cannot match on a varargs method by using 'Object[]' in your signature, + * this affects call/execution/initialization/withincode + */ +public class VarargsTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(VarargsTests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc150.xml"); + } + + // check when signature is from a call PCD + // should get message: + // "an array type as the last parameter in a signature does not match on the varargs declared method: " + public void test001_cantMatchVarargsWithObjectArray_callPCD() { + runTest("varargs not matched by Object[] (call)"); + } + + // check when signature is from an execution PCD + public void test002_cantMatchVarargsWithObjectArray_execPCD() { + runTest("varargs not matched by Object[] (exe)"); + } + + // check when signature is from an initialization PCD + public void test003_cantMatchVarargsWithObjectArray_initPCD() { + runTest("varargs not matched by Object[] (init)"); + } + + // check when signature is from an withincode PCD + public void test003_cantMatchVarargsWithObjectArray_withincodePCD() { + runTest("varargs not matched by Object[] (withincode)"); + } + + // before(): call(* *(Integer...)) { } + public void test_usingVarargsInPointcuts1() { + runTest("call with varargs signature"); + } + + // before(): call(* *(int,Integer...)) { } - slightly more complex pcut + public void test_usingVarargsInPointcuts2() { + runTest("call with varargs multi-signature"); + } + + public void testAJDKExamples() { + runTest("ajdk: varargs"); + } + + public void testStarVarargs() { + runTest("star varargs pattern"); + } + + public void testVarargsWithDotDotInPointcut() { + runTest("Varargs with .. in pointcut"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ajc150.xml new file mode 100644 index 000000000..9eda00b0c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ajc150.xml @@ -0,0 +1,6308 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java new file mode 100644 index 000000000..bfbc289f6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors + * 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: + * initial development Jonas Bon�r, Alexandre Vasseur + *******************************************************************************/ +package org.aspectj.systemtest.ajc150.ataspectj; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * A suite for @AspectJ aspects located in java5/ataspectj + * + * @author Alexandre Vasseur + */ +public class AtAjAnnotationGenTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AtAjAnnotationGenTests.class); + } + + protected File getSpecFile() { + return getClassResource("annotationgen.xml"); + } + + public void testSimpleAspect() { + runTest("annotation gen for simple aspect"); + } + + public void testSimpleAspectIn14Mode() { + runTest("annotation gen for simple aspect pre 1.5"); + } + + public void testAspectAlreadyAnnotated() { + runTest("annotation gen for simple annotated aspect"); + } + + public void testPrivilegedAspect() { + runTest("annotation gen for privileged aspect"); + } + + public void testPerThisAspect() { + runTest("annotation gen for perthis aspect"); + } + + public void testPerTargetAspect() { + runTest("annotation gen for pertarget aspect"); + } + + public void testPerCflowAspect() { + runTest("annotation gen for percflow aspect"); + } + + public void testPerCflowbelowAspect() { + runTest("annotation gen for percflowbelow aspect"); + } + + public void testPertypewithinAspect() { + runTest("annotation gen for pertypewithin aspect"); + } + + public void testInnerAspectOfClass() { + runTest("annotation gen for inner aspect of aspect"); + } + + public void testInnerAspectOfAspect() { + runTest("annotation gen for inner aspect of class"); + } + + public void testAdvice() { + runTest("annotation gen for advice declarations"); + } + + public void testSimplePointcut() { + runTest("annotation gen for simple pointcut"); + } + + public void testPointcutModifiers() { + runTest("annotation gen for pointcut modifiers"); + } + + public void testPointcutParams() { + runTest("annotation gen for pointcut params"); + } + + public void testPointcutRefs() { + runTest("annotation gen for pointcut refs"); + } + + public void testBeforeWithBadReturn() { + runTest("before ann with non-void return"); + } + + public void testTwoAnnotationsOnSameElement() { + runTest("two anns on same element"); + } + + public void testBadPcutInAdvice() { + runTest("bad pcut in after advice"); + } + + public void testBadParameterBinding() { + runTest("bad parameter binding in advice"); + } + + public void testSimpleAtPointcut() { + runTest("simple pointcut no params"); + } + + public void testPointcutMedley() { + runTest("pointcut medley"); + } + + public void testAdviceDeclaredInClass() { + runTest("advice in a class"); + } + + public void testDeows() { + runTest("ann gen for deows"); + } + + // no reliable way to get around classpath issues for + // running this test as part of release script :( +// public void testRuntimePointcutsReferencingCompiledPointcuts() { +// runTest("runtime pointcut resolution referencing compiled pointcuts"); +// } + + public void testDecP() { + runTest("ann gen for decp"); + } + + public void testDecPAdvanced() { + runTest("ann gen for decp 2"); + } + + public void testDecS() { + runTest("ann gen for decs"); + } + + public void testDecPrecedence() { + runTest("ann gen for dec precedence"); + } + + public void testDecAnnotation() { + runTest("ann gen for dec annotation"); + } + + public void testITDs() { + runTest("ann gen for itds"); + } +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java new file mode 100644 index 000000000..966642da2 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -0,0 +1,237 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150.ataspectj; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.FileUtil; + +/** + * @author Alexandre Vasseur + */ +public class AtAjLTWTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(org.aspectj.systemtest.ajc150.ataspectj.AtAjLTWTests.class); + } + + protected File getSpecFile() { + return getClassResource("ltw.xml"); + } + + public void testRunThemAllWithJavacCompiledAndLTW() { + runTest("RunThemAllWithJavacCompiledAndLTW"); + } + + public void testAjcLTWPerClauseTest_XterminateAfterCompilation() { + runTest("AjcLTW PerClauseTest -XterminateAfterCompilation"); + } + + public void testAjcLTWPerClauseTest_Xreweavable() { + runTest("AjcLTW PerClauseTest -Xreweavable"); + } + + public void testJavaCAjcLTWPerClauseTest() { + runTest("JavaCAjcLTW PerClauseTest"); + } + + public void testAjcLTWAroundInlineMungerTest_XterminateAfterCompilation() { + runTest("AjcLTW AroundInlineMungerTest -XterminateAfterCompilation"); + } + + public void testAjcLTWAroundInlineMungerTest_Xreweavable() { + runTest("AjcLTW AroundInlineMungerTest"); + } + + public void testAjcLTWAroundInlineMungerTest() { + runTest("AjcLTW AroundInlineMungerTest"); + } + + public void testAjcLTWAroundInlineMungerTest_XnoInline_Xreweavable() { + runTest("AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable"); + } + + public void testAjcLTWAroundInlineMungerTest2() { + runTest("AjcLTW AroundInlineMungerTest2"); + } + + public void testLTWDumpNone() { + runTest("LTW DumpTest none"); + + File f = new File("_ajdump/ataspectj/DumpTest.class"); + assertFalse(f.exists()); + f = new File("_ajdump/_before/ataspectj/DumpTestTheDump.class"); + assertFalse(f.exists()); + f = new File("_ajdump/ataspectj/DumpTestTheDump.class"); + assertFalse(f.exists()); + } + + public void testLTWDump() { + runTest("LTW DumpTest"); + + File f = new File("_ajdump/ataspectj/DumpTest.class"); + assertFalse(f.exists()); + f = new File("_ajdump/_before/ataspectj/DumpTestTheDump.class"); + assertFalse(f.exists()); + f = new File("_ajdump/ataspectj/DumpTestTheDump.class"); + assertTrue(f.exists()); + + // tidy up... + f = new File("_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } + + public void testLTWDumpBeforeAndAfter() { + runTest("LTW DumpTest before and after"); + + // before + File f = new File("_ajdump/_before/com/foo/bar"); + CountingFilenameFilter cff = new CountingFilenameFilter(".class"); + f.listFiles(cff); + assertEquals("Expected dump file in " + f.getAbsolutePath(), 1, cff.getCount()); + + // after + f = new File("_ajdump/com/foo/bar"); + cff = new CountingFilenameFilter(".class"); + f.listFiles(cff); + assertEquals("Expected dump file in " + f.getAbsolutePath(), 1, cff.getCount()); + + // tidy up... + f = new File("_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } + + public void testLTWDumpClosure() { + runTest("LTW DumpTest closure"); + + File f = new File("_ajdump/ataspectj/DumpTestTheDump$AjcClosure1.class"); + assertTrue("Missing dump file " + f.getAbsolutePath(), f.exists()); + + // tidy up... + f = new File("_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } + + public void testLTWDumpProxy() { + runTest("LTW DumpTest proxy"); + + // The working directory is different because this test must be forked + File dir = new File("../tests/java5/ataspectj"); + File f = new File(dir, "_ajdump/_before/com/sun/proxy"); + CountingFilenameFilter cff = new CountingFilenameFilter(".class"); + f.listFiles(cff); + assertEquals("Expected dump file in " + f.getAbsolutePath(), 1, cff.getCount()); + f = new File(dir, "_ajdump/com/sun/proxy"); + cff = new CountingFilenameFilter(".class"); + f.listFiles(cff); + assertEquals(1, cff.getCount()); + + // tidy up... + f = new File(dir, "_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } + + public void testLTWDumpJSP() { + runTest("LTW DumpTest JSP"); + + // The working directory is different because this test must be forked + File f = new File("_ajdump/_before/com/ibm/_jsp"); + CountingFilenameFilter cff = new CountingFilenameFilter(".class"); + f.listFiles(cff); + assertEquals("Expected dump file in " + f.getAbsolutePath(), 1, cff.getCount()); + f = new File("_ajdump/com/ibm/_jsp"); + cff = new CountingFilenameFilter(".class"); + f.listFiles(cff); + assertEquals(1, cff.getCount()); + + // tidy up... + f = new File("_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } + + public void testAjcAspect1LTWAspect2_Xreweavable() { + runTest("Ajc Aspect1 LTW Aspect2 -Xreweavable"); + } + + public void testLTWLogSilent() { + runTest("LTW Log silent"); + } + + public void testLTWLogVerbose() { + runTest("LTW Log verbose"); + } + + public void testLTWLogVerboseAndShow() { + runTest("LTW Log verbose and showWeaveInfo"); + } + + public void testLTWLogMessageHandlerClass() { + runTest("LTW Log messageHandlerClass"); + } + + public void testLTWUnweavable() { + // actually test that we do LTW proxy and jit classes + runTest("LTW Unweavable"); + } + + public void testLTWDecp() { + runTest("LTW Decp"); + } + + public void testLTWDecp2() { + runTest("LTW Decp2"); + } + + public void testCompileTimeAspectsDeclaredToLTWWeaver() { + runTest("Compile time aspects declared to ltw weaver"); + } + + public void testConcreteAtAspect() { + runTest("Concrete@Aspect"); + } + + public void testConcreteAspect() { + runTest("ConcreteAspect"); + } + + public void testConcretePrecedenceAspect() { + runTest("ConcretePrecedenceAspect"); + } + + // public void testAspectOfWhenAspectNotInInclude() { + // runTest("AspectOfWhenAspectNotInInclude"); + // } + // + // public void testAspectOfWhenAspectExcluded_pr152873() { + // runTest("AspectOfWhenAspectExcluded"); + // } + + public void testAspectOfWhenNonAspectExcluded_pr152873() { + runTest("AspectOfWhenNonAspectExcluded"); + } + + public void testAppContainer() { + runTest("AppContainer"); + } + + public void testCflowBelowStack() { + runTest("CflowBelowStack"); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjMisuseTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjMisuseTests.java new file mode 100644 index 000000000..0f13e8f8b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjMisuseTests.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * 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: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150.ataspectj; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Alexandre Vasseur + */ +public class AtAjMisuseTests extends XMLBasedAjcTestCase { + + protected File getSpecFile() { + return getClassResource("misuse.xml"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AtAjMisuseTests.class); + } + + public void testQAspectClassExtendingQAspectClass() { + runTest("@Aspect class extending @Aspect class"); + } + + // TODO asc commented out for now until Alex manages to get ajdtcore up to date... +// public void testClassWithQBeforeExtendingQAspectClass() { +// runTest("class with @Before extending @Aspect class"); +// } + + public void testQPointcutNotReturningVoid() { + runTest("@Pointcut not returning void"); + } + + public void testQPointcutWithGarbageString() { + runTest("@Pointcut with garbage string"); + } + + public void testQPointcutWithThrowsClause() { + runTest("@Pointcut with throws clause"); + } + + public void testQAfterReturningWithWrongNumberOfArgs() { + runTest("@AfterReturning with wrong number of args"); + } + + public void testQBeforeOnNon_publicMethod() { + runTest("@Before on non-public method"); + } + + public void testQBeforeOnMethodNotReturningVoid() { + runTest("@Before on method not returning void"); + } + + public void testQBeforeWithPJP() { + runTest("@Before with PJP"); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java new file mode 100644 index 000000000..794fce907 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java @@ -0,0 +1,145 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * initial implementation Alexandre Vasseur + *******************************************************************************/ +package org.aspectj.systemtest.ajc150.ataspectj; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * A suite for @AspectJ aspects located in java5/ataspectj + * + * @author Alexandre Vasseur + */ +public class AtAjSyntaxTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AtAjSyntaxTests.class); + } + + protected File getSpecFile() { + return getClassResource("syntax.xml"); + } + + public void testSimpleBefore() { + runTest("SimpleBefore"); + } + + public void testSimpleAfter() { + runTest("SimpleAfter"); + } + + public void testSingletonAspectBindings() { + // Note AV: uncomment setReporting to get it in modules/tests folder + // org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true); + runTest("singletonAspectBindings"); + // same stuff with AJ + // org.aspectj.asm.AsmManager.setReporting("debug-aj.txt",true,true,true,true); + // runTest("singletonAspectBindings2"); + + } + + public void testCflowTest() { + runTest("CflowTest"); + } + + public void testPointcutReferenceTest() { + runTest("PointcutReferenceTest"); + } + + public void testXXJoinPointTest() { + runTest("XXJoinPointTest"); + } + + public void testPrecedenceTest() { + runTest("PrecedenceTest"); + } + + public void testAfterXTest() { + runTest("AfterXTest"); + } + + public void testBindingTest() { + runTest("BindingTest"); + } + + public void testBindingTestNoInline() { + runTest("BindingTest no inline"); + } + + public void testPerClause() { + runTest("PerClause"); + } + + public void testAroundInlineMunger_XnoInline() { + runTest("AroundInlineMunger -XnoInline"); + } + + public void testAroundInlineMunger() { + try { + runTest("AroundInlineMunger"); + } finally { + System.out.println(ajc.getLastCompilationResult().getStandardError()); + } + } + + public void testAroundInlineMunger2() { + runTest("AroundInlineMunger2"); + } + + public void testDeow() { + runTest("Deow"); + } + + public void testSingletonInheritance() { + runTest("singletonInheritance"); + } + + public void testPerClauseInheritance() { + runTest("perClauseInheritance"); + } + + public void testIfPointcut() { + runTest("IfPointcutTest"); + } + + public void testIfPointcut2() { + runTest("IfPointcut2Test"); + } + + public void testMultipleBinding() { + runTest("MultipleBinding"); + } + + public void testBug104212() { + runTest("Bug104212"); + } + + public void testDeclareParentsInterface() { + runTest("DeclareParentsInterface"); + } + + public void testDeclareParentsImplements() { + runTest("DeclareParentsImplements"); + } + + public void testAbstractAspectNPE() { + runTest("AbstractAspectNPE"); + } + + public void testAbstractInherited() { + runTest("AbstractInherited"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml new file mode 100644 index 000000000..3a8bda2ad --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/CoverageTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/CoverageTests.java new file mode 100644 index 000000000..534c7e57d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/CoverageTests.java @@ -0,0 +1,43 @@ +package org.aspectj.systemtest.ajc150.ataspectj.coverage; + +import java.io.File; + +import junit.framework.Test; +import junit.framework.TestResult; + +public class CoverageTests extends + org.aspectj.testing.AutowiredXMLBasedAjcTestCase { + + // set to false to debug tests + static final boolean failing = true; + + /** + * disabled here so Ant JUnit rule wrt running *Tests works. + */ + public static Test suite() { + if (failing) { + return new Test() { + public int countTestCases() { + return 1; + } + + public void run(TestResult r) { + r.startTest(this); + r.endTest(this); + } + + public String toString() { + return CoverageTests.class.getName() + " fail"; + } + }; + } + return org.aspectj.testing.AutowiredXMLBasedAjcTestCase + .loadSuite(CoverageTests.class); + } + + protected File getSpecFile() { + return new File( + "../tests/src/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml new file mode 100644 index 000000000..f0ad3f4d3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml new file mode 100644 index 000000000..a72fa4ebf --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them + since such just added methods are an interesting case (percflow ajc$perCflowStack advice) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/misuse.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/misuse.xml new file mode 100644 index 000000000..9aec9d7a4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/misuse.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + a warning. We ignore the pointcut (TBD) - line is enclosing class (TBD Andy do better ?) + + + + + + + + + + + + + + line is enclosing class - TBD + + + + + + + + + + + + + line is enclosing class - TBD + + + + + + + very dirty hack - can't get this location to work properly so added match all error.. + amc - with new checks for binding of returning this was giving a different message, so I + tweaked the test slightly by swapping the order of the args + + + + + + + + line number is enclosing type + + + + + + + line number is enclosing type + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml new file mode 100644 index 000000000..69055af39 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWServerTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWServerTests.java new file mode 100644 index 000000000..d73e594b9 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWServerTests.java @@ -0,0 +1,27 @@ +package org.aspectj.systemtest.ajc150.ltw; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class LTWServerTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return loadSuite(LTWServerTests.class); + } + + protected File getSpecFile() { + return getClassResource("ltw.xml"); + } + + public void testServerWithHelloWorld () { + runTest("TestServer with HelloWorld"); + } + + public void testServerWithParentAndChild () { + runTest("TestServer with Parent and Child"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java new file mode 100644 index 000000000..ff9e59339 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java @@ -0,0 +1,213 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Webster initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150.ltw; + +import java.io.File; +import java.util.Enumeration; +import java.util.Properties; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.tools.WeavingAdaptor; + +public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(LTWTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/ltw/ltw.xml"); + } + + public void testInclusionAndPattern() { + runTest("Inclusion and patterns"); + } + + public void testExclusionAndPattern() { + runTest("Exclusion and patterns"); + } + + public void testAndPatternsAspects() { + runTest("And patterns aspects"); + } + + public void test001(){ + runTest("Ensure 1st aspect is rewoven when weaving 2nd aspect"); + } + + public void testOutxmlFile (){ + runTest("Ensure valid aop.xml file is generated"); + } + public void testOutxmlJar (){ + runTest("Ensure valid aop.xml is generated for -outjar"); + } + + public void testNoAopxml(){ + setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true"); + runTest("Ensure no weaving without visible aop.xml"); + } + + public void testDefineConcreteAspect(){ + runTest("Define concrete sub-aspect using aop.xml"); + } + + public void testDeclareAbstractAspect(){ +// setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true"); +// setSystemProperty(WeavingAdaptor.SHOW_WEAVE_INFO_PROPERTY,"true"); + runTest("Use abstract aspect for ITD using aop.xml"); + } + + public void testAspectsInclude () { + runTest("Ensure a subset of inherited aspects is used for weaving"); + } + + public void testAspectsIncludeWithLintWarning () { + runTest("Ensure weaver lint warning issued when an aspect is not used for weaving"); + } + + public void testXsetEnabled () { + runTest("Set Xset properties enabled"); + } + public void testXsetDisabled () { + runTest("Set Xset properties disabled"); + } + + public void testXlintfileEmpty () { + runTest("Empty Xlint.properties file"); + } + + public void testXlintfileMissing () { + runTest("Warning with missing Xlint.properties file"); + } + + public void testXlintWarningAdviceDidNotMatchSuppressed () { + runTest("Warning when advice doesn't match suppressed for LTW"); + } + + public void testXlintfile () { + runTest("Override suppressing of warning when advice doesn't match using -Xlintfile"); + } + + public void testXlintDefault () { + runTest("Warning when advice doesn't match using -Xlint:default"); + } + + public void testXlintWarning () { + runTest("Override suppressing of warning when advice doesn't match using -Xlint:warning"); + } + + public void testNonstandardJarFiles() { + runTest("Nonstandard jar file extensions"); + } + + public void testOddzipOnClasspath() { + runTest("Odd zip on classpath"); + } + + public void testJ14LTWWithXML() { + runTest("JDK14 LTW with XML"); + } + +// public void testJ14LTWWithASPECTPATH() { +// runTest("JDK14 LTW with ASPECTPATH"); +// } + + + //public void testDiscardingWovenTypes() { + // runTest("discarding woven types - 1"); + //} + + public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_pr133770() { + runTest("aggressive ltw - decp"); + } + + public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_pr133770_Deactivate() { + runTest("aggressive ltw - decp - deactivate"); + } + + public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_Nested_pr133770() { + runTest("aggressive ltw - decp - 2"); + } + + public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_Hierarchy_pr133770() { + runTest("aggressive ltw - hierarchy"); + } + + public void testSeparateCompilationDeclareParentsCall_pr133770() { + runTest("separate compilation with ltw: declare parents and call"); + } + + public void testConfigurationSystemProperty_pr149289() { + runTest("override default path using -Dorg.aspectj.weaver.loadtime.configuration"); + } + + public void testSimpleLTW_pr159854 () { + runTest("simple LTW"); + } + + public void testDumpOnError_pr155033 () { + runTest("dump on error"); + + File dir = getSandboxDirectory(); + CountingFilenameFilter cff = new CountingFilenameFilter(".txt"); + dir.listFiles(cff); + assertEquals("Missing ajcore file in " + dir.getAbsolutePath(),1,cff.getCount()); + } + + public void testMultipleDumpOnError_pr155033 () { + runTest("multiple dump on error"); + + File dir = getSandboxDirectory(); + CountingFilenameFilter cff = new CountingFilenameFilter(".txt"); + dir.listFiles(cff); + assertEquals("Missing ajcore file in " + dir.getAbsolutePath(),2,cff.getCount()); + } + + /* + * Allow system properties to be set and restored + * TODO maw move to XMLBasedAjcTestCase or RunSpec + */ + private final static String NULL = "null"; + + private Properties savedProperties; + + protected void setSystemProperty (String key, String value) { + Properties systemProperties = System.getProperties(); + copyProperty(key,systemProperties,savedProperties); + systemProperties.setProperty(key,value); + } + + private static void copyProperty (String key, Properties from, Properties to) { + String value = from.getProperty(key,NULL); + to.setProperty(key,value); + } + + protected void setUp() throws Exception { + super.setUp(); + savedProperties = new Properties(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + + /* Restore system properties */ + Properties systemProperties = System.getProperties(); + for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements(); ) { + String key = (String)enu.nextElement(); + String value = savedProperties.getProperty(key); + if (value == NULL) systemProperties.remove(key); + else systemProperties.setProperty(key,value); + } + } +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml new file mode 100644 index 000000000..0dcdbf142 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml @@ -0,0 +1,670 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw.xml b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw.xml new file mode 100644 index 000000000..311872c09 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/ltw.xml @@ -0,0 +1,11 @@ + +]> + + + + + +&tests; + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore b/tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore new file mode 100644 index 000000000..9d3c17f8d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore @@ -0,0 +1 @@ +ajcTestSuite.dtd diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc151/Ajc151Tests.java new file mode 100644 index 000000000..8928678c8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -0,0 +1,282 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc151; + +import java.io.File; +import java.io.IOException; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.systemtest.ajc150.GenericsTests; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Some @DeclareParents testing + public void testAtDecp_1() { + runTest("atDecp - simple"); + } + + public void testAtDecp_2() { + runTest("atDecp - annotation"); + } + + public void testAtDecp_3() { + runTest("atDecp - binary interface"); + } + + public void testAtDecp_4() { + runTest("atDecp - binary interface - 2"); + } + + public void testAnnotationsAndItds_pr98901() { + runTest("annotations and itds"); + } + + public void testAnnotationsAndItds_pr98901_2() { + runTest("annotations and itds - 2"); + } + + public void testCircularGenerics_pr133307() { + runTest("circular generics"); + } + + public void testDeca() { + runTest("doubly annotating a method with declare"); + } + + public void testDeca2() { + runTest("doubly annotating a method with declare - 2"); + } + + public void testCrashingWithASM_pr132926_1() { + runTest("crashing on annotation type resolving with asm - 1"); + } + + public void testCrashingWithASM_pr132926_2() { + runTest("crashing on annotation type resolving with asm - 2"); + } + + public void testCrashingWithASM_pr132926_3() { + runTest("crashing on annotation type resolving with asm - 3"); + } + + public void testGenericAdviceParameters_pr123553() { + runTest("generic advice parameters"); + } + + public void testMemberTypesInGenericTypes_pr122458() { + runTest("member types in generic types"); + } + + public void testMemberTypesInGenericTypes_pr122458_2() { + runTest("member types in generic types - 2"); + } + + public void testNPEOnDeclareAnnotation_pr123695() { + runTest("Internal nullptr exception with complex declare annotation"); + } + + public void testHasMemberPackageProblem_pr124105() { + runTest("hasMember problems with packages"); + } + + public void testDifferentNumbersofTVars_pr124803() { + runTest("generics and different numbers of type variables"); + } + + public void testDifferentNumbersofTVars_pr124803_2() { + runTest("generics and different numbers of type variables - classes"); + } + + public void testParameterizedCollectionFieldMatching_pr124808() { + runTest("parameterized collection fields matched via pointcut"); + } + + public void testGenericAspectsAndAnnotations_pr124654() { + runTest("generic aspects and annotations"); + } + + public void testCallInheritedGenericMethod_pr124999() { + runTest("calling inherited generic method from around advice"); + } + + public void testIncorrectlyReferencingPointcuts_pr122452() { + runTest("incorrectly referencing pointcuts"); + } + + public void testIncorrectlyReferencingPointcuts_pr122452_2() { + runTest("incorrectly referencing pointcuts - 2"); + } + + public void testInlinevisitorNPE_pr123901() { + runTest("inlinevisitor NPE"); + } + + // public void testExposingWithintype_enh123423() { runTest("exposing withintype");} + // public void testMissingImport_pr127299() { runTest("missing import gives funny message");} + public void testUnusedInterfaceMessage_pr120527() { + runTest("incorrect unused interface message"); + } + + public void testAtAspectInheritsAdviceWithTJPAndThis_pr125699() { + runTest("inherit advice with this() and thisJoinPoint"); + } + + public void testAtAspectInheritsAdviceWithTJPAndThis_pr125699_2() { + runTest("inherit advice with this() and thisJoinPoint - 2"); + } + + public void testBrokenLTW_pr128744() { + runTest("broken ltw"); + } + + public void testAtAspectNoInvalidAbsoluteTypeName_pr126560() { + runTest("@AJ deow doesn't throw an invalidAbsoluteTypeName when specify type in the same package"); + } + + public void testAtAspectNoInvalidAbsoluteTypeName_pr126560_2() { + runTest("@AJ deow doesn't throw an invalidAbsoluteTypeName when specify type in the same file"); + } + + public void testArrayindexoutofbounds_pr129566() { + runTest("arrayindexoutofbounds"); + // public class SkipList extends Object implements Set, Iterable + GenericsTests.verifyClassSignature(ajc, "common.SkipList", + "Ljava/lang/Object;Ljava/util/Set;Ljava/lang/Iterable;"); + // protected class SkipListElement extends Object + GenericsTests.verifyClassSignature(ajc, "common.SkipList$SkipListElement", "Ljava/lang/Object;"); + // protected class SkipListIterator implements Iterator + GenericsTests.verifyClassSignature(ajc, "common.SkipList$SkipListIterator", + "Ljava/lang/Object;Ljava/util/Iterator;"); + } + + public void testMixingNumbersOfTypeParameters_pr125080() { + runTest("mixing numbers of type parameters"); + GenericsTests.verifyClassSignature(ajc, "AspectInterface", "Ljava/lang/Object;"); + GenericsTests.verifyClassSignature(ajc, "AbstractAspect", + "Ljava/lang/Object;LAspectInterface;"); + GenericsTests.verifyClassSignature(ajc, "ConcreteAspect", "LAbstractAspect;"); + } + + public void testMixingNumbersOfTypeParameters_pr125080_2() { + runTest("mixing numbers of type parameters - 2"); + GenericsTests.verifyClassSignature(ajc, "AspectInterface", "Ljava/lang/Object;"); + GenericsTests.verifyClassSignature(ajc, "AbstractAspect", + "Ljava/lang/Object;LAspectInterface;"); + GenericsTests.verifyClassSignature(ajc, "ConcreteAspect", "LAbstractAspect;"); + } + + public void testIProgramElementMethods_pr125295() throws IOException { + runTest("new IProgramElement methods"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement typeC = top.findElementForType("pkg", "C"); + IProgramElement pe = top.findElementForSignature(typeC, IProgramElement.Kind.METHOD, "foo(int,java.lang.Object)"); + assertNotNull("Couldn't find 'foo' element in the tree", pe); + // check that the defaults return the fully qualified arg + assertEquals("foo(int,java.lang.Object)", pe.toLabelString()); + assertEquals("C.foo(int,java.lang.Object)", pe.toLinkLabelString()); + assertEquals("foo(int,java.lang.Object)", pe.toSignatureString()); + // check that can get hold of the non qualified args + assertEquals("foo(int,Object)", pe.toLabelString(false)); + assertEquals("C.foo(int,Object)", pe.toLinkLabelString(false)); + assertEquals("foo(int,Object)", pe.toSignatureString(false)); + + IProgramElement typeA = top.findElementForType("pkg", "A"); + IProgramElement pe2 = top.findElementForSignature(typeA,IProgramElement.Kind.METHOD,"printParameters(org.aspectj.lang.JoinPoint)"); + assertNotNull("Couldn't find 'printParameters' element in the tree", pe2); + // the argument is org.aspectj.lang.JoinPoint, check that this is added + assertFalse("printParameters method should have arguments", pe2.getParameterSignatures().isEmpty()); + } + + public void testParameterizedEnum_pr126316() { + runTest("E extends Enum(E) again"); + } + + public void testSwallowedException() { + runTest("swallowed exceptions"); + } + + public void testAtAspectVerifyErrorWithAfterThrowingAndthisJoinPoint_pr122742() { + runTest("@AJ VerifyError with @AfterThrowing and thisJoinPoint argument"); + } + + public void testAtAspectVerifyErrorWithAfterReturningAndthisJoinPoint_pr122742() { + runTest("@AJ VerifyError with @AfterReturning and thisJoinPoint argument"); + } + + public void testSwallowedExceptionIgnored() { + runTest("swallowed exceptions with xlint"); + } + + public void testGenericAspectWithUnknownType_pr131933() { + runTest("no ClassCastException with generic aspect and unknown type"); + } + + /* + * @AspectJ bugs and enhancements + */ + // public void testAtAspectInheritsAdviceWithTJPAndThis_pr125699 () { + // runTest("inherit adivce with this() and thisJoinPoint"); + // } + public void testAtAspectInheritsAbstractPointcut_pr125810() { + runTest("warning when inherited pointcut not made concrete"); + } + + public void testAtAspectWithoutJoinPointImport_pr121616() { + runTest("@AJ without JoinPoint import"); + } + + public void testAtAspectDeclareParentsRetainsFieldState_pr122370() { + runTest("@AJ declare parents retains field state"); + } + + public void testAtAspectNoNPEWithPcdContainingOrThisAndWildcard_pr128237() { + runTest("@AJ no npe with pointcut containing or, this and a wildcard"); + } + + /* + * Load-time weaving bugs and enhancements + */ + public void testEmptyPointcutInAtAspectJ_pr125475() { + runTest("define empty pointcut using an annotation"); + } + + public void testEmptyPointcutInAtAspectJ_pr125475_2() { + runTest("define empty pointcut using an annotation - 2"); + } + + public void testEmptyPointcutInAtAspectJWithLTW_pr125475() { + runTest("define empty pointcut using aop.xml"); + } + + public void testGenericAspectsWithAnnotationTypeParameters() { + runTest("Generic aspects with annotation type parameters"); + } + + public void testPointcutInterfaces_pr130869() { + runTest("Pointcut interfaces"); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc151Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc151.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java b/tests/src/test/java/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java new file mode 100644 index 000000000..32a3ed5b3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc151; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ151 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.5.1 tests"); + //$JUnit-BEGIN$ + suite.addTest(Ajc151Tests.suite()); + suite.addTest(NewarrayJoinpointTests.suite()); + suite.addTest(AtAroundTests.suite()); + suite.addTest(SerialVersionUIDTests.suite()); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/AtAroundTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc151/AtAroundTests.java new file mode 100644 index 000000000..9512e8db4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/AtAroundTests.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc151; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * This testcode shows what is possible with code style and the current limitations + * of @AJ style. Each program is written in both styles and those variations + * not currently possible are commented out. + * + * @author AndyClement + * + */ +public class AtAroundTests extends XMLBasedAjcTestCase { + + public void testCodeBasic() { runTest("code style - basic"); } + public void testAtBasicNoInline() { runTest("annotation style - basic - noinline"); } + public void testAtBasic() { runTest("annotation style - basic"); } + + public void testCodeBindingTarget() { runTest("code style - correct usage, binding and passing same target for call"); } + public void testAtBindingTargetNoInline() { runTest("annotation style - correct usage, binding and passing same target for call - noinline"); } + public void testAtBindingTarget() { runTest("annotation style - correct usage, binding and passing same target for call"); } + + public void testCodeBindingTarget2() { runTest("code style - correct usage, binding and passing new target for call"); } + public void testAtBindingTargetNoInline2() { runTest("annotation style - correct usage, binding and passing new target for call - noinline"); } + public void testAtBindingTarget2() { runTest("annotation style - correct usage, binding and passing new target for call"); } + + public void testCodeErrorCase1() { runTest("code style - forget to pass target");} + // Don't think we can report correct errors for @AJ as the parameters are specified as an object array + //public void testAtErrorCase1() { runTest("annotation style - forget to pass target");} + + public void testCodeBindThisCallChangeProceed() { runTest("code style - bind this on call - change on proceed - no effect");} + public void testAtBindThisCallChangeProceedNoInline() { runTest("annotation style - bind this on call - change on proceed - no effect - noinline");} + public void testAtBindThisCallChangeProceed() { runTest("annotation style - bind this on call - change on proceed - no effect");} + + public void testCodeBindThisExecutionChangeProceed() { runTest("code style - bind this on execution - change on proceed - works");} + public void testAtBindThisExecutionChangeProceedNoInline() { runTest("annotation style - bind this on execution - change on proceed - works - noinline");} + public void testAtBindThisExecutionChangeProceed() { runTest("annotation style - bind this on execution - change on proceed - works");} + + public void testCodeBindBothExecutionChangeProceed() { runTest("code style - bind this and target on execution - change on proceed - works");} + public void testAtBindBothExecutionChangeProceedNoInline() { runTest("annotation style - bind this and target on execution - change on proceed - works - noinline");} + public void testAtBindBothExecutionChangeProceed() { runTest("annotation style - bind this and target on execution - change on proceed - works");} + + public void testCodeErrorCase2() { runTest("code style - incorrect arg types");} + // Don't think we can report correct errors for @AJ as the parameters are specified as an object array + // public void testAtErrorCase2() { runTest("annotation style - incorrect arg types");} + + public void testCodeChangingTargetDifferingOrder() { runTest("code style - changing target for call - reverse order"); } + // @AJ cant cope with the changing of the order of arguments bound and passed through proceed + //public void testAtChangingTargetDifferingOrder() { runTest("annotation style - changing target for call - reverse order"); } + + public void testCodeBindBothCallChangeProceed() { runTest("code style - bind this and target on call - change on proceed - works");} + public void testAtBindBothCallChangeProceedNoInline() { runTest("annotation style - bind this and target on call - change on proceed - works - noinline");} + public void testAtBindBothCallChangeProceed() { runTest("annotation style - bind this and target on call - change on proceed - works");} + + public void testBreakingIt1() { runTest("breaking it - one");} + public void testBreakingIt2() { runTest("breaking it - two");} + + public void testBugCase1() { runTest("bug case one");} + public void testBugCase2() { runTest("bug case two");} + public void testMultipleArgs() { runTest("multiple args");} + + public void testCodeSubsetArguments() { runTest("code style - works with subset of arguments in advice");} + // cant do this for annotation style + //public void testAtSubsetArguments() { runTest("annotation style - works with subset of arguments in advice");} + + // --- + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AtAroundTests.class); + } + + protected File getSpecFile() { + return getClassResource("ataround.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java new file mode 100644 index 000000000..9654c04dd --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc151; + +import java.io.File; +import java.util.List; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/* + * The design: + * + * There are 3 instructions that create arrays: + * + * - NEWARRAY for primitive arrays + * - ANEWARRAY for object arrays + * - MULTIANEWARRAY for multidimensional arrays + * + * The changes to expose the new joinpoint are in: + * BcelClassWeaver.match(LazyMethodGen mg,InstructionHandle ih,BcelShadow enclosingShadow,List shadowAccumulator) + * + * Determining the type of the array is easy. Determining the size of the array is not easy statically, it is on the stack. + * + * + * What still needs testing: + * - structure model + * + */ + +public class NewarrayJoinpointTests extends XMLBasedAjcTestCase { + + // when its the creation of a new 'object' (not a primitive) single dimension array + public void testTheBasics_1() { + runTest("basics"); + } + + public void testTheBasics_2() { + runTest("basics - 2"); + } + + public void testWhatShouldntMatch() { + runTest("shouldnt match"); + } + + public void testThisJoinPoint() { + runTest("thisjoinpoint"); + } + + public void testThisJoinPoint19() { + try { + System.setProperty("ASPECTJ_OPTS", "-Xajruntimetarget:1.9"); + runTest("thisjoinpoint"); + } finally { + System.setProperty("ASPECTJ_OPTS", ""); + } + } + + public void testDifferentAdviceKinds() { + runTest("different advice kinds"); + } + + public void testArgs() { + runTest("args"); + } + + // when it is the creation of a new array of primitives + public void testBasicWithAPrimitiveArray() { + runTest("basic primitive array creation"); + } + + // when it is the creation of a new multi-dimensional array + public void testBasicWithAMultiDimensionalArray() { + runTest("multi dimensional array creation"); + } + + public void testArgsWithAMultiDimensionalArray() { + runTest("multi dimensional array args"); + } + + // various + public void testOptionoff() { + runTest("option deactivated - no match expected"); + } + + public void testUsingTargetAndAfterReturningAdvice() { + runTest("using target and after returning"); + } + + public void testUsingItForReal() { + runTest("using it for real"); + } + + public void testDifferentiatingArrayTypes() { + runTest("differentiating array types"); + } + + public void testStructureModel() { + // AsmManager.setReporting("c:/foo.txt",true,true,true,true); + runTest("structure model"); + IProgramElement ipe = AsmManager.lastActiveStructureModel.getHierarchy().findElementForType("", "Five"); + assertTrue("Couldnt find 'Five' type in the model", ipe != null); + List kids = ipe.getChildren(); + assertTrue("Couldn't find 'main' method in the 'Five' type", kids != null && kids.size() == 1); + List codenodes = kids.get(0).getChildren(); + assertTrue("Couldn't find nodes below 'main' method", codenodes != null && codenodes.size() == 1); + IProgramElement arrayCtorCallNode = codenodes.get(0); + String exp = "constructor-call(void java.lang.Integer[].(int))"; + assertTrue("Expected '" + exp + "' but found " + arrayCtorCallNode.toString(), arrayCtorCallNode.toString().equals(exp)); + List rels = AsmManager.lastActiveStructureModel.getRelationshipMap().get(arrayCtorCallNode); + assertTrue("Should have a relationship from the ctorcall node, but didn't find one?", rels != null && rels.size() == 1); + } + + // + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(NewarrayJoinpointTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("newarray_joinpoint.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java new file mode 100644 index 000000000..c1bf29475 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc151; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + + +public class SerialVersionUIDTests extends XMLBasedAjcTestCase { + + public void testTheBasics() { runTest("basic"); } + public void testTheBasicsWithLint() { runTest("basic - lint"); } + public void testHorrible() { runTest("horrible"); } + + public void testAbstractClass() { runTest("abstract class");} + + // + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SerialVersionUIDTests.class); + } + + protected File getSpecFile() { + return getClassResource("serialversionuid.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/ajc151.xml b/tests/src/test/java/org/aspectj/systemtest/ajc151/ajc151.xml new file mode 100644 index 000000000..279c56e04 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/ajc151.xml @@ -0,0 +1,414 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/ataround.xml b/tests/src/test/java/org/aspectj/systemtest/ajc151/ataround.xml new file mode 100644 index 000000000..d8b625823 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/ataround.xml @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml b/tests/src/test/java/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml new file mode 100644 index 000000000..fb11fa596 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/serialversionuid.xml b/tests/src/test/java/org/aspectj/systemtest/ajc151/serialversionuid.xml new file mode 100644 index 000000000..f7b05af63 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/serialversionuid.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java new file mode 100644 index 000000000..eef463214 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -0,0 +1,384 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc152; + +import java.io.File; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.internal.CharOperation; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // public void testCovarianceAndDecp_pr128443_1() { runTest("covariance and decp - 1"); } + // public void testSuperITDExplosion_pr134425() { runTest("super ITDs");} + // public void testMisbehavingDeclareAnnotation_pr135865() { runTest("misbehaving declare annotation");} + // public void testMisbehavingDeclareAnnotation_pr135865_2() { runTest("misbehaving declare annotation - 2");} + // public void testClassCastForInvalidAnnotationValue_pr148537() { runTest("classcast annotation value");} + + // tests added post 152rc1 and before final + public void testSeparateCallAspectOf_pr148727() { + runTest("separate compilation calling aspectOf and hasAspect"); + } + + public void testIntegratedCallAspectOf_pr148727() { + runTest("integrated compilation calling aspectOf and hasAspect"); + } + + public void testFreakyNewArrayJoinpoint_pr148786() { + runTest("freaky new array joinpoint"); + } + + // tests adding during 152 development + public void testPrivilegeGeneric_pr148545() { + runTest("nosuchmethoderror for privileged aspect"); + } + + public void testPrivilegeGeneric_pr148545_2() { + runTest("nosuchmethoderror for privileged aspect - 2"); + } + + public void testUnknownAnnotationNPE() { + runTest("NPE for unknown annotation"); + } + + public void testDuplicateBridgeMethods_pr147801_1() { + runTest("duplicate bridge methods"); + } + + public void testPackageIgnoredForException_pr147701_1() { + runTest("package for exception ignored"); + } + + public void testPackageIgnoredForException_pr147701_2() { + runTest("package for exception ignored - 2"); + } + + public void testPackageIgnoredForException_pr147701_3() { + runTest("package for exception ignored - 3"); + } + + public void testBrokenAddSerialVersionUID_pr145950() { + runTest("fails to discover Serializable"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_1() { + runTest("no unnecessary declaration of thrown exception warning - 1"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_2() { + runTest("no unnecessary declaration of thrown exception warning - 2"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_3() { + runTest("no unnecessary declaration of thrown exception warning - 3"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_4() { + runTest("no unnecessary declaration of thrown exception warning - 4"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_5() { + runTest("no unnecessary declaration of thrown exception warning - 5"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_6() { + runTest("no unnecessary declaration of thrown exception warning - 6"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_7() { + runTest("no unnecessary declaration of thrown exception warning - 7"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_8() { + runTest("no unnecessary declaration of thrown exception warning - 8"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_9() { + runTest("no unnecessary declaration of thrown exception warning - 9"); + } + + public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_10() { + runTest("no unnecessary declaration of thrown exception warning - 10"); + } + + public void testAtAJVerificationError_pr144602() { + runTest("atAJ perthis aspect verification error"); + } + + public void testLTWAndGeneratingSUID_pr144465() { + runTest("ltw with serialversionUID creation"); + } + + public void testAspects14PerSingleton_pr122253() { + runTest("aspects14 - persingleton"); + } + + public void testAspects14PerCflow_pr122253() { + runTest("aspects14 - percflow"); + } + + public void testAspects14PerThis_pr122253() { + runTest("aspects14 - perthis"); + } + + public void testAspects14PerTypeWithin_pr122253() { + runTest("aspects14 - pertypewithin"); + } + + public void testFunkyGenericErrorWithITDs_pr126355() { + runTest("bizarre generic error with itds"); + } + + public void testConcretizingAbstractMethods_pr142466() { + runTest("aop.xml aspect inheriting but not concretizing abstract method"); + } + + public void testConcretizingAbstractMethods_pr142466_2() { + runTest("aop.xml aspect inheriting but not concretizing abstract method - 2"); + } + + public void testComplexGenericDecl_pr137568() { + runTest("complicated generics declaration"); + } + + public void testItdOnInnerTypeOfGenericType_pr132349() { + runTest("ITD on inner type of generic type"); + } + + public void testItdOnInnerTypeOfGenericType_pr132349_2() { + runTest("ITD on inner type of generic type - 2"); + } + + public void testItdOnInnerTypeOfGenericType_pr132349_3() { + runTest("ITD on inner type of generic type - 3"); + } + + public void testLTWGeneratedAspectAbstractMethod_pr125480() { + runTest("aop.xml aspect inheriting abstract method "); + } + + public void testLTWGeneratedAspectAbstractMethod_pr125480_2() { + runTest("aop.xml aspect inheriting abstract method - code style"); + } + + public void testCompletelyBrokenAopConcretization_pr142165_1() { + runTest("broken concretization"); + } + + public void testCompletelyBrokenAopConcretization_pr142165_2() { + runTest("broken concretization - 2"); + } + + public void testCompletelyBrokenAopConcretization_pr142165_3() { + runTest("broken concretization - 3"); + } + + // public void testVerifyErrorLTW_pr135068() { runTest("ltw verifyerror");} + // public void testVerifyErrorLTW_pr135068_2() { runTest("ltw verifyerror - 2");} + // public void testVerifyErrorLTW_pr135068_3() { runTest("ltw verifyerror - 3");} + public void testVerifyErrorLTW_pr135068_4() { + runTest("ltw verifyerror - 4"); + } + + public void testVerifyErrorForComplexCflow_pr136026() { + runTest("verifyerror"); + } + + public void testVerifyErrorForComplexCflow_pr136026_2() { + runTest("verifyerror - 2"); + } + + public void testAnnotationsAndGenericsBCException_pr129704() { + runTest("annotations and generics leading to BCException"); + } + + public void testMethodTooBigAfterWeaving_pr138384() { + runTest("method too big"); + } + + public void testNotAtWithincode_pr138158_1() { + runTest("not at withincode - 1"); + } + + public void testNotAtWithincode_pr138158_2() { + runTest("not at withincode - 2"); + } + + public void testNotAtWithincode_pr138158_3() { + runTest("not at within - 3"); + } + + public void testNpeOnDup_pr138143() { + runTest("npe on duplicate method with ataj"); + } + + public void testPointcutsAndGenerics_pr137496_1() { + runTest("pointcuts and generics - B"); + } + + public void testPointcutsAndGenerics_pr137496_2() { + runTest("pointcuts and generics - D"); + } + + public void testPointcutsAndGenerics_pr137496_3() { + runTest("pointcuts and generics - E"); + } + + public void testPointcutsAndGenerics_pr137496_4() { + runTest("pointcuts and generics - F"); + } + + public void testPointcutsAndGenerics_pr137496_5() { + runTest("pointcuts and generics - G"); + } + + public void testPointcutsAndGenerics_pr137496_6() { + runTest("pointcuts and generics - H"); + } + + public void testAspectLibrariesAndASM_pr135001() { + runTest("aspect libraries and asm"); + } + + public void testStackOverflow_pr136258() { + runTest("stack overflow"); + } + + public void testIncorrectOverridesEvaluation13() { + runTest("incorrect overrides evaluation - 1.3"); + } + + public void testIncorrectOverridesEvaluation15() { + runTest("incorrect overrides evaluation - 1.5"); + } + + public void testAtWithinCodeBug_pr138798() { + runTest("atWithinCodeBug"); + } + + public void testReferencePCutInDeclareWarning_pr138215() { + runTest("Reference pointcut fails inside @DeclareWarning"); + } + + public void testReferencePCutInPerClause_pr138219() { + runTest("Can't use a FQ Reference pointcut in any pointcut expression referenced by a per-clause"); + } + + public void testReferencePCutInPerClause_pr130722() { + runTest("FQ Reference pointcut from perclause ref pc"); + } + + public void testDoubleAnnotationMatching_pr138223() { + runTest("Double at annotation matching (no binding)"); + } + + public void testSuperCallsInAtAspectJAdvice_pr139749() { + runTest("Super calls in @AspectJ advice"); + } + + public void testNoClassCastExceptionWithPerThis_pr138286() { + runTest("No ClassCastException with perThis"); + } + + public void testGenericAspectHierarchyWithBounds_pr147845() { + runTest("Generic abstract aspect hierarchy with bounds"); + } + + public void testJRockitBooleanReturn_pr148007() { + runTest("jrockit boolean fun"); + } + + public void testJRockitBooleanReturn2_pr148007() { + runTest("jrockit boolean fun (no aspects)"); + } + + public void testSyntheticAjcMembers_pr147711() { + runTest("synthetic ajc$ members"); + } + + // this next one reported as a bug by Rob Harrop, but I can't reproduce the failure yet... + // public void testAtAspectWithReferencePCPerClause_pr138220() { runTest("@Aspect with reference pointcut in perclause");} + + public void testJarChecking_pr137235_1() { + runTest("directory with .jar extension: source and outjar"); + } + + public void testJarChecking_pr137235_2() { + runTest("directory with .jar extension"); + } + + public void testMakePreMethodNPE_pr136393() { + runTest("NPE in makePreMethod"); + } + + public void testGetParameterSignatures_pr141730() { + runTest("new iprogramelement method getParameterSignatures"); + + checkGetParamSigOfMethod("stringMethod(java.lang.String)", "Ljava/lang/String;"); + checkGetParamSigOfMethod("main(java.lang.String[])", "[Ljava/lang/String;"); + checkGetParamSigOfMethod("multiMethod(java.lang.String[][])", "[[Ljava/lang/String;"); + } + + public void testGetParameterSignaturesWithGenerics_pr141730() { + runTest("new iprogramelement method getParameterSignatures with generics"); + + checkGetParamSigOfMethod("genericMethod(java.util.List)", "Ljava/util/List;"); + checkGetParamSigOfMethod("genericMethod2(MyGenericClass)", + "LMyGenericClass;"); + } + + // public void testFunkyGenericErrorWithITDs_pr126355_2() { + // runTest("bizarre generic error with itds - 2"); + // // public class Pair affected by pertarget aspect + // GenericsTests.verifyClassSignature(ajc,"Pair","Ljava/lang/Object;LIdempotentCache$ajcMightHaveAspect;;"); + // } + + public void testNoAspects() { + // setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true"); + runTest("Ensure no weaving without included aspects"); + } + + public void testWeaveinfoMessages() { + runTest("weaveinfo messages with include and exclude"); + } + + // tests that can't be included for some reason + + // Not valid whilst the ajc compiler forces debug on (ignores -g:none) - it will be green but is invalid, trust me + // public void testLongWindedMessages_pr129408() { runTest("long winded ataj messages");} + + // ---------------- helper methods --------------- + + private void checkGetParamSigOfMethod(String ipeLabel, String expectedParm) { + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, ipeLabel); + assertNotNull("Couldn't find '" + ipeLabel + "' element in the tree", ipe); + List l = ipe.getParameterSignatures(); + boolean eq = CharOperation.equals(((char[]) l.get(0)), expectedParm.toCharArray()); + assertTrue("expected parameter to be '" + expectedParm + "' but found '" + new String(((char[]) l.get(0))) + "'", eq); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc152Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc152.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/AllTestsAspectJ152.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/AllTestsAspectJ152.java new file mode 100644 index 000000000..05c311f50 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/AllTestsAspectJ152.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc152; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ152 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.5.2 tests"); + //$JUnit-BEGIN$ + suite.addTest(Ajc152Tests.suite()); + suite.addTest(SynchronizationTests.suite()); + suite.addTest(SynchronizationTransformTests.suite()); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTests.java new file mode 100644 index 000000000..47baa2940 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTests.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc152; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Work items, phase #1: lock()/unlock() x expose new joinpoints x parse new pcds x fix tjp string x preventing double unlock() + * messages/markers in structure model x error messages appropriate for attempting to use around advice on synchronization join + * points x making the use of lock/unlock conditional on an -Xjoinpoints:synchronization x activating the -Xjoinpoints options from + * LTW configurations rather than through batch/AJDT x ensure the lock/unlock joinpoints only appear when + * -Xjoinpoints:synchronization specified TAG: Completion of PHASE1 + * + * + * Work items, phase #2: transformation + * + * Design: transform all synchronized methods: public synchronized void m() { ... } => public void m() { synchronized (this) { ... } + * } + * + * x transforming synchronized methods x matching execution(synchronized * *(..)) for transformed code x warning message for + * execution() hitting a synchronized method x ensure verifier runs over generated code (done by just executing the code as part of + * the test spec) - Ant task support for -Xjoinpoints TAG: Completion of PHASE2 + * + * + * TAG: Finished + * + * Future work items: - optimize matching for transformed methods since we *know* the type we are locking on - supporting type + * pattern in lock() unlock() - this is not entirely trivial as kinded pointcuts do not usually have any residue - weaving messages + * include 'unusual' strings for the join points, not the same as revealed by thisJoinPoint.getSignature() in code - handler is + * probably similar - documentation - lazy translation of synchronized methods, rather than eager - applying execution(* *(..)) + * correctly to transformed methods (i.e. inside lock/unlock) - use knowledge of type containing synchronized methods to optimize + * matching of (un)lock() - not always needing residue - line number table is incorrect for transformed code (lock joinpoint has no + * line number) + * + * Notes: IllegalMonitorStateException Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify + * other threads waiting on an object's monitor without owning the specified monitor. + * + * around advice won't work on SUN VMs (may be a bug that it does work on other VMs) since the monitor instructions are extracted to + * a separate method for proceed() calls and yet the VM seems to want them paired inside a single method. + * + * Really we only need to restrict the use of around advice on synchronization join points if the advice uses proceed() - but + * policing that is a little tough because (DOH) the AdviceAttribute field 'proceedCallSignatures' is never filled in (which records + * how many proceeds occur in the advice) - see where it isnt filled in at AdviceDeclaration.resolveStatements() in the loop that + * goes over the proceedCalls list. + * + * + * Problems: - Can't run it on a 1.2.1 runtime - just not practical + * + * + * Method transformation, example: + * + * public synchronized void m(); Code: Stack=2, Locals=1, Args_size=1 0: getstatic #2; //Field + * java/lang/System.err:Ljava/io/PrintStream; 3: ldc #3; //String hello 5: invokevirtual #4; //Method + * java/io/PrintStream.println:(Ljava/lang/String;)V 8: getstatic #2; //Field java/lang/System.err:Ljava/io/PrintStream; 11: ldc #5; + * //String world 13: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 16: return LineNumberTable: line + * 4: 0 line 5: 8 line 6: 16 + * + * public void m2(); Code: Stack=2, Locals=3, Args_size=1 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: getstatic #2; //Field + * java/lang/System.err:Ljava/io/PrintStream; 7: ldc #3; //String hello 9: invokevirtual #4; //Method + * java/io/PrintStream.println:(Ljava/lang/String;)V 12: getstatic #2; //Field java/lang/System.err:Ljava/io/PrintStream; 15: ldc + * #5; //String world 17: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 20: aload_1 21: monitorexit + * 22: goto 30 25: astore_2 26: aload_1 27: monitorexit 28: aload_2 29: athrow 30: return Exception table: from to target type 4 22 + * 25 any 25 28 25 any + * + * Factors affecting transformation: - LDC in Java5 supports referring to a class literal, e.g. Foo.class whereas before Java5, it + * did not. This means if generating the synchronized() block for a static method from a preJava5 class then we have to generate a + * lot of crap to build the class object for locking and unlocking. The object is also stored in a local field of the type (if we + * follow the pattern of JDT/JAVAC) + */ + +public class SynchronizationTests extends XMLBasedAjcTestCase { + + // testing the new join points for monitorenter/monitorexit + public void testTheBasics_1() { + runTest("basic"); + } + + public void testTheBasics_2() { + runTest("basic - within"); + } + + public void testTheBasics_3() { + runTest("basic - within plus args"); + } + + public void testTheBasics_4() { + runTest("basic - within plus this"); + } // this null in static context + + public void testTheBasics_5() { + runTest("basic - within plus target"); + } // target null in static context? + + // testing parsing of the new PCDs lock/unlock + public void testParsing_1() { + runTest("parsing - lock"); + } + + public void testParsing_2() { + runTest("parsing - unlock"); + } + + public void testParsing_errors_1() { + runTest("parsing - error - lock"); + } + + public void testParsing_errors_2() { + runTest("parsing - error - unlock"); + } + + // testing parsing and matching with the new PCDs + public void testParsingAndMatching_1() { + runTest("parsing and matching - lock and static context"); + } + + public void testParsingAndMatching_2() { + runTest("parsing and matching - unlock and static context"); + } + + public void testParsingAndMatching_3() { + runTest("parsing and matching - lock and non-static context"); + } + + public void testParsingAndMatching_4() { + runTest("parsing and matching - unlock and non-static context"); + } + + public void testParsingAndMatching_5() { + runTest("parsing and matching - lock and non-static context"); + } + + public void testParsingAndMatching_6() { + runTest("parsing and matching - unlock and non-static context"); + } + + // using the new PCDs in a LTW environment + public void testUsingWithLTW_MissingFlag_1() { + runTest("using lock with LTW - missing flag"); + } + + public void testUsingWithLTW_MissingFlag_2() { + runTest("using unlock with LTW - missing flag"); + } + + public void testUsingWithLTW_1() { + runTest("using lock with LTW"); + } + + public void testUsingWithLTW_2() { + runTest("using unlock with LTW"); + } + + // multiple PCDs + public void testCombiningPCDs_1() { + runTest("combining pcds - lock and this"); + } + + public void testCombiningPCDs_2() { + runTest("combining pcds - unlock and this"); + } + + // useful examples + public void testUseful_1() { + runTest("a useful program"); + } // just uses within/args - matching the (un)lock jps + + public void testUseful_2() { + runTest("a useful program - with lock"); + } // uses lock/args + + // all the methods of thisJoinPoint + public void testThisJoinPoint_1() { + runTest("thisjoinpoint - monitor entry"); + } + + public void testThisJoinPoint_2() { + runTest("thisjoinpoint - monitor exit"); + } + + public void testDoubleMessagesOnUnlock() { + // AsmManager.setReporting("c:/foo.txt",true,true,true,true); + runTest("prevent double unlock weaving messages and model contents"); + // checkModel1(); + } + + // targetting 1.2 runtime - signature creation code in LazyClassGen.initializeTjp may not work + + // different advice kinds + public void testBeforeAdvice_1() { + runTest("before advice - lock"); + } + + public void testBeforeAdvice_2() { + runTest("before advice - unlock"); + } + + public void testAfterAdvice_1() { + runTest("after advice - lock"); + } + + public void testAfterAdvice_2() { + runTest("after advice - unlock"); + } + + public void testAroundAdvice_1() { + runTest("around advice - lock"); + } + + public void testAroundAdvice_2() { + runTest("around advice - unlock"); + } + + public void testLockingTJP() { + runTest("obtaining locked object through getArgs"); + } + + // binary weaving? + + // nested locking/unlocking + + // --- helpers + + // Half finished - could check there is only one relationship for unlock() rather than two - but + // that seems to be the case anyway (peculiar...) + // private void checkModel1() { + // // Verifies only one unlock relationship, not two + // IProgramElement unlockNode = + // AsmManager.getDefault().getHierarchy().findElementForLabel(AsmManager.getDefault().getHierarchy().getRoot(), + // IProgramElement.Kind.CODE,"unlock(void java.lang.Object.(java.lang.Object))"); + // assertTrue("Couldn't find the unlock node",unlockNode!=null); + // List l = AsmManager.getDefault().getRelationshipMap().get(unlockNode); + // assertTrue("should be one entry :"+l,l!=null && l.size()==1); + // IRelationship ir = (IRelationship)l.get(0); + // System.err.println(ir); + // List targs = ir.getTargets(); + // System.err.println(targs.size()); + // System.err.println(targs.get(0)); + // } + + // --- + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SynchronizationTests.class); + } + + protected File getSpecFile() { + return getClassResource("synchronization.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java new file mode 100644 index 000000000..922f4c5b4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -0,0 +1,310 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc152; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.util.TestUtil; +import org.aspectj.testing.util.TestUtil.LineStream; +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.World; +import org.aspectj.weaver.bcel.BcelObjectType; +import org.aspectj.weaver.bcel.BcelWorld; +import org.aspectj.weaver.bcel.LazyClassGen; +import org.aspectj.weaver.bcel.LazyMethodGen; + +/** + * Method transformation, example: + * + * public synchronized void m(); Code: Stack=2, Locals=1, Args_size=1 0: getstatic #2; //Field + * java/lang/System.err:Ljava/io/PrintStream; 3: ldc #3; //String hello 5: invokevirtual #4; //Method + * java/io/PrintStream.println:(Ljava/lang/String;)V 8: getstatic #2; //Field java/lang/System.err:Ljava/io/PrintStream; 11: ldc #5; + * //String world 13: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 16: return LineNumberTable: line + * 4: 0 line 5: 8 line 6: 16 + * + * public void m2(); Code: Stack=2, Locals=3, Args_size=1 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: getstatic #2; //Field + * java/lang/System.err:Ljava/io/PrintStream; 7: ldc #3; //String hello 9: invokevirtual #4; //Method + * java/io/PrintStream.println:(Ljava/lang/String;)V 12: getstatic #2; //Field java/lang/System.err:Ljava/io/PrintStream; 15: ldc + * #5; //String world 17: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 20: aload_1 21: monitorexit + * 22: goto 30 25: astore_2 26: aload_1 27: monitorexit 28: aload_2 29: athrow 30: return Exception table: from to target type 4 22 + * 25 any 25 28 25 any + */ + +public class SynchronizationTransformTests extends XMLBasedAjcTestCase { + + private static boolean regenerate; + + static { + regenerate = false; + } + + private World world; + + public void testInvestigatingTransforming() { + runTest("investigation"); + checkMethod("Investigation", "b"); // similar output to One.b + checkMethod("Investigation", "c"); + checkMethod("Investigation", "d"); + checkMethod("Investigation", "e"); + } + + public void testTransform1() { + runTest("One"); + checkMethod("One", "b"); + checkMethod("One", "c"); + checkMethod("One", "e"); + } + + // before() on execution jp + public void testTransform2() { + runTest("Two"); + checkMethod("C", "ma"); + } + + public void testTransform2XlintOff() { + runTest("Two - xlintoff"); + checkMethod("C", "ma"); + } + + // after() returning/after() throwing on execution jp + // after() returning -> make all returns go through the same exit point and make + // it call the advice + // after() throwing -> add a catch block that calls the advice + public void testTransform3() { + runTest("Three"); + checkMethod("C", "m3"); + checkMethod("C", "m32"); + checkMethod("C", "m33"); // like m() but synchronized block + checkMethod("C", "m34"); // like m2() but synchronized block + } + + // like testTransform3() but pointcuts explicitly specify synchronized + public void testTransform4() { + runTest("Four"); + checkMethod("C", "m"); + checkMethod("C", "m2"); + } + + // Java5 variant + public void testStaticSynchronizedMethodTransformJava5() { + runTest("Five - Java5"); + checkMethod("C", "b"); + } + + // < Java5 variant + public void testStaticSynchronizedMethodTransformPreJava5() { + runTest("Six - preJava5"); + checkMethod("C", "bbb"); + } + + public void testLockPcdOnTransformedNonStaticMethod() { + runTest("lock pcd on transformed non-static method"); + } + + public void testUnlockPcdOnTransformedNonStaticMethod() { + runTest("unlock pcd on transformed non-static method"); + } + + public void testLockPcdOnTransformedStaticMethod() { + runTest("lock pcd on transformed static method - J5"); + } + + public void testUnlockPcdOnTransformedStaticMethod() { + runTest("unlock pcd on transformed static method - J5"); + } + + public void testLockPcdOnTransformedStaticMethodPreJ5() { + runTest("lock pcd on transformed static method - preJ5"); + } + + public void testUnlockPcdOnTransformedStaticMethodPreJ5() { + runTest("unlock pcd on transformed static method - preJ5"); + } + + public void testJoinpointsEnabledButNoLock() { + runTest("joinpoints enabled but no lock"); + } + + public void testTransformWithLTW() { + runTest("transform with LTW"); + } + + public void testTransformStaticMethodPreJava5() { + runTest("transform static method - preJ5"); + } + + public void testTransformStaticMethodPreJava5_2() { + runTest("transform static method - packages - preJ5"); + } + + // more complex code sequences... + public void testOtherTargeters() { + runTest("other targeters"); + } + + // --- infrastructure below + + private void checkMethod(String typename, String methodname) { + LazyMethodGen m = getMethod(typename, methodname); + File expectedF = new File(".." + File.separator + "tests" + File.separator + "features152" + File.separator + + "synchronization" + File.separator + "transformed" + File.separator + "expected" + File.separator + typename + + "." + methodname + ".txt"); + if (regenerate) { + saveMethod(expectedF, m); + } else { + compareMethod(expectedF, m); + } + } + + private LazyMethodGen getMethod(String typename, String methodname) { + BcelObjectType type = getBcelObjectFor(typename); + LazyClassGen lcg = type.getLazyClassGen(); + List methods = lcg.getMethodGens(); + for (LazyMethodGen element: methods) { + if (element.getName().equals(methodname)) { + return element; + } + } + return null; + } + + private BcelObjectType getBcelObjectFor(String clazzname) { + ensureWorldSetup(); + ResolvedType rt = world.resolve(clazzname); + if (rt == null) + fail("Couldn't find class " + clazzname); + ReferenceType rtt = (ReferenceType) rt; + BcelObjectType bot = (BcelObjectType) rtt.getDelegate(); + return bot; + } + + private void ensureWorldSetup() { + if (world == null) { + world = new BcelWorld(getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path")); + } + } + + protected Method getMethod(JavaClass cl, String methodname) { + Method[] methods = cl.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method m = methods[i]; + if (m.getName().equals(methodname)) { + return m; + } + } + return null; + } + + public void dump(String title, String[] strs) { + System.err.println(title); + for (int i = 0; i < strs.length; i++) { + System.err.println(i + ") " + strs[i]); + } + } + + private void compareMethod(File f, LazyMethodGen m) { + BufferedReader fr; + if (!f.exists()) { + fail("Can't find expected output file " + f); + } + try { + // Load the file in + fr = new BufferedReader(new FileReader(f)); + String line = null; + List originalFileContents = new ArrayList<>(); + while ((line = fr.readLine()) != null) + originalFileContents.add(line); + String[] fileContents = (String[]) originalFileContents.toArray(new String[] {}); + + LineStream ls = new TestUtil.LineStream(); + m.print(ls, null); + String[] lines = ls.getLines(); + for (int i = 0; i < lines.length; i++) { + String existingLine = lines[i]; + if (fileContents[i].indexOf("MethodDeclarationLineNumber") == -1 && !fileContents[i].equals(existingLine)) { + dump("File contents:", fileContents); + dump("Actual:", lines); + fail("\nDifference in method " + m.getName() + " on line " + i + " between the expected:\n" + fileContents[i] + + "\nand the found:\n" + existingLine); + } + } + } catch (Exception e) { + fail("Unexpected exception saving weaving messages:" + e); + } + } + + private String stringify(List l) { + StringBuffer result = new StringBuffer(); + for (Iterator iter = l.iterator(); iter.hasNext();) { + String str = iter.next(); + result.append(str); + result.append("\n"); + } + return result.toString(); + } + + private void saveMethod(File f, LazyMethodGen m) { + System.out.println("Saving method into " + f.getName()); + try { + m.print(new PrintStream(new FileOutputStream(f)), null); + } catch (FileNotFoundException e) { + e.printStackTrace(); + fail("Couldn't store the method in file " + f); + } + } + + // --- helpers + + // Half finished - could check there is only one relationship for unlock() rather than two - but + // that seems to be the case anyway (peculiar...) + // private void checkModel1() { + // // Verifies only one unlock relationship, not two + // IProgramElement unlockNode = + // AsmManager.getDefault().getHierarchy().findElementForLabel(AsmManager.getDefault().getHierarchy().getRoot(), + // IProgramElement.Kind.CODE,"unlock(void java.lang.Object.(java.lang.Object))"); + // assertTrue("Couldn't find the unlock node",unlockNode!=null); + // List l = AsmManager.getDefault().getRelationshipMap().get(unlockNode); + // assertTrue("should be one entry :"+l,l!=null && l.size()==1); + // IRelationship ir = (IRelationship)l.get(0); + // System.err.println(ir); + // List targs = ir.getTargets(); + // System.err.println(targs.size()); + // System.err.println(targs.get(0)); + // } + + // --- + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SynchronizationTransformTests.class); + } + + protected File getSpecFile() { + return getClassResource("synchronization.xml"); + } + + public void tearDown() { + world = null; + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/test/java/org/aspectj/systemtest/ajc152/ajc152.xml new file mode 100644 index 000000000..c7a917688 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/ajc152.xml @@ -0,0 +1,777 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/synchronization.xml b/tests/src/test/java/org/aspectj/systemtest/ajc152/synchronization.xml new file mode 100644 index 000000000..99096fa53 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/synchronization.xml @@ -0,0 +1,650 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/Ajc153Tests.java new file mode 100644 index 000000000..304e34898 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/Ajc153Tests.java @@ -0,0 +1,508 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc153; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.bcel.Utility; + +public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testFormalCommentsAreSetForConstructorIPEs_pr164340() { + runTest("formal comments are set for constructor ipes"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CONSTRUCTOR, "C()"); + assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment()); + } + + // public void testGenericsProblem_pr151978() { runTest("generics problem");} + // public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");} + // public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); } + // public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");} + // public void testNegatedAnnotationMatchingProblem_pr153464() { runTest("negated annotation matching problem");} + public void testAnnotationStyleBcException_pr162135() { + runTest("bcexception in annotation style around advice"); + } + + public void testAnnotationStyleBcException_pr162135_2() { + runTest("bcexception in annotation style around advice - 2"); + } + + public void testAnnotationStyleBcException_pr162135_3() { + runTest("bcexception in annotation style around advice - 3"); + } + + public void testAnnotationStyleBcException_pr162135_4() { + runTest("bcexception in annotation style around advice - 4"); + } + + public void testAnnotationStyleBcException_pr162135_5() { + runTest("bcexception in annotation style around advice - 5"); + } + + public void testAnnotationStyleBcException_pr162135_6() { + runTest("bcexception in annotation style around advice - 6"); + } + + public void testAnnotationStyleBcException_pr162135_7() { + runTest("bcexception in annotation style around advice - 7"); + } + + public void testIncompatibleClassChangeWithITD_pr164633() { + runTest("incompatibleclasschange"); + } + + public void testComplexPointcut_pr162657() { + runTest("complex pointcut"); + } + + public void testGenericsInPointcuts_pr161502() { + runTest("generics in pointcuts"); + } + + public void testGenericsInPointcuts_pr161502_2() { + runTest("generics in pointcuts - 2"); + } + + public void testNoNPEDueToMissingType_pr149908() { + runTest("ensure no npe due to missing type"); + } + + public void testNoNPEDueToMember_pr149908() { + runTest("ensure no npe due to missing member"); + } + + public void testPTWgetWithinTypeName_pr123423_1() { + runTest("basic usage of getWithinTypeName"); + } + + public void testPTWgetWithinTypeName_pr123423_2() { + runTest("basic usage of getWithinTypeName - multiple types"); + } + + public void testPTWgetWithinTypeName_pr123423_3() { + runTest("basic usage of getWithinTypeName - non matching types"); + } + + public void testPTWgetWithinTypeName_pr123423_4() { + runTest("basic usage of getWithinTypeName - types in packages"); + } + + public void testPTWgetWithinTypeName_pr123423_5() { + runTest("basic usage of getWithinTypeName - annotation style"); + } + + public void testTurningOffBcelCaching_pr160674() { + runTest("turning off bcel caching"); + } + + public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058() { + runTest("no IllegalStateException with generic inner aspect"); + } + + public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058_2() { + runTest("no IllegalStateException with generic inner aspect - 2"); + } + + public void testDeclareMethodAnnotations_pr159143() { + runTest("declare method annotations"); + } + + public void testVisibilityProblem_pr149071() { + runTest("visibility problem"); + } + + public void testMissingLineNumbersInStacktraceAfter_pr145442() { + runTest("missing line numbers in stacktrace after"); + } + + public void testMissingLineNumbersInStacktraceAround_pr145442() { + runTest("missing line numbers in stacktrace around"); + } + + public void testGenericArrays_pr158624() { + runTest("generics and arrays"); + } + + public void testMissingLineNumbersInStacktraceBefore_pr145442() { + runTest("missing line numbers in stacktrace before"); + } + + public void testMissingLineNumbersInStacktraceBefore_pr145442_Binary() { + runTest("missing line numbers in stacktrace before - binary"); + } + + public void testAnnotationStylePointcutNPE_pr158412() { + runTest("annotation style pointcut npe"); + } + + public void testAnnotationStylePointcutNPE_pr158412_2() { + runTest("annotation style pointcut npe - 2"); + } + + public void testAnnotationsCallConstructors_pr158126() { + runTest("annotations, call and constructors problem"); + } + + public void testIllegalStateExceptionGenerics_pr153845() { + runTest("IllegalStateException at GenericSignatureParser.java"); + } + + public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_1() { + runTest("no illegal state exception from AsmDelegate - 1"); + } + + public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_2() { + runTest("no illegal state exception from AsmDelegate - 2"); + } + + public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_3() { + runTest("no illegal state exception from AsmDelegate - 3"); + } + + public void testAnnotMethod_pr156962() { + runTest("Test Annot Method"); + } + + public void testAnnotMethodHasMember_pr156962() { + runTest("Test Annot Method Has Member"); + } + + public void testMixingGenerics_pr152848() { + runTest("mixing generics"); + } + + public void testIncorrectStaticinitializationWeaving_pr149560_1() { + runTest("incorrect staticinitialization weaving - codestyle"); + } + + public void testIncorrectStaticinitializationWeaving_pr149560_2() { + runTest("incorrect staticinitialization weaving - annstyle"); + } + + public void testIncorrectDeprecatedAnnotationProcessing_pr154332() { + runTest("incorrect deprecated annotation processing"); + } + + public void testPipeliningProblemWithAnnotationsDecp_pr153380_1() { + runTest("pipelining decps"); + } + + public void testUnwantedPointcutWarning_pr148219() { + runTest("unwanted warning for pointcut"); + } + + public void testDecpAndCflowadderMungerClash_pr152631() { + runTest("decp and cflowadder munger clash"); + } + + public void testGenericInheritanceDecp_pr150095() { + runTest("generics, inheritance and decp"); + } + + public void testIllegalStateException_pr148737() { + runTest("illegalstateexception for non generic type"); + } + + public void testAtajInheritance_pr149305_1() { + runTest("ataj inheritance - 1"); + } + + public void testAtajInheritance_pr149305_2() { + runTest("ataj inheritance - 2"); + } + + public void testAtajInheritance_pr149305_3() { + runTest("ataj inheritance - 3"); + } + + // public void testVerificationFailureForAspectOf_pr148693() { + // runTest("verification problem"); // build the code + // Utils.verifyClass(ajc, "mypackage.MyAspect"); // verify it <<< BRAND NEW VERIFY UTILITY FOR EVERYONE TO TRY ;) + // } + + public void testIncorrectAnnotationValue_pr148537() { + runTest("incorrect annotation value"); + } + + public void testVerifyErrNoTypeCflowField_pr145693_1() { + runTest("verifyErrNoTypeCflowField"); + } + + public void testVerifyErrInpathNoTypeCflowField_pr145693_2() { + runTest("verifyErrInpathNoTypeCflowField"); + } + + public void testCpathNoTypeCflowField_pr145693_3() { + runTest("cpathNoTypeCflowField"); + } + + // public void testAdviceNotWovenAspectPath_pr147841() { runTest("advice not woven on aspectpath");} + public void testGenericSignatures_pr148409() { + runTest("generic signature problem"); + } + + public void testCantFindType_pr149322_01() { + runTest("can't find type on interface call 1"); + } + + public void testCantFindType_pr149322_02() { + runTest("can't find type on interface call 2"); + } + + public void testCantFindType_pr149322_03() { + runTest("can't find type on interface call 3"); + } + + public void testParsingBytecodeLess_pr152871() { + Utility.testingParseCounter = 0; + runTest("parsing bytecode less"); + assertTrue("Should have called parse 2 times, not " + Utility.testingParseCounter + " times", + Utility.testingParseCounter == 2); + // 5 means: // 3 of these are gone with change to UnwovenClassFileWTPMB to take a classname in ctor + // (1)=registerAspect + // (2,3)=checkingIfShouldWeave,AcceptingResult for class + // (4,5)=checkingIfShouldWeave,AcceptingResult for aspect + } + + public void testMatchVolatileField_pr150671() { + runTest("match volatile field"); + } + + public void testDuplicateJVMTIAgents_pr151938() { + runTest("Duplicate JVMTI agents"); + } + + public void testLTWWorldWithAnnotationMatching_pr153572() { + runTest("LTWWorld with annotation matching"); + } + + public void testReweavableAspectNotRegistered_pr129525() { + runTest("reweavableAspectNotRegistered error"); + } + + public void testNPEinConstructorSignatureImpl_pr155972() { + runTest("NPE in ConstructorSignatureImpl"); + } + + public void testNPEinFieldSignatureImpl_pr155972() { + runTest("NPE in FieldSignatureImpl"); + } + + public void testNPEinInitializerSignatureImpl_pr155972() { + runTest("NPE in InitializerSignatureImpl"); + } + + public void testLineNumberTableCorrectWithGenericsForEachAndContinue_pr155763() { + runTest("ensure LineNumberTable correct with generics, for each and continue"); + } + + public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772() { + runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class"); + } + + public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772_2() { + runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2"); + } + + public void testDeclareSoftAndInnerClasses_pr125981() { + runTest("declare soft and inner classes"); + } + + public void testGetSourceSignature_pr148908() { + runTest("ensure getSourceSignature correct with static field"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "MY_COMPARATOR"); + String expected = "static final Comparator MY_COMPARATOR = null;\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "aString"); + expected = "static final String aString = \"Constant String\";\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "bString"); + expected = "static final String bString = aString;\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "cString"); + expected = "static final String cString = (aString + bString);\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "dString"); + expected = "static final String dString = ((aString + \" and \") + bString);\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "eString"); + expected = "static final String eString = \"Hello World\";\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "aList"); + expected = "public List aList = null;\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "bList"); + expected = "public List bList = null;\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "cList"); + expected = "public List cList = null;\n"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + } + + // public void testNPEWithCustomAgent_pr158205() { + // runTest("NPE with custom agent"); + // } + + public void testWeaveConcreteSubaspectWithAdvice_pr132080() { + runTest("Weave concrete sub-aspect with advice"); + } + + public void testWeaveConcreteSubaspectWithITD_pr132080() { + runTest("Weave concrete sub-aspect with ITD"); + } + + public void testWeaveConcreteSubaspectWithAroundClosure_pr132080() { + runTest("Weave concrete sub-aspect with around closure"); + } + + public void testWeaveConcreteSubaspectWithCflow_pr132080() { + runTest("Weave concrete sub-aspect with cflow"); + } + + public void testNPEWithLTWPointcutLibraryAndMissingAspectDependency_pr158957() { + runTest("NPE with LTW, pointcut library and missing aspect dependency"); + } + + public void testNoInvalidAbsoluteTypeNameWarning_pr156904_1() { + runTest("ensure no invalidAbsoluteTypeName when do match - 1"); + } + + public void testNoInvalidAbsoluteTypeNameWarning_pr156904_2() { + runTest("ensure no invalidAbsoluteTypeName when do match - 2"); + } + + public void testNoInvalidAbsoluteTypeNameWarning_pr156904_3() { + runTest("ensure no invalidAbsoluteTypeName when do match - 3"); + } + + public void testNoInvalidAbsoluteTypeNameWarning_pr156904_4() { + runTest("ensure no invalidAbsoluteTypeName when do match - 4"); + } + + public void testNoNPEWithThrownExceptionWarningAndAtAspectj_pr161217() { + runTest("NPE with thrown exception warning and at aspectj"); + } + + public void testJavadocCommentsAreSetIfHaveNormalComments_pr164340() { + runTest("javadoc comments are set if have normal comments"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "foo()"); + assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "bar()"); + assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "goo()"); + assertNull("expected formal comment to be null but" + " found that it was " + ipe.getFormalComment(), ipe + .getFormalComment()); + + } + + public void testBinaryWeavingIntoJava6Library_pr164384() { + runTest("binary weaving into java 6 library"); + } + + public void testCompilanceJava6ThrowsUsageError_pr164384() { + runTest("compliance java 6 throws usage error"); + } + + public void testSourceLevelJava6ThrowsUsageError_pr164384() { + runTest("source level java 6 throws usage error"); + } + + public void testTargetLevelJava6ThrowsUsageError_pr164384() { + runTest("target level java 6 throws usage error"); + } + + public void testStaticImport() { + runTest("ensure static import reference have static modifier set"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.IMPORT_REFERENCE, + "ABC.StaticImport.Alphabet.A"); + String expected = "import static ABC.StaticImport.Alphabet.A;"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + } + + public void testAspected_Annotation() { + runTest("ensure Annotations are added to import list"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.IMPORT_REFERENCE, "annotation.A"); + String expected = "import annotation.A;"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + } + + public void testGetSourceSignature_GenericMethods() { + runTest("ensure getSourceSignature correct with generic method"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "returnT(T)"); + String expected = "public T returnT(T a)"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "returnQ(Q)"); + expected = "public Q returnQ(Q a)"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "doubleGeneric(Q,T)"); + expected = "public void doubleGeneric(Q a, T b)"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + + // Generic Method Constructor + ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CONSTRUCTOR, "C(T)"); + expected = "public C(T b)"; + assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe + .getSourceSignature()); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc153.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/AllTestsAspectJ153.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/AllTestsAspectJ153.java new file mode 100644 index 000000000..2951175f3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/AllTestsAspectJ153.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc153; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ153 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.5.3 tests"); + //$JUnit-BEGIN$ + suite.addTest(Ajc153Tests.suite()); + suite.addTest(JDTLikeHandleProviderTests.suite()); + suite.addTest(PipeliningTests.suite()); + suite.addTest(LTWServer153Tests.suite()); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java new file mode 100644 index 000000000..e26c8c90b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -0,0 +1,553 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.systemtest.ajc153; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { + + // IElementHandleProvider handleProvider; + + protected void setUp() throws Exception { + super.setUp(); + // handleProvider = AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); + } + + protected void tearDown() throws Exception { + super.tearDown(); + // AsmManager.getDefault().setHandleProvider(handleProvider); + } + + public void testMoreThanOneNamedPointcut() { + runTest("More than one named pointcut"); + } + + public void testAspectHandle() { + runTest("aspect handle"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement pe = top.findElementForType("pkg", "A1"); + String expected = "", "", "(java.io.FileNotFoundException))"; + assertNotNull("expected to find node with handle " + handle1 + ", but did not", top.getElement(handle1)); + + String handle2 = "<*Handler.aj[C~method?exception-handler(void C." + "(java.io.FileNotFoundException))!2"; + assertNotNull("expected to find node with handle " + handle2 + ", but did not", top.getElement(handle2)); + } + + public void testIPEsWithSameNameHaveUniqueHandles_get() { + runTest("ipes with same name have unique handles - get"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + String handle1 = "<*Get.aj[C1~method1?field-get(int C1.x)"; + assertNotNull("expected to find node with handle " + handle1 + ", but did not", top.getElement(handle1)); + + String handle2 = "<*Get.aj[C1~method1?field-get(int C1.x)!2"; + assertNotNull("expected to find node with handle " + handle2 + ", but did not", top.getElement(handle2)); + } + + public void testIPEsWithSameNameHaveUniqueHandles_set() { + runTest("ipes with same name have unique handles - set"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + String handle1 = "<*Set.aj[C1~method?field-set(int C1.x)"; + assertNotNull("expected to find node with handle " + handle1 + ", but did not", top.getElement(handle1)); + + String handle2 = "<*Set.aj[C1~method?field-set(int C1.x)!2"; + assertNotNull("expected to find node with handle " + handle2 + ", but did not", top.getElement(handle2)); + } + + public void testTwoPiecesOfBeforeAdviceInInjarAspectHaveUniqueHandles_pr159896() { + runTest("advice with same name in injar aspect should have unique handles"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + String handle1 = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "before(): p..").getHandleIdentifier(); + String handle2 = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "before(): exec..") + .getHandleIdentifier(); + assertFalse("expected the two advice nodes to have unique handles but" + " did not", handle1.equals(handle2)); + try { + AsmManager.lastActiveStructureModel.dumptree(AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void testTwoDeclareWarningsInInjarAspectHaveUniqueHandles_pr159896() { + runTest("declare warnings in injar aspect should have unique handles"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + String handle1 = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"blah\"") + .getHandleIdentifier(); + String handle2 = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"blah2\"") + .getHandleIdentifier(); + assertFalse("expected the two declare warning nodes to have unique handles but" + " did not", handle1.equals(handle2)); + } + + // if have one declare warning and one declare error statement within an + // injar + // aspect, neither of them should have a counter (i.e. "!2") at the end of + // their handle + public void testOnlyIncrementSameDeclareTypeFromInjar_pr159896() { + runTest("dont increment counter for different declares"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + String warning = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_WARNING, + "declare warning: \"warning\"").getHandleIdentifier(); + assertTrue("shouldn't have incremented counter for declare warning handle " + "because only one declare warning statement", + warning.indexOf("!0") == -1 && warning.indexOf("!2") == -1); + String error = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ERROR, "declare error: \"error\"") + .getHandleIdentifier(); + assertTrue("shouldn't have incremented counter for declare error handle " + "because only one declare error statement", + error.indexOf("!0") == -1 && error.indexOf("!2") == -1); + } + + // public void testOnlyIncrementSameAdviceKindFromInjar_pr159896() { + // runTest("dont increment counter for different advice kinds"); + // IHierarchy top = AsmManager.getDefault().getHierarchy(); + // String before = top.findElementForLabel(top.getRoot(), + // IProgramElement.Kind.ADVICE, "before(): p..") + // .getHandleIdentifier(); + // assertTrue("shouldn't have incremented counter for before handle " + // + "because only one before advice", before.indexOf("!0") == -1 + // && before.indexOf("!2") == -1 && before.indexOf("!3") == -1); + // String after = top.findElementForLabel(top.getRoot(), + // IProgramElement.Kind.ADVICE, "after(): p..") + // .getHandleIdentifier(); + // assertTrue("shouldn't have incremented counter for after handle " + // + "because only one after advice", after.indexOf("!0") == -1 + // && after.indexOf("!2") == -1 && after.indexOf("!3") == -1); + // String around = top.findElementForLabel(top.getRoot(), + // IProgramElement.Kind.ADVICE, "around(): p1..") + // .getHandleIdentifier(); + // assertTrue("shouldn't have incremented counter for around handle " + // + "because only one around advice", around.indexOf("!0") == -1 + // && around.indexOf("!2") == -1 && around.indexOf("!3") == -1); + // + // } + + // ---------- following tests ensure we produce the same handles as jdt + // -----// + // ---------- (apart from the prefix) + + // NOTES: there is no ipe equivalent to a package fragment root or + // + + public void testCompilationUnitSameAsJDT() { + // JDT: =TJP Example/src; + runTest("method with generic arg same as jdt"); + compareHandles(IProgramElement.Kind.METHOD, "genericMethod1(java.util.List)", + ";"); + } + + public void testMethodWithTwoGenericArgsSameAsJDT() { + // JDT: =Java5 Handles/src;~QMyGenericClass\; + runTest("method with two generic args same as jdt"); + compareHandles(IProgramElement.Kind.METHOD, "genericMethod2(java.util.List," + + "pkg.MyGenericClass)", ";~QMyGenericClass\\;"); + } + + public void testMethodWithTwoTypeParametersSameAsJDT() { + // JDT: =Java5 Handles/src; + runTest("method with two type parameters same as jdt"); + compareHandles(IProgramElement.Kind.METHOD, "genericMethod4(pkg.MyGenericClass2)", + ";"); + } + + public void testMethodWithTwoArgsSameAsJDT_2() { + // JDT: =Java5 Handles/src; + runTest("method with two args one of which is generic same as jdt"); + compareHandles(IProgramElement.Kind.METHOD, "genericMethod3(int,java.util.List)", + ";"); + } + + /* + * Still to do; PROJECT, PACKAGE, FILE, FILE_ASPECTJ, FILE_LST, DECLARE_ERROR, DECLARE_SOFT, DECLARE_PRECEDENCE, + */ + + // ----------- helper methods --------------- + private void compareHandles(IProgramElement.Kind kind, String ipeName, String expectedHandle) { + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement pe = top.findElementForLabel(top.getRoot(), kind, ipeName); + String found = pe.getHandleIdentifier(); + System.err.println("expected: " + expectedHandle); + System.err.println("actual: " + found); + assertEquals("handleIdentifier - expected " + expectedHandle + ", but found " + found, expectedHandle, found); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(JDTLikeHandleProviderTests.class); + } + + protected File getSpecFile() { + return getClassResource("jdtlikehandleprovider.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/LTWServer153Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/LTWServer153Tests.java new file mode 100644 index 000000000..b307cb30a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/LTWServer153Tests.java @@ -0,0 +1,23 @@ +package org.aspectj.systemtest.ajc153; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class LTWServer153Tests extends XMLBasedAjcTestCase { + + public static Test suite() { + return loadSuite(LTWServer153Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc153.xml"); + } + + public void testHandleDuplicateConfiguration_pr157474 () { + runTest("TestServer with duplicate configuration"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/PipeliningTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/PipeliningTests.java new file mode 100644 index 000000000..9edd04515 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/PipeliningTests.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc153; + +import java.io.File; + +import junit.framework.Test; + +//import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter; +import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * testplan: (x = complete) + * + * x @AspectJ aspects - are they recognized and sorted correctly ? + * x compiling classes (various orderings) + * x compiling classes (inheritance relationships) + * x compiling aspects and classes (various orderings - aspects first/last) + * x eclipse annotation transformation logic + * x aspects extending classes + * x nested types (and aspect inside a regular class) + * x set of files that are only aspects + * x pointcuts in super classes + * - classes with errors + * - aspects with errors + * - Xterminate after compilation (now == skip weaving??) + * + * That this pipeline works OK for large systems is kind of confirmed by using it to build shadows! + * + */ +public class PipeliningTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // straightforward compilation + public void testBuildTwoClasses() { runTest("build two classes");} + public void testBuildOneAspectTwoClasses() { runTest("build one aspect and two classes");} + public void testBuildTwoClassesOneAspect() { runTest("build two classes and one aspect");} + public void testBuildTwoAspects() { runTest("build two aspects");} + public void testBuildClassAndNestedAspect() { runTest("build one class and deeply nested aspect");} + + public void testAspectExtendsClass() { runTest("aspect extends class"); } + + // verifying the type sorting + public void testRecognizingAnnotationStyleAspects1() { + AjPipeliningCompilerAdapter.pipelineTesting=true; + runTest("recognizing annotation style aspects - 1"); + + String filesContainingAspects = AjPipeliningCompilerAdapter.getPipelineDebugOutput("filesContainingAspects"); + assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1")); + + String weaveOrder = AjPipeliningCompilerAdapter.getPipelineDebugOutput("weaveOrder"); + String expectedOrder="[AtAJAspect.java,ClassOne.java]"; + assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder)); + } + public void testRecognizingAnnotationStyleAspects2() { + AjPipeliningCompilerAdapter.pipelineTesting=true; + runTest("recognizing annotation style aspects - 2"); + + String filesContainingAspects = AjPipeliningCompilerAdapter.getPipelineDebugOutput("filesContainingAspects"); + assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1")); + + String weaveOrder = AjPipeliningCompilerAdapter.getPipelineDebugOutput("weaveOrder"); + String expectedOrder="[AtInnerAJAspect.java,ClassOne.java]"; + assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder)); + } + + // verifying the new code for transforming Eclipse Annotations into AspectJ ones + public void testAnnotationTransformation() { runTest("annotation transformation"); } + + // -- + protected void tearDown() throws Exception { + super.tearDown(); + //AjPipeliningCompilerAdapter.pipelineTesting=false; + } + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(PipeliningTests.class); + } + protected File getSpecFile() { + return getClassResource("pipelining.xml"); + } +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/test/java/org/aspectj/systemtest/ajc153/ajc153.xml new file mode 100644 index 000000000..c4300e9c7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/ajc153.xml @@ -0,0 +1,886 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml b/tests/src/test/java/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml new file mode 100644 index 000000000..215240fe4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/pipelining.xml b/tests/src/test/java/org/aspectj/systemtest/ajc153/pipelining.xml new file mode 100644 index 000000000..05b85d1f8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/pipelining.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java new file mode 100644 index 000000000..ebba76303 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc154/Ajc154Tests.java @@ -0,0 +1,442 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc154; + +import java.io.File; +import java.lang.reflect.Field; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.LineNumber; +import org.aspectj.apache.bcel.classfile.LineNumberTable; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.generic.MethodGen; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.tools.ContextBasedMatcher; +import org.aspectj.weaver.tools.FuzzyBoolean; +import org.aspectj.weaver.tools.MatchingContext; +import org.aspectj.weaver.tools.PointcutDesignatorHandler; + +/** + * These are tests for AspectJ1.5.4 + */ +public class Ajc154Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // public void testNewDesignatorsReferencePointcuts_pr205907() { + // BeanDesignatorHandler beanHandler = new BeanDesignatorHandler(); + // Set set = new HashSet(); + // set.add(beanHandler); + // PatternParser.setTestDesignators(set); + // //parser.registerPointcutDesignatorHandler(beanHandler); + // runTest("new pointcut designators in a reference pointcut"); + // } + // public void testAfterThrowingAnnotationStyle_pr211674_1() { runTest("after throwing annotation style problem - 1");} + // public void testAfterThrowingAnnotationStyle_pr211674_2() { runTest("after throwing annotation style problem - 2");} + + // crappy solution - see the bug + // public void testCflowLtwProblem_pr166647_1() { + // try { + // runTest("ltw and cflow problem"); + // } catch (AssertionFailedError afe) { + // // this is OK.... sadly + // // at least lets check we warned the user it was going to happen: + // String stderr = (getLastRunResult() == null ? "" : getLastRunResult().getStdErr()); + // // Expected line: + // // [WeavingURLClassLoader] warning XML Defined aspects must be woven in cases where cflow pointcuts are involved. + // // Currently the include/exclude patterns exclude 'x.Aspect2' [Xlint:mustWeaveXmlDefinedAspects] + // assertTrue("Did not see warning about needing to weave xml defined aspects", stderr + // .indexOf("warning XML Defined aspects must be woven in cases where cflow pointcuts are involved.") != -1); + // assertTrue("Xlint warning was expected '[Xlint:mustWeaveXmlDefinedAspects]'", stderr + // .indexOf("[Xlint:mustWeaveXmlDefinedAspects]") != -1); + // } + // } + + // Testing some issues with declare at type + public void testDeclareAtTypeProblems_pr211052_1() { + runTest("declare atType problems - 1"); + } + + public void testDeclareAtTypeProblems_pr211052_2() { + runTest("declare atType problems - 2"); + } + + public void testDeclareAtTypeProblems_pr211052_3() { + runTest("declare atType problems - 3"); + } + + public void testDeclareAtTypeProblems_pr211052_4() { + runTest("declare atType problems - 4"); + } + + public void testDeclareAtTypeProblems_pr211052_5() { + runTest("declare atType problems - 5"); + } + + // declare at type and binary weaving + public void testDeclareAtTypeProblems_pr211052_6() { + runTest("declare atType problems - 6"); + } + + public void testDeclareAtTypeProblems_pr211052_7() { + runTest("declare atType problems - 7"); + } + + public void testNPEWithMissingAtAspectAnnotationInPointcutLibrary_pr162539_1() { + runTest("NPE with missing @aspect annotation in pointcut library - 1"); + } + + public void testNPEWithMissingAtAspectAnnotationInPointcutLibrary_pr162539_2() { + runTest("NPE with missing @aspect annotation in pointcut library - 2"); + } + + public void testWrongNumberOfTypeParameters_pr176991() { + runTest("wrong number of type parameters"); + } + + public void testArgNamesDoesNotWork_pr148381_1() { + runTest("argNames does not work - simple"); + } + + public void testArgNamesDoesNotWork_pr148381_2() { + runTest("argNames does not work - error1"); + } + + public void testArgNamesDoesNotWork_pr148381_3() { + runTest("argNames does not work - error2"); + } + + public void testArgNamesDoesNotWork_pr148381_4() { + runTest("argNames does not work - error3"); + } + + public void testDecpProblemWhenTargetAlreadyImplements_pr169432_1() { + runTest("declare parents problem when target already implements interface - 1"); + } + + public void testDecpProblemWhenTargetAlreadyImplements_pr169432_2() { + runTest("declare parents problem when target already implements interface - 2"); + } + + public void testDecpProblemWhenTargetAlreadyImplements_pr169432_3() { + runTest("declare parents problem when target already implements interface - 3"); + } + + public void testVariousLtwAroundProblems_pr209019_1() { + runTest("various issues with ltw and around advice - 1"); + } + + public void testVariousLtwAroundProblems_pr209019_2() { + runTest("various issues with ltw and around advice - 2"); + } + + public void testVariousLtwAroundProblems_pr209019_3() { + runTest("various issues with ltw and around advice - 3"); + } + + public void testVariousLtwAroundProblems_pr209019_4() { + runTest("various issues with ltw and around advice - 4"); + } + + public void testAbstractAnnotationStylePointcutWithContext_pr202088() { + runTest("abstract annotation style pointcut with context"); + } + + public void testNoErrorForAtDecpInNormalClass_pr169428() { + runTest("no error for atDecp in normal class"); + } + + public void testJarsZipsNonStandardSuffix_pr186673() { + runTest("jars and zips with non-standard suffix"); + } + + public void testItdOnGenericInnerInterface_pr203646() { + runTest("npe with itd on inner generic interface"); + } + + public void testItdOnGenericInnerInterface_pr203646_A() { + runTest("npe with itd on inner generic interface - exampleA"); + } + + public void testItdOnGenericInnerInterface_pr203646_B() { + runTest("npe with itd on inner generic interface - exampleB"); + } + + public void testItdOnGenericInnerInterface_pr203646_C() { + runTest("npe with itd on inner generic interface - exampleC"); + } + + public void testItdOnGenericInnerInterface_pr203646_D() { + runTest("npe with itd on inner generic interface - exampleD"); + } + + // public void testItdOnGenericInnerInterface_pr203646_E() { runTest("npe with itd on inner generic interface - exampleE");} // + // needs parser change + public void testItdOnGenericInnerInterface_pr203646_F() { + runTest("npe with itd on inner generic interface - exampleF"); + } + + public void testItdOnGenericInnerInterface_pr203646_G() { + runTest("npe with itd on inner generic interface - exampleG"); + } + + public void testItdClashForTypesFromAspectPath_pr206732() { + runTest("itd clash for types from aspectpath"); + } + + // public void testAnnotationStyleAndMultiplePackages_pr197719() { + // runTest("annotation style syntax and cross package extension"); } + + /** + * Complex test that attempts to damage a class like a badly behaved bytecode transformer would and checks if AspectJ can cope. + * + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + public void testCopingWithGarbage_pr175806_1() throws ClassNotFoundException, SecurityException, NoSuchFieldException, + IllegalArgumentException, IllegalAccessException { + + // Compile the program we are going to mess with + runTest("coping with bad tables"); + + // Load up the class and the method 'main' we are interested in + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "A"); + Method[] meths = jc.getMethods(); + Method oneWeWant = null; + for (int i = 0; i < meths.length && oneWeWant == null; i++) { + Method method = meths[i]; + if (method.getName().equals("main")) { + oneWeWant = meths[i]; + } + } + + /** + * For the main method: Stack=2, Locals=3, Args_size=1 0: iconst_5 1: istore_1 2: ldc #18; //String 3 4: astore_2 5: + * getstatic #24; //Field java/lang/System.out:Ljava/io/PrintStream; 8: aload_2 9: invokevirtual #30; //Method + * java/io/PrintStream.println:(Ljava/lang/String;)V 12: goto 23 15: pop 16: getstatic #24; //Field + * java/lang/System.out:Ljava/io/PrintStream; 19: iload_1 20: invokevirtual #33; //Method java/io/PrintStream.println:(I)V + * 23: return Exception table: from to target type 2 15 15 Class java/lang/Exception + * + * LineNumberTable: line 4: 0 line 6: 2 line 7: 5 line 8: 15 line 9: 16 line 11: 23 LocalVariableTable: Start Length Slot + * Name Signature 0 24 0 argv [Ljava/lang/String; 2 22 1 i I 5 10 2 s Ljava/lang/String; + */ + + ConstantPool cp = oneWeWant.getConstantPool(); + // ConstantPool cpg = new ConstantPool(cp); + + // Damage the line number table, entry 2 (Line7:5) so it points to an invalid (not on an instruction boundary) position of 6 + Field ff = LineNumber.class.getDeclaredField("startPC"); + ff.setAccessible(true); + ff.set(oneWeWant.getLineNumberTable().getLineNumberTable()[2], new Integer(6)); + // oneWeWant.getLineNumberTable().getLineNumberTable()[2].setStartPC(6); + + // Should be 'rounded down' when transforming it into a MethodGen, new position will be '5' + // System.out.println("BEFORE\n"+oneWeWant.getLineNumberTable().toString()); + MethodGen toTransform = new MethodGen(oneWeWant, "A", cp, false); + LineNumberTable lnt = toTransform.getMethod().getLineNumberTable(); + assertTrue("Should have been 'rounded down' to position 5 but is " + lnt.getLineNumberTable()[2].getStartPC(), lnt + .getLineNumberTable()[2].getStartPC() == 5); + // System.out.println("AFTER\n"+lnt.toString()); + } + + public void testCopingWithGarbage_pr175806_2() throws ClassNotFoundException { + + // Compile the program we are going to mess with + runTest("coping with bad tables"); + + // Load up the class and the method 'main' we are interested in + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "A"); + Method[] meths = jc.getMethods(); + Method oneWeWant = null; + for (int i = 0; i < meths.length && oneWeWant == null; i++) { + Method method = meths[i]; + if (method.getName().equals("main")) { + oneWeWant = meths[i]; + } + } + // see previous test for dump of main method + + ConstantPool cp = oneWeWant.getConstantPool(); + // ConstantPoolGen cpg = new ConstantPoolGen(cp); + + // Damage the local variable table, entry 2 (" 2 22 1 i I") so it points to an invalid start pc of 3 + oneWeWant.getLocalVariableTable().getLocalVariable(1).setStartPC(3); + + // Should be 'rounded down' when transforming it into a MethodGen, new position will be '2' + // This next line will go BANG with an NPE if we don't correctly round the start pc down to 2 + new MethodGen(oneWeWant, "A", cp, true); + } + + public void testGenericAspectGenericPointcut_pr174449() { + runTest("problem with generic aspect and generic pointcut"); + } + + public void testGenericAspectGenericPointcut_noinline_pr174449() { + runTest("problem with generic aspect and generic pointcut - noinline"); + } + + public void testGenericMethodsAndOrdering_ok_pr171953_2() { + runTest("problem with generic methods and ordering - ok"); + } + + public void testGenericMethodsAndOrdering_bad_pr171953_2() { + runTest("problem with generic methods and ordering - bad"); + } + + public void testItdAndJoinpointSignatureCollection_ok_pr171953() { + runTest("problem with itd and join point signature collection - ok"); + } + + public void testItdAndJoinpointSignatureCollection_bad_pr171953() { + runTest("problem with itd and join point signature collection - bad"); + } + + public void testGenericMethodsAndItds_pr171952() { + runTest("generic methods and ITDs"); + } + + // public void testUsingDecpAnnotationWithoutAspectAnnotation_pr169428() { + // runTest("using decp annotation without aspect annotation");} + public void testItdsParameterizedParameters_pr170467() { + runTest("itds and parameterized parameters"); + } + + public void testComplexGenerics_pr168044() { + runTest("complex generics - 1"); + } + + public void testIncorrectlyMarkingFieldTransient_pr168063() { + runTest("incorrectly marking field transient"); + } + + public void testInheritedAnnotations_pr169706() { + runTest("inherited annotations"); + } + + public void testGenericFieldNPE_pr165885() { + runTest("generic field npe"); + } + + public void testIncorrectOptimizationOfIstore_pr166084() { + runTest("incorrect optimization of istore"); + } + + public void testDualParameterizationsNotAllowed_pr165631() { + runTest("dual parameterizations not allowed"); + } + + public void testSuppressWarnings1_pr166238() { + runTest("Suppress warnings1"); + } + + public void testSuppressWarnings2_pr166238() { + runTest("Suppress warnings2"); + } + + public void testNullReturnedFromGetField_pr172107() { + runTest("null returned from getField()"); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc154Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc154.xml"); + } + + // --- + private class BeanDesignatorHandler implements PointcutDesignatorHandler { + + private String askedToParse; + public boolean simulateDynamicTest = false; + + public String getDesignatorName() { + return "bean"; + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.tools.PointcutDesignatorHandler#parse(java.lang.String) + */ + public ContextBasedMatcher parse(String expression) { + this.askedToParse = expression; + return new BeanPointcutExpression(expression, this.simulateDynamicTest); + } + + public String getExpressionLastAskedToParse() { + return this.askedToParse; + } + } + + private class BeanPointcutExpression implements ContextBasedMatcher { + + private final String beanNamePattern; + private final boolean simulateDynamicTest; + + public BeanPointcutExpression(String beanNamePattern, boolean simulateDynamicTest) { + this.beanNamePattern = beanNamePattern; + this.simulateDynamicTest = simulateDynamicTest; + } + + public boolean couldMatchJoinPointsInType(Class aClass) { + return true; + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.tools.ContextBasedMatcher#couldMatchJoinPointsInType(java.lang.Class) + */ + public boolean couldMatchJoinPointsInType(Class aClass, MatchingContext context) { + if (this.beanNamePattern.equals(context.getBinding("beanName"))) { + return true; + } else { + return false; + } + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.tools.ContextBasedMatcher#mayNeedDynamicTest() + */ + public boolean mayNeedDynamicTest() { + return this.simulateDynamicTest; + } + + public FuzzyBoolean matchesStatically(MatchingContext matchContext) { + if (this.simulateDynamicTest) { + return FuzzyBoolean.MAYBE; + } + if (this.beanNamePattern.equals(matchContext.getBinding("beanName"))) { + return FuzzyBoolean.YES; + } else { + return FuzzyBoolean.NO; + } + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.tools.ContextBasedMatcher#matchesDynamically(org.aspectj.weaver.tools.MatchingContext) + */ + public boolean matchesDynamically(MatchingContext matchContext) { + return this.beanNamePattern.equals(matchContext.getBinding("beanName")); + } + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc154/AllTestsAspectJ154.java b/tests/src/test/java/org/aspectj/systemtest/ajc154/AllTestsAspectJ154.java new file mode 100644 index 000000000..625327344 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc154/AllTestsAspectJ154.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc154; + + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ154 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.5.4 tests"); + //$JUnit-BEGIN$ + suite.addTest(Ajc154Tests.suite()); + // removed for now - it keeps creating unwanted directories in the source tree rather than building into the sandbox +// suite.addTestSuite(CustomMungerExtensionTest.class); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java b/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java new file mode 100644 index 000000000..7c0d26d4c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java @@ -0,0 +1,137 @@ +/* ******************************************************************* + * Copyright (c) 2007 Contributors + * 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: + * Linton Ye https://bugs.eclipse.org/bugs/show_bug.cgi?id=193065 + * ******************************************************************/ + +package org.aspectj.systemtest.ajc154; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.aspectj.ajde.core.AjCompiler; +import org.aspectj.bridge.ISourceLocation; +import org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbed; +import org.aspectj.weaver.Checker; +import org.aspectj.weaver.ConcreteTypeMunger; +import org.aspectj.weaver.CustomMungerFactory; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.ResolvedTypeMunger; +import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.ShadowMunger; +import org.aspectj.weaver.World; +import org.aspectj.weaver.patterns.DeclareErrorOrWarning; +import org.aspectj.weaver.patterns.IfPointcut; +import org.aspectj.weaver.patterns.Pointcut; + +public class CustomMungerExtensionTest extends AjdeInteractionTestbed { + + File oldSandBoxDir; + + protected void setUp() throws Exception { + super.setUp(); + oldSandBoxDir = sandboxDir; + sandboxDir = new File("../tests"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + sandboxDir = oldSandBoxDir; + } + + public void testExtension() { + String testFileDir = "bugs/pointcutdoctor-bug193065"; + AjCompiler compiler = getCompilerForProjectWithName(testFileDir); + compiler.setCustomMungerFactory(new DumbCustomMungerFactory()); + + doBuild(testFileDir); + + CustomMungerFactory factory = (CustomMungerFactory) compiler.getCustomMungerFactory(); + assertTrue(factory.getAllCreatedCustomShadowMungers().size() > 0); + for (Iterator i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();) { + assertTrue(((DumbShadowMunger) i.next()).called); + } + + assertTrue(factory.getAllCreatedCustomTypeMungers().size() > 0); + for (Iterator i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();) { + assertTrue(((DumbTypeMunger) i.next()).called); + } + } + + class DumbCustomMungerFactory implements CustomMungerFactory { + Collection allShadowMungers = new ArrayList(); + Collection allTypeMungers = new ArrayList(); + + public Collection createCustomShadowMungers(ResolvedType aspectType) { + List mungers = new ArrayList(); + Pointcut pointcut = new IfPointcut("abc"); + mungers.add(new DumbShadowMunger(new DeclareErrorOrWarning(false, pointcut, ""))); + allShadowMungers.addAll(mungers); + return mungers; + } + + public Collection createCustomTypeMungers(ResolvedType aspectType) { + List mungers = new ArrayList(); + mungers.add(new DumbTypeMunger(null, aspectType)); + allTypeMungers.addAll(mungers); + return mungers; + } + + public Collection getAllCreatedCustomShadowMungers() { + return allShadowMungers; + } + + public Collection getAllCreatedCustomTypeMungers() { + return allTypeMungers; + } + } + + class DumbShadowMunger extends Checker { + public DumbShadowMunger(DeclareErrorOrWarning deow) { + super(deow); + } + + public ISourceLocation getSourceLocation() { + return ISourceLocation.EMPTY; + } + + boolean called; + + public boolean match(Shadow shadow, World world) { + called = true; + return false; + } + } + + class DumbTypeMunger extends ConcreteTypeMunger { + boolean called; + + public DumbTypeMunger(ResolvedTypeMunger munger, ResolvedType aspectType) { + super(munger, aspectType); + } + + public ConcreteTypeMunger parameterizedFor(ResolvedType targetType) { + return null; + } + + public boolean matches(ResolvedType onType) { + called = true; + return false; + } + + public ConcreteTypeMunger parameterizeWith(Map parameterizationMap, World world) { + // TODO Auto-generated method stub + return null; + } + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc154/ajc154.xml b/tests/src/test/java/org/aspectj/systemtest/ajc154/ajc154.xml new file mode 100644 index 000000000..9cb0eae87 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc154/ajc154.xml @@ -0,0 +1,491 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/Ajc160Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/Ajc160Tests.java new file mode 100644 index 000000000..5f5162b0d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/Ajc160Tests.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2007-2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc160; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * These are tests for AspectJ1.6.0 + */ +public class Ajc160Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // AspectJ1.6.0rc1 + // public void testPipelineCompilationGenericReturnType_pr226567() { + // runTest("pipeline compilation and generic return type"); + // } + public void testPipelineCompilationAnonymous_pr225916() { + runTest("pipeline compilation and anonymous type"); + } + + public void testGenericITDs_pr214994() { + runTest("generic itd"); + } + + public void testGenericDecpLtw_pr223605() { + runTest("generic decp ltw"); + } + + public void testDuplicateITDsNPE_pr173602() { + runTest("duplicate itd npe"); + } + + public void testLTWITDs_pr223094() { + runTest("ltw inherited itds"); + } + + // public void testBrokenIfArgsCflowAtAj_pr145018() { + // runTest("ataj crashing with cflow, if and args"); + // } + public void testClassCastOnArrayType_pr180264() { + runTest("classcastexception on array type"); + } + + // public void testITDWithArray_pr201748() { runTest("itd with array");} + public void testBadMessage() { + runTest("incorrect itd error with generics"); + } + + public void testBadMessage2() { + runTest("incorrect itd error with generics - 2"); + } + + public void testHasMethodAnnoValueInt_various() { + runTest("hasmethod anno value - I"); + } + + public void testHasMethodAnnoValueBoolean_various() { + runTest("hasmethod anno value - Z"); + } + + public void testHasMethodAnnoValueString_various() { + runTest("hasmethod anno value - S"); + } + + public void testGenericTypeParameterizedWithArrayType_pr167197() { + runTest("generic type parameterized with array type"); + } + + public void testGenericTypeParameterizedWithArrayType_pr167197_2() { + runTest("generic type parameterized with array type - 2"); + } + + // AspectJ1.6.0m2 and earlier + public void testBoundsCheckShouldFail_pr219298() { + runTest("bounds check failure"); + } + + public void testBoundsCheckShouldFail_pr219298_2() { + runTest("bounds check failure - 2"); + } + + public void testGenericMethodMatching_pr204505_1() { + runTest("generics method matching - 1"); + } + + public void testGenericMethodMatching_pr204505_2() { + runTest("generics method matching - 2"); + } + + public void testDecFieldProblem_pr218167() { + runTest("dec field problem"); + } + + public void testGenericsSuperITD_pr206911() { + runTest("generics super itd"); + } + + public void testGenericsSuperITD_pr206911_2() { + runTest("generics super itd - 2"); + } + + public void testSerializationAnnotationStyle_pr216311() { + runTest("serialization and annotation style"); + } + + public void testDecpRepetition_pr214559() { + runTest("decp repetition problem"); + } // all code in one file + + public void testDecpRepetition_pr214559_2() { + runTest("decp repetition problem - 2"); + } // all code in one file, default package + + public void testDecpRepetition_pr214559_3() { + runTest("decp repetition problem - 3"); + } // across multiple files + + public void testISEAnnotations_pr209831() { + runTest("illegal state exception with annotations"); + } + + public void testISEAnnotations_pr209831_2() { + runTest("illegal state exception with annotations - 2"); + } + + // See HasMemberTypePattern.hasMethod() + // public void testHasMethodSemantics() { runTest("hasmethod semantics"); } + + // See BcelTypeMunger line 786 relating to these + // String sig = interMethodDispatcher.getSignature();BROKE - should get the generic signature here and use that. + // public void testITDLostGenerics_pr211146() { runTest("itd lost generic signature");} + // public void testITDLostGenerics_pr211146_2() { runTest("itd lost generic signature - field");} + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc160Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc160.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/AllTestsAspectJ160.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/AllTestsAspectJ160.java new file mode 100644 index 000000000..1a47719e6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/AllTestsAspectJ160.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc160; + + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ160 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.0 tests"); + //$JUnit-BEGIN$ + suite.addTest(ParameterAnnotationMatchingTests.suite()); + suite.addTest(AnnotationValueMatchingTests.suite()); + suite.addTest(SanityTests.suite()); + suite.addTest(NewFeatures.suite()); + suite.addTest(Ajc160Tests.suite()); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/AnnotationValueMatchingTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/AnnotationValueMatchingTests.java new file mode 100644 index 000000000..d26cb9856 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/AnnotationValueMatchingTests.java @@ -0,0 +1,55 @@ +/* ******************************************************************* + * Copyright (c) 2008 Contributors + * 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 + * Andy Clement + * ******************************************************************/ +package org.aspectj.systemtest.ajc160; + + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Parameter value matching + * + */ +public class AnnotationValueMatchingTests extends XMLBasedAjcTestCase { + + public void testParsing() { runTest("parsing"); } + public void testBroken1() { runTest("broken - 1"); } + public void testParsingAllAnnotationValueKinds() { runTest("allkinds"); } + public void testSimpleCase() { runTest("simple"); } + public void testReferencingEnums1() { runTest("enum references - 1"); } + public void testReferencingEnums2() { runTest("enum references - 2"); } + public void testReferencingEnums3() { runTest("enum references - 3"); } + public void testIntValueMatching() { runTest("int value matching");} + public void testFloatValueMatching() { runTest("float value matching");} + public void testDoubleValueMatching() { runTest("double value matching");} + public void testByteValueMatching() { runTest("byte value matching");} + public void testLongValueMatching() { runTest("long value matching");} + public void testBooleanValueMatching() { runTest("boolean value matching");} + public void testShortValueMatching() { runTest("short value matching");} + public void testCharValueMatching() { runTest("char value matching");} + public void testStringValueMatching() { runTest("string value matching");} + public void testExampleOne() { runTest("example one");} + public void testError_InvalidValueTypes() { runTest("error case");} + public void testErrorOne_NonExistingValue() { runTest("error - non existing value");} + + ///////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AnnotationValueMatchingTests.class); + } + + protected File getSpecFile() { + return getClassResource("annotationValueMatching.xml"); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/NewFeatures.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/NewFeatures.java new file mode 100644 index 000000000..03c8d4f50 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/NewFeatures.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc160; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Supporting -Xset:weaveJavaPackages=true and -Xset:weaveJavaxPackages=true + public void testWeaveJavaxClassesNo() { runTest("weave javax classes - no");} + public void testWeaveJavaxClassesYes() { runTest("weave javax classes - yes");} + + ///////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(NewFeatures.class); + } + + protected File getSpecFile() { + return getClassResource("newfeatures-tests.xml"); + } + + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java new file mode 100644 index 000000000..95a3f218f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java @@ -0,0 +1,98 @@ +/* ******************************************************************* + * Copyright (c) 2008 Contributors + * 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 + * Andy Clement + * ******************************************************************/ +package org.aspectj.systemtest.ajc160; + + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Parameter annotation matching + * + * The full implementation will require static matching, binding and possibly runtime + * matching (need to check on inheritance of annotations specified in these positions). + * The extension to the syntax for method-signatures is to require parentheses when + * specifying annotations relating to parameters and parameter types - the position of + * the parentheses enable the distinction to be made between annotations attached to + * the type of the parameter and annotations attached to the parameter itself. + * + * For example: + * + * public void goo(MyType s) {} // where MyType has annotation @B + * public void foo(@A String s) {} // String has no annotations, @A is a parameter annotation + * + * A method signature to match the former would be: + * execution(public void goo(@B MyType)) + * or execution(public void goo((@B MyType))) + * + * To match the latter: + * execution(public void foo(@A (String))) + * The parentheses around String are telling us that there are no annotations attached to the + * parameter type we are interested in, and @A should be treated as an intent to match on + * parameter annotation A. + * + * In a more complex case: + * public void hoo(@A MyType s) {} // now there are two potential annotations we are interested in + * the match expression is: + * execution(public void hoo(@A (@B MyType))) + * the parentheses associating @B with the type of the parameter leaving @A outside to be + * treated as a parameter annotation. + * + * Testplan: + * Test cases for the parameter annotation matching: + * DONE: + * 1. Basic pointcut parsing for the new method signature syntax + * 2. Expression matching with the new syntax + * 3. Real static matching with the new syntax + * 4. hasmethod should pick up the new syntax + * 5. ellipsis usage not impacted + * 6. recognizing varargs + * 7. constructor matching + * 8. binary weaving + * + * NOT DONE: + * . New pointcut designator parsing + * . Expression matching with the new syntax + * . Real matching with the new syntax + * . Binding with the new syntax. + * . complaining about annotations that dont target the right type + * . itds + * . annotation visibility tests + * . wildcarded @Ann*1 - broken (not my doing) + * . ltw + * + */ +public class ParameterAnnotationMatchingTests extends XMLBasedAjcTestCase { + + public void testDeow() { runTest("deow"); } + public void testDeow2() { runTest("deow2"); } + public void testNoWarningForWrongType() { runTest("no xlint for wrong target");} + public void testVariousCombinations() { runTest("various combinations"); } + public void testVariousCombinationsCtors() { runTest("various combinations - ctors"); } + public void testHasMethod() { runTest("hasmethod"); } + public void testBinaryWeaving() { runTest("binary weaving"); } + // this is broken and it was already broken before I added parameter annotation matching ! +// public void testWildcardedAnnotationMatching() { runTest("wildcarded matching"); } + + + ///////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(ParameterAnnotationMatchingTests.class); + } + + protected File getSpecFile() { + return getClassResource("parameterAnnotations.xml"); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java new file mode 100644 index 000000000..45eac49ce --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc160; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.Code; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/* + * Some very trivial tests that help verify things are OK. + * Followed by some Java6 specific checks to ensure the class files are well formed. + * A Java6 JDK is not required to run these tests as they introspect the .class files + * rather than executing them. + */ +public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + // Check the version number in the classfiles is correct when Java6 options specified + public void testVersionCorrect1() throws ClassNotFoundException { + runTest("simple - j"); + checkVersion("A", 50, 0); + } + + public void testVersionCorrect2() throws ClassNotFoundException { + runTest("simple - k"); + checkVersion("A", 50, 0); + } + + public void testVersionCorrect3() throws ClassNotFoundException { + runTest("simple - l"); + checkVersion("A", 50, 0); + } + + public void testVersionCorrect4() throws ClassNotFoundException {// check it is 49.0 when -1.5 is specified + runTest("simple - m"); + checkVersion("A", 49, 0); + } + + // Check the stackmap stuff appears for methods in a Java6 file + // public void testStackMapAttributesAppear() throws ClassNotFoundException { + // runTest("simple - n"); + // checkStackMapExistence("A","_"); + // checkStackMapExistence("X","__ajc$pointcut$$complicatedPointcut$1fe"); + // } + + /* For the specified class, check that each method has a stackmap attribute */ + @SuppressWarnings("unused") + private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException { + toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_"; + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + Method[] methods = jc.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (toIgnore.contains("_" + method.getName() + "_")) { + continue; + } + boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable"); + if (!hasStackMapAttribute) { + fail("Could not find StackMap attribute for method " + method.getName()); + } + } + } + + private boolean findAttribute(Attribute[] attrs, String attributeName) { + if (attrs == null) { + return false; + } + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals(attributeName)) { + return true; + } + // System.out.println(attribute.getName()); + if (attribute.getName().equals("Code")) { + Code c = (Code) attribute; + Attribute[] codeAttributes = c.getAttributes(); + for (int j = 0; j < codeAttributes.length; j++) { + Attribute codeAttribute = codeAttributes[j]; + if (codeAttribute.getName().equals(attributeName)) { + return true; + // System.out.println(codeAttribute.getName()); + } + } + } + } + return false; + } + + private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + if (jc.getMajor() != major) { + fail("Expected major version to be " + major + " but was " + jc.getMajor()); + } + if (jc.getMinor() != minor) { + fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); + } + } + + // Check the stackmap stuff is removed when a method gets woven (for now...) + // public void testStackMapAttributesDeletedInWovenCode() { + // fail("Not implemented"); + // } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTests.class); + } + + protected File getSpecFile() { + return getClassResource("sanity-tests.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/ajc160.xml b/tests/src/test/java/org/aspectj/systemtest/ajc160/ajc160.xml new file mode 100644 index 000000000..6e02e8903 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/ajc160.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/annotationValueMatching.xml b/tests/src/test/java/org/aspectj/systemtest/ajc160/annotationValueMatching.xml new file mode 100644 index 000000000..ebcc8b4c2 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/annotationValueMatching.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/newfeatures-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc160/newfeatures-tests.xml new file mode 100644 index 000000000..3b00c8d15 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/newfeatures-tests.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/parameterAnnotations.xml b/tests/src/test/java/org/aspectj/systemtest/ajc160/parameterAnnotations.xml new file mode 100644 index 000000000..1f06e2d82 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/parameterAnnotations.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/sanity-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc160/sanity-tests.xml new file mode 100644 index 000000000..3d5654361 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/sanity-tests.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java new file mode 100644 index 000000000..cbe5e788b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -0,0 +1,204 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc161; + +import java.io.File; +import java.util.Iterator; +import java.util.Set; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IRelationshipMap; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // AspectJ1.6.1 + public void testSignatureProcessing_pr237447() { + runTest("signature processing"); + } + + public void testGenericAtAround_pr237419() { + runTest("generics ataround"); + } + + public void testGenericMarkerMatch_pr203367() { + runTest("generic marker match"); + } + + // public void testSuperItds_pr134425() { runTest("super itds"); } + public void testSuperItds_pr198196_1() { + runTest("super itds - 2"); + } + + public void testSuperItds_pr198196_2() { + runTest("super itds - 3"); + } + + public void testSuperItds_pr198196_3() { + runTest("super itds - 4"); + } + + public void testDeow_pr237381_1() { + runTest("ataspectj deow - 1"); + } + + public void testDeow_pr237381_2() { + runTest("ataspectj deow - 2"); + } + + public void testRunningBrokenCode_pr102733_2() { + runTest("running broken code - 2"); + } + + public void testRunningBrokenCode_pr102733() { + runTest("running broken code"); + } + + public void testErrorOnNonabstractGenericAtAspectJAspect_pr168982() { + runTest("error on non-abstract generic ataspectj aspect"); + } + + public void testIgnoringTypeLevelSuppression_pr234933() { + runTest("ignoring type level suppress"); + } + + public void testDuplicateMethodSignature_pr223226_2() { + runTest("duplicate method signature - 2"); + } + + public void testDuplicateMethodSignature_pr223226() { + runTest("duplicate method signature"); + } + + public void testProtectedMethodsAroundAdvice_pr197719_2() { + runTest("protected methods and around advice - again - 2"); + } + + public void testProtectedMethodsAroundAdvice_pr197719() { + runTest("protected methods and around advice - again"); + } + + public void testProtectedMethodsAroundAdvice_pr230075() { + runTest("protected methods and around advice"); + } + + public void testFinalStringsAnnotationPointcut_pr174385() { + runTest("static strings in annotation pointcuts"); + } + + public void testComplexBoundsGenericAspect_pr199130_1() { + runTest("complex bounds on generic aspect - 1"); + } + + public void testComplexBoundsGenericAspect_pr199130_2() { + runTest("complex bounds on generic aspect - 2"); + } + + public void testComplexBoundsGenericAspect_pr199130_3() { + runTest("complex bounds on generic aspect - 3"); + } + + public void testPrivilegedGenericAspect_pr235505() { + runTest("privileged generic aspect"); + } + + public void testPrivilegedGenericAspect_pr235505_2() { + runTest("privileged generic aspect - 2"); + } + + public void testParsingAroundNoReturn_pr64222() { + runTest("parsing around advice no return"); + } + + public void testParsingBeforeArrayRef_pr159268() { + runTest("before array name"); + } + + public void testGenericAspectAroundAdvice_pr226201() { + runTest("generic aspect around advice"); + } + + public void testCrazyGenericsInnerTypes_pr235829() { + runTest("crazy generics and inner types"); + } + + public void testAnnotationExposureGenerics_pr235597() { + runTest("annotation exposure and generics"); + } + + public void testIncorrectRelationship_pr235204() { + runTest("incorrect call relationship"); + IRelationshipMap irm = AsmManager.lastActiveStructureModel.getRelationshipMap(); + Set entries = irm.getEntries(); + boolean gotSomethingValid = false; + String expected = " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc161/annotationFieldBinding.xml b/tests/src/test/java/org/aspectj/systemtest/ajc161/annotationFieldBinding.xml new file mode 100644 index 000000000..94b99951a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc161/annotationFieldBinding.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1610/Ajc1610Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1610/Ajc1610Tests.java new file mode 100644 index 000000000..80d85d9e8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1610/Ajc1610Tests.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1610; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc1610Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + + public void testNPE_pr363962() { + runTest("pr363962"); + } + + public void testOffset0_bug324932() { + runTest("pr324932"); + } + + public void testOffset0_bug324932_2() { + runTest("pr324932 - 2"); + } + + public void testAbstractAspectDeclareParents_322446() { + runTest("declare parents abstract aspect"); + } + + public void testAbstractAspectAndDeclares_322272_2() { + runTest("abstract aspects and declares - 2"); + } + + public void testAbstractAspectAndDeclares_322272() { + runTest("abstract aspects and declares"); + } + + // Interesting new behaviour on AspectJ 1.6.9 - probably due to initial inner type changes. + // Looks a real error (creating two annotations the same on a type is a bad thing) + // public void testDuplicateAnnotations() { + // runTest("duplicate annotation"); + // } + + public void testLoadingOldCode_319431() { + runTest("loading old code"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1610Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1610.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java b/tests/src/test/java/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java new file mode 100644 index 000000000..2dd2ebf1e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1610; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1610 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.10 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1610Tests.suite()); + suite.addTest(NewFeatures.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1610/NewFeatures.java b/tests/src/test/java/org/aspectj/systemtest/ajc1610/NewFeatures.java new file mode 100644 index 000000000..588d71186 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1610/NewFeatures.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2010 Lucierna + * 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: + * Abraham Nevado - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1610; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testMakeSJPOptimizationLDCNo() { + this.runTest("makeSJP optimization - LDC - No"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + NewFeatures.assertTrue("For 1.4 it must use classForName", preClinitMethod.getCode().toString().contains("forName")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + @SuppressWarnings("unused") + public void testMakeSJPOptimizationCollapsedSJPYes14() { + this.runTest("makeSJP optimization - Collapsed SJP - Yes 1.4"); + try { + JavaClass myClass = getMyClass("B"); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + public void testMakeSJPOptimizationLDCYes() { + this.runTest("makeSJP optimization - LDC - Yes"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + NewFeatures.assertTrue("For 1.5 it must not use classForName", !preClinitMethod.getCode().toString() + .contains("forName")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + public void testMakeSJPOptimizationCollapsedSJPYes() { + this.runTest("makeSJP optimization - Collapsed SJP - Yes"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + NewFeatures.assertTrue("MakedMethodSig MUST not be present", + !preClinitMethod.getCode().toString().contains("makeMethodSig")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + public void testMakeSJPOptimizationCollapsedSJPNo() { + this.runTest("makeSJP optimization - Collapsed SJP - No"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + NewFeatures.assertTrue("MakedMethodSig required", preClinitMethod.getCode().toString().contains("makeMethodSig")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + public void testMakeSJPOptimizationNoExceptionNo() { + this.runTest("makeSJP optimization - No Exception - No"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + NewFeatures + .assertTrue( + "MakedMethodSig required", + preClinitMethod + .getCode() + .toString() + .contains( + "invokevirtual org.aspectj.runtime.reflect.Factory.makeMethodSig (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/aspectj/lang/reflect/MethodSignature;")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + public void testMakeSJPOptimizationNoExceptionYes() { + this.runTest("makeSJP optimization - No Exception - Yes"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + NewFeatures + .assertTrue( + "MakedMethodSig required", + preClinitMethod + .getCode() + .toString() + .contains( + "org.aspectj.runtime.reflect.Factory.makeSJP (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lorg/aspectj/lang/JoinPoint$StaticPart;")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + public void testMakeSJPOptimizationRemoveExtraColon() { + this.runTest("makeSJP optimization - Remove Colon"); + try { + JavaClass myClass = getMyClass("B"); + Method preClinitMethod = getPreClinitMethod(myClass); + System.out.println(preClinitMethod.getCode().toString()); + NewFeatures.assertTrue("MakedMethodSig required", + preClinitMethod.getCode().toString().contains("50: ldc \"java.lang.String\" (108)")); + } catch (Exception e) { + NewFeatures.fail(e.toString()); + } + } + + // /////////////////////////////////////// + + private Method getPreClinitMethod(JavaClass myClass) { + Method lm[] = myClass.getMethods(); + for (int i = 0; i < lm.length; i++) { + if (lm[i].getName().equals("ajc$preClinit")) { + return lm[i]; + } + } + return null; + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(NewFeatures.class); + } + + private JavaClass getMyClass(String className) throws ClassNotFoundException { + return getClassFrom(ajc.getSandboxDirectory(), className); + } + + protected File getSpecFile() { + return getClassResource("newfeatures-tests.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1610/ajc1610.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1610/ajc1610.xml new file mode 100644 index 000000000..7dce456b7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1610/ajc1610.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml new file mode 100644 index 000000000..d6a2b7652 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml @@ -0,0 +1,113 @@ + + + + + +"makeSJP optimization - LDC - YES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1611/Ajc1611Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1611/Ajc1611Tests.java new file mode 100644 index 000000000..de0c20a89 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1611/Ajc1611Tests.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1611; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.systemtest.ajc150.GenericsTests; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc1611Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // error without the fix: + // Second.java:8:0::0 Bound mismatch: The generic method foo(R, Class) of type II is not applicable for the arguments (E1, + // Class). The inferred type capture#1-of ? extends E2 is not a valid substitute for the bounded + // parameter + public void testBoundsChecking_pr336880() { + runTest("bounds check confusion"); + } + + public void testClashingItds_pr336774() { + runTest("clashing itds"); + } + + public void testBadGenericSigAttribute_pr336745() { + runTest("incorrect signature"); + JavaClass jc = GenericsTests.getClass(ajc, "C"); + assertNotNull(jc); + Method m = getMethod(jc, "m"); + Method mitd = getMethod(jc, "mitd"); + assertEquals("(TT;)V", m.getGenericSignature()); + assertEquals("(TT;)V", mitd.getGenericSignature()); + } + + private Method getMethod(JavaClass jc, String name) { + for (Method m : jc.getMethods()) { + if (m.getName().equals(name)) { + return m; + } + } + return null; + } + + public void testESJP_336471() { + runTest("esjp"); + } + + public void testITIT_336136() { + runTest("itit"); + } + + public void testITIT_336136_2() { + runTest("itit - 2"); + } + + public void testDeserialization_335682() { + runTest("pr335682"); + } + + public void testDeserialization_335682_2() { + runTest("pr335682 - 2"); + } + + public void testDeserialization_335682_3() { + runTest("pr335682 - 3"); + } + + public void testDeserialization_335682_5() { + runTest("pr335682 - 5"); + } + + public void testNPEAddSerialVersionUID_bug335783() { + runTest("pr335783"); + } + + public void testGenericsAndItds_333469() { + runTest("pr333469"); + } + + public void testMissingType_332388() { + runTest("pr332388"); + } + + public void testMissingType_332388_2() { + runTest("pr332388 - 2"); + } + + public void testDeclareField_328840() { + runTest("pr328840"); + } + + // public void testAnnoStyleAdviceChain_333274() { + // runTest("anno style advice chain"); + // } + // + // public void testAnnoStyleAdviceChain_333274_2() { + // runTest("code style advice chain"); + // } + // + // public void testAnnoStyleAdviceChain_333274_3() { + // runTest("code style advice chain - no inline"); + // } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1611Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1611.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1611/AllTestsAspectJ1611.java b/tests/src/test/java/org/aspectj/systemtest/ajc1611/AllTestsAspectJ1611.java new file mode 100644 index 000000000..d52d22ea7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1611/AllTestsAspectJ1611.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1611; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1611 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.11 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1611Tests.suite()); + suite.addTest(NewFeatures.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1611/NewFeatures.java b/tests/src/test/java/org/aspectj/systemtest/ajc1611/NewFeatures.java new file mode 100644 index 000000000..58a8f0ae2 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1611/NewFeatures.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2010 Lucierna + * 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: + * Abraham Nevado - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1611; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testAddingRemoving() { + runTest("adding and removing"); + } + + public void testAddingRemoving2() { + runTest("adding and removing - 2"); + } + + public void testAddingRemoving3() { + runTest("adding and removing - 3"); + } + + public void testDeclareMinus() { + runTest("declare minus - 1"); + } + + public void testDeclareMinusItd() { + runTest("declare minus - itd"); + } + + public void testDeclareMinus2annos() { + runTest("declare minus - 2 annos"); + } + + public void testDeclareMinusmultifiles() { + runTest("declare minus - multifiles"); + } + + public void testDeclareMinusmultifiles2() { + runTest("declare minus - multifiles - 2"); + } + + public void testDeclareMinusmultifiles3() { + runTest("declare minus - multifiles - 3"); + } + + public void testDeclareMinusWithValues() { + runTest("declare minus - with values"); + } + + public void testDeclareMinusUnsupported() { + runTest("declare minus - unsupported"); + } + + public void testBinaryWeaving() { + runTest("binary weaving"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(NewFeatures.class); + } + + protected File getSpecFile() { + return getClassResource("newfeatures-tests.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1611/ajc1611.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1611/ajc1611.xml new file mode 100644 index 000000000..beb922924 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1611/ajc1611.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " + + + + + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml new file mode 100644 index 000000000..914042633 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1612/Ajc1612Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1612/Ajc1612Tests.java new file mode 100644 index 000000000..347b63e17 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1612/Ajc1612Tests.java @@ -0,0 +1,420 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1612; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.asm.internal.ProgramElement; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc1612Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // public void testAnnoCopying_345515() { + // runTest("anno copying"); + // } + + // public void testDoubleITDF() throws Exception { + // runTest("double itdf"); + // } + + // public void testItdSplitCompilation_354683() throws Exception { + // runTest("itd split compilation"); + // } + + public void testClassCast_327141() { + runTest("classcast"); + } + + public void testXmlDefs() { + runTest("xml defined advice"); + } + + public void testXmlDefs2() { + runTest("xml defined advice 2"); + } + + // using a parameter + public void testXmlDefs3() { + runTest("xml defined advice 3"); + } + + // using bad parameters + public void testXmlDefs4() { + runTest("xml defined advice 4"); + } + + // binding + public void testXmlDefs5() { + runTest("xml defined advice 5"); + } + + // before and after advice + public void testXmlDefs6() { + runTest("xml defined advice 6"); + } + + // thisJoinPoint + public void testXmlDefs7() { + runTest("xml defined advice 7"); + } + + // thisJoinPointStaticPart + public void testXmlDefs8() { + runTest("xml defined advice 8"); + } + + // void around advice + public void testXmlDefs9() { + runTest("xml defined advice 9"); + } + + // non-void around advice + public void testXmlDefs10() { + runTest("xml defined advice 10"); + } + + // non-void around advice with proceed + public void testXmlDefs11() { + runTest("xml defined advice 11"); + } + + // non primitive return (that is actually used) and proceed + public void testXmlDefs12() { + runTest("xml defined advice 12"); + } + + // delegate type in package + public void testXmlDefs13() { + runTest("xml defined advice 13"); + } + + public void testCorrespondingType_357582() { + for (int i = 0; i < 100000; i++) { + assertEquals("AAA", convert("AAA")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("A", convert("aa.ba.ca.A")); + assertEquals("AAA<>", convert("a.b.c.AAA<>")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("AAA>", convert("a.b.c.AAA>")); + assertEquals("AAA,AA>>", convert("a.b.c.AAA,a.b.c.AA>>")); + } + long time = System.currentTimeMillis(); + for (int i = 0; i < 1000000; i++) { + assertEquals("AAA", convert("AAA")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("A", convert("aa.ba.ca.A")); + assertEquals("AAA<>", convert("a.b.c.AAA<>")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("AAA", convert("a.b.c.AAA")); + assertEquals("AAA>", convert("a.b.c.AAA>")); + assertEquals("AAA,AA>>", convert("a.b.c.AAA,a.b.c.AA>>")); + } + System.out.println(System.currentTimeMillis() - time); + } + + private String convert(String totrim) { + return ProgramElement.trim(totrim); + } + + public void testPervasivePerthis_354470() throws Exception { + runTest("perthis too pervasive"); + } + + public void testPervasivePerthis_354470_2() throws Exception { + runTest("perthis too pervasive 2"); + } + + public void testPervasivePerthis_354470_3() throws Exception { + runTest("perthis too pervasive 3"); + } + + public void testNotEqualWithAnnotationValues_357013() throws Exception { + runTest("annotation values not equal"); + } + + public void testNotEqualWithAnnotationValues_357013_2() throws Exception { + runTest("annotation values not equal 2"); + } + + public void testClassRef_357012() throws Exception { + runTest("class reference in annotation value"); + } + + public void testClassRefInvalidName_357012_2() throws Exception { + runTest("class reference in annotation value - invalid typename"); + } + + public void testClassRef_357012_3() throws Exception { + runTest("class reference in annotation value 3"); + } + + public void testAnnotationFieldBindingOptimization_356612() throws Exception { + runTest("annotation field binding optimization"); + } + + public void testAnnotationFieldBindingOptimization_356612_2() throws Exception { + runTest("annotation field binding optimization - 2"); + } + + public void testThisAspectInstance_239649_1() throws Exception { + // simple case + runTest("thisAspectInstance - 1"); + } + + public void testThisAspectInstance_239649_2() throws Exception { + // before advice toggling on/off through if called method + runTest("thisAspectInstance - 2"); + } + + public void testThisAspectInstance_239649_3() throws Exception { + // after advice toggling on/off through if called method + runTest("thisAspectInstance - 3"); + } + + public void testThisAspectInstance_239649_4() throws Exception { + // before advice, also using thisJoinPointStaticPart + runTest("thisAspectInstance - 4"); + } + + public void testThisAspectInstance_239649_5() throws Exception { + // before advice, also using thisJoinPoint + runTest("thisAspectInstance - 5"); + } + + public void testThisAspectInstance_239649_6() throws Exception { + // before advice, also using thisEnclosingJoinPointStaticPart + runTest("thisAspectInstance - 6"); + } + + public void testThisAspectInstance_239649_7() throws Exception { + // before advice, also using thisJoinPoint and thisJoinPointStaticPart + runTest("thisAspectInstance - 7"); + } + + public void testThisAspectInstance_239649_8() throws Exception { + // before advice, also using abstract aspects + runTest("thisAspectInstance - 8"); + } + + public void testThisAspectInstance_239649_9() throws Exception { + // before advice, also using abstract aspects 2 + runTest("thisAspectInstance - 9"); + } + + public void testThisAspectInstance_239649_10() throws Exception { + // aspects in a package + runTest("thisAspectInstance - 10"); + } + + public void testThisAspectInstance_239649_11() throws Exception { + // non-singleton aspect - should be an error for now + runTest("thisAspectInstance - 11"); + } + + public void testThisAspectInstance_239649_12() throws Exception { + // arg binding and tjpsp + runTest("thisAspectInstance - 12"); + } + + public void testThisAspectInstance_239649_13() throws Exception { + // pass instance + runTest("thisAspectInstance - 13"); + } + + public void testThisAspectInstance_239649_14() throws Exception { + // multiple ifs + runTest("thisAspectInstance - 14"); + } + + public void testThisAspectInstance_239649_15() throws Exception { + // abstract aspects + runTest("thisAspectInstance - 15"); + } + + // public void testVerifyPerthis() throws Exception { + // runTest("verify perthis"); + // } + + public void testRangeForLocalVariables_353936() throws ClassNotFoundException { + runTest("local variable tables"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method[] meths = jc.getMethods(); + boolean checked = false; + for (int i = 0; i < meths.length; i++) { + Method method = meths[i]; + if (method.getName().equals("ajc$before$X$2$3444dde4")) { + System.out.println(method.getName()); + System.out.println(stringify(method.getLocalVariableTable())); + System.out.println(method.getCode().getLength()); + checked = true; + assertEquals("LX; this(0) start=0 len=48", stringify(method.getLocalVariableTable(), 0)); + assertEquals("Lorg/aspectj/lang/JoinPoint; thisJoinPoint(1) start=0 len=48", + stringify(method.getLocalVariableTable(), 1)); + assertEquals("I i(2) start=8 len=22", stringify(method.getLocalVariableTable(), 2)); + } + } + assertTrue(checked); + } + + public void testEmptyPattern_pr352363() { + runTest("empty pattern"); + } + + public void testGenericsIssue_pr351592() { + runTest("generics issue"); + } + + public void testGenericsIssue_pr351592_2() { + runTest("generics issue - 2"); + } + + public void testGenericsNpe_pr350800() { + runTest("generics npe"); + } + + public void testGenericsNpe_pr350800_code() { + runTest("generics npe - code"); + } + + public void testGenericsNpe_pr350800_3() { + runTest("generics npe - 3"); + } + + public void testOrdering_pr349961() { + runTest("ordering"); + } + + public void testOrdering_pr349961_2() { + runTest("ordering - 2"); + } + + /* + * public void testVerifyError_pr347395() { runTest("verifyerror - inline"); } + */ + + public void testDuplicateMethods_349398() { + runTest("duplicate methods"); + } + + public void testBindingInts_347684() { + runTest("binding ints"); + } + + public void testBindingInts_347684_2() { + runTest("binding ints - 2"); + } + + public void testBindingInts_347684_3() { + runTest("binding ints - 3"); + } + + public void testBindingInts_347684_4() { + runTest("binding ints - 4"); + } + + public void testBindingInts_347684_5() { + runTest("binding ints - 5"); + } + + public void testBindingInts_347684_6() { + runTest("binding ints - 6"); + } + + public void testIncorrectAnnos_345172() { + runTest("incorrect annos"); + } + + public void testIncorrectAnnos_345172_2() { + runTest("incorrect annos 2"); + } + + public void testIncorrectAnnos_345172_3() { + runTest("incorrect annos 3"); + } + + public void testSyntheticMethods_327867() { + runTest("synthetic methods"); + } + + // public void testSignedJarLtw_328099() { + // runTest("signed jar ltw"); + // } + + public void testVerifyError_315398() { + runTest("verifyerror"); + } + + public void testVerifyError_315398_2() { + runTest("verifyerror - 2"); + } + + public void testRawTypePointcut_327134() { + runTest("rawtype pointcut"); + } + + public void testRawTypeWarning_335810() { + runTest("rawtype warning"); + } + + // public void testDecpGenerics_344005() { + // runTest("decp generics"); + // } + + public void testIllegalAccessError_343051() { + runTest("illegalaccesserror"); + } + + public void testItitNpe_339974() { + runTest("itit npe"); + } + + // public void testNoImportError_342605() { + // runTest("noimporterror"); + // } + + public void testClashingLocalTypes_342323() { + runTest("clashing local types"); + } + + public void testITIT_338175() { + runTest("itit"); + } + + public void testThrowsClause_292239() { + runTest("throws clause"); + } + + public void testThrowsClause_292239_2() { + runTest("throws clause - 2"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1612Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1612.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1612/AllTestsAspectJ1612.java b/tests/src/test/java/org/aspectj/systemtest/ajc1612/AllTestsAspectJ1612.java new file mode 100644 index 000000000..702cfdc39 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1612/AllTestsAspectJ1612.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1612; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1612 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.12 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1612Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1612/ajc1612.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1612/ajc1612.xml new file mode 100644 index 000000000..38f46c7d6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1612/ajc1612.xml @@ -0,0 +1,755 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc162/Ajc162Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc162/Ajc162Tests.java new file mode 100644 index 000000000..fb42a6351 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc162/Ajc162Tests.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc162; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc162Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // AspectJ1.6.2 + + // When faulting in the binary hierarchy: + // [java source file] + // Clazz.java [java source file] C:\temp\ajcSandbox\aspectj16_2\ajcTest3344.tmp\Clazz.java:1::0 + // import declarations [import reference] + // Clazz [class] C:\temp\ajcSandbox\aspectj16_2\ajcTest3344.tmp\Clazz.java:1::13 + // foo() [method] C:\temp\ajcSandbox\aspectj16_2\ajcTest3344.tmp\Clazz.java:2::36 + // Asp.class (binary) [class] C:\temp\ajcSandbox\aspectj16_2\ajcTest3344.tmp\binaryaspect.jar!Asp.class:1::0 + // import declarations [import reference] + // Asp [aspect] C:\temp\ajcSandbox\aspectj16_2\ajcTest3344.tmp\binaryaspect.jar!Asp.class:1::0 + // before(): [advice] C:\temp\ajcSandbox\aspectj16_2\ajcTest3344.tmp\binaryaspect.jar!Asp.class:2::0 + // Hid:1:(targets=1) [Asp.class (binary)}Asp&before (advises) {Clazz.java[Clazz~foo + // Hid:2:(targets=1) {Clazz.java[Clazz~foo (advised by) [Asp.class (binary)}Asp&before + + // without faulting in the model they stop at the top level (the class level) + + // Hid:1:(targets=1) "{Clazz.java[Clazz~foo" (advised by) "{Asp.class" + // Hid:2:(targets=1) "{Asp.class" (advises) "{Clazz.java[Clazz~foo" + + // what I want for the hid is: + + // "[Asp.class}Asp&before" + /* + * public void testBinaryAspectModeling() throws Exception { runTest("binary aspects model"); + * AsmManager.dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); PrintWriter pw = new PrintWriter(System.out); + * AsmManager.getDefault().dumprels(pw); pw.flush(); } + */ + public void testPerClause() { + runTest("ltw perclause"); + } + + public void testNullDelegateForArray_pr247683() { + runTest("null delegate for array"); + } + + public void testPerClause2() { + runTest("ltw perclause - 2"); + } + + public void testPerClause3() { + runTest("ltw perclause - 3"); + } + + public void testPerClause4_IncorrectPerClause() { + runTest("ltw perclause - 4"); + } + + public void testAnnoValueBinding_pr246264() { + runTest("anno value binding"); + } + + public void testAroundAdviceProceed_pr211607() { + runTest("around advice proceed"); + } + + // public void testAdvisingInterfaces_pr163005() { runTest("advising joinpoints in interfaces"); } + public void testChainedItds_pr176905() { + runTest("chained itds"); + } + + public void testDecAtAnnoDecP_pr198341() { + runTest("dec atanno and decp"); + } + + public void testMissingMarkers_pr197720() { + runTest("missing markers on inherited annotated method"); + } + + public void testLostGenericsSigOnItd_pr211146() { + runTest("lost generic sig on itd"); + } + + public void testLostGenericsSigOnItd_pr211146_2() { + runTest("lost generic sig on itd - 2"); + } + + public void testLostGenericsSigOnItd_pr211146_3() { + runTest("lost generic sig on itd - 3"); + } + + public void testLostGenericsSigOnItd_pr211146_4() { + runTest("lost generic sig on itd - 4"); + } + + public void testLostGenericsSigOnItd_pr211146_5() { + runTest("lost generic sig on itd - 5"); + } + + public void testMissingContext_pr194429() { + runTest("missing context"); + } + + public void testWarningsForLimitations_pr210114() { + runTest("warnings for limitations"); + } + + public void testPTW_pr244830() { + runTest("ptw initFailureCause"); + } + + public void testGenericItdsOverrides_pr222648() { + runTest("generic itds - overrides"); + } + + public void testGenericItdsOverrides_pr222648_2() { + runTest("generic itds - overrides - 2"); + } + + public void testItdCallingGenericMethod_pr145391() { + runTest("itd calling generic method"); + } + + public void testItdCallingGenericMethod_pr145391_2() { + runTest("itd calling generic method - 2"); + } + + public void testPublicPointcut_pr239539() { + runTest("public pointcut"); + } + + public void testGenericDecp_pr241047() { + runTest("generic decp"); + } + + public void testGenericDecp_pr241047_2() { + runTest("generic decp - 2"); + } + + public void testGenericItds_pr242797_1() { + runTest("generic itds - 1"); + } + + public void testGenericItds_pr242797_2() { + runTest("generic itds - 2"); + } + + public void testGenericItds_pr242797_3() { + runTest("generic itds - 3"); + } + + public void testPrivilegedGenerics_pr240693() { + runTest("privileged generics"); + } + + // public void testParamAnnosPipelining_pr241847() { runTest("param annos pipelining");} + // public void testParamAnnoInner_pr241861() { + // runTest("param annotation inner class"); + // } + + // public void testParamAnnoInner_pr241861_2() { + // runTest("param annotation inner class - 2"); + // } + + // public void testParamAnnoInner_pr241861_3() { + // runTest("param annotation inner class - 3"); + // } + + public void testAnnotationDecp_pr239441() { + runTest("annotation decp"); + } + + public void testAtAspectJPerTarget_pr198181() { + runTest("ataspectj ltw pertarget"); + } + + public void testAnnotationValueDecp_pr238992() { + runTest("annotation value decp"); + } + + public void testAnnotationValueDecp_pr238992_2() { + runTest("annotation value decp - 2"); + } + + public void testAnnotationValueDecp_pr238992_3() { + runTest("annotation value decp - 3"); + } + + public void testAnnotationValueDecp_pr238992_4() { + runTest("annotation value decp - 4"); + } + + public void testAnnotationValueDecp_pr238992_5() { + runTest("annotation value decp - 5"); + } + + /* + * test plan execution((..,String,..)) args(..,String,..) + * + * @args(..,Foo,..) + */ + // public void testParameterSubsettingMatching_pr233718_Matching() { runTest("parameter subsetting - matching");} + // public void testParameterSubsettingMatching_pr233718_ArgsMatching() { runTest("parameter subsetting - args matching");} + // public void testParameterSubsettingMatching_pr233718_ArgsBinding() { runTest("parameter subsetting - args binding");} + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc162Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc162.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc162/AllTestsAspectJ162.java b/tests/src/test/java/org/aspectj/systemtest/ajc162/AllTestsAspectJ162.java new file mode 100644 index 000000000..409d0d670 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc162/AllTestsAspectJ162.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc162; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ162 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.2 tests"); + //$JUnit-BEGIN$ + suite.addTest(Ajc162Tests.suite()); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc162/ajc162.xml b/tests/src/test/java/org/aspectj/systemtest/ajc162/ajc162.xml new file mode 100644 index 000000000..d8b86f20d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc162/ajc162.xml @@ -0,0 +1,336 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java new file mode 100644 index 000000000..15abc8921 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -0,0 +1,320 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc163; + +import java.io.File; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.LocalVariable; +import org.aspectj.apache.bcel.classfile.LocalVariableTable; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.testing.Utils; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testGenericMethodBridging_pr251326() { + runTest("itd anonymous inner class in wrong package"); + } + + public void testOrderingRepetitive_pr259279() { + runTest("ordering repetitive method"); + } + + public void testOrderingRepetitive_pr259279_2() { + runTest("ordering repetitive method - 2"); + } + + public void testExtendingASI_pr252722() { + runTest("extending AbstractSecurityInterceptor"); + } + + public void testExtendingASI_pr252722_2() { + runTest("extending AbstractSecurityInterceptor - 2"); + } + + public void testExtendingASI_pr252722_3() { + runTest("extending AbstractSecurityInterceptor - 3"); + } + + public void testExtendingASI_pr252722_4() { + runTest("extending AbstractSecurityInterceptor - 4"); + } + + public void testGetNode_pr258653() { + runTest("getNode"); + } + + public void testAtTargetPlus_pr255856() { + runTest("attarget with plus"); + } + + public void testNonNullAtArgs_pr257833() { + runTest("param annos and at args"); + } + + public void testIncorrectArgOrdering_pr219419() { + runTest("incorrect arg ordering anno style"); + } + + public void testIncorrectArgOrdering_pr219419_2() { + runTest("incorrect arg ordering anno style - 2"); + } + + public void testIncorrectArgOrdering_pr219419_3() { + runTest("incorrect arg ordering anno style - 3"); + } + + // similar to 3 but parameters other way round + public void testIncorrectArgOrdering_pr219419_4() { + runTest("incorrect arg ordering anno style - 4"); + } + + // similar to 3 but also JoinPoint passed into advice + public void testIncorrectArgOrdering_pr219419_5() { + runTest("incorrect arg ordering anno style - 5"); + } + + public void testDecpAnnoStyle_pr257754() { + runTest("decp anno style"); + } + + public void testDecpAnnoStyle_pr257754_2() { + runTest("decp anno style - 2"); + } + + public void testPoorAtAjIfMessage_pr256458() { + runTest("poor ataj if message - 1"); + } + + public void testPoorAtAjIfMessage_pr256458_2() { + runTest("poor ataj if message - 2"); + } + + /* + * public void testInheritedAnnotations_pr128664() { runTest("inherited annotations"); } + * + * public void testInheritedAnnotations_pr128664_2() { runTest("inherited annotations - 2"); } + */ + public void testGetMethodNull_pr154427() { + runTest("getMethod returning null"); + } + + public void testItdOnAnonInner_pr171042() { + runTest("itd on anonymous inner"); + } + + public void testMixedStyles_pr213751() { + runTest("mixed styles"); + } + + public void testHandles_pr249216c24() { + runTest("handles - escaped square brackets"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement ipe = null; + ipe = findElementAtLine(top.getRoot(), 4);// public java.util.List Ship.i(List[][] u) + assertEquals("<{Handles.java'Handles)Ship.i)\\[\\[QList\\;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 7);// public java.util.List Ship.i(Set[][] u) + assertEquals("<{Handles.java'Handles)Ship.i)\\[\\[QSet\\;", ipe.getHandleIdentifier()); + + // public java.util.Set i(java.util.Set[][] u) + ipe = findElementAtLine(top.getRoot(), 10); + assertEquals("<{Handles.java'Handles~i~\\[\\[Qjava.util.Set\\;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 13);// public java.util.Set i(java.util.Set[][] u,int i) { + assertEquals("<{Handles.java'Handles~i~\\[\\[Qjava.util.Set\\;~I", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 16);// public java.util.Set i2(java.util.Set>[][] u) { + assertEquals("<{Handles.java'Handles~i2~\\[\\[Qjava.util.Set\\<+QCollection\\;>;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 19);// public java.util.Set i3(java.util.Set>[][] u) + assertEquals("<{Handles.java'Handles~i3~\\[\\[Qjava.util.Set\\<+QCollection\\<\\[QString;>;>;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 22); + assertEquals("<{Handles.java'Handles~i4~Qjava.util.Set\\<+QCollection\\;>;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 25); + assertEquals("<{Handles.java'Handles~i5~Qjava.util.Set\\<*>;", ipe.getHandleIdentifier()); + + } + + public void testFQType_pr256937() { + runTest("fully qualified return type"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement itd = findElementAtLine(top.getRoot(), 10); + String type = itd.getCorrespondingType(true); + assertEquals("java.util.List", type); + + itd = findElementAtLine(top.getRoot(), 16); + type = itd.getCorrespondingType(true); + assertEquals("java.util.List", type); + } + + private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) { + if (whereToLook == null) { + return null; + } + if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) { + return whereToLook; + } + List kids = whereToLook.getChildren(); + for (IProgramElement object: kids) { + if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) { + return object; + } + IProgramElement gotSomething = findElementAtLine(object, line); + if (gotSomething != null) { + return gotSomething; + } + } + return null; + } + + public void testParameterAnnotationsOnITDs_pr256669() { // regular itd + runTest("parameter annotations on ITDs"); + } + + public void testParameterAnnotationsOnITDs_pr256669_2() { // static itd + runTest("parameter annotations on ITDs - 2"); + } + + public void testParameterAnnotationsOnITDs_pr256669_3() { // multiple parameters + runTest("parameter annotations on ITDs - 3"); + } + + public void testParameterAnnotationsOnITDs_pr256669_4() { // itd on interface + runTest("parameter annotations on ITDs - 4"); + } + + public void testOrderingIssue_1() { + runTest("ordering issue"); + } + + public void testOrderingIssue_2() { + runTest("ordering issue - 2"); + } + + // public void testGenericPointcuts_5() { + // runTest("generic pointcuts - 5"); + // } + + public void testGenericPointcuts_1() { + runTest("generic pointcuts - 1"); + } + + public void testGenericPointcuts_2() { + runTest("generic pointcuts - 2"); + } + + public void testGenericPointcuts_3() { + runTest("generic pointcuts - 3"); + } + + public void testGenericPointcuts_4() { + runTest("generic pointcuts - 4"); + } + + public void testDontAddMethodBodiesToInterface_pr163005() { + runTest("do not add method bodies to an interface"); + } + + public void testDontAddMethodBodiesToInterface_pr163005_2() { + runTest("do not add method bodies to an interface - 2"); + } + + public void testDontAddMethodBodiesToInterface_pr163005_3() { + runTest("do not add method bodies to an interface - 3"); + } + + public void testMissingLocalVariableTableEntriesOnAroundAdvice_pr173978() throws Exception { + runTest("missing local variable table on around advice"); + JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Test"); + Method[] ms = jc.getMethods(); + Method m = null; + for (int i = 0; i < ms.length; i++) { + if (ms[i].getName().equals("sayHello")) { + m = ms[i]; + } + } + if (m.getLocalVariableTable() == null) { + fail("Local variable table should not be null"); + } + assertEquals(2, m.getLocalVariableTable().getLocalVariableTable().length); + // LocalVariableTable: + // Start Length Slot Name Signature + // 0 12 0 this LTest; + // 0 12 1 message Ljava/lang/String; + LocalVariable lv = m.getLocalVariableTable().getLocalVariable(0); + assertNotNull(lv); + assertEquals("this", lv.getName()); + assertEquals(0, lv.getStartPC(), 0); + assertEquals(12, lv.getLength(), 12); + assertEquals("LTest;", lv.getSignature()); + lv = m.getLocalVariableTable().getLocalVariable(1); + assertNotNull(lv); + assertEquals("message", lv.getName()); + assertEquals(0, lv.getStartPC(), 0); + assertEquals(12, lv.getLength(), 12); + assertEquals("Ljava/lang/String;", lv.getSignature()); + // print(m.getLocalVariableTable()); + } + + public void testTerminateAfterCompilation_pr249710() { + runTest("terminateAfterCompilation"); + } + + public void testItdCCE_pr250091() { + runTest("itd cce"); + } + + public void testBreakingRecovery_pr226163() { + runTest("breaking recovery"); + } + + public void testGenericMethodConversions_pr250632() { + runTest("type conversion in generic itd"); + } + + public void testGenericMethodBridging_pr250493() { + runTest("bridge methods for generic itds"); + } + + public void testGenericFieldBridging_pr252285() { + runTest("bridge methods for generic itd fields"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc163Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc163.xml"); + } + + // --- + + private void print(LocalVariableTable localVariableTable) { + LocalVariable[] lvs = localVariableTable.getLocalVariableTable(); + for (int i = 0; i < lvs.length; i++) { + LocalVariable localVariable = lvs[i]; + System.out.println(localVariable); + } + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java b/tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java new file mode 100644 index 000000000..f0fbbeaf6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc163; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ163 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.3 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc163Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml new file mode 100644 index 000000000..c26204aa5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java new file mode 100644 index 000000000..866fbb729 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java @@ -0,0 +1,443 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc164; + +import java.io.File; +import java.io.PrintWriter; +import java.util.Iterator; +import java.util.List; + +import org.aspectj.apache.bcel.classfile.LocalVariable; +import org.aspectj.apache.bcel.classfile.LocalVariableTable; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testGenericAspectsNpe_pr268689() { + runTest("generics aspects npe"); + } + + public void testGenericAspectsNpe_pr268710() { + runTest("generics aspects incorrect error"); + } + + public void testGenericsItdNpe_pr267559() { + runTest("generics and itd npe"); + } + + public void testAnnoStyleLong_pr266564() { + runTest("annotation style long"); + } + + public void testAnnoStyleLong_pr266564_2() { + runTest("annotation style long - 2"); + } + + public void testUnusedPrivateWarning_pr266420() { + runTest("unused private warning"); + } + + public void testUnusedPrivateWarning_pr266420_2() { + runTest("unused private warning - 2"); + } + + public void testUnusedPrivateWarning_pr266420_3() { + runTest("unused private warning - 3"); + } + + /** + * This test program can be used to compare handles for faulted in binary aspects with handles that would be used if the aspect + * was available as source. There are two compile steps in the xml for the test - commenting out the first will allow the source + * handles to be seen, leaving it in will switch to binary. Effectively the only difference should be that in the binary case + * the handles are prefixed 'binaries'. + * + * Change due to bug 274558: now AJDT wants (blah.class as the 'source file' for the ITD so that is another difference when + * switching. + */ + public void testItdsAspectPathModel_pr265729_1() { + runTest("aspectpath model"); + AsmManager model = AsmManager.lastActiveStructureModel; + IHierarchy top = model.getHierarchy(); + printModel(model); + IProgramElement ipe = null; + + // ITD METHOD + // should be the ITD method from the binary aspect: + // public Color Orange.getColor() { return Color.orange; } + ipe = top.findElementForType("demo", "Orange"); + assertNotNull(ipe); + assertEquals(" ptypes = itdcpe.getParameterTypes(); + assertEquals("java.awt.Color", new String(ptypes.get(0))); + assertEquals("java.lang.String", new String(ptypes.get(1))); + } + + private void printModel(AsmManager model) { + try { + AsmManager.dumptree(model.getHierarchy().getRoot(), 0); + model.dumprels(new PrintWriter(System.out)); + } catch (Exception e) { + } + } + + public void testGenericsAopXml_pr266220() { + runTest("generics and aop.xml"); + } + + public void testOptimizingIf_pr266165_1() { + runTest("optimizing if for constant reference - 1"); + } + + public void testOptimizingIf_pr266165_2() { + runTest("optimizing if for constant reference - 2"); + } + + public void testOptimizingIf_pr266165_3() { + runTest("optimizing if for constant reference - 3"); + } + + public void testOptimizingIf_pr266165_4() { + runTest("optimizing if for constant reference - 4"); + } + + // public void testAnnoInherited_pr265695() { + // runTest("anno inherited"); + // } + // + // public void testAnnoInherited_pr265695_2() { + // runTest("new syntax for inherited anno - 1"); + // } + // + // public void testAnnoInherited_pr265695_3() { + // runTest("new syntax for inherited anno - 3"); + // } + + public void testParserProblemSubArrayPatterns_pr148508() { + runTest("parser problem for array subtypes"); + } + + public void testVarargs_pr265418() { + runTest("varargs"); + } + + public void testIncorrectDateResolution_pr265360() { + runTest("incorrect resolution of Date"); + } + + public void testDualPreClinit_pr233032() { + runTest("dual preClinit"); + } + + public void testHandles_pr263310() { + runTest("inner handles"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement ipe = null; + ipe = findElementAtLine(top.getRoot(), 13); + assertEquals(" l = sortedLocalVariables(method.getLocalVariableTable()); + assertEquals("LBar; bar(1) start=0 len=34", stringify(l, 0)); + assertEquals("Ljava/lang/Exception; e(3) start=29 len=4", stringify(l, 1)); + assertEquals("LFoo2; this(0) start=0 len=34", stringify(l, 4)); + assertEquals("Ljava/lang/String; s(2) start=15 len=19", stringify(l, 2)); + // With the 1.8 compiler looks like len=7 and not len=10 here, the goto to jump to the return is no longer included + // in the variable range + assertEquals("Ljava/lang/String; s2(3) start=18 len=7", stringify(l, 3)); + } + + // Two pieces of advice on before execution of a method with a this and a + // parameter and another local within it + public void testDebuggingBeforeAdvice_pr262509_3() throws Exception { + // Compile with -preserveAllLocals + runTest("debugging before advice - 3"); + Method method = getMethodFromClass(getClassFrom(ajc.getSandboxDirectory(), "Foo3"), "foo"); + System.out.println(stringify(method.getLocalVariableTable())); + assertEquals("LFoo3; this(0) start=0 len=35", stringify(method.getLocalVariableTable(), 0)); + assertEquals("LBar; bar(1) start=0 len=35", stringify(method.getLocalVariableTable(), 1)); + assertEquals("Ljava/lang/Exception; e(2) start=30 len=4", stringify(method.getLocalVariableTable(), 2)); + } + + public void testRogueErrors_pr246393_1() { + runTest("rogue errors - 1"); + } + + // public void testNameClash_pr262257() { + // runTest("name clash"); + // fail("incomplete"); + // } + + public void testCompilingSpring_pr260384() { + runTest("compiling spring"); + } + + public void testCompilingSpring_pr260384_2() { + runTest("compiling spring - 2"); + } + + public void testCompilingSpring_pr260384_3() { + runTest("compiling spring - 3"); + } + + public void testCompilingSpring_pr260384_4() { + runTest("compiling spring - 4"); + } + + public void testAtAspectJDecp_pr164016() { + runTest("ataspectj decp 164016"); + } + + public void testAtAspectJDecp_pr258788() { + runTest("ataspectj decp 258788"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc164Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc164.xml"); + } + + private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) { + if (whereToLook == null) { + return null; + } + if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) { + return whereToLook; + } + List kids = whereToLook.getChildren(); + for (Iterator iterator = kids.iterator(); iterator.hasNext();) { + IProgramElement object = iterator.next(); + if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) { + return object; + } + IProgramElement gotSomething = findElementAtLine(object, line); + if (gotSomething != null) { + return gotSomething; + } + } + return null; + } +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/AllTestsAspectJ164.java b/tests/src/test/java/org/aspectj/systemtest/ajc164/AllTestsAspectJ164.java new file mode 100644 index 000000000..1cd45e428 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/AllTestsAspectJ164.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc164; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ164 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.4 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc164Tests.suite()); + suite.addTest(DeclareMixinTests.suite()); + suite.addTest(JointpointIdTests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/DeclareMixinTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc164/DeclareMixinTests.java new file mode 100644 index 000000000..a8e9b6875 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/DeclareMixinTests.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc164; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + *

Design and test coverage


+ * In many ways the design is similar to DeclareParents now - so we have to plug in at the same points, but the code generation for + * generating the delegate object and the choice of which interfaces (and methods within those) to mixin is different. + * + *

Tested:


+ *
    + *
  • Factory method with void or primitive return value + *
  • Check the factory method has at most one parameter + *
  • incremental compilation + *
  • error message if mixin target instance not compatible with factory method parameter + *
+ * + *

Still to test/explore:


+ *
    + *
  • model relationships + *
  • ltw + *
  • generic factory methods + *
  • showWeaveInfo + *
  • Clashing with existing methods + *
  • varying parameter type on the factory method + *
+ * + * @author Andy Clement + */ +public class DeclareMixinTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Very basics with a simple static factory method + public void testCaseA() { + runTest("casea"); + } + + // non static factory method, will need aspectOf() calling on + // the aspect before the factory is called + public void testCaseB() { + runTest("caseb"); + } + + // factory method takes the object for which the delegate exists + public void testCaseC() { + runTest("casec"); + } + + // factory method is non static and takes the object for which the delegate is being created + public void testCaseD() { + runTest("cased"); + } + + // multiple instances causing factory invocation multiple times (but is cached) + public void testCaseE() { + runTest("casee"); + } + + // Factory method directly takes the type specified in the Mixin target (strongly typed) + public void testCaseF() { + runTest("casef"); + } + + // targeting multiple types from the Mixin + public void testCaseG() { + runTest("caseg"); + } + + // Null value for mixin target pattern + public void testCaseH() { + runTest("caseh"); + } + + // Invalid interfaces annotation value entries + public void testCaseI() { + runTest("casei"); + } + + // invalid return type for factory method + public void testCaseJ() { + runTest("casej"); + } + + // too many arguments to the factory method + public void testCaseK() { + runTest("casek"); + } + + // mixin of a class - should be an error (this one reported by the compiler due to a failed cast) + public void testCaseL() { + runTest("casel"); + } + + // mixin of a class - should be an error (this one reported by the annotation processing) + public void testCaseM() { + runTest("casem"); + } + + // factory returns class but interface specified - this is OK + public void testCaseN() { + runTest("casen"); + } + + // factory returns class but interface specified - not ok as class doesn't implement interface + public void testCaseO() { + runTest("caseo"); + } + + // interface subsetting used (factory returns class) - but only one method should be delegated + public void testCaseP() { + runTest("casep"); + } + + // factory return type implements two interfaces, both should be mixed as specified + public void testCaseQ() { + runTest("caseq"); + } + + // testing a pure marker interface - no methods added + public void testCaseR() { + runTest("caser"); + } + + // factory method has incompatible return type - verifyerror if we did use that factory + public void testCaseS() { + runTest("cases"); + } + + // weave info - what happens? + public void testCaseT() { + runTest("caset"); + } + + // -- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(DeclareMixinTests.class); + } + + protected File getSpecFile() { + return getClassResource("declareMixin.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/JointpointIdTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc164/JointpointIdTests.java new file mode 100644 index 000000000..68f769af6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/JointpointIdTests.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc164; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * + * @author Andy Clement + */ +public class JointpointIdTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testCaseA() { + runTest("casea"); + } + + // -- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(JointpointIdTests.class); + } + + protected File getSpecFile() { + return getClassResource("joinpointid.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/ajc164.xml b/tests/src/test/java/org/aspectj/systemtest/ajc164/ajc164.xml new file mode 100644 index 000000000..e1c8e87b4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/ajc164.xml @@ -0,0 +1,278 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/declareMixin.xml b/tests/src/test/java/org/aspectj/systemtest/ajc164/declareMixin.xml new file mode 100644 index 000000000..02853f93a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/declareMixin.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/joinpointid.xml b/tests/src/test/java/org/aspectj/systemtest/ajc164/joinpointid.xml new file mode 100644 index 000000000..6f2bdc79b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/joinpointid.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java new file mode 100644 index 000000000..196e07ca1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc165; + +import java.io.File; +import java.util.List; + +import org.aspectj.bridge.IMessage; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.LintMessage; + +import junit.framework.Test; + +public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +// fix is too disruptive for 1.6.5 +// public void testGenericsBridge_pr279983() { +// runTest("generics bridge"); +// } + + public void testVerifyError_pr277959() { + runTest("verifyerror"); + } + + // on the build machine (linux) - these tests don't expect the right output - i suspect due to CR/LF issues + // since that will affect the generated name of the if methods + + // public void testIfNames_pr277508() { + // runTest("if method names"); + // } + // + // public void testIfNames_pr277508_2() { + // runTest("if method names - 2"); + // } + + public void testDecAnnoMethod_pr275625() { + runTest("dec anno method"); + } + + public void testDecAnnoField_pr275625() { + runTest("dec anno field"); + } + + // check ITD can replace a generated default constructor + public void testItdDefaultCtor_pr275032() { + runTest("itd default ctor"); + } + + // check ITD can't overwrite an existing constructor + public void testItdDefaultCtor_pr275032_2() { + runTest("itd default ctor - 2"); + } + + // binary weaving version of case 2 - check ITD can't overwrite an existing constructor + public void testItdDefaultCtor_pr275032_3() { + runTest("itd default ctor - 3"); + } + + // binary weaving version of case 4 - check ITD can replace a generated default constructor + public void testItdDefaultCtor_pr275032_4() { + runTest("itd default ctor - 4"); + } + + public void testVerifyOnAnnoBind_pr273628() { + runTest("verifyerror on anno bind"); + } + + public void testFunkyPointcut_pr272233() { + runTest("funky pointcut"); + } + + public void testFunkyPointcut_pr272233_2() { + runTest("funky pointcut 2"); + } + + public void testAnnotationStyle_pr265356() { + runTest("annotation style message positions"); + List ms = ajc.getLastCompilationResult().getWarningMessages(); + boolean checked = true; + // Look for the message relating to 'List' and check the offsets + for (int i = 0; i < ms.size(); i++) { + LintMessage m = (LintMessage) ms.get(i); + if (m.toString().indexOf("List") != -1) { + // 225/228 on windows - 237/240 on linux + if (!(m.getSourceStart() == 225 || m.getSourceStart() == 237)) { + fail("Did not get expected start position, was:" + m.getSourceStart()); + } + if (!(m.getSourceEnd() == 228 || m.getSourceEnd() == 240)) { + fail("Did not get expected end position, was:" + m.getSourceEnd()); + } + checked = true; + } + } + assertTrue("Failed to check the message", checked); + } + + public void testAroundCall_pr271169() { + runTest("around call npe"); + } + + public void testGenericITD_pr272825() { + runTest("generic ITD"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc165Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc165.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc165/AllTestsAspectJ165.java b/tests/src/test/java/org/aspectj/systemtest/ajc165/AllTestsAspectJ165.java new file mode 100644 index 000000000..f89671e22 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc165/AllTestsAspectJ165.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc165; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ165 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.5 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc165Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc165/WorldTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc165/WorldTests.java new file mode 100644 index 000000000..171aee572 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc165/WorldTests.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc165; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.bcel.BcelWorld; + +public class WorldTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testWorldSize() { + BcelWorld world = new BcelWorld("../weaver5/bin/"); + assertEquals(9, world.getFixed().size()); // 9 primitive types + assertEquals(0, world.getExpendable().size()); // nothing loaded + + world.resolve(UnresolvedType.forSignature("LMA;")); + assertEquals(9, world.getFixed().size()); + assertEquals(1, world.getExpendable().size()); + + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(WorldTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc165/world.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc165/ajc165.xml b/tests/src/test/java/org/aspectj/systemtest/ajc165/ajc165.xml new file mode 100644 index 000000000..6c3b74d71 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc165/ajc165.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc165/world.xml b/tests/src/test/java/org/aspectj/systemtest/ajc165/world.xml new file mode 100644 index 000000000..e9c113cc5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc165/world.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc166/Ajc166Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc166/Ajc166Tests.java new file mode 100644 index 000000000..4622ae492 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc166/Ajc166Tests.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc166; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc166Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testParentsLTW_286473_binary() { + runTest("parents ltw - binary"); + } + + public void testParentsLTW_286473_ltw() { + runTest("parents ltw - ltw"); + } + + public void testNpeForJavacBuilt_290227() { + runTest("npe for javac built"); + } + + public void testBinaryDecpSuperRewrite_290087() { + runTest("binary decp super rewrite"); + } + + public void testITDannos_288049() { + runTest("itd decanno"); + } + + public void testVerifyErrorAnnoStyle_288712() { + runTest("verifyerror anno style"); + } + + public void testMungerCCE_288635() { + runTest("munger cce"); + } + + public void testMungerCCE_288635_2() { + runTest("munger cce - 2"); + } + + public void testNPEonBadAspectDecl_286375() { + runTest("npe on bad aspect decl"); + } + + // + // public void testAnnoModifierOrdering_287597_1() { + // runTest("anno modifier ordering - 1"); + // } + // + // public void testDeclareAnnoCompoundExpression_287613() { + // runTest("dec anno compound expressions"); + // } + + public void testHasMember_284862() { + runTest("npe hasmember"); + } + + public void testHasMember_284862_2() { + runTest("npe hasmember - 2"); + } + + public void testHasMember_284862_3() { + runTest("npe hasmember - 3"); + } + + // fix is too disruptive for 1.6.5 + public void testGenericsBridge_pr279983() { + runTest("generics bridge"); + } + + public void testGenericsDecp_pr282299() { + runTest("generics and decp"); + } + + public void testGenericSigProblem_pr284297() { + runTest("generic signature problem"); + } + + public void testInterfacesSerializable_pr283229() { + runTest("interfaces and serializable"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc166Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc166.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc166/AllTestsAspectJ166.java b/tests/src/test/java/org/aspectj/systemtest/ajc166/AllTestsAspectJ166.java new file mode 100644 index 000000000..d15a59c0f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc166/AllTestsAspectJ166.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc166; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ166 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.6 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc166Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc166/ajc166.xml b/tests/src/test/java/org/aspectj/systemtest/ajc166/ajc166.xml new file mode 100644 index 000000000..d19a3b485 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc166/ajc166.xml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/Ajc167Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc167/Ajc167Tests.java new file mode 100644 index 000000000..7360222ba --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/Ajc167Tests.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc167; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc167Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // public void testGenericsItds_298665() { + // runTest("itd generics"); + // } + public void testGenericAspectSignatures_296533() { + runTest("generic aspect signatures"); + } + + public void testOptimizingAnnotationStringValueBinding() { + runTest("optimizing string anno value binding"); + } + + public void testOptimizingAnnotationBinding() { + runTest("optimizing annotation binding"); + } + + // bit flakey - can depend on machine load + // public void testOptimizingAnnotationBindingPerfTest() { + // runTest("optimizing annotation binding - 2"); + // } + + /* + * public void testPerThisLTW_295092() { runTest("perthis ltw"); } + */ + + public void testNpeOnBrokenCode_296054() { + runTest("npe on broken code"); + } + + public void testBrokenGeneratedCode_296040() { + runTest("broken generated code"); + } + + public void testHierarchyBuilderNPE_pr293457() { + runTest("hierarchy builder npe"); + } + + public void testTimers_1() { + runTest("timers - 1"); + } + + // Test harness parse of -Xset:a=b,c=d will see c=d as a second option + // public void testTimers_2() { + // runTest("timers - 2"); + // } + + public void testAnnoMatching_pr293203() { + runTest("anno matching"); + } + + public void testScalaOuterClassNames_pr288064() { + runTest("outer class names - scala"); + } + + public void testScalaOuterClassNames_pr288064_ltw() { + runTest("outer class names - scala - ltw"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc167Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc167.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/AllTestsAspectJ167.java b/tests/src/test/java/org/aspectj/systemtest/ajc167/AllTestsAspectJ167.java new file mode 100644 index 000000000..c587e4e2f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/AllTestsAspectJ167.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc167; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ167 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.7 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc167Tests.suite()); + suite.addTest(OverweavingTests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/IntertypeTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc167/IntertypeTests.java new file mode 100644 index 000000000..5aa2d4110 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/IntertypeTests.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc167; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Tests for the new all singing all dancing intertype syntax. + * + * @author Andy Clement + */ +public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // absolutely trivial, just parse something and dont crash + public void testSimple() { + runTest("simple"); + } + + // simple field inside the intertype scope + public void testSimpleWithField() { + runTest("simple with field"); + } + + // simple field inside the intertype scope and method after the intertype scope + public void testSimpleWithField2() { + runTest("simple with field2"); + } + + // now a method that new's up an instance of the type targetted by the intertype scope + public void testNewInstance() { + runTest("new instance"); + } + + // now aspect method attempts to new up target of the itd scope and access something introduced by it + public void testNewInstanceAndAccess() { + runTest("new instance and access"); + } + + // two fields + public void testNewInstanceAndAccess2() { + runTest("new instance and access to two fields"); + } + + // more tests: + // intertype X { int a,b,c=4; } + // intertype X { int a=4,b=3; } // can we say that? + + // extends/implements on the intertype become declare parents + // annotations on the intertype become declare @type + + // what about recovery when we have a problem leaving the scope of the intertype block? How do we make sure + // we don't accidentally use the activeScope for ordinary methods? Can we even check that... + + + // -- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IntertypeTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc167/intertype.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/OverweavingTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc167/OverweavingTests.java new file mode 100644 index 000000000..ebd66a0b5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/OverweavingTests.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc167; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Testing whether AspectJ can overweave. Overweaving is where we attempt to weave something that has already been woven. The simple + * rule followed is that aspects that applied to the type before are not applied this time around (if they are visible to the + * weaver). + * + * @author Andy Clement + */ +public class OverweavingTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testGetSet1() { + runTest("getset - 1"); // testing what should happen for get/set + } + + public void testGetSet2() { + runTest("getset - 2"); // testing what actually happens when overweaving + } + + public void testGetSetTjp1() { + runTest("getset - tjp - 1"); + } + + public void testCalls1() { + runTest("calls - 1"); // testing what should happen for calls + } + + public void testCalls2() { + runTest("calls - 2"); // testing what actually happens when overweaving + } + + public void testCallsTjp1() { + runTest("calls - tjp - 1"); + } + + public void testComplex() { + runTest("really messy"); + } + + public void testSimple() { + runTest("simple"); + } + + /** + * Now an aspect used on the original weave is mentioned in the aop.xml - we shouldn't apply it again! + */ + public void testMessy() { + runTest("messy"); + } + + /** + * Testing a shadow munger created to support cflow + */ + public void testCflow() { + runTest("cflow"); + } + + // -- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(OverweavingTests.class); + } + + protected File getSpecFile() { + return getClassResource("overweaving.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/ajc167.xml b/tests/src/test/java/org/aspectj/systemtest/ajc167/ajc167.xml new file mode 100644 index 000000000..c1acde861 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/ajc167.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/intertype.xml b/tests/src/test/java/org/aspectj/systemtest/ajc167/intertype.xml new file mode 100644 index 000000000..a432ee188 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/intertype.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc167/overweaving.xml b/tests/src/test/java/org/aspectj/systemtest/ajc167/overweaving.xml new file mode 100644 index 000000000..044223d88 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc167/overweaving.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/Ajc169Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc169/Ajc169Tests.java new file mode 100644 index 000000000..3aff31ca8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/Ajc169Tests.java @@ -0,0 +1,253 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc169; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc169Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testMessyDecp_318241() { + runTest("messy decp"); + } + + // public void testMultiAnnosRunning_pr315820_1() { + // runTest("multiple annos running - 1"); + // } + + public void testMultiAnnosParsing_pr315820() { + runTest("multiple annos parsing"); + } + + public void testDeclareAnnot_pr287613_5() { + runTest("compound declare patterns - method - 2"); + } + + public void testDeclareAnnot_pr287613_4() { + runTest("compound declare patterns - method - 1"); + } + + public void testDeclareAnnot_pr287613_3() { + runTest("compound declare patterns - methodctor - 1"); + } + + public void testDeclareAnnot_pr287613_2() { + runTest("compound declare patterns - fields - 2"); + } + + public void testDeclareAnnot_pr287613() { + runTest("compound declare patterns - fields - 1"); + } + + public void testOptionalAspects_pr310506() { + runTest("optional aspects"); + } + + public void testOptionalAspects_pr310506_2() { + runTest("optional aspects 2"); + } + + // public void testClashingDeclareAnnos_313026_1() { + // runTest("clashing declare annos"); + // } + + public void testInfiniteLoop_pr315651() { + runTest("infinite loop"); + } + + public void testAnnoType_pr314965() { + runTest("anno typo"); + } + + public void testValidateBranchRecursion_314840() { + runTest("validate branch recursion"); + } + + public void testClassFileSize_312839_1() { + runTest("class file size - 1"); + // 2531 (0x404): 1.6.9.M2 size of Class.class + // 2494 (0x3DF): first little stab, compressing aspectnames attached to type mungers + // 2370 (0x363): changed read/write sourcelocation to write path rather than File object: + // 2358 (0x357): aspects affecting type compressed (weaverstate reweavable info) + // 2102 (0x257): changed read/write sourcelocation in type munger to NOT use object streams + // 2053 (0x1EF): changed path in sourcelocation read/write to be constant pool (so shared between both mungers) + // 2019: changed resolvedMemberImpl name/signature to be compressed refs + // 1954 (0x18C) + + // Aspect size (X.class) down from 6459 to 4722 + // 4551: changed exact type pattern writing to use constant pool, and + // changed typepatternlist to not both writing/reading location + + // TODO actually test something :) + } + + // control test - weaves everything + public void testScopingLTW_122460_1() { + runTest("scoping ltw - 1"); + } + + // scoped to one type + public void testScopingLTW_122460_2() { + runTest("scoping ltw - 2"); + } + + // scope is '!*' - nothing woven + public void testScopingLTW_122460_3() { + runTest("scoping ltw - 3"); + } + + public void testDeclareSoftCall_307009_1() { + runTest("declare soft and call - 1"); + } + + public void testDeclareSoftCall_307009_2() { + runTest("declare soft and call - 2"); + } + + public void testAmbiguousMethod_298665() { + runTest("ambiguous method"); + } + + // public void testStaticallyAnalyzableIf_292262_1() { + // runTest("if with statically recognizable code"); + // } + + // public void testAdvisingPrivilegedAccessMethod_307147() { + // runTest("advising privileged access method"); + // } + + public void testRogueError_310043() { + runTest("rogue error"); + } + + public void testItdMarkerAnnotations_309743() { + runTest("itd marker annotations - 1"); + } + + public void testItdMarkerAnnotations_309743_2() { + runTest("itd marker annotations - 2"); + } + + public void testPipeliningAndGenerics_309336() { + runTest("pipelining and generics"); + } + + public void testCrashParamAnnos_309440() { + runTest("crash param annos"); + } + + // 1.6.9 M1 below here + public void testSubtleGenericsIssue_308773() { + runTest("subtle generics problem"); + } + + public void testAdvisingPrivilegedAccessMember_307120() { + runTest("advising privileged access member"); + } + + public void testAdvisingPrivilegedAccessMember_307120_2() { + runTest("advising privileged access member - 2"); + } + + public void testTypePatternCategories_44365_Class() { + runTest("type category type patterns - class"); + } + + public void testTypePatternCategories_44365_Interface() { + runTest("type category type patterns - interface"); + } + + public void testTypePatternCategories_44365_Enum() { + runTest("type category type patterns - enum"); + } + + public void testTypePatternCategories_44365_Annotation() { + runTest("type category type patterns - annotation"); + } + + public void testTypePatternCategories_44365_Anonymous() { + runTest("type category type patterns - anonymous"); + } + + public void testTypePatternCategories_44365_Inner() { + runTest("type category type patterns - inner"); + } + + public void testTypePatternCategories_44365_Inner_2() { + runTest("type category type patterns - inner - 2"); + } + + public void testTypePatternCategories_44365_Inner_3() { + runTest("type category type patterns - inner - 3"); + } + + public void testTypePatternCategories_44365_Aspect() { + runTest("type category type patterns - aspect"); + } + + public void testTypePatternCategories_44365_e1() { + runTest("type category type patterns - e1"); + } + + public void testTypePatternCategories_44365_e3() { + runTest("type category type patterns - e3"); + } + + public void testTypePatternCategories_44365_e2() { + runTest("type category type patterns - e2"); + } + + public void testChecker() { + runTest("inserts in messages"); + } + + /* + * public void testVerifyError() { runTest("verifyerror on atAj"); } + */ + public void testDeclareTypeWarning1() { + runTest("declare type warning - 1"); + } + + public void testDeclareTypeWarning2() { + runTest("declare type warning - 2"); + } + + public void testDeclareTypeWarning3() { + runTest("declare type warning - 3"); + } + + public void testDeclareTypeError1() { + runTest("declare type error - 1"); + } + + public void testPr298388() { + runTest("declare mixin and generics"); + } + + // public void testPr292584() { + // runTest("annotation around advice verifyerror"); + // } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc169Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc169.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/AllTestsAspectJ169.java b/tests/src/test/java/org/aspectj/systemtest/ajc169/AllTestsAspectJ169.java new file mode 100644 index 000000000..f143fca99 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/AllTestsAspectJ169.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc169; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ169 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.9 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc169Tests.suite()); + suite.addTest(TransparentWeavingTests.suite()); + suite.addTest(IntertypeTests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java new file mode 100644 index 000000000..5099a929b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2010 Contributors + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc169; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintWriter; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IRelationshipMap; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * Tests exploring intertype declared inner types and the new intertype syntax. + * + * Some design notes.
+ *

+ * Supporting inner types is not quite as straightforward as for the other kinds of ITD like methods, fields and constructors. When + * 'resolving' methods/fields/constructors they may refer to intertyped inner types, these means they must be in place early on - + * ahead of any member resolution. In order to achieve this they are done really early (for both the cases of pulling in a + * binarytypebinding - see AjLookupEnvironment.weaveInterTypeDeclarations(), and for sourcetypebindings + * AjLookupEnvironment.completeTypeBindings() where it calls processInterTypeMemberTypes). + *

+ * The logic in AjLookupEnvironment.weaveInterTypeDeclarations() is temporarily disabled because I can't write a testcase that + * requires it! It should be an incremental build where a class is loaded as a binary type binding on a secondary (incremental) + * compile and that class needs the inner class applying. + *

+ * Eclipse polices the names of inner types when loading binary type data. The name of the inner is actually maintained as the + * aspect name (so an inner type of Foo in an aspect Bar will be called Bar$Foo). The compiler looks after 'attaching' the inner + * type to the target type binding when required. + * + * @author Andy Clement + */ +public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + /** + * This is testing that on a secondary compile we can work out what happened in the first compile (where an inner type was + * intertyped onto another type). I think we need two conditions to be true for this to pass:
+ * 1) we need an innerclass attribute on the target type
+ * 2) we need the name of the innerclass to match its target rather than the declaring aspect
+ * Line 277 in ClassScope:
+ * + * memberTypeBindings[count++] = memberScope.buildType(sourceType, sourceType.fPackage, accessRestriction);
+ * which then: builds the name based on the containing aspect. + * + * TypeDeclaration.generateCode() + * + */ + public void testSeparateCompilation() throws Exception { + runTest("separate compilation"); + } + + /** + * Interestingly this test makes no reference in the type Basic to the new ITD'd inner type, this causes the Basic type to be + * missing the innertype attribute! + */ + public void testSeparateCompilation2() throws Exception { + runTest("separate compilation - 2"); + } + + public void testErrorTargettingTypeThatAlreadyHasIt() { + runTest("already has it"); + } + + public void testConstruction4() { + runTest("construction4"); + } + + public void testConstruction3() { + runTest("construction3"); + } + + public void testConstruction2() { + runTest("construction2"); + } + + public void testConstruction() { + runTest("construction"); + } + + // now the itd and the itd member class are in different aspects + public void testVoteItdMixture2() { + runTest("vote - itd mixture 2"); + } + + // This test is necessary because it verifies what happens when other ITDs are around + // in addition to the itd member class. In order to apply the other ITDs the methods in a target + // may get resolved. When they are resolved their types (return,etc) are resolved. If this + // happens before the innertype has been added to the target and the types involved reference that + // member type, then a failure will occur. + public void testVoteItdMixture() { + runTest("vote - itd mixture"); + } + + public void testVoteMethodReference() { + runTest("vote - method reference"); + } + + public void testVoteFieldReference() { + runTest("vote - field reference"); + } + + public void testVoteInnerInner() { + runTest("vote - inner inner"); + } + + public void testVoteReferenceViaAnnotation2() { + runTest("vote - reference via annotation - two"); + } + + public void testVoteReferenceViaAnnotation() { + runTest("vote - reference via annotation"); + } + + public void testVoteConstruction() { + runTest("vote - construction"); + } + + public void testVoteBasic() { + runTest("vote - basic"); + } + + // inter type declared classes - working scenarios + public void testFieldAccess() throws Exception { + runTest("field access"); + } + + public void testMethodAccess() throws Exception { + runTest("method access"); + } + + public void testRooScenario() throws Exception { + runTest("choice"); + } + + public void testRooScenario2() throws Exception { + runTest("choice2"); + } + + public void testRooScenarioWeaveInfo() throws Exception { + runTest("choice - weaveinfo"); + } + + public void testModel() throws Exception { + runTest("choice - model"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = new PrintWriter(baos); + AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); + IRelationshipMap irm = AsmManager.lastActiveStructureModel.getRelationshipMap(); + pw.write(irm.toString()); + pw.flush(); + String model = baos.toString(); + assertTrue(model.indexOf("<{Choice.java[Choice=[aspect declarations]") != -1); + assertTrue(model.indexOf("<{Choice.java'X[Keys=[declared on]") != -1); + } + + public void testGenerics1() throws Exception { + runTest("choice - generics 1"); + } + + public void testGenerics2() throws Exception { + runTest("choice - generics 2"); + } + + // compiler limitation tests + public void testNotAllowedOnInterface() throws Exception { + runTest("on interface"); + } + + public void testNotAllowedOnEnum() throws Exception { + runTest("on enum"); + } + + public void testNotAllowedOnAnnotation() throws Exception { + runTest("on annotation"); + } + + public void testOnlyStatic() throws Exception { + runTest("only static"); + } + + // tests for alternate syntax, not yet supported in the grammar + + // intertype {} syntax + // public void testWillItParseEmptyIntertype() throws Exception { + // runTest("simplest", true); + // } + // + // public void testWithAnInnerClass() throws Exception { + // runTest("simplest 2"); + // } + // + // public void testIntertypeMethodInNewStyle() throws Exception { + // runTest("simplest 3"); + // } + // -- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IntertypeTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("intertype.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/TransparentWeavingTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc169/TransparentWeavingTests.java new file mode 100644 index 000000000..a32f4f15e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/TransparentWeavingTests.java @@ -0,0 +1,244 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc169; + +import java.io.File; +import java.lang.reflect.Modifier; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.Field; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * What would a completely transparent weave be? Is there a minimal subset that makes sense? What is the roadmap to get there? What + * needs testing + * + * --- 'Transparent' here is meaning that the resultant bytecode is more representative of the original declarations, so that it + * looks like the intertype declaration and associated constructs have been seamless added to the affected targets. + * + * + * Fully transparent weaving, what would we like to have: - ITDs appear exactly as declared: 'private int A.i' will create 'private + * int i' in A + * + * - What is the benefit? - although this isn't really in keeping with the AspectJ definition of what an ITD represents, having the + * end result look like the declaration does make it easier for users simply looking at the resultant class file or attempting + * reflection to access what they just ITD'd in place + * + * + * testing For transparent weaving of ITD fields - annotations on new fields - AJDT model - AjType support - what happens to it? - + * advice on within() how does that get affected? - visibility - accessors created when required? - handling clashes with existing + * fields - handling clashes with other aspects - generic declarations - interface declarations - initializers - static and + * non-static - accessibility from advice, for read and write + * + * Design
+ * The intention will be 'new code' uses the new style whilst old code continues to cause the old code to be built. Whether the code + * wants to use the old or new naming should be apparent from the + * + * @author Andy Clement + */ +public class TransparentWeavingTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Simple private ITD onto a target + public void testSimplePrivate() throws Exception { + runTest("one - private"); + checkForField("OnePrivate", Modifier.PRIVATE, "x"); + } + + // Default visibility ITD field + public void testSimpleDefault() throws Exception { + runTest("one - default"); + checkForField("OneDefault", 0, "x"); + } + + // annotated private ITD + public void testSimplePrivateAnnotated() throws Exception { + runTest("one - private - annotated"); + Field f = checkForField("OnePrivateAnnotated", Modifier.PRIVATE, "x"); + AnnotationGen[] annos = f.getAnnotations(); + assertTrue(annos.length > 0); // 0==Anno 1==ajcITD + assertEquals("LAnno;", annos[0].getTypeSignature()); + } + + // annotated default ITD + public void testSimpleDefaultAnnotated() throws Exception { + runTest("one - default - annotated"); + Field f = checkForField("OneDefaultAnnotated", 0, "x"); + AnnotationGen[] annos = f.getAnnotations(); + assertTrue(annos.length > 0); // 0==Anno 1==ajcITD + assertEquals("LAnno;", annos[0].getTypeSignature()); + } + + // Simple private ITD with getter/setter usage + public void testSimplePrivateWithAccessors() throws Exception { + runTest("one - private - accessors"); + } + + // check initializer runs OK + public void testSimplePrivateInitializer() throws Exception { + runTest("one - private - initializer"); + } + + public void testDeclareAtOnPrivateItd() throws Exception { + runTest("declare at on private itd"); + Field f = checkForField("OneDeclareAt", Modifier.PRIVATE, "x"); + AnnotationGen[] annos = f.getAnnotations(); + assertTrue(annos.length > 0); // 1==Anno 0==ajcITD + assertEquals("LAnno;", annos[1].getTypeSignature()); + } + + // declare @field on a field that already has one + public void testDeclareAtTwo() throws Exception { + runTest("declare at two"); + Field f = checkForField("DeclareAtTwo", Modifier.PRIVATE, "x"); + AnnotationGen[] annos = f.getAnnotations(); + assertTrue(annos.length > 2); // 1==Anno 0==ajcITD + assertEquals("LAnno;", annos[0].getTypeSignature()); + assertEquals("LAnno2;", annos[2].getTypeSignature()); + } + + public void testTwoItdsOnTarget() throws Exception { + runTest("two itds on target"); + // Aspect X gets the field, aspect Y gets a mangled one + if (hasField("TwoItdsOnTarget", "ajc$interField$Y$x")) { + checkForField("TwoItdsOnTarget", Modifier.PRIVATE, "x"); + checkForField("TwoItdsOnTarget", Modifier.PUBLIC, "ajc$interField$Y$x"); + } else { + checkForField("TwoItdsOnTarget", Modifier.PRIVATE, "x"); + checkForField("TwoItdsOnTarget", Modifier.PUBLIC, "ajc$interField$X$x"); + } + } + + public void testTwoItdsOnTargetThatAlreadyHasIt() throws Exception { + runTest("two itds on target that already has it"); + // Aspect X gets the field, aspect Y gets a mangled one + checkForField("TwoItdsOnTargetHasAlready", Modifier.PUBLIC, "ajc$interField$X$x"); + checkForField("TwoItdsOnTargetHasAlready", Modifier.PUBLIC, "ajc$interField$Y$x"); + } + + public void testInteractingOldAndNew() throws Exception { + runTest("interacting old and new"); + int SYNTHETIC = 0x00001000; // 4096 + if (hasField("InteractingOldAndNew", "ajc$interField$Y$i")) { + checkForField("InteractingOldAndNew", Modifier.PRIVATE, "i"); + checkForField("InteractingOldAndNew", Modifier.PUBLIC, "ajc$interField$Y$i"); + } else { + checkForField("InteractingOldAndNew", Modifier.PRIVATE, "i"); + checkForField("InteractingOldAndNew", Modifier.PUBLIC, "ajc$interField$X$i"); + } + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC | Modifier.STATIC, "main"); + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC | Modifier.STATIC | SYNTHETIC, "ajc$get$i"); + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC | Modifier.STATIC | SYNTHETIC, "ajc$set$i"); + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC, "getI1"); + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC, "getI2"); + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC, "setI1"); + checkForMethod("InteractingOldAndNew", Modifier.PUBLIC, "setI2"); + } + + public void testPrivateGenerics() throws Exception { + runTest("generics - private"); + Field f = checkForField("Generics", Modifier.PRIVATE, "listOfString"); + assertEquals("Ljava/util/List;", f.getGenericSignature()); + f = checkForField("Generics", Modifier.PRIVATE, "thing"); + assertEquals("TX;", f.getGenericSignature()); + } + + // --- + + private boolean hasField(String clazzname, String name) { + try { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), clazzname); + Field[] fs = jc.getFields(); + StringBuffer fields = new StringBuffer(); + for (Field f : fs) { + fields.append(f.getName()).append(" "); + if (f.getName().equals(name)) { + return true; + } + } + } catch (Exception e) { + return false; + } + return false; + } + + private Field checkForField(String clazzname, int modifiers, String name) throws Exception { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), clazzname); + Field[] fs = jc.getFields(); + StringBuffer fields = new StringBuffer(); + for (Field f : fs) { + fields.append(f.getName()).append(" "); + if (f.getName().equals(name)) { + if (f.getModifiers() != modifiers) { + fail("Found field " + name + " in " + clazzname + " but modifiers were wrong, they were " + f.getModifiers()); + } + return f; + } + } + fail("Did not find field " + name + " in class " + clazzname + ". Found fields: " + fields.toString()); + return null; + } + + private Method checkForMethod(String clazzname, int modifiers, String name) throws Exception { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), clazzname); + Method[] fs = jc.getMethods(); + StringBuffer methods = new StringBuffer(); + methods.append("\n"); + for (Method f : fs) { + methods.append(f.getName()).append("\n"); + if (f.getName().equals(name)) { + if (f.getModifiers() != modifiers) { + fail("Found method " + name + " in " + clazzname + " but modifiers were wrong, they were " + f.getModifiers()); + } + return f; + } + System.out.println(f.getGenericSignature()); + } + fail("Did not find method " + name + " in class " + clazzname + ". Found methods: " + methods.toString()); + return null; + } + + // public itd onto a target that already has a field of that name + // just to check what goes wrong and who checks it + public void testPublicClash() throws Exception { + runTest("two"); + } + + public void testPrivateClash() throws Exception { + runTest("three"); + + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Three"); + Field[] fs = jc.getFields(); + for (Field f : fs) { + System.out.println(f); + } + + // public int ajc$interField$X$xPrivate [RuntimeVisibleAnnotations] + // public Integer ajc$interField$$yDefault [RuntimeVisibleAnnotations] + // public String zPublic [RuntimeVisibleAnnotations] + + } + + // -- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(TransparentWeavingTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("transparentweaving.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/ajc169.xml b/tests/src/test/java/org/aspectj/systemtest/ajc169/ajc169.xml new file mode 100644 index 000000000..66de48191 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/ajc169.xml @@ -0,0 +1,413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.txt b/tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.txt new file mode 100644 index 000000000..0fedf993f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.txt @@ -0,0 +1,5 @@ +AspectDeclaration.buildInterTypeAndPerClause + +EclipseTypeMunger.mungeNewInnerClass + +EclipseTypeMunger.findOrCreateInterTypeMemberClassFinder \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.xml b/tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.xml new file mode 100644 index 000000000..75846b05c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/intertype.xml @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/transparentweaving.xml b/tests/src/test/java/org/aspectj/systemtest/ajc169/transparentweaving.xml new file mode 100644 index 000000000..4eb5f6d37 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/transparentweaving.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc170/Ajc170Tests.java new file mode 100644 index 000000000..1f1017328 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2008-2012 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc170; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.Field; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.TypeFactory; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.World; +import org.aspectj.weaver.internal.tools.StandardPointcutExpressionImpl; +import org.aspectj.weaver.patterns.Pointcut; +import org.aspectj.weaver.patterns.PointcutRewriter; +import org.aspectj.weaver.reflect.ReflectionWorld; +import org.aspectj.weaver.tools.StandardPointcutParser; + +/** + * @author Andy Clement + */ +public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +// public void testLostAnnos_377130() { +// runTest("missing annos on priv aspects"); +// } +// +// public void testLostAnnos_377130_2() { +// runTest("missing annos on priv aspects - 2"); +// } + + public void testCovariantGenerics382435_1() { + runTest("covariant generic itds 1"); + } + + public void testCovariantGenerics382435_2() { + runTest("covariant generic itds 2"); + } + + public void testCovariantGenericsItd382189_1() { + runTest("covariant generics 1"); + } + + public void testCovariantGenericsItd382189_2() { + runTest("covariant generics 2"); + } + + public void testCovariantGenericsItd382189_3() { + runTest("covariant generics 3"); + } + + public void testCovariantGenericsItd382189() { + runTest("covariant generics"); + } + + public void testGenericAspectAround382723() { + runTest("generic aspect"); + } + + public void testGenericAspectAround382723_2() { + runTest("generic aspect 2"); + } + + public void testGenericAspectAround382723_3() { + runTest("generic aspect 3"); + } + + public void testGenericAspectAround382723_4() { + runTest("generic aspect 4"); + } + + + public void testAttributeErrorJ7() { + runTest("attribute issue with J7"); + } + + public void testSwitchOnEnum() { + runTest("switch on enum"); + } + + public void testDecAtFieldOrderingLTW1() { + runTest("dec at field ordering ltw 1"); + } + + public void testDecAtFieldOrdering1() { + runTest("dec at field ordering 1"); + } + +// public void testDecAtFieldOrdering2() { +// runTest("dec at field ordering 2"); +// } + + public void testXmlDefsDeclareAnnoType() { + runTest("xml defined dec anno - type"); + } + + public void testXmlDefsDeclareAnnoMethod() { + runTest("xml defined dec at method"); + } + + // anno not runtime vis + public void testXmlDefsDeclareAnnoMethod2() { + runTest("xml defined dec at method 2"); + } + + public void testXmlDefsDeclareAnnoField() { + runTest("xml defined dec at field"); + } + + public void testXmlDefsDeclareAnnoFieldVariants1() { + runTest("xml defined dec anno - variants 1"); + } + + public void testXmlDefsDeclareAnnoFieldVariants2() { + runTest("xml defined dec anno - variants 2"); + } + + public void testXmlDefsDeclareAnnoFieldMultipleValues() { + runTest("xml defined dec anno - multiple values"); + } + + public void testXmlDefsDeclareAnnoFieldMultipleValuesAndSpaces() { + runTest("xml defined dec anno - multiple values and spaces"); + } + + public void testPointcutExpense_374964() { + // check a declaring type being specified causes the call() to be considered cheaper than this() + + World world = new ReflectionWorld(true, getClass().getClassLoader()); + StandardPointcutParser pointcutParser = StandardPointcutParser.getPointcutParserSupportingAllPrimitives(world); + StandardPointcutExpressionImpl pointcutExpression = (StandardPointcutExpressionImpl)pointcutParser.parsePointcutExpression("call(* *(..)) && this(Object)"); + Pointcut pc = pointcutExpression.getUnderlyingPointcut(); + Pointcut newp = new PointcutRewriter().rewrite(pc); + // no declaring type so this() is considered cheaper + assertEquals("(this(java.lang.Object) && call(* *(..)))",newp.toString()); + + pointcutExpression = (StandardPointcutExpressionImpl)pointcutParser.parsePointcutExpression("call(* String.*(..)) && this(Object)"); + pc = pointcutExpression.getUnderlyingPointcut(); + newp = new PointcutRewriter().rewrite(pc); + // declaring type, so call() is cheaper + assertEquals("(call(* java.lang.String.*(..)) && this(java.lang.Object))",newp.toString()); + + pointcutExpression = (StandardPointcutExpressionImpl)pointcutParser.parsePointcutExpression("this(Object) && call(* *(..)) && call(* String.*(..))"); + pc = pointcutExpression.getUnderlyingPointcut(); + newp = new PointcutRewriter().rewrite(pc); + // more complex example, mix of them + assertEquals("((call(* java.lang.String.*(..)) && this(java.lang.Object)) && call(* *(..)))",newp.toString()); + } + + public void testBCExceptionAnnoDecp_371998() { + runTest("BCException anno decp"); + } + + public void testTransientTjpFields()throws Exception { + runTest("transient tjp fields"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code"); + Field[] fs = jc.getFields(); + //private static final org.aspectj.lang.JoinPoint$StaticPart ajc$tjp_0 [Synthetic] + //private static final org.aspectj.lang.JoinPoint$StaticPart ajc$tjp_1 [Synthetic] + for (Field f: fs) { + if (!f.isTransient()) { + fail("Field should be transient: "+f); + } + } + } + + public void testGenericsWithTwoTypeParamsOneWildcard() { + UnresolvedType ut; + + ut = TypeFactory.createTypeFromSignature("LFoo<**>;"); + assertEquals(2,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo<***>;"); + assertEquals(3,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo;"); + assertEquals(2,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo<*+Ljava/lang/String;TP;>;"); + assertEquals(2,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo<*+Ljava/lang/String;TP;>;"); + assertEquals(2,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo<*TT;>;"); + assertEquals(2,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo<[I>;"); + assertEquals(1,ut.getTypeParameters().length); + + ut = TypeFactory.createTypeFromSignature("LFoo<[I[Z>;"); + assertEquals(2,ut.getTypeParameters().length); + } + + public void testPerThis() { + runTest("perthis"); + } + + public void testPerTarget() { + runTest("pertarget"); + } + + public void testPerCflow() { + runTest("percflow"); + } + + public void testPerTypeWithin() { + runTest("pertypewithin"); + } + + // not specifying -1.7 + public void testDiamond1() { + runTest("diamond 1"); + } + + public void testDiamond2() { + runTest("diamond 2"); + } + + public void testDiamondItd1() { + runTest("diamond itd 1"); + } + + public void testLiterals1() { + runTest("literals 1"); + } + + public void testLiterals2() { + runTest("literals 2"); + } + + public void testLiteralsItd1() { + runTest("literals itd 1"); + } + + public void testStringSwitch1() { + runTest("string switch 1"); + } + + public void testStringSwitch2() { + runTest("string switch 2"); + } + + public void testMultiCatch1() { + runTest("multi catch 1"); + } + + public void testMultiCatch2() { + runTest("multi catch 2"); + } + + public void testMultiCatchWithHandler1() { + runTest("multi catch with handler 1"); + } + + public void testMultiCatchAspect1() { + runTest("multi catch aspect 1"); + } + + // public void testMultiCatchWithHandler2() { + // runTest("multi catch with handler 2"); + // } + + public void testSanity1() { + runTest("sanity 1"); + } + + public void testMissingImpl_363979() { + runTest("missing impl"); + } + + public void testMissingImpl_363979_2() { + runTest("missing impl 2"); + } + + public void testStackOverflow_364380() { + runTest("stackoverflow"); + } + + // public void testTryResources1() { + // runTest("try resources 1"); + // } + // + // public void testTryResources2() { + // runTest("try resources 2"); + // } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc170Tests.class); + } + + @Override + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc170/ajc170.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc170/AllTestsAspectJ170.java b/tests/src/test/java/org/aspectj/systemtest/ajc170/AllTestsAspectJ170.java new file mode 100644 index 000000000..fbb7cd2c9 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc170/AllTestsAspectJ170.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc170; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ170 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.7.0 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc170Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc170/IndyTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc170/IndyTests.java new file mode 100644 index 000000000..5846a66fd --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc170/IndyTests.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc170; + +import java.io.File; +import java.io.IOException; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class IndyTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // staticinitialization on bytecode containing methodtyperef/methodhandle/bootstrapmethods/invokedynamic + public void testInvokeDynamic_staticinitialization() throws IOException { + runTest("indy - 1"); + } + + // execution pointcuts on same bytecode + public void testInvokeDynamic_execution() throws IOException { + runTest("indy - 2"); + } + + // call pointcuts on same bytecode + public void testInvokeDynamic_call() throws IOException { + runTest("indy - 3"); + } + + // within(Code1) on same bytecode + public void testInvokeDynamic_target() throws IOException { + runTest("indy - 4"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IndyTests.class); + } + + @Override + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc170/indy.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/test/java/org/aspectj/systemtest/ajc170/ajc170.xml new file mode 100644 index 000000000..e379d6cab --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc170/ajc170.xml @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc170/indy.xml b/tests/src/test/java/org/aspectj/systemtest/ajc170/indy.xml new file mode 100644 index 000000000..0c4bbe580 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc170/indy.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests.java new file mode 100644 index 000000000..922ac483a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2012 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc171; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc171Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testNpe_pr384401() { + runTest("npe"); + } + + public void testUnresolvableEnum_pr387568() { + runTest("unresolvable enum"); + } + + public void testAbstractItds_pr386049() { + runTest("itd abstract"); + } + + public void testPublicITDFs_pr73507_1() { + runTest("public ITDfs - 1"); + } + + public void testPublicITDFs_pr73507_2() { + runTest("public ITDfs - 2"); + } + + public void testPublicITDFs_pr73507_3() { + runTest("public ITDfs - 3"); + } + + public void testPublicITDFs_pr73507_4() { + runTest("public ITDfs - 4"); + } + + public void testPublicITDFs_pr73507_5() { + runTest("public ITDfs - 5"); + } + + public void testGenerics_384398() { + runTest("generics itds"); + } + +// public void testGenerics_384398_2() { +// runTest("generics itds 2"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc171Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc171.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java b/tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java new file mode 100644 index 000000000..d6faaa516 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2012 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc171; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc171Tests_need17jre extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testSoft17_pr387444() { + runTest("soft 17"); + } + + public void testSoft17_pr387444_2() { + runTest("soft 17 2"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc171Tests_need17jre.class); + } + + @Override + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc171/ajc171.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java b/tests/src/test/java/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java new file mode 100644 index 000000000..f9d309794 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc171; + +import org.aspectj.systemtest.ajc1610.NewFeatures; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ171 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.7.1 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc171Tests.suite()); + suite.addTest(NewFeatures.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc171/NewFeatures.java b/tests/src/test/java/org/aspectj/systemtest/ajc171/NewFeatures.java new file mode 100644 index 000000000..6a713e930 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc171/NewFeatures.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2012 Lucierna + * 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: + * Abraham Nevado (lucierna) - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc171; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +// NOTE THIS IS ACTUALLY IN 1.7.2 - IT IS JUST THAT THE PATCH WAS CREATED AGAINST 1.7.1 +public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testSharedCache() { + this.runTest("Test Shared Cache"); + File cacheFolder = new File(ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "panenka.cache"); + assertTrue("Cache folder should be written when using share cache", cacheFolder.exists()); + //Delete the cache from the ajc sandbox + deleteFolder(cacheFolder); + } + + public void testPerClassLoaderCache() { + this.runTest("Test Per ClassLoader Cache"); + File cacheFolder = new File(ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "panenka.cache"); + assertFalse("Shared Cache Folder should not be present", cacheFolder.exists()); + } + + public void testDefaultCachePerClassloader() { + this.runTest("Test Default Cache Per ClassLoader"); + File cacheFolder = new File(ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "panenka.cache"); + assertFalse("By Default Per ClassLoader Cache should be used and not the shared one", cacheFolder.exists()); + } + + // /////////////////////////////////////// + + private static void deleteFolder(File folder) { + File[] files = folder.listFiles(); + if(files!=null) { //some JVMs return null for empty dirs + for(File f: files) { + if(f.isDirectory()) { + deleteFolder(f); + } else { + f.delete(); + } + } + } + folder.delete(); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(NewFeatures.class); + } + + @SuppressWarnings("unused") + private JavaClass getMyClass(String className) throws ClassNotFoundException { + return getClassFrom(ajc.getSandboxDirectory(), className); + } + + @Override + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc171/newfeatures-tests.xml"); + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc171/ajc171.xml b/tests/src/test/java/org/aspectj/systemtest/ajc171/ajc171.xml new file mode 100644 index 000000000..d9a7651f3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc171/ajc171.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc171/newfeatures-tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc171/newfeatures-tests.xml new file mode 100644 index 000000000..32f0f1845 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc171/newfeatures-tests.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc172/Ajc172Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc172/Ajc172Tests.java new file mode 100644 index 000000000..c4c10d1fa --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc172/Ajc172Tests.java @@ -0,0 +1,210 @@ +/******************************************************************************* + * Copyright (c) 2012 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc172; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc172Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testUnsupportedShouldBeNormalError_pr391384() { + runTest("unsupported should be normal error"); + } + + // if the test is failing because the classes won't run, remove the run blocks from the ajc172.xml entry and re-run to check signatures. + public void testSignatures_pr394535() throws Exception { + runTest("signatures"); + + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Bug2$ClassA2"); // the working one + String sss = jc.getSignatureAttribute().getSignature(); + assertEquals("Ljava/lang/Object;Ljava/io/Serializable;", sss); + + jc = getClassFrom(ajc.getSandboxDirectory(),"Bug$ClassA"); + sss = jc.getSignatureAttribute().getSignature(); + assertEquals("Ljava/lang/Object;Ljava/io/Serializable;", sss); + } + + // extends + public void testPSignatures_pr399590() throws Exception { + runTest("p signatures 1"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); + String sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";>;>LBar;", sss); + jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); + sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";>;>LBar2;Ljava/io/Serializable;", sss); + } + + // extends two classes + public void testPSignatures_pr399590_2() throws Exception { + runTest("p signatures 2"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); + String sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";LIntf;>;Q:Ljava/lang/Object;>LBar;", sss); + jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); + sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";LIntf2;>;Q:Ljava/lang/Object;>LBar2;Ljava/io/Serializable;", sss); + } + + // super + public void testPSignatures_pr399590_3() throws Exception { + runTest("p signatures 3"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); + String sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";>;>LBar;", sss); + jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); + sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";>;>LBar2;Ljava/io/Serializable;", sss); + } + + // super + public void testPSignatures_pr399590_4() throws Exception { + runTest("p signatures 4"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); + String sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";LYYY;>;>LBar;", sss); + jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); + sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";LYYY2;>;>LBar2;Ljava/io/Serializable;", sss); + } + + // unbound + public void testPSignatures_pr399590_5() throws Exception { + runTest("p signatures 5"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); + String sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";>LBar;", sss); + jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); + sss = jc.getSignatureAttribute().getSignature(); + assertEquals(";>LBar2;Ljava/io/Serializable;", sss); + } + + public void testIfPointcutNames_pr398246() throws Exception { + runTest("if pointcut names"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if"); + assertEquals("ajc$if$andy", m.getName()); + } + + public void testIfPointcutNames_pr398246_2() throws Exception { + runTest("if pointcut names 2"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if"); + assertEquals("ajc$if$fred", m.getName()); + } + + // fully qualified annotation name is used + public void testIfPointcutNames_pr398246_3() throws Exception { + runTest("if pointcut names 3"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if"); + assertEquals("ajc$if$barney", m.getName()); + } + + // compiling a class later than the initial build - does it pick up the + // right if clause name? + public void testIfPointcutNames_pr398246_4() throws Exception { + runTest("if pointcut names 4"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if"); + assertEquals("ajc$if$sid", m.getName()); + } + + // new style generated names + public void testIfPointcutNames_pr398246_5() throws Exception { + runTest("if pointcut names 5"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if"); + assertEquals("ajc$if$ac0cb804", m.getName()); + + jc = getClassFrom(ajc.getSandboxDirectory(), "X2"); + m = getMethodStartsWith(jc, "ajc$if"); + assertEquals("ajc$if$ac0cb804", m.getName()); + } + + // new style generated names - multiple ifs in one pointcut + public void testIfPointcutNames_pr398246_6() throws Exception { + runTest("if pointcut names 6"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if",1); + assertEquals("ajc$if$aac93da8", m.getName()); + m = getMethodStartsWith(jc, "ajc$if",2); + assertEquals("ajc$if$1$ae5e778a", m.getName()); + } + + // new style generated names - multiple ifs in one advice + public void testIfPointcutNames_pr398246_7() throws Exception { + runTest("if pointcut names 7"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); + Method m = getMethodStartsWith(jc, "ajc$if",1); + assertEquals("ajc$if$1$ac0607c", m.getName()); + m = getMethodStartsWith(jc, "ajc$if",2); + assertEquals("ajc$if$1$1$4d4baf36", m.getName()); + } + + public void testOptionalAspects_pr398588() { + runTest("optional aspects"); + } + + public void testInconsistentClassFile_pr389750() { + runTest("inconsistent class file"); + } + + public void testInconsistentClassFile_pr389750_2() { + runTest("inconsistent class file 2"); + } + + public void testInconsistentClassFile_pr389750_3() { + runTest("inconsistent class file 3"); + } + + public void testInconsistentClassFile_pr389750_4() { + runTest("inconsistent class file 4"); + } + + public void testAnnotationValueError_pr389752_1() { + runTest("annotation value error 1"); + } + + public void testAnnotationValueError_pr389752_2() { + runTest("annotation value error 2"); + } + + // this needs some cleverness to fix... the annotation value is parsed as a + // string and then not checked + // to see if the user is accidentally supplying, for example, an enum value. + // Due to the use of strings, it + // is hard to check. The verification code might go here: + // WildAnnotationTypePattern, line 205 (the string case) + // public void testAnnotationValueError_pr389752_3() { + // runTest("annotation value error 3"); + // } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc172Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc172.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java b/tests/src/test/java/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java new file mode 100644 index 000000000..b79cc40fa --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc172; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ172 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.7.2 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc172Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc172/ajc172.xml b/tests/src/test/java/org/aspectj/systemtest/ajc172/ajc172.xml new file mode 100644 index 000000000..3eb4f2cb3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc172/ajc172.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc173/Ajc173Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc173/Ajc173Tests.java new file mode 100644 index 000000000..5e007441f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc173/Ajc173Tests.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2013 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc173; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc173Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testAddRemoveAnnos_407739() throws Exception { + runTest("add remove annos"); + } + +// public void testOrdering_407966() throws Exception { +// runTest("ordering"); +// } +// +// public void testInnerInterfaceMixin_408014() throws Exception { +// runTest("inner interface mixin"); +// } + + public void testClassAnnoValue_405016_1() throws Exception { + // test that class literals allowed + runTest("class anno value 1"); + } + + public void testInnerNames_407494() throws Exception { + runTest("inner names"); + } + + public void testInnerNames_407494_2() throws Exception { + runTest("inner names 2"); + } + +// public void testClassAnnoValue_405016() throws Exception { +// runTest("class anno value"); +// } + + public void testAbstractMethodError_404601() throws Exception { + runTest("abstract method error"); + } + + public void testDeclareAnnoOnItd() throws Exception { + runTest("declare anno on itd"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"C"); + Method m = getMethodStartsWith(jc, "getName"); + assertNotNull(m); + AnnotationGen[] ags = m.getAnnotations(); + for (int i=0;i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc174/Ajc174Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc174/Ajc174Tests.java new file mode 100644 index 000000000..274fc892c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc174/Ajc174Tests.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2013 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc174; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc174Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +/* wip + public void testAjdtMarkers() throws Exception { + runTest("ajdt markers"); + } +*/ + + public void testExtraInserts() throws Exception { + runTest("extra inserts"); + } + + public void testMoreConfigurableLint_419279() throws Exception { + runTest("more configurable lint"); + } + + public void testAnnotatedItd_418129() throws Exception { + runTest("annotated itd"); + } + + public void testAnnotatedItd_418129_2() throws Exception { + runTest("annotated itd 2"); + } + + public void testAnnotatedItd_418129_3() throws Exception { + runTest("annotated itd 3"); + } + + public void testAnnotatedItd_418129_4() throws Exception { + runTest("annotated itd 4"); + } + + public void testSuperItdCtor_413378() throws Exception { + runTest("super itd ctor"); + } + + // no exclusion, this is how it should work + public void testCLExclusion_pr368046_1_noskippedloaders() { + runTest("classloader exclusion - 1"); + } + + public void testCLExclusion_pr368046_1_syspropset() { + try { + System.setProperty("aj.weaving.loadersToSkip", "foo"); + runTest("classloader exclusion - 2"); + } finally { + System.setProperty("aj.weaving.loadersToSkip", ""); + } + } + + // final repeat this test, to confirm no lingering static + public void testCLExclusion_pr368046_1_again_noskippedloaders() { + runTest("classloader exclusion - 3"); + } + + public void testCLExclusion_pr368046_2_usingaopxml() { + runTest("classloader exclusion - 4"); + } + + public void testCLExclusion_pr368046_2_usingaopxmlReal() { + runTest("classloader exclusion - 5"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc174Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc174.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java b/tests/src/test/java/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java new file mode 100644 index 000000000..01a9525ec --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2013 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc174; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ174 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.7.4 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc174Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc174/ajc174.xml b/tests/src/test/java/org/aspectj/systemtest/ajc174/ajc174.xml new file mode 100644 index 000000000..456fb412f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc174/ajc174.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc175/Ajc175Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc175/Ajc175Tests.java new file mode 100644 index 000000000..2296c8e59 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc175/Ajc175Tests.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2013 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc175; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc175Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +// public void testIllegalAccessError_430243() throws Exception { +// runTest("illegalaccesserror"); +// } + + public void testVertxVerifyError_423257() throws Exception { + runTest("vertx verify error"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc175Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc175.xml"); + } + + public static void main(String[] args) { + + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc175/AllTestsAspectJ175.java b/tests/src/test/java/org/aspectj/systemtest/ajc175/AllTestsAspectJ175.java new file mode 100644 index 000000000..7be7c3bac --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc175/AllTestsAspectJ175.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2013 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc175; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ175 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.7.5 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc175Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc175/ajc175.xml b/tests/src/test/java/org/aspectj/systemtest/ajc175/ajc175.xml new file mode 100644 index 000000000..2db4a984a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc175/ajc175.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc180/Ajc180Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc180/Ajc180Tests.java new file mode 100644 index 000000000..558179f0a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc180/Ajc180Tests.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2013-2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc180; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc180Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testPercflowLtw_432178() { + runTest("percflow ltw"); + } + + public void testStackmapframe_431976() { + runTest("stackmapframe"); + } + + public void testThisJoinPointNotInitialized_431976() { + runTest("thisJoinPoint not initialized"); + } + + public void testNullAnnotationMatching_431541() { + runTest("NullAnnotationMatching exception"); + } + + public void testAnnosWith18Flags_415957() { + runTest("annotations with 1.8 flags"); + } + + public void testJava8Code() throws Exception { + runTest("first advised java 8 code"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc180Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc180.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java b/tests/src/test/java/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java new file mode 100644 index 000000000..453c057eb --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2013 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc180; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ180 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.0 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc180Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc180/ajc180.xml b/tests/src/test/java/org/aspectj/systemtest/ajc180/ajc180.xml new file mode 100644 index 000000000..257f5972c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc180/ajc180.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc181/Ajc181Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc181/Ajc181Tests.java new file mode 100644 index 000000000..3aa41837e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc181/Ajc181Tests.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc181; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc181Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testParameterNamesAttribute_436531() { + runTest("parameter names attribute"); + } + + public void testVariableNotInitialized_431976() { + runTest("variable not initialized"); + } + + public void testThisEnclosingJoinPointStaticPartNotInitialized_431976() { + runTest("thisEnclosingJoinPointStaticPart not initialized"); + } + + public void testLvarTable_435446() throws Exception { + runTest("lvartable"); + } + + public void testBrokenAnnotations_377096() throws Exception { + runTest("broken annotations"); + Method method = getMethodFromClass(getClassFrom(ajc.getSandboxDirectory(), "C"), "xxx"); + method.getAnnotations(); + } + + public void testDefaultMethods_433744() { + runTest("default methods"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc181Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc181.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc181/AllTestsAspectJ181.java b/tests/src/test/java/org/aspectj/systemtest/ajc181/AllTestsAspectJ181.java new file mode 100644 index 000000000..a6c89f895 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc181/AllTestsAspectJ181.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc181; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.systemtest.apt.AptTests; + +public class AllTestsAspectJ181 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.1 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc181Tests.suite()); + suite.addTest(AptTests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc181/ajc181.xml b/tests/src/test/java/org/aspectj/systemtest/ajc181/ajc181.xml new file mode 100644 index 000000000..1a8b1acfc --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc181/ajc181.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java new file mode 100644 index 000000000..37896b42f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1810; + +import java.io.File; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testBinding_508661() { + runTest("various ltw"); + } + + public void testBinding_500035() { + runTest("ataspectj binding"); + } + + public void testBinding_500035_2() { + runTest("ataspectj binding 2"); + } + + public void testBinding_500035_3() { + runTest("ataspectj binding 3 -XnoInline"); + } + + public void testBinding_500035_4() { + runTest("ataspectj binding 4"); + } + + public void testGenericsException_501656() { + runTest("generics exception"); + } + + public void testAIOOBE_502807() { + runTest("unexpected aioobe"); + } + + public void testInvokeDynamic_490315() { + runTest("indy"); + } + + public void testAmbigMessage17() throws Exception { + runTest("ambiguous message - 17"); + } + + public void testAmbigMessage18() throws Exception { + runTest("ambiguous message - 18"); + } + + // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6 + public void testInnerClassesAttributeStructure_493554() throws Exception { + runTest("pertarget"); + + // Testcode commented out below is for full analysis of the inner class attribute but under + // 493554 we are going to remove that attribute for this class + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect"); + assertNotNull(jc); + assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers()); + Attribute[] attributes = jc.getAttributes(); + for (Attribute attribute: attributes) { + if (attribute.getName().equals("InnerClasses")) { + fail("Did not expect to find InnerClasses attribute"); + } + } + +// // Is InnerClasses attribute well formed for the pertarget interface? +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect"); +// assertNotNull(jc); +// assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers()); +// Attribute attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses"); +// assertNotNull(attr); +// InnerClasses innerClasses = (InnerClasses)attr; +// InnerClass[] innerClassArray = innerClasses.getInnerClasses(); +// assertEquals(1,innerClassArray.length); +// InnerClass innerClass = innerClassArray[0]; +// ConstantPool cp = jc.getConstantPool(); +// +// // The value of the inner_class_info_index item must be a valid index into the +// // constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info +// // structure representing C. +// int innerClassIndex = innerClass.getInnerClassIndex(); +// ConstantClass cc = (ConstantClass)cp.getConstant(innerClassIndex); +// ConstantUtf8 utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue()); +// +// // The remaining items in the classes array entry give information about C. +// // The value of the outer_class_info_index item must be a valid index into the +// // constant_pool table, and the entry at that index must be a CONSTANT_Class_info +// // structure representing the class or interface of which C is a member. +// int outerClassIndex = innerClass.getOuterClassIndex(); +// cc = (ConstantClass)cp.getConstant(outerClassIndex); +// utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect",utf8.getStringValue()); +// +// // The value of the inner_name_index item must be a valid index into the constant_pool table, +// // and the entry at that index must be a CONSTANT_Utf8_info structure (§4.4.7) that represents +// // the original simple name of C, as given in the source code from which this class file was compiled. +// int innerNameIndex = innerClass.getInnerNameIndex(); +// utf8 = cp.getConstantUtf8(innerNameIndex); +// assertEquals("ajcMightHaveAspect",utf8.getStringValue()); +// +// int innerAccessFlags = innerClass.getInnerAccessFlags(); +// assertEquals(Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags); +// +// // Is InnerClasses attribute well formed for the containing type? +// jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect"); +// assertNotNull(jc); +// attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses"); +// assertNotNull(attr); +// innerClasses = (InnerClasses)attr; +// innerClassArray = innerClasses.getInnerClasses(); +// assertEquals(1,innerClassArray.length); +// innerClass = innerClassArray[0]; +// cp = jc.getConstantPool(); +// System.out.println(innerClass); +// +// // inner class name +// innerClassIndex = innerClass.getInnerClassIndex(); +// cc = (ConstantClass)cp.getConstant(innerClassIndex); +// utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue()); +// +// // outer class name +// outerClassIndex = innerClass.getOuterClassIndex(); +// cc = (ConstantClass)cp.getConstant(outerClassIndex); +// utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect",utf8.getStringValue()); +// +// // Simple name +// innerNameIndex = innerClass.getInnerNameIndex(); +// utf8 = cp.getConstantUtf8(innerNameIndex); +// assertEquals("ajcMightHaveAspect",utf8.getStringValue()); +// +// // inner modifiers +// innerAccessFlags = innerClass.getInnerAccessFlags(); +// assertEquals(Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags); +// +// // Reflection work getDeclaredClasses? +// +// // What about other interfaces? + } + + + +// public void testOverweaving_352389() throws Exception { +// runTest("overweaving"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1810Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1810.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java b/tests/src/test/java/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java new file mode 100644 index 000000000..b4fe6a8f3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1810; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1810 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.10 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1810Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1810/ajc1810.xml new file mode 100644 index 000000000..0171f5b55 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java new file mode 100644 index 000000000..9aa1bff94 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1811; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.bcel.BcelWorld; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testParameterizedWithInner() throws Exception { + runTest("parameterized with inner"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Outer"); + assertNotNull(jc); + BcelWorld world = new BcelWorld(ajc.getSandboxDirectory().toString()); + + ResolvedType outerType = world.resolve(UnresolvedType.forName("Outer")); + ResolvedMember m = findMethod(outerType,"m"); + + UnresolvedType type = m.getReturnType(); + assertEquals("LOuter$Inner;",type.getSignature()); + + type = m.getGenericReturnType(); + assertEquals("LOuter$Inner;",type.getSignature()); + + ResolvedType resolvedType = world.resolve(type); + ResolvedType outerResolvedType = resolvedType.getOuterClass(); + assertEquals("LOuter;",outerResolvedType.getSignature()); + + ResolvedMember m2 = findMethod(outerType,"m2"); + type = m2.getReturnType(); + assertEquals("LOuter$Inner;",type.getSignature()); + + type = m2.getGenericReturnType(); + assertEquals("LOuter$Inner;",type.getSignature()); + + // public Inner m() { ... } +// Method m = findMethod(jc,"m"); +// System.out.println(m); +// System.out.println(">"+m.getReturnType()); +// assertNotNull(returnType); + + // public Outer.Inner m2() { ... } + } + +// +// public void testMultiArgs_509235() { +// runTest("multiargs"); +// } +// +// public void testMultiArgs_509235_2() { +// runTest("multiargs - no ellipsis"); +// } + + // 1.8.13: + + public void testAjcGenerics() { + runTest("generics"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1811Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1811.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java b/tests/src/test/java/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java new file mode 100644 index 000000000..b8aca6712 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1811; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1811 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.11 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1811Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1811/ajc1811.xml b/tests/src/test/java/org/aspectj/systemtest/ajc1811/ajc1811.xml new file mode 100644 index 000000000..fe59c3595 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1811/ajc1811.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc182/Ajc182Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc182/Ajc182Tests.java new file mode 100644 index 000000000..545def45d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc182/Ajc182Tests.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc182; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisTypeAnnos; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc182Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testInvisTypeAnnos_440983() throws ClassNotFoundException { + runTest("invis type annos"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code"); + Method m = getMethodStartsWith(jc, "xxx"); + RuntimeInvisTypeAnnos rita = (RuntimeInvisTypeAnnos)getAttributeStartsWith(m.getCode().getAttributes(),"RuntimeInvisibleTypeAnnotations"); + assertEquals("AnnotationGen:[Anno #0 {}]",rita.getTypeAnnotations()[0].getAnnotation().toString()); + } + + public void testInvisTypeAnnos_440983_2() throws ClassNotFoundException { + runTest("invis type annos 2"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc182Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("tests.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java b/tests/src/test/java/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java new file mode 100644 index 000000000..c0323f0ef --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc182; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ182 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.2 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc182Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc182/tests.xml b/tests/src/test/java/org/aspectj/systemtest/ajc182/tests.xml new file mode 100644 index 000000000..9b7383810 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc182/tests.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc183/Ajc183Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc183/Ajc183Tests.java new file mode 100644 index 000000000..db6878e15 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc183/Ajc183Tests.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc183; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc183Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testSuperCalls_443355() { + runTest("super calls"); + } + + public void testSuppressTypeNotFoundAbstract_436653_2() { + runTest("suppress type not found - abstract 2"); + } + + public void testSuppressTypeNotFoundAbstract_436653_1() { + runTest("suppress type not found - abstract 1"); + } + + public void testSuppressTypeNotFound_436653() { + runTest("suppress type not found"); + } + + public void testSuppressTypeNotFound_436653_2() { + runTest("suppress type not found 2"); + } + + public void testSuppressTypeNotFound_436653_3() { + runTest("suppress type not found 3"); + } + + public void testSuppressTypeNotFound_436653_4() { + runTest("suppress type not found 4"); + } + + public void testSuppressTypeNotFound_436653_5() { + runTest("suppress type not found 5"); + } + + public void testSuppressTypeNotFound_436653_6() { + runTest("suppress type not found 6"); + } + + public void testSuppressTypeNotFound_436653_7() { + runTest("suppress type not found 7"); + } + + public void testSuppressTypeNotFound_436653_8() { + runTest("suppress type not found 8"); + } + + public void testConstantPool_445395_0() { + runTest("constant pool 0"); + } + + public void testConstantPool_445395() { + runTest("constant pool"); + } + + public void testAbstractAspectNPE_444398() { + runTest("abstract aspect npe"); + } + + public void testVerifyError_443447() { + runTest("verifyerror"); + } +// +// public void testAnnoStyleDecp_442425() { +// runTest("anno style decp"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc183Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc183.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java b/tests/src/test/java/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java new file mode 100644 index 000000000..8b68b8e40 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc183; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ183 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.3 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc183Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc183/ajc183.xml b/tests/src/test/java/org/aspectj/systemtest/ajc183/ajc183.xml new file mode 100644 index 000000000..e1c40ae72 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc183/ajc183.xml @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc184/Ajc184Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc184/Ajc184Tests.java new file mode 100644 index 000000000..7e1265a0b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc184/Ajc184Tests.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc184; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc184Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + // The thisAspectInstance tests here are a copy from Ajc1612Tests but we are compiling with -1.8 and not -1.5 + + public void testThisAspectInstance_239649_1() throws Exception { + // simple case + runTest("thisAspectInstance - 1"); + } + + public void testThisAspectInstance_239649_2() throws Exception { + // before advice toggling on/off through if called method + runTest("thisAspectInstance - 2"); + } + + public void testThisAspectInstance_239649_3() throws Exception { + // after advice toggling on/off through if called method + runTest("thisAspectInstance - 3"); + } + + public void testThisAspectInstance_239649_4() throws Exception { + // before advice, also using thisJoinPointStaticPart + runTest("thisAspectInstance - 4"); + } + + public void testThisAspectInstance_239649_5() throws Exception { + // before advice, also using thisJoinPoint + runTest("thisAspectInstance - 5"); + } + + public void testThisAspectInstance_239649_6() throws Exception { + // before advice, also using thisEnclosingJoinPointStaticPart + runTest("thisAspectInstance - 6"); + } + + public void testThisAspectInstance_239649_7() throws Exception { + // before advice, also using thisJoinPoint and thisJoinPointStaticPart + runTest("thisAspectInstance - 7"); + } + + public void testThisAspectInstance_239649_8() throws Exception { + // before advice, also using abstract aspects + runTest("thisAspectInstance - 8"); + } + + public void testThisAspectInstance_239649_9() throws Exception { + // before advice, also using abstract aspects 2 + runTest("thisAspectInstance - 9"); + } + + public void testThisAspectInstance_239649_10() throws Exception { + // aspects in a package + runTest("thisAspectInstance - 10"); + } + + public void testThisAspectInstance_239649_11() throws Exception { + // non-singleton aspect - should be an error for now + runTest("thisAspectInstance - 11"); + } + + public void testThisAspectInstance_239649_12() throws Exception { + // arg binding and tjpsp + runTest("thisAspectInstance - 12"); + } + + public void testThisAspectInstance_239649_13() throws Exception { + // pass instance + runTest("thisAspectInstance - 13"); + } + + public void testThisAspectInstance_239649_14() throws Exception { + // multiple ifs + runTest("thisAspectInstance - 14"); + } + + public void testThisAspectInstance_239649_15() throws Exception { + // abstract aspects + runTest("thisAspectInstance - 15"); + } + + public void testIsFinal_449739() { + runTest("is final"); + } + + public void testIsFinal_449739_2() { + runTest("is final - 2"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc184Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc184.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java b/tests/src/test/java/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java new file mode 100644 index 000000000..be0b12112 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc184; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ184 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.4 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc184Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc184/ajc184.xml b/tests/src/test/java/org/aspectj/systemtest/ajc184/ajc184.xml new file mode 100644 index 000000000..3010ce169 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc184/ajc184.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc185/Ajc185Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc185/Ajc185Tests.java new file mode 100644 index 000000000..77b453188 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc185/Ajc185Tests.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc185; + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc185Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testUnresolvableMember_456357() throws Exception { + runTest("unresolvable member"); + } + + // Waiting on JDT fix. Second test is a 'variant' that is also causing me issues but not JDT it seems. Let's + // see what happens when we pick up the real fixes. +// public void testBadAnnos_455608() throws Exception { +// runTest("bad annos"); +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code2"); +// File f = new File(ajc.getSandboxDirectory(), "Code2.class"); +// byte[] data = loadFileAsByteArray(f); +// // Will throw ClassFormatException if there is a problem +// new ClassFileReader(data, null); +// } +// +// public void testBadAnnos_455608_2() throws Exception { +// runTest("bad annos 2"); +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code3"); +// File f = new File(ajc.getSandboxDirectory(), "Code3.class"); +// byte[] data = loadFileAsByteArray(f); +// // Will throw ClassFormatException if there is a problem +// new ClassFileReader(data, null); +// } + + public void testITDInterface_451966() throws Exception { + runTest("itd interface"); + } + + public void testITDInterface_451966_2() throws Exception { + // call made from inner type + runTest("itd interface - 2"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc185Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc185.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc185/AllTestsAspectJ185.java b/tests/src/test/java/org/aspectj/systemtest/ajc185/AllTestsAspectJ185.java new file mode 100644 index 000000000..0cd580fce --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc185/AllTestsAspectJ185.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc185; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ185 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.5 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc185Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc185/ajc185.xml b/tests/src/test/java/org/aspectj/systemtest/ajc185/ajc185.xml new file mode 100644 index 000000000..15fee4e84 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc185/ajc185.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java new file mode 100644 index 000000000..1625f96d1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc186; + +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.tools.ContextBasedMatcher; +import org.aspectj.weaver.tools.DefaultMatchingContext; +import org.aspectj.weaver.tools.FuzzyBoolean; +import org.aspectj.weaver.tools.MatchingContext; +import org.aspectj.weaver.tools.PointcutDesignatorHandler; +import org.aspectj.weaver.tools.PointcutExpression; +import org.aspectj.weaver.tools.PointcutParser; + +/** + * @author Andy Clement + */ +public class Ajc186Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + private class FooDesignatorHandler implements PointcutDesignatorHandler { + + private String askedToParse; + public boolean simulateDynamicTest = false; + + public String getDesignatorName() { + return "foo"; + } + + public ContextBasedMatcher parse(String expression) { + this.askedToParse = expression; + return new FooPointcutExpression(expression, this.simulateDynamicTest); + } + + public String getExpressionLastAskedToParse() { + return this.askedToParse; + } + } + + private class FooPointcutExpression implements ContextBasedMatcher { + + private final String beanNamePattern; + private final boolean simulateDynamicTest; + + public FooPointcutExpression(String beanNamePattern, + boolean simulateDynamicTest) { + this.beanNamePattern = beanNamePattern; + this.simulateDynamicTest = simulateDynamicTest; + } + + public boolean couldMatchJoinPointsInType(Class aClass) { + System.out.println("wubble?"); + return true; + } + + public boolean couldMatchJoinPointsInType(Class aClass, + MatchingContext context) { + System.out.println("wibble?"); + if (this.beanNamePattern.equals(context.getBinding("beanName"))) { + return true; + } else { + return false; + } + } + + public boolean mayNeedDynamicTest() { + return this.simulateDynamicTest; + } + + public FuzzyBoolean matchesStatically(MatchingContext matchContext) { + System.out.println("wobble?"); + if (this.simulateDynamicTest) + return FuzzyBoolean.MAYBE; + if (this.beanNamePattern + .equals(matchContext.getBinding("beanName"))) { + return FuzzyBoolean.YES; + } else { + return FuzzyBoolean.NO; + } + } + + public boolean matchesDynamically(MatchingContext matchContext) { + System.out.println("wabble?"); + return this.beanNamePattern.equals(matchContext + .getBinding("beanName")); + } + } + + public void testLambdaBeans() throws Exception { + runTest("lambda beans"); + + // Load the 1.8 compiled code + URLClassLoader ucl = new URLClassLoader(new URL[] {ajc.getSandboxDirectory().toURI().toURL()},this.getClass().getClassLoader()); + Class applicationClass = Class.forName("Application",false,ucl); + assertNotNull(applicationClass); + Object instance = applicationClass.newInstance(); + Method works = applicationClass.getDeclaredMethod("fromInnerClass"); + works.setAccessible(true); + Runnable r = (Runnable) works.invoke(instance); + // r.getClass().getName() == Application$1 + + Method fails = applicationClass.getDeclaredMethod("fromLambdaExpression"); + fails.setAccessible(true); + Runnable r2 = (Runnable) fails.invoke(instance); + // r2.getClass().getName() == Application$$Lambda$1/1652149987 + +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Application"); + PointcutParser parser = PointcutParser + .getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(ucl); + FooDesignatorHandler beanHandler = new FooDesignatorHandler(); + parser.registerPointcutDesignatorHandler(beanHandler); + PointcutExpression pc = parser.parsePointcutExpression("foo(myBean)"); + DefaultMatchingContext context = new DefaultMatchingContext(); + pc.setMatchingContext(context); + + context.addContextBinding("beanName", "myBean"); + assertTrue(pc.couldMatchJoinPointsInType(r.getClass())); + + context.addContextBinding("beanName", "yourBean"); + assertFalse(pc.couldMatchJoinPointsInType(r.getClass())); + + context.addContextBinding("beanName", "myBean"); + assertTrue(pc.couldMatchJoinPointsInType(r2.getClass())); + + context.addContextBinding("beanName", "yourBean"); + assertFalse(pc.couldMatchJoinPointsInType(r2.getClass())); + } + + + public void testMissingExtends() throws Exception { + runTest("missing extends on generic target"); + } + + public void testMissingMethod_462821() throws Exception { + runTest("missing method"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc186Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc186.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java b/tests/src/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java new file mode 100644 index 000000000..ff67705de --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc186; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ186 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.6 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc186Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc186/ajc186.xml b/tests/src/test/java/org/aspectj/systemtest/ajc186/ajc186.xml new file mode 100644 index 000000000..4f1394a95 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc186/ajc186.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc187/Ajc187Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc187/Ajc187Tests.java new file mode 100644 index 000000000..4ff34b28e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc187/Ajc187Tests.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc187; + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc187Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testCompileError_476245() throws Exception { + runTest("compile error"); + } + + public void testMissingJoinpoint_307147() throws Exception { + runTest("missing joinpoint"); + } + + public void testMissingJoinpoint_307147_2() throws Exception { + runTest("missing joinpoint 2"); + } + + public void testInfiniteLoop_475152() throws Exception { + runTest("infinite loop"); + } + + public void testAnnoConversion_474165() throws Exception { + runTest("anno conversion"); + } + + public void testLambda_470633() throws Exception { + runTest("lambda"); + } + +// public void testBrokenJava_469889() throws Exception { +// runTest("broken java"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc187Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc187.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java b/tests/src/test/java/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java new file mode 100644 index 000000000..ef8ff0a1c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc187; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ187 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.7 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc187Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc187/ajc187.xml b/tests/src/test/java/org/aspectj/systemtest/ajc187/ajc187.xml new file mode 100644 index 000000000..dfa22f696 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc187/ajc187.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc188/Ajc188Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc188/Ajc188Tests.java new file mode 100644 index 000000000..c2f5e888c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc188/Ajc188Tests.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2015 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc188; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc188Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testClassCast() throws Exception { + runTest("classcast"); + } + + public void testAnnotationDiscoveryNpe() throws Exception { + runTest("annotation discovery npe"); + } + + public void testDefaultMethodsWithXnoInline() throws Exception { + runTest("default methods 1"); + } + + public void testDefaultMethodsWithoutXnoInline() throws Exception { + runTest("default methods 2"); + } + + public void testCompileError_478003() throws Exception { + runTest("compile error"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc188Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc188.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java b/tests/src/test/java/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java new file mode 100644 index 000000000..32d3c12bf --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc188; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ188 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.8 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc188Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc188/ajc188.xml b/tests/src/test/java/org/aspectj/systemtest/ajc188/ajc188.xml new file mode 100644 index 000000000..685b50240 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc188/ajc188.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc189/Ajc189Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc189/Ajc189Tests.java new file mode 100644 index 000000000..456c4a41f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc189/Ajc189Tests.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc189; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc189Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testJarWeaving_433351() { + runTest("jar weaving"); + } + + public void testJarWeaving_433351_4() { + runTest("jar weaving 4"); + } + + public void testJarWeaving_433351_3() { + runTest("jar weaving 3"); + } + + public void testJarWeaving_433351_2() { + runTest("jar weaving 2"); + } + + public void testNPEAtAspectJ() throws Exception { + runTest("NPE at aspectj"); + } + + public void testLostBounds() throws Exception { + runTest("lost bounds"); + // This type has I added via declare parents + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "B"); + assertEquals("LC;Ljava/io/Serializable;LI;",jc.getGenericSignature()); + jc = getClassFrom(ajc.getSandboxDirectory(), "D"); + assertEquals("Ljava/lang/Object;LI;",jc.getGenericSignature()); + } + + public void testWhileNPE_486203() throws Exception { + runTest("while npe"); + } + +// public void testOverweaving_352389() throws Exception { +// runTest("overweaving"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc189Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc189.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java b/tests/src/test/java/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java new file mode 100644 index 000000000..546ef02de --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc189; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ189 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.9 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc189Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.out.xml b/tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.out.xml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.xml b/tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.xml new file mode 100644 index 000000000..8693c1e24 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc189/ajc189.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/Ajc190Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/Ajc190Tests.java new file mode 100644 index 000000000..3d3659f77 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/Ajc190Tests.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc190; + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc190Tests extends XMLBasedAjcTestCaseForJava9OrLater { + + public void testParamAnnosNegative() { + runTest("param annos negative"); + } + + public void testAnnotMethodHasMember_pr156962_1() { // From similar in Ajc153Tests + runTest("Test Annot Method Has Member 1"); + } + + public void testAnnotMethodHasMember_pr156962_2() { // From similar in Ajc153Tests + runTest("Test Annot Method Has Member 1"); + } + + public void testFunnySignature() { + runTest("funny signature with method reference"); + } + + // Weave a module with code that isn't in a module + public void testWeaveModule() throws Exception { + runTest("weave module"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc190Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc190.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java new file mode 100644 index 000000000..d0f7734f3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc190; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ190 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.0 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc190Tests.suite()); + suite.addTest(SanityTests19.suite()); + suite.addTest(EfficientTJPTests.suite()); + suite.addTest(ModuleTests.suite()); + suite.addTest(Annotations.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/Annotations.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/Annotations.java new file mode 100644 index 000000000..b2f8c267e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/Annotations.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2004, 2017 IBM + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc190; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * A copy of the 1.5.0 Annotations test but with compliance set to 1.9 + * The testdata is referenced in the 150 test folder but the XML file indicates compliance of 1.9. + * + * @author Andy Clement + */ +public class Annotations extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Annotations.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc190/ajc190_from150.xml"); + } + + public void testCompilingAnnotation() { + runTest("compiling an annotation"); + } + + public void testCompilingAnnotatedFile() { + runTest("compiling annotated file"); + } + + public void testCompilingUsingWithinAndAnnotationTypePattern() { + runTest("annotations and within (src)"); + } + + /** + * We had a bug where annotations were not present in the output class file for + * methods that got woven. This was due to unpacking bugs in LazyMethodGen. This + * test compiles a simple program then checks the annotations were copied + * across. + */ + public void testBugWithAnnotationsLostOnWovenMethods() throws ClassNotFoundException { + runTest("losing annotations..."); + if (getCurrentTest().canRunOnThisVM()) { + + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Program"); + Method[] meths = jc.getMethods(); + for (int i = 0; i < meths.length; i++) { + Method method = meths[i]; + if (method.getName().equals("m1")) { + assertTrue("Didn't have annotations - were they lost? method=" + method.getName(), + method.getAnnotations().length == 1); + } + } + } + } + + public void testAnnotatedAnnotations() { + runTest("annotated annotations (@Target)"); + } + + public void testSimpleAnnotatedAspectMembers() { + runTest("simple annotated aspect members"); + } + + public void testAnnotatedAspectMembersWithWrongAnnotationType() { + runTest("simple annotated aspect members with bad target"); + } + + // more implementation work needed before this test passes + public void testAnnotatedITDs() { + runTest("annotated itds"); + } + + public void testAnnotatedITDs2() { + runTest("annotated public itds"); + } + + public void testAnnotatedITDs3() { + runTest("annotated public itds - values"); + } + + public void testAnnotatedITDs4() { + runTest("annotated public itds - multiple complex annotations"); + } + + public void testAnnotatedITDsWithWrongAnnotationType() { + runTest("annotated itds with bad target"); + } + + public void testAnnotatedAdvice() { + runTest("annotated advice"); + } + + public void testAnnotatedAdviceWithWrongAnnotationType() { + runTest("annotated advice with bad target"); + } + + public void testAnnotatedPointcut() { + runTest("annotated pointcut"); + } + + // FIXME asc uncomment this test when parser is opened up + // public void testAnnotatedDeclareStatements() { + // runTest("annotated declare statements"); + // } + + public void testBasicDeclareAnnotation() { + runTest("basic declare annotation parse test"); + } + + public void testAJDKAnnotatingAspects() { + runTest("ajdk: annotating aspects chapter"); + } + + public void testAJDKAnnotatingAspects2() { + runTest("ajdk: annotating aspects chapter, ex 2"); + } + + public void testAnnotationPatterns() { + runTest("ajdk: annotation pattern matching"); + } + + public void testAnnotationTypePatterns() { + runTest("ajdk: annotation type pattern matching"); + } + + public void testAnnotationSigPatterns() { + runTest("ajdk: annotations in sig patterns"); + } + + public void testAnnotationRuntimeMatching() { + runTest("ajdk: runtime annotations"); + } + + public void testAnnotationRetentionChecking() { + runTest("ajdk: @retention checking"); + } + + public void testAnnotationInheritance() { + runTest("ajdk: @inherited"); + } + + public void testAnnotationDEOW() { + runTest("ajdk: deow-ann"); + } + + public void testAnnotationDecp() { + runTest("ajdk: decp-ann"); + } + + public void testAnnotationDecPrecedence() { + runTest("ajdk: dec precedence"); + } + + public void testAnnotationDecAnnotation() { + runTest("ajdk: dec annotation"); + } + + public void testAnnotationsAndITDs() { + runTest("nasty annotation and itds test"); + } + + // helper methods..... + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java new file mode 100644 index 000000000..3564f9469 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc190; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Assert; +import junit.framework.Test; + +/** + * + * @author Andy Clement + */ +public class EfficientTJPTests extends XMLBasedAjcTestCase { + + public void testThisJoinPointMethodExecution() { + // Test setting it via sys props rather than passing the option directly + try { + System.setProperty("ASPECTJ_OPTS", "-Xajruntimetarget:1.9"); + runTest("tjp 1"); + checkPreClinitContains("One","Factory.makeMethodSJP"); + } finally { + System.setProperty("ASPECTJ_OPTS", ""); + } + } + + public void testThisEnclosingJoinPointMethodExecution() { + runTest("tjp 2"); + checkPreClinitContains("Two","Factory.makeMethodESJP"); + } + + public void testThisJoinPointConstructorExecution() { + runTest("tjp 3"); + checkPreClinitContains("Three","Factory.makeConstructorSJP"); + } + + public void testThisEnclosingJoinPointConstructorExecution() { + runTest("tjp 3a"); + checkPreClinitContains("ThreeA","Factory.makeConstructorESJP"); + } + + public void testThisJoinPointHandler() { + runTest("tjp 4"); + checkPreClinitContains("Four","Factory.makeCatchClauseSJP"); + } + + public void testThisEnclosingJoinPointHandler() { + runTest("tjp 4a"); + checkPreClinitContains("FourA","Factory.makeMethodESJP"); + } + + public void testThisJoinPointFieldGet() { + runTest("tjp get fields"); + checkPreClinitContains("Fields","Factory.makeFieldSJP"); + } + + public void testThisEnclosingJoinPointFieldGet() { + runTest("tjp get fieldsE"); + checkPreClinitContains("FieldsE","Factory.makeMethodESJP"); + } + + public void testThisJoinPointFieldSet() { + runTest("tjp set fields"); + checkPreClinitContains("Fields2","Factory.makeFieldSJP"); + } + + public void testThisJoinPointClinit() { + runTest("tjp clinit"); + checkPreClinitContains("Clinit","Factory.makeInitializerSJP"); + } + + public void testThisEnclosingJoinPointClinit() { + runTest("tejp clinit"); + checkPreClinitContains("ClinitE","Factory.makeInitializerESJP"); + } + + public void testThisJoinPointAdvice() { + // covers enclosing joinpoint too + runTest("tjp advice"); + checkPreClinitContains("X","Factory.makeAdviceESJP"); + } + + public void testThisJoinPointInitialization() { + runTest("tjp init"); + checkPreClinitContains("A","Factory.makeConstructorESJP"); + checkPreClinitContains("B","Factory.makeConstructorESJP"); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(EfficientTJPTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("features190.xml"); + } + + public void checkPreClinitContains(String classname, String text) { + try { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + Method[] meths = jc.getMethods(); + for (int i = 0; i < meths.length; i++) { + Method method = meths[i]; + if (method.getName().equals("ajc$preClinit")) { + String code = method.getCode().getCodeString(); + assertTrue("Expected to contain '"+text+"':\n"+code,code.contains(text)); + return; + } + } + Assert.fail("Unable to find ajc$preClinit in class "+classname); + } catch (Exception e) { + Assert.fail(e.toString()); + } + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java new file mode 100644 index 000000000..08d7f500f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * Copyright (c) 2017 Contributors + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc190; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.Code; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater; +import org.aspectj.util.LangUtil; + +import junit.framework.Test; + +/** + * Building and weaving with modules in the picture. + * + * Module options from http://openjdk.java.net/jeps/261 + * + * @author Andy Clement + * + */ +public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater { + + public void testBuildAModule() { + runTest("build a module"); + } + + public void testRunModuleClassPath() { + runTest("run a module - classpath"); + } + + public void testRunModuleModulePath() { + runTest("run a module - modulepath"); + } + + public void testPackageAndRunModuleFromModulePath() { + runTest("package and run a module - modulepath"); + } + + public void testBuildModuleIncludingAspects() { + runTest("compile module including aspects"); + } + + public void testBuildModuleAndApplyAspectsFromAspectPath() { + runTest("compile module and apply aspects via aspectpath"); + } + + public void testBinaryWeavingAModuleJar() { + // Pass a module on inpath, does it weave ok with a source aspect, does it run afterwards? + runTest("binary weaving module"); + } + + public void testModulepathClasspathResolution1() { + runTest("module path vs classpath 1"); + } + +// public void testModulepathClasspathResolution2() { +// runTest("module path vs classpath 2"); +// } + + // --add-modules + + // This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK) + // that it can be found without needing to set --module-path (this seems to be implicitly included by javac too) + public void testAddModules1() { + if (LangUtil.is11VMOrGreater()) { + // java.xml.bind is gone in Java11 + return; + } + runTest("compile use of java.xml.bind"); + } + + // This tests that we can use add-modules to pull in something from the JDK jmods package and that + // when subsequently weaving we can see types from those modules + public void testWovenAfterAddModules() { + if (LangUtil.is11VMOrGreater()) { + // java.xml.bind is gone in Java11 + return; + } + runTest("weave use of java.xml.bind"); + } + + // --limit-modules + public void testLimitModules1() { + if (LangUtil.is11VMOrGreater()) { + // java.xml.bind is gone in Java11 + return; + } + runTest("limit modules 1"); + } + + // --add-reads + public void testAddReads1() { + if (LangUtil.is11VMOrGreater()) { + // java.xml.bind is gone in Java11 + return; + } + runTest("add reads 1"); + } + + + // --- + + /* For the specified class, check that each method has a stackmap attribute */ + private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException { + toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_"; + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + Method[] methods = jc.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (toIgnore.contains("_" + method.getName() + "_")) { + continue; + } + boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable"); + if (!hasStackMapAttribute) { + fail("Could not find StackMap attribute for method " + method.getName()); + } + } + } + + private boolean findAttribute(Attribute[] attrs, String attributeName) { + if (attrs == null) { + return false; + } + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals(attributeName)) { + return true; + } + // System.out.println(attribute.getName()); + if (attribute.getName().equals("Code")) { + Code c = (Code) attribute; + Attribute[] codeAttributes = c.getAttributes(); + for (int j = 0; j < codeAttributes.length; j++) { + Attribute codeAttribute = codeAttributes[j]; + if (codeAttribute.getName().equals(attributeName)) { + return true; + // System.out.println(codeAttribute.getName()); + } + } + } + } + return false; + } + + private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + if (jc.getMajor() != major) { + fail("Expected major version to be " + major + " but was " + jc.getMajor()); + } + if (jc.getMinor() != minor) { + fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); + } + } + + // Check the stackmap stuff is removed when a method gets woven (for now...) + // public void testStackMapAttributesDeletedInWovenCode() { + // fail("Not implemented"); + // } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(ModuleTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc190.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java new file mode 100644 index 000000000..5544022c4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java @@ -0,0 +1,153 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc190; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/* + * Some very trivial tests that help verify things are OK. + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -1.9 option + * to check code generation and modification with that version specified. + */ +public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + // Check the version number in the classfiles is correct when Java6 options specified + public void testVersionCorrect1() throws ClassNotFoundException { + runTest("simple - j"); + checkVersion("A", 53, 0); + } + + public void testVersionCorrect2() throws ClassNotFoundException { + runTest("simple - k"); + checkVersion("A", 53, 0); + } + + public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified + runTest("simple - m"); + checkVersion("A", 49, 0); + } + + // Check the stackmap stuff appears for methods in a Java6 file + // public void testStackMapAttributesAppear() throws ClassNotFoundException { + // runTest("simple - n"); + // checkStackMapExistence("A","_"); + // checkStackMapExistence("X","__ajc$pointcut$$complicatedPointcut$1fe"); + // } + + /* For the specified class, check that each method has a stackmap attribute */ +// private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException { +// toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_"; +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); +// Method[] methods = jc.getMethods(); +// for (int i = 0; i < methods.length; i++) { +// Method method = methods[i]; +// if (toIgnore.contains("_" + method.getName() + "_")) { +// continue; +// } +// boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable"); +// if (!hasStackMapAttribute) { +// fail("Could not find StackMap attribute for method " + method.getName()); +// } +// } +// } + +// private boolean findAttribute(Attribute[] attrs, String attributeName) { +// if (attrs == null) { +// return false; +// } +// for (int i = 0; i < attrs.length; i++) { +// Attribute attribute = attrs[i]; +// if (attribute.getName().equals(attributeName)) { +// return true; +// } +// // System.out.println(attribute.getName()); +// if (attribute.getName().equals("Code")) { +// Code c = (Code) attribute; +// Attribute[] codeAttributes = c.getAttributes(); +// for (int j = 0; j < codeAttributes.length; j++) { +// Attribute codeAttribute = codeAttributes[j]; +// if (codeAttribute.getName().equals(attributeName)) { +// return true; +// // System.out.println(codeAttribute.getName()); +// } +// } +// } +// } +// return false; +// } + + private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + if (jc.getMajor() != major) { + fail("Expected major version to be " + major + " but was " + jc.getMajor()); + } + if (jc.getMinor() != minor) { + fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); + } + } + + // Check the stackmap stuff is removed when a method gets woven (for now...) + // public void testStackMapAttributesDeletedInWovenCode() { + // fail("Not implemented"); + // } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTests19.class); + } + + protected File getSpecFile() { + return getClassResource("sanity-tests-19.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190.xml b/tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190.xml new file mode 100644 index 000000000..d6507dace --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190.xml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190_from150.xml b/tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190_from150.xml new file mode 100644 index 000000000..24d683928 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/ajc190_from150.xml @@ -0,0 +1,6290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/features190.xml b/tests/src/test/java/org/aspectj/systemtest/ajc190/features190.xml new file mode 100644 index 000000000..1fb931e97 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/features190.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/sanity-tests-19.xml b/tests/src/test/java/org/aspectj/systemtest/ajc190/sanity-tests-19.xml new file mode 100644 index 000000000..4965b448a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/sanity-tests-19.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/Ajc191Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc191/Ajc191Tests.java new file mode 100644 index 000000000..230a9128d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/Ajc191Tests.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc191; + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc191Tests extends XMLBasedAjcTestCaseForJava10OrLater { + + public void testVar1() { + runTest("var 1"); + } + + public void testVar2() { + runTest("var 2"); + } + + public void testVarIncludesAspect3() { + runTest("var 3"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc191Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc191.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java b/tests/src/test/java/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java new file mode 100644 index 000000000..8588b845b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc191; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ191 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.1 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc191Tests.suite()); + suite.addTest(SanityTestsJava10.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java b/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java new file mode 100644 index 000000000..f4b8f3698 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2006, 2081 IBM and contributors + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc191; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/* + * Some very trivial tests that help verify things are OK. + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option + * to check code generation and modification with that version specified. + * + * @author Andy Clement + */ +public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase { + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + public void testVersionCorrect1() throws ClassNotFoundException { + runTest("simple - j"); + checkVersion("A", 54, 0); + } + + public void testVersionCorrect2() throws ClassNotFoundException { + runTest("simple - k"); + checkVersion("A", 54, 0); + } + + public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified + runTest("simple - m"); + checkVersion("A", 49, 0); + } + + private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + if (jc.getMajor() != major) { + fail("Expected major version to be " + major + " but was " + jc.getMajor()); + } + if (jc.getMinor() != minor) { + fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); + } + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTestsJava10.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("sanity-tests-10.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/ajc191.xml b/tests/src/test/java/org/aspectj/systemtest/ajc191/ajc191.xml new file mode 100644 index 000000000..3a87375e9 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/ajc191.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/sanity-tests-10.xml b/tests/src/test/java/org/aspectj/systemtest/ajc191/sanity-tests-10.xml new file mode 100644 index 000000000..a6bdbd938 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/sanity-tests-10.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/Ajc192Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc192/Ajc192Tests.java new file mode 100644 index 000000000..ea1215b2d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/Ajc192Tests.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc192; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.NestHost; +import org.aspectj.apache.bcel.classfile.NestMembers; +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc192Tests extends XMLBasedAjcTestCase { + + public void testITDLambdas() throws Exception { + runTest("itd lambdas"); + } + + public void test11Flags() throws Exception { + runTest("11flags"); + } + + public void testNestmates() throws Exception { + runTest("nestmates"); + JavaClass outer = getClassFrom(ajc.getSandboxDirectory(), "Outer"); + JavaClass inner = getClassFrom(ajc.getSandboxDirectory(), "Outer$Inner"); + NestMembers nestMembers = (NestMembers) getAttributeStartsWith(outer.getAttributes(),"NestMembers"); + assertEquals(1,nestMembers.getClasses().length); + assertEquals("Outer$Inner",nestMembers.getClassesNames()[0]); + NestHost nestHost = (NestHost) getAttributeStartsWith(inner.getAttributes(),"NestHost"); + assertEquals("Outer",nestHost.getHostClassName()); + } + + // Verifying not destroyed on weaving + public void testNestmates2() throws Exception { + runTest("nestmates 2"); + JavaClass outer = getClassFrom(ajc.getSandboxDirectory(), "Outer2"); + JavaClass inner = getClassFrom(ajc.getSandboxDirectory(), "Outer2$Inner2"); + NestMembers nestMembers = (NestMembers) getAttributeStartsWith(outer.getAttributes(),"NestMembers"); + assertEquals(1,nestMembers.getClasses().length); + assertEquals("Outer2$Inner2",nestMembers.getClassesNames()[0]); + NestHost nestHost = (NestHost) getAttributeStartsWith(inner.getAttributes(),"NestHost"); + assertEquals("Outer2",nestHost.getHostClassName()); + } + + public void testCflowFinal() { + runTest("no final on cflow elements"); + } + + // TODO Still to be fixed, the workaround to not mix style is good enough for now... + public void xtestAroundAdvice_AnnoStyle() { + runTest("around advice"); + } + + public void testAroundAdvice_CodeStyle() { + runTest("around advice - 2"); + } + + public void testPTW_nonPrivileged() { + runTest("ptw"); + } + + public void testPTW_nonPrivilegedSamePackage() { + runTest("ptw - same package"); + } + + public void testPTW_privileged() { + runTest("ptw - privileged"); + } + + public void testPTWW_privilegedSamePackage() { + runTest("ptw - privileged same package"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc192Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc192.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java b/tests/src/test/java/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java new file mode 100644 index 000000000..e47b11632 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc192; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ192 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.2 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc192Tests.suite()); + suite.addTest(SanityTestsJava11.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java new file mode 100644 index 000000000..e14ec33df --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2006, 2018 Contributors + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc192; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater; + +import junit.framework.Test; + +/* + * Some very trivial tests that help verify things are OK. + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option + * to check code generation and modification with that version specified. + * + * @author Andy Clement + */ +public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater { + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + public void testVersionCorrect1() throws ClassNotFoundException { + runTest("simple - j"); + checkVersion("A", 55, 0); + } + + public void testVersionCorrect2() throws ClassNotFoundException { + runTest("simple - k"); + checkVersion("A", 55, 0); + } + + public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified + runTest("simple - m"); + checkVersion("A", 49, 0); + } + + private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + if (jc.getMajor() != major) { + fail("Expected major version to be " + major + " but was " + jc.getMajor()); + } + if (jc.getMinor() != minor) { + fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); + } + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTestsJava11.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("sanity-tests-11.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/ajc192.xml b/tests/src/test/java/org/aspectj/systemtest/ajc192/ajc192.xml new file mode 100644 index 000000000..095c3978a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/ajc192.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/sanity-tests-11.xml b/tests/src/test/java/org/aspectj/systemtest/ajc192/sanity-tests-11.xml new file mode 100644 index 000000000..cdce29082 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/sanity-tests-11.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc193/Ajc193Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc193/Ajc193Tests.java new file mode 100644 index 000000000..e0d6a2ede --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc193/Ajc193Tests.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * Copyright (c) 2018-2019 Contributors + * 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 + *******************************************************************************/ +package org.aspectj.systemtest.ajc193; + +import java.io.File; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater; +import org.aspectj.weaver.WeaverStateInfo; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater { + + public void testDeclareMixinOverweavingControl() { + runTest("overweaving decm - control"); + } + + public void testDeclareMixinOverweavingReweaving() { + runTest("overweaving decm - reweaving"); + } + + public void testDeclareMixinOverweaving() { + runTest("overweaving decm - 1"); + } + + public void xtestDeclareMixinOverweaving2() { + runTest("overweaving decm - 2"); + } + + public void xtestOverweavingDeclareMixinTargetingAspect() { + runTest("mood indicator 4"); + } + + public void testOverweavingAtDecPControl() { + runTest("overweaving atdecp - control"); + } + + public void testOverweavingAtDecP() { + runTest("overweaving atdecp"); + } + + public void testComplexOverweaving1() { + // This is the same code as the other test but overweaving OFF + runTest("overweaving"); + } + + public void testComplexOverweaving2() throws Exception { + // This is the same code as the other test but overweaving ON + runTest("overweaving 2"); + // Asserting the weaver state info in the tests that will drive overweaving behaviour: + + // After step 1 of the test, MyAspect will have been applied. + JavaClass jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow1.jar"), "Application"); + WeaverStateInfo wsi = getWeaverStateInfo(jc); + assertEquals("[LMyAspect;]", wsi.getAspectsAffectingType().toString()); + assertTrue(wsi.getUnwovenClassFileData().length>0); + + // After overweaving, MyAspect2 should also be getting applied but the unwovenclassfile + // data has been blanked out - because we can no longer use it, only overweaving is possible + // once one overweaving step is done + jc = getClassFrom(ajc.getSandboxDirectory(), "Application"); + wsi = getWeaverStateInfo(jc); + assertEquals("[LMyAspect2;, LMyAspect;]", wsi.getAspectsAffectingType().toString()); + assertEquals(0,wsi.getUnwovenClassFileData().length); + } + + // Two steps of overweaving + public void testComplexOverweaving3() throws Exception { + // This is the same code as the other test but overweaving ON + runTest("overweaving 3"); + // Asserting the weaver state info in the tests that will drive overweaving behaviour: + + // After step 1 of the test, MyAspect will have been applied. + JavaClass jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow1.jar"), "Application"); + WeaverStateInfo wsi = getWeaverStateInfo(jc); + assertEquals("[LMyAspect;]", wsi.getAspectsAffectingType().toString()); + assertTrue(wsi.getUnwovenClassFileData().length>0); + + // After overweaving, MyAspect2 should also be getting applied but the unwovenclassfile + // data has been blanked out - because we can no longer use it, only overweaving is possible + // once one overweaving step is done + jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow3.jar"), "Application"); + wsi = getWeaverStateInfo(jc); + assertEquals("[LMyAspect2;, LMyAspect;]", wsi.getAspectsAffectingType().toString()); + assertEquals(0,wsi.getUnwovenClassFileData().length); + + jc = getClassFrom(ajc.getSandboxDirectory(), "Application"); + wsi = getWeaverStateInfo(jc); + assertEquals("[LMyAspect3;, LMyAspect2;, LMyAspect;]", wsi.getAspectsAffectingType().toString()); + assertEquals(0,wsi.getUnwovenClassFileData().length); + } + + // overweaving then attempt non overweaving - should fail + public void testComplexOverweaving4() throws Exception { + // This is the same code as the other test but overweaving ON + runTest("overweaving 4"); + // Asserting the weaver state info in the tests that will drive overweaving behaviour: + + // After step 1 of the test, MyAspect will have been applied. + JavaClass jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow1.jar"), "Application"); + WeaverStateInfo wsi = getWeaverStateInfo(jc); + assertEquals("[LMyAspect;]", wsi.getAspectsAffectingType().toString()); + assertTrue(wsi.getUnwovenClassFileData().length>0); + } + + // Altered version of this test from org.aspectj.systemtest.ajc150.Enums for 542682 + public void testDecpOnEnumNotAllowed_xlints() { + runTest("wildcard enum match in itd"); + } + + public void testEnumDecmixinMessage() { + runTest("declare mixin a"); + } + + public void testIsAbstractType() { + runTest("is abstract"); + } + + public void testIsAbstractType2() { + runTest("is abstract - 2"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc193Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc193.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java b/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java new file mode 100644 index 000000000..62cfcccb2 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc193; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ193 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.3 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc193Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc193/ajc193.xml b/tests/src/test/java/org/aspectj/systemtest/ajc193/ajc193.xml new file mode 100644 index 000000000..7d64d493e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc193/ajc193.xml @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/apt/AllTestsApt.java b/tests/src/test/java/org/aspectj/systemtest/apt/AllTestsApt.java new file mode 100644 index 000000000..fbba0be31 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/apt/AllTestsApt.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.apt; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsApt { + + public static Test suite() { + TestSuite suite = new TestSuite("Annotation processing tests"); + // $JUnit-BEGIN$ + suite.addTest(AptTests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/apt/AptTests.java b/tests/src/test/java/org/aspectj/systemtest/apt/AptTests.java new file mode 100644 index 000000000..01ab16ca0 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/apt/AptTests.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2014,2018 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.apt; + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.LangUtil; + +import junit.framework.Test; + +/** + * Annotation processing tool tests. + * + * @author Sergey Stupin. + */ +public class AptTests extends XMLBasedAjcTestCase { + + public void testAptWithSpecifiedProcessor() { + if (LangUtil.is19VMOrGreater()) { + return; + } + runTest("annotation processing with specified processor"); + } + + /** + * SPI - http://docs.oracle.com/javase/tutorial/sound/SPI-intro.html + */ + public void testAptUsingSPI() { + if (LangUtil.is19VMOrGreater()) { + return; + } + runTest("annotation processing in action using SPI"); + } + + public void testDisabledApt() { + if (LangUtil.is11VMOrGreater()) { + // javax.annotation.Generated not in Java11 + return; + } + runTest("disabled annotation processing"); + } + + public void testAptWithJavaFilesAsAspects() { + runTest("annotation processing generating java files with aspects"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AptTests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("apt-spec.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/apt/apt-spec.xml b/tests/src/test/java/org/aspectj/systemtest/apt/apt-spec.xml new file mode 100644 index 000000000..0ce327c49 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/apt/apt-spec.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/aspectpath/AspectPathTests.java b/tests/src/test/java/org/aspectj/systemtest/aspectpath/AspectPathTests.java new file mode 100644 index 000000000..3a77d2778 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/aspectpath/AspectPathTests.java @@ -0,0 +1,112 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.aspectpath; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class AspectPathTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AspectPathTests.class); + } + + protected File getSpecFile() { + return getClassResource("aspectpath.xml"); + } + + + public void test001(){ + runTest("testing new options"); + } + + public void test002(){ + runTest("aspect-declared interface members in libraries - baseline"); + } + + public void test003(){ + runTest("aspect-declared interface members in libraries - interfaceOnly.jar"); + } + + public void test004(){ + runTest("aspect-declared interface members in libraries - aspectOnly.jar"); + } + + public void test005(){ + runTest("aspect-declared interface members in libraries - aspectedInterfaceOnly.jar"); + } + + public void test006(){ + runTest("aspect-declared interface members in libraries - aspectedInterfaceOnly.jar,aspectOnly.jar"); + } + + public void test007(){ + runTest("aspect-declared interface members in libraries - aspectedInterfaceOnlyBinary.jar,aspectOnly.jar"); + } + + public void test008(){ + runTest("aspect-declared interface members in libraries - aspectedInterfaceOnly.jar,aspectpath=aspectOnly.jar"); + } + + public void test009(){ + runTest("aspect-declared interface members in libraries - aspectedInterfaceOnly.jar,aspectpath=aspectOnly.jar"); + } + + public void test010(){ + runTest("exception clause for aspect-declared interface methods - positive"); + } + + public void test011(){ + runTest("exception clause for aspect-declared interface methods - negative"); + } + + public void test012(){ + runTest("exception clause for aspect-declared class methods - positive"); + } + + public void test013(){ + runTest("exception clause for aspect-declared class methods - negative"); + } + + public void test014(){ + runTest("exception clause for aspect-declared interface methods - positive binary"); + } + + public void test015(){ + runTest("exception clause for aspect-declared interface methods - negative binary"); + } + + public void test016(){ + runTest("exception clause for aspect-declared class methods - positive binary"); + } + + public void test017(){ + runTest("exception clause for aspect-declared class methods - negative binary"); + } + + public void test018(){ + runTest("percflow aspects compiled from jars share one instance for all entry points"); + } + + public void test019(){ + runTest("(using aspectpath) percflow aspects compiled from jars share one instance for all entry points"); + } + + public void test020(){ + runTest("Introduced abstract method on abstract class not implemented by subtype"); + } + + public void test021(){ + runTest("Introduced abstract method on interface not implemented by subtype (aspectpath)"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath-tests.xml b/tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath-tests.xml new file mode 100644 index 000000000..5f201b355 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath-tests.xml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath.xml b/tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath.xml new file mode 100644 index 000000000..ba587fe9e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/aspectpath/aspectpath.xml @@ -0,0 +1,12 @@ + +]> + + + + + +&tests; + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/base/BaseTests.java b/tests/src/test/java/org/aspectj/systemtest/base/BaseTests.java new file mode 100644 index 000000000..e85d327c7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/base/BaseTests.java @@ -0,0 +1,188 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.base; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class BaseTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(BaseTests.class); + } + + protected File getSpecFile() { + return getClassResource("baseTests.xml"); + } + + + public void test001(){ + runTest("static and non-static before methods -- one file"); + } + + public void test002(){ + runTest("static and non-static before methods -- many files"); + } + + public void test003(){ + runTest("this redirection in non-static before methods"); + } + + public void test004(){ + runTest("DEPRECATED: introductions"); + } + + public void test005(){ + runTest("before constructors -- one file"); + } + + public void test006(){ + runTest("advise weaves find methods typed to builtins or non-woven classes"); + } + + public void test007(){ + runTest("make sure new weaves work inside of packages"); + } + + public void test008(){ + runTest("make sure new weaves work inside of packages (again)"); + } + + public void test009(){ + runTest("Inheritance of class and aspect vars in weaves"); + } + + public void test010(){ + runTest("Accessibility of class and aspect members from inside weaves"); + } + + public void test011(){ + runTest("Packaged aspects referring to packaged classes"); + } + + public void test012(){ + runTest("Inheritance of methods advised by aspects"); + } + + public void test013(){ + runTest("Inherited weaves on constructor"); + } + + public void test014(){ + runTest("Initializers in Aspect and Class Bodies"); + } + + public void test015(){ + runTest("Weaver Resolution of method names in method calls passed as args"); + } + + public void test016(){ + runTest("DEPRECATED: Introduce constructor with class inheritance"); + } + + public void test017(){ + runTest("empty and singular patterns on modifiers and throws"); + } + + public void test018(){ + runTest("DEPRECATED: Introduce of constructors"); + } + + public void test019(){ + runTest("Local declarations in advise bodies"); + } + + public void test020(){ + runTest("advises on introduced methods and constructors"); + } + + public void test021(){ + runTest("DEPRECATED: Method introduction into interface implemented by abstract class"); + } + + public void test022(){ + runTest("Crossing super calls in constructors"); + } + + public void test023(){ + runTest("empty modifier pattern"); + } + + public void test024(){ + runTest("Alpha conversion of argument names in designators"); + } + + public void test025(){ + runTest("advice uses its own formals to get actuals"); + } + + public void test026(){ + runTest("DEPRECATED: introduce weaves can use this"); + } + + public void test027(){ + runTest("DEPRECATED: introduce of abstract methods works"); + } + + public void test028(){ + runTest("multiple arounds successfully intercept and return own values"); + } + + public void test029(){ + runTest("proper matching of overloaded constructors"); + } + + public void test030(){ + runTest("proper handling of formals in catch advice"); + } + + public void test031(){ + runTest("proper values for thisJoinPoint attributes"); + } + + public void test032(){ + runTest("supers, supers, supers"); + } + + public void test033(){ + runTest("operations on private and protected aspect members (++, -- in partciular)"); + } + + public void test034(){ + runTest("only register things once"); + } + + public void test035(){ + runTest("inner aspects and around"); + } + + public void test036(){ + runTest("aspect inheritance and advice, introduction"); + } + + public void test037(){ + runTest("thisResultObject for primitives"); + } + + public void test038(){ + runTest("introductions calling super."); + } + + public void test039(){ + runTest("allow one argument calls even when there's a comma in the arglist"); + } + + public void test040(){ + runTest("advice on calls to static methods even works when called on super"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/bringup/BringUpTests.java b/tests/src/test/java/org/aspectj/systemtest/bringup/BringUpTests.java new file mode 100644 index 000000000..3eb98775e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/bringup/BringUpTests.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.bringup; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * These are tests that will run on Java 1.4 and use the old harness format for test specification. + */ +public class BringUpTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(BringUpTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/bringup/bringup.xml"); + } + + public void testEmptyClass() { + runTest("empty class"); + } + + public void testEmptyAspect() { + runTest("empty aspect"); + } +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/bringup/bringup.xml b/tests/src/test/java/org/aspectj/systemtest/bringup/bringup.xml new file mode 100644 index 000000000..6009c9484 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/bringup/bringup.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/design/DesignTests.java b/tests/src/test/java/org/aspectj/systemtest/design/DesignTests.java new file mode 100644 index 000000000..3a19663a6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/design/DesignTests.java @@ -0,0 +1,84 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.design; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class DesignTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(DesignTests.class); + } + + protected File getSpecFile() { + return getClassResource("design.xml"); + } + + + public void test001(){ + runTest("initial tests for new introduction style"); + } + + public void test002(){ + runTest("overriding of introduced methods and accessibility"); + } + + public void test003(){ + runTest("within and introductions behaves correctly"); + } + + public void test004(){ + runTest("correct inheritance of multiple concrete methods"); + } + + public void test005(){ + runTest("errors in inheritance of multiple concrete methods"); + } + + public void test006(){ + runTest("declared exceptions are checked correctly on intros (errors)"); + } + + public void test007(){ + runTest("declared exceptions are checked correctly on intros"); + } + + public void test008(){ + runTest("Joinpoint is not created for foo(String) when before() advice is present."); + } + + public void test009(){ + runTest("more tests of eachobject with some difficult typing issues"); + } + + public void test010(){ + runTest("eachobject: eachobject(receptions(...)) [eachobject]"); + } + + public void test011(){ + runTest("Checking new joinpoints"); + } + + public void test012(){ + runTest("eachobject: simple test [eachobject] (still)"); + } + + public void test013(){ + runTest("scope issues with introduction (needs more work)"); + } + +// uncomment this test if we implement 42743 +// public void test014_DeclareSoft(){ +// runTest("declare soft limitation"); +// } +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/design/design.xml b/tests/src/test/java/org/aspectj/systemtest/design/design.xml new file mode 100644 index 000000000..51cc93173 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/design/design.xml @@ -0,0 +1,11 @@ + +]> + + + + + +&designTests; + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/design/designtest.xml b/tests/src/test/java/org/aspectj/systemtest/design/designtest.xml new file mode 100644 index 000000000..21be1943c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/design/designtest.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java new file mode 100644 index 000000000..a499e1421 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java @@ -0,0 +1,309 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.incremental; + +import java.io.File; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.ajdt.internal.core.builder.AbstractStateListener; +import org.aspectj.ajdt.internal.core.builder.AjState; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class IncrementalTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IncrementalTests.class); + } + + protected File getSpecFile() { + return getClassResource("incremental.xml"); + } + + + /* (non-Javadoc) + * @see org.aspectj.testing.XMLBasedAjcTestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + AjState.FORCE_INCREMENTAL_DURING_TESTING = true; + } + + protected void tearDown() throws Exception { + super.tearDown(); + AjState.FORCE_INCREMENTAL_DURING_TESTING = false; + } + + public void test001() throws Exception { + runTest("expect class added in initial incremental tests"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("src.20/main/Main.java","src/main/Main.java"); + assertAdded("main/Target.class"); + run("main.Main"); + } + + public void test002() throws Exception { + runTest("expect class removed in initial incremental tests"); + nextIncrement(false); + assertAdded("main/Target.class"); + copyFileAndDoIncrementalBuild("src.20/main/Main.java","src/main/Main.java"); + assertDeleted("main/Target.class"); + run("main.Main"); + } + + public void test003() throws Exception { + runTest("expect class updated in initial incremental tests"); + long lastTime = nextIncrement(true); + copyFileAndDoIncrementalBuild("src.20/main/Main.java","src/main/Main.java"); + assertUpdated("main/Main.class",lastTime); + run("main.Main"); + } + + public void test004() throws Exception { + runTest("add file with class"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("src.20/main/Target.java","src/main/Target.java"); + assertAdded("main/Target.class"); + long lastTime = nextIncrement(true); + copyFileAndDoIncrementalBuild("src.30/main/Main.java","src/main/Main.java"); + assertUpdated("main/Main.class",lastTime); + run("main.Main"); + } + + public void test005()throws Exception { + runTest("delete source file before incremental compile"); + nextIncrement(false); + MessageSpec messageSpec = new MessageSpec(null,newMessageList(new Message(6,"delete/Target.java",null,null))); + deleteFileAndDoIncrementalBuild("src/delete/DeleteMe.java",messageSpec); + nextIncrement(false); + copyFileAndDoIncrementalBuild("src.30/delete/Target.java","src/delete/Target.java"); + run("delete.Main"); + } + + public void test006() throws Exception { + runTest("do everything in default package (sourceroots)"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Target.20.java","src/Target.java"); + run("Target"); + long lastTime = nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/Main.30.java","src/Main.java"); + assertUpdated("Main.class",lastTime); + nextIncrement(false); + MessageSpec messageSpec = new MessageSpec(null,newMessageList(new Message(6,"Main.java",null,null))); + deleteFileAndDoIncrementalBuild("src/Target.java",messageSpec); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Main.50.java","src/Main.java"); + run("Main"); + } + + public void test007() throws Exception { + runTest("change sources in default package"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Main.20.java","src/Main.java"); + run("Main"); + } + + public void test008() throws Exception { + runTest("change source"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Main.20.java","src/app/Main.java"); + run("app.Main"); + } + + /** + * See bug report 85297. We plugged a hole so that we check whether the contents of + * directories on the classpath have changed when deciding whether we can do an + * incremental build or not - the implementation didn't allow for the output location + * being on the classpath. This test verifies the fix is OK + */ + public void testIncrementalOKWithOutputPathOnClasspath() throws Exception { + class MyStateListener extends AbstractStateListener { + public boolean pathChange = false; + public void pathChangeDetected() {pathChange = true;} + public void aboutToCompareClasspaths(List oldClasspath, List newClasspath) {} + public void detectedClassChangeInThisDir(File f) {} + public void buildSuccessful(boolean wasFullBuild) {} + }; + MyStateListener sl = new MyStateListener(); + try { + AjState.stateListener = sl; + runTest("change source"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Main.20.java","src/app/Main.java"); + assertTrue("Did not expect a path change to be detected ",!sl.pathChange); + run("app.Main"); + } finally { + AjState.stateListener=null; + } + } + + public void test009() throws Exception { + runTest("incrementally change only string literal, still expect advice"); + long lastTime = nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/Main.20.java","src/packageOne/Main.java"); + assertUpdated("packageOne/Main.class",lastTime); + run("packageOne.Main",new String[] {"in longer packageOne.Main.main(..)", + "before main packageOne.Main"}, + null); + } + + public void test010() throws Exception { + runTest("add aspect source file and check world is rewoven"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Detour.20.java","src/Detour.java"); + assertAdded("Detour.class"); + run("Main"); + } + + public void test011() throws Exception { + runTest("make sure additional classes generated during weave are deleted with src class file"); + nextIncrement(false); + assertTrue("AdviceOnIntroduced$AjcClosure1.class exists", + new File(ajc.getSandboxDirectory(),"AdviceOnIntroduced$AjcClosure1.class").exists()); + deleteFileAndDoIncrementalBuild("src/AdviceOnIntroduced.java"); + assertDeleted("AdviceOnIntroduced$AjcClosure1.class"); + } + + public void test012() throws Exception { + runTest("incremental with aspect-driven full rebuild"); + nextIncrement(false); + MessageSpec messageSpec = new MessageSpec(newMessageList(new Message(3,"Main.java",null,null)),null); + copyFileAndDoIncrementalBuild("changes/Aspect.20.java","src/Aspect.java",messageSpec); + run("Main"); + } + + public void testIncrementalResourceAdditionToInPath() throws Exception { + runTest("incremental with addition of resource to inpath directory"); + RunResult result = run("Hello"); + assertTrue("Should have been advised",result.getStdOut().indexOf("World") != -1); + nextIncrement(false); + assertFalse("Resource file should not exist yet",new File(ajc.getSandboxDirectory(),"AResourceFile.txt").exists()); + copyFileAndDoIncrementalBuild("changes/AResourceFile.txt", "indir/AResourceFile.txt"); + // resources are *NOT* copied from inpath directories + assertFalse("Resource file should not exist yet",new File(ajc.getSandboxDirectory(),"AResourceFile.txt").exists()); + } + + public void testAdditionOfResourceToInJar() throws Exception { + runTest("incremental with addition of resource to inpath jar"); + nextIncrement(true); + assertFalse("Resource file should not exist yet",new File(ajc.getSandboxDirectory(),"AResourceFile.txt").exists()); + copyFileAndDoIncrementalBuild("changes/MyJar.20.jar", "MyJar.jar"); + // resources *are* copied from inpath jars + assertAdded("AResourceFile.txt"); + } + + public void testRemovalOfResourceFromInJar() throws Exception { + runTest("incremental with removal of resource from inpath jar"); + nextIncrement(true); + assertAdded("AResourceFile.txt"); + copyFileAndDoIncrementalBuild("changes/MyJar.20.jar", "MyJar.jar"); + // resources *are* copied from inpath jars + assertDeleted("AResourceFile.txt"); + } + + public void testAdditionOfClassToInPathJar() throws Exception { + runTest("incremental with addition of class to inpath jar"); + nextIncrement(true); + assertFalse("Hello2.class should not exist yet",new File(ajc.getSandboxDirectory(),"Hello2.class").exists()); + copyFileAndDoIncrementalBuild("changes/MyJar.20.jar", "MyJar.jar"); + assertAdded("Hello2.class"); + } + + public void testRemovalOfClassFromInPathJar() throws Exception { + runTest("incremental with removal of class from inpath jar"); + nextIncrement(true); + assertAdded("Hello2.class"); + copyFileAndDoIncrementalBuild("changes/MyJar.20.jar", "MyJar.jar"); + assertDeleted("Hello2.class"); + } + + public void testAdditionOfClassToInJarJar() throws Exception { + runTest("incremental with addition of class to injar jar"); + nextIncrement(true); + assertFalse("Hello2.class should not exist yet",new File(ajc.getSandboxDirectory(),"Hello2.class").exists()); + copyFileAndDoIncrementalBuild("changes/MyJar.20.jar", "MyJar.jar"); + assertAdded("Hello2.class"); + } + + public void testRemovalOfClassFromInJarJar() throws Exception { + runTest("incremental with removal of class from injar jar"); + nextIncrement(true); + assertAdded("Hello2.class"); + copyFileAndDoIncrementalBuild("changes/MyJar.20.jar", "MyJar.jar"); + assertDeleted("Hello2.class"); + } + + public void testAdditionOfClassToInPathDir() throws Exception { + runTest("incremental with addition of class to inpath dir"); + nextIncrement(true); + assertFalse("Hello2.class should not exist yet",new File(ajc.getSandboxDirectory(),"Hello2.class").exists()); + copyFileAndDoIncrementalBuild("changes/Hello2.20.class", "indir/Hello2.class"); + assertAdded("Hello2.class"); + } + + public void testRemovalOfClassFromInPathDir() throws Exception { + runTest("incremental with removal of class from inpath dir"); + nextIncrement(true); + assertAdded("Hello2.class"); + deleteFileAndDoIncrementalBuild("indir/Hello2.class"); + assertDeleted("Hello2.class"); + } + + public void testUpdateOfClassInInPathDir() throws Exception { + runTest("incremental with update of class in inpath dir"); + nextIncrement(true); + RunResult before = run("Hello"); + assertTrue("Should say hello",before.getStdOut().startsWith("hello")); + copyFileAndDoIncrementalBuild("changes/Hello.20.class", "indir/Hello.class"); + RunResult after = run("Hello"); + assertTrue("Should say updated hello",after.getStdOut().startsWith("updated hello")); + } + + public void testUsesPointcutRelsWhenReferringToPCTIn2ndFile_pr90806() throws Exception { + runTest("NPE in genHandleIdentifier"); + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/X.20.aj","src/X.aj"); + } + + public void testPersistingDeow_pr84033() throws Exception { + runTest("incremental declare error persists after fix"); + copyFileAndDoIncrementalBuild("changes/Aspect.20.java", "src/pack/Aspect.java"); + nextIncrement(true); + RunResult before = run("pack.Main"); + } + + public void testIncrementalUpdateOfBodyInAroundAdvice_pr154054() throws Exception { + runTest("incremental update of body in around advice"); + nextIncrement(true); + RunResult before = run("MyClass"); + assertTrue("value should be 13 but was " + before.getStdOut(), + before.getStdOut().startsWith("13")); + // update value added to proceed + copyFileAndDoIncrementalBuild("changes/MyAspect.20.aj","src/MyAspect.aj"); + RunResult after = run("MyClass"); + assertTrue("value should be 14 but was " + after.getStdOut(), + after.getStdOut().startsWith("14")); + } + + public void testIncrementalUpdateOfBodyInAroundAdviceWithString_pr154054() throws Exception { + runTest("incremental update of body in around advice with string"); + nextIncrement(true); + RunResult before = run("MyClass"); + assertTrue("expected 'Fred and George' in output but found " + before.getStdOut(), + before.getStdOut().startsWith("Fred and George")); + // update value added to proceed + copyFileAndDoIncrementalBuild("changes/MyAspect.30.aj","src/MyAspect.aj"); + RunResult after = run("MyClass"); + assertTrue("expected 'Fred and Harry' in output but found " + after.getStdOut(), + after.getStdOut().startsWith("Fred and Harry")); + } +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/incremental-junit-tests.xml b/tests/src/test/java/org/aspectj/systemtest/incremental/incremental-junit-tests.xml new file mode 100644 index 000000000..659abff47 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/incremental-junit-tests.xml @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/incremental-tests.xml b/tests/src/test/java/org/aspectj/systemtest/incremental/incremental-tests.xml new file mode 100644 index 000000000..1ce24711e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/incremental-tests.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/incremental.xml b/tests/src/test/java/org/aspectj/systemtest/incremental/incremental.xml new file mode 100644 index 000000000..39d6a6823 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/incremental.xml @@ -0,0 +1,10 @@ + +]> + + + + +&tests; + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java new file mode 100644 index 000000000..a2ce02c0c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java @@ -0,0 +1,187 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.incremental.model; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.asm.AsmManager; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.util.StructureModelUtil; + +public class IncrementalModelTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IncrementalModelTests.class); + } + + protected File getSpecFile() { + return getClassResource("incremental-model.xml"); + } + + // This first test doesnt do a lot currently, but is ready too... + public void test001() throws Exception { + runTest("Testing incremental structure model: Intertype declarations (and a declare parents)"); + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/CloneablePoint.20.java", "src/introduction/CloneablePoint.java"); + nextIncrement(true); + copyFile("changes/Point.30.java", "src/introduction/Point.java"); + copyFileAndDoIncrementalBuild("changes/HashablePoint.30.java", "src/introduction/HashablePoint.java"); + StructureModelUtil.checkModel("declare parents=2"); + } + + public void test002() throws Exception { + runTest("Testing incremental structure model: Intertype field declarations"); + + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/BetaA.20.java", "src/secondary/BetaA.java"); + StructureModelUtil.checkModel("inter-type field=2,RelationshipMapSize=3"); + + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/BetaA.30.java", "src/secondary/BetaA.java"); + // TODO Andy - fix this test, what should the real results be in the model? + // when we go slow it seems to be relmapsize=0 + // StructureModelUtil.checkModel("inter-type field=1,RelationshipMapSize=2"); + } + + public void test003() throws Exception { + runTest("Testing incremental structure model: Weaving handlers"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.20.java", "src/primary/BetaA.java"); + // if (AsmHierarchyBuilder.shouldAddUsesPointcut) { + // StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3"); + // } else { + StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2"); + // } + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/GammaA.30.java", "src/secondary/GammaA.java"); + // if (AsmHierarchyBuilder.shouldAddUsesPointcut) { + // StructureModelUtil.checkModel("code=1,advice=2,RelationshipMapSize=5"); + // } else { + StructureModelUtil.checkModel("code=1,advice=2,RelationshipMapSize=3"); + // } + + // + nextIncrement(true); + deleteFileAndDoIncrementalBuild("src/primary/BetaA.java"); + // if (AsmHierarchyBuilder.shouldAddUsesPointcut) { + // StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3"); + // } else { + StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2"); + // } + + } + + public void test004() throws Exception { + runTest("Testing incremental structure model: Weaving"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.20.java", "src/primary/BetaA.java"); + // if (AsmHierarchyBuilder.shouldAddUsesPointcut) { + // StructureModelUtil.checkModel("code=2,advice=2,java source file=3,RelationshipMapSize=6"); + // } else { + StructureModelUtil.checkModel("code=2,advice=2,java source file=3,RelationshipMapSize=4"); + // } + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.30.java", "src/primary/BetaA.java"); + // if (AsmHierarchyBuilder.shouldAddUsesPointcut) { + // StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3"); + // } else { + StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2"); + // } + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.40.java", "src/primary/BetaA.java"); + StructureModelUtil.checkModel("code=0,RelationshipMapSize=0,advice=0"); + } + + public void test005() throws Exception { + runTest("Testing incremental structure model: Updating files"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/Beta.20.java", "src/primary/Beta.java"); + StructureModelUtil.checkModel("java source file=5,method=4,class=3,FileMapSize=4"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Delta.30.java", "src/secondary/Delta.java"); + StructureModelUtil.checkModel("java source file=5,method=4,class=4,advice=1"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.40.java", "src/secondary/Gamma.java"); + StructureModelUtil.checkModel("advice=2"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.50.java", "src/secondary/Gamma.java"); + StructureModelUtil.checkModel("advice=2,pointcut=1"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.60.java", "src/secondary/Gamma.java"); + StructureModelUtil.checkModel("advice=0,pointcut=1"); + + } + + public void test006() throws Exception { + runTest("Testing incremental structure model: Adding and removing files"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/Beta.20.java", "src/primary/Beta.java"); + StructureModelUtil.checkModel("java source file=3,FileMapSize=2"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.30.java", "src/secondary/Gamma.java"); + StructureModelUtil.checkModel("java source file=4"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Delta.40.java", "src/secondary/Delta.java"); + StructureModelUtil.checkModel("java source file=5,package=2,FileMapSize=4"); + + // + nextIncrement(true); + deleteFileAndDoIncrementalBuild("src/secondary/Gamma.java"); + StructureModelUtil.checkModel("java source file=4,package=2"); + + // + nextIncrement(true); + deleteFile("src/primary/Beta.java"); + deleteFileAndDoIncrementalBuild("src/secondary/Delta.java"); + StructureModelUtil.checkModel("java source file=2,FileMapSize=1"); + } + + protected void setUp() throws Exception { + super.setUp(); + AsmManager.attemptIncrementalModelRepairs = true; + } + + protected void tearDown() throws Exception { + // To see the model after a test, uncomment these lines... + // AsmManager.ModelInfo mi = AsmManager.ModelInfo.summarizeModel(); + // System.err.println(mi.toString()); + super.tearDown(); + + AsmManager.attemptIncrementalModelRepairs = false; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml b/tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml new file mode 100644 index 000000000..ae9e6be31 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model.xml b/tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model.xml new file mode 100644 index 000000000..1768ea102 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/model/incremental-model.xml @@ -0,0 +1,10 @@ + +]> + + + + +&tests; + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java new file mode 100644 index 000000000..229a22a5d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java @@ -0,0 +1,284 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Adrian Colyer initial implementation + * Helen Hawkins Converted to new interface (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.aspectj.ajdt.internal.core.builder.AjState; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; +import org.aspectj.asm.IRelationshipMap; +import org.aspectj.testing.util.FileUtil; + +public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeInteractionTestbed { + + public static boolean VERBOSE = false; + + public static void dumptree(IProgramElement node, int indent) { + for (int i = 0; i < indent; i++) { + System.out.print(" "); + } + String loc = ""; + if (node != null) { + if (node.getSourceLocation() != null) { + loc = Integer.toString(node.getSourceLocation().getLine()); + } + } + // System.out.println(node + " [" + (node == null ? "null" : node.getKind().toString()) + "] " + loc); + System.out.println(node + " [" + (node == null ? "null" : node.getKind().toString()) + "] " + loc + + (node == null ? "" : " hid:" + node.getHandleIdentifier())); + if (node != null) { + // for (int i = 0; i < indent; i++) + // System.out.print(" "); + // System.out.println(" hid is " + node.getHandleIdentifier()); + // Map m = ((ProgramElement) node).kvpairs; + // if (m != null) { + // Set keys = m.keySet(); + // for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + // Object object = (Object) iterator.next(); + // + // for (int i = 0; i < indent; i++) + // System.out.print(" "); + // System.out.println("kvp: " + object + " = " + m.get(object)); + // } + // } + for (Iterator i = node.getChildren().iterator(); i.hasNext();) { + dumptree( i.next(), indent + 2); + } + } + } + + protected void setUp() throws Exception { + super.setUp(); + AjdeInteractionTestbed.VERBOSE = VERBOSE; + AjState.FORCE_INCREMENTAL_DURING_TESTING = true; + } + + protected void tearDown() throws Exception { + super.tearDown(); + AjState.FORCE_INCREMENTAL_DURING_TESTING = false; + } + + protected String runMethod(String projectName, String classname, String methodname) throws Exception { + File f = getProjectOutputRelativePath(projectName, ""); + ClassLoader cl = new URLClassLoader(new URL[] { f.toURI().toURL() }); + Class clazz = Class.forName(classname, false, cl); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream realOut = System.out; + try { + System.setOut(new PrintStream(baos)); + clazz.getDeclaredMethod(methodname).invoke(null); + } finally { + System.setOut(realOut); + } + return new String(baos.toByteArray()); + } + + protected File getProjectOutputRelativePath(String p, String filename) { + File projDir = new File(getWorkingDir(), p); + return new File(projDir, "bin" + File.separator + filename); + } + + public void build(String projectName) { + constructUpToDateLstFile(projectName, "build.lst"); + doBuild(projectName); + if (AjdeInteractionTestbed.VERBOSE) + printBuildReport(projectName); + } + + public int getRelationshipCount(String project) { + IRelationshipMap relmap = getModelFor(project).getRelationshipMap(); + int ctr = 0; + Set entries = relmap.getEntries(); + for (Iterator iter = entries.iterator(); iter.hasNext();) { + String hid = (String) iter.next(); + List rels = relmap.get(hid); + for (Iterator iterator = rels.iterator(); iterator.hasNext();) { + ctr+=iterator.next().getTargets().size(); + } + } + return ctr; + } + + public void fullBuild(String projectName) { + constructUpToDateLstFile(projectName, "build.lst"); + doFullBuild(projectName); + if (AjdeInteractionTestbed.VERBOSE) + printBuildReport(projectName); + } + + private void constructUpToDateLstFile(String pname, String configname) { + File projectBase = new File(sandboxDir, pname); + File toConstruct = new File(projectBase, configname); + List filesForCompilation = new ArrayList(); + collectUpFiles(projectBase, projectBase, filesForCompilation); + + try { + FileOutputStream fos = new FileOutputStream(toConstruct); + DataOutputStream dos = new DataOutputStream(fos); + for (String file: filesForCompilation) { + dos.writeBytes(file + "\n"); + } + dos.close(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + + private void collectUpFiles(File location, File base, List collectionPoint) { + String contents[] = location.list(); + if (contents == null) + return; + for (int i = 0; i < contents.length; i++) { + String string = contents[i]; + File f = new File(location, string); + if (f.isDirectory()) { + collectUpFiles(f, base, collectionPoint); + } else if (f.isFile() && (f.getName().endsWith(".aj") || f.getName().endsWith(".java"))) { + String fileFound; + try { + fileFound = f.getCanonicalPath(); + String toRemove = base.getCanonicalPath(); + if (!fileFound.startsWith(toRemove)) + throw new RuntimeException("eh? " + fileFound + " " + toRemove); + collectionPoint.add(fileFound.substring(toRemove.length() + 1));// +1 captures extra separator + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * Fill in the working directory with the project base files, from the 'base' folder. + */ + protected void initialiseProject(String p) { + File projectSrc = new File(testdataSrcDir + File.separatorChar + p + File.separatorChar + "base"); + File destination = new File(getWorkingDir(), p); + if (!destination.exists()) { + destination.mkdir(); + } + copy(projectSrc, destination);// ,false); + // create the AjCompiler instance associated with this project + // (has id of the form c:\temp\ajcSandbox\\) + CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + p); + } + + /** + * Applies an overlay onto the project being tested - copying the contents of the specified overlay directory. + */ + public void alter(String projectName, String overlayDirectory) { + File projectSrc = new File(testdataSrcDir + File.separatorChar + projectName + File.separatorChar + overlayDirectory); + File destination = new File(getWorkingDir(), projectName); + + if (AjdeInteractionTestbed.VERBOSE) + System.out.println("Altering project " + projectName); + copy(projectSrc, destination); + } + + /** + * Copy the contents of some directory to another location - the copy is recursive. + */ + protected void copy(File from, File to) { + String contents[] = from.list(); + if (contents == null) + return; + for (int i = 0; i < contents.length; i++) { + String string = contents[i]; + File f = new File(from, string); + File t = new File(to, string); + + if (f.isDirectory() && !f.getName().startsWith("inc")) { + t.mkdir(); + copy(f, t); + } else if (f.isFile()) { + StringBuffer sb = new StringBuffer(); + // if (VERBOSE) System.err.println("Copying "+f+" to "+t); + FileUtil.copyFile(f, t, sb); + if (sb.length() != 0) { + System.err.println(sb.toString()); + } + } + } + } + + /** + * Count the number of times a specified aspectName appears in the default aop.xml file and compare with the expected number of + * occurrences. If just want to count the number of aspects mentioned within the file then pass "" for the aspectName, + * otherwise, specify the name of the aspect interested in. + */ + protected void checkXMLAspectCount(String projectName, String aspectName, int expectedOccurrences, String outputDir) { + int aspectCount = 0; + File aopXML = new File(outputDir + File.separatorChar + "META-INF" + File.separatorChar + "aop-ajc.xml"); + + if (!aopXML.exists()) { + fail("Expected file " + aopXML.getAbsolutePath() + " to exist but it doesn't"); + } + try { + BufferedReader reader = new BufferedReader(new FileReader(aopXML)); + String line = reader.readLine(); + while (line != null) { + if (aspectName.equals("") && line.indexOf("aspect name=\"") != -1) { + aspectCount++; + } else if (line.indexOf("aspect name=\"" + aspectName + "\"") != -1) { + aspectCount++; + } + line = reader.readLine(); + } + reader.close(); + } catch (IOException ie) { + ie.printStackTrace(); + } + if (aspectCount != expectedOccurrences) { + fail("Expected aspect " + aspectName + " to appear " + expectedOccurrences + " times" + + " in the aop.xml file but found " + aspectCount + " occurrences"); + } + } + + protected void assertContains(String expectedSubstring, Object object) { + String actualString = object.toString(); + if (actualString.indexOf(expectedSubstring) == -1) { + fail("Expected to find '" + expectedSubstring + "' in '" + actualString + "'"); + } + } + + /** @return the number of relationship pairs */ + protected void printModel(String projectName) throws Exception { + dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); + PrintWriter pw = new PrintWriter(System.out); + getModelFor(projectName).dumprels(pw); + pw.flush(); + } + + protected File getProjectRelativePath(String p, String filename) { + File projDir = new File(getWorkingDir(), p); + return new File(projDir, filename); + } + + protected void assertNoErrors(String projectName) { + assertTrue("Should be no errors, but got " + getErrorMessages(projectName), getErrorMessages(projectName).size() == 0); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java new file mode 100644 index 000000000..01426d923 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -0,0 +1,559 @@ +/******************************************************************** + * Copyright (c) 2005 Contributors.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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement initial implementation + * Helen Hawkins Converted to new interface (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junit.framework.TestCase; + +import org.aspectj.ajde.core.AjCompiler; +import org.aspectj.ajde.core.IBuildMessageHandler; +import org.aspectj.ajde.core.ICompilerConfiguration; +import org.aspectj.ajde.core.IOutputLocationManager; +import org.aspectj.ajdt.internal.core.builder.AbstractStateListener; +import org.aspectj.ajdt.internal.core.builder.AjState; +import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager; +import org.aspectj.asm.AsmManager; +import org.aspectj.bridge.IMessage; +import org.aspectj.tools.ajc.Ajc; + +/** + * This class uses Ajde in the same way that an IDE (e.g. AJDT) does. + * + * The build is driven through 'doBuild(projectName)' but the build can be configured by the methods beginning 'configure***'. + * Information about what happened during a build is accessible through the get*, was*, print* public methods... + * + */ +public class AjdeInteractionTestbed extends TestCase { + + public static boolean VERBOSE = false; // do you want the gory details? + + public static String testdataSrcDir = "../tests/multiIncremental"; + protected static File sandboxDir; + + private static boolean buildModel; + + // Methods for configuring the build + public void configureNewProjectDependency(String fromProjectName, String projectItDependsOn) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + fromProjectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addDependancy(projectItDependsOn); + } + + public void addSourceFolderForSourceFile(String projectName, File f, String sourceFolder) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestOutputLocationManager) ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()) + .getOutputLocationManager()).setSourceFolderFor(f, sourceFolder); + } + + public void setNextChangeResponse(String projName, int flags) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).changed = flags; + } + + public void setProjectEncoding(String projName, String encoding) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProjectEncoding(encoding); + } + + public void addProjectSourceFileChanged(String projectName, File changedFile) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addProjectSourceFileChanged(changedFile); + } + + public void addXmlConfigFile(String projectName, String xmlfile) { + List l = new ArrayList(); + l.add(xmlfile); + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProjectXmlConfigFiles(l); + } + + public void addClasspathEntry(String projectName, File classpathEntry) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + MultiProjTestCompilerConfiguration config = ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()); + config.setClasspath(config.getClasspath() + File.pathSeparator + classpathEntry.toString()); + } + + public void addClasspathEntryChanged(String projectName, String changedDir) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addClasspathEntryChanged(changedDir); + } + + public void configureNonStandardCompileOptions(String projectName, String options) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setNonStandardOptions(options); + } + + public void configureAspectPath(String projectName, Set aspectpath) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(aspectpath); + } + + public void configureProcessor(String projectName, String processor) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProcessor(processor); + } + + public void configureProcessorPath(String projectName, String processorPath) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProcessorPath(processorPath); + } + + public void configureAspectPath(String projectName, File aspectpath) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + Set s = new HashSet(); + s.add(aspectpath); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(s); + } + + public void configureResourceMap(String projectName, Map resourcesMap) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setSourcePathResources(resourcesMap); + } + + public void configureJavaOptionsMap(String projectName, Map options) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setJavaOptions(options); + } + + public static void configureInPath(String projectName, Set inpath) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setInpath(inpath); + } + + public static void configureInPath(String projectName, File inpath) { + Set s = new HashSet(); + s.add(inpath); + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setInpath(s); + } + + public static void configureOutputLocationManager(String projectName, IOutputLocationManager mgr) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setOutputLocationManager(mgr); + } + + public void configureShowWeaveInfoMessages(String projectName, boolean showWeaveInfo) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + IBuildMessageHandler handler = compiler.getMessageHandler(); + if (showWeaveInfo) { + handler.dontIgnore(IMessage.WEAVEINFO); + } else { + handler.ignore(IMessage.WEAVEINFO); + } + } + + // End of methods for configuring the build + + public AjCompiler getCompilerForProjectWithName(String projectName) { + return CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + } + + protected File getWorkingDir() { + return sandboxDir; + } + + protected void setUp() throws Exception { + super.setUp(); + // need this line because otherwise reset in previous tests + AsmManager.attemptIncrementalModelRepairs = true; + if (AjState.stateListener == null) { + AjState.stateListener = MyStateListener.getInstance(); + + } + MyStateListener.reset(); + // Create a sandbox in which to work + sandboxDir = Ajc.createEmptySandbox(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + AjState.stateListener = null; + CompilerFactory.clearCompilerMap(); + IncrementalStateManager.clearIncrementalStates(); + } + + /** Drives a build */ + public boolean doBuild(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + resetCompilerRecords(compiler); + addSourceFilesToBuild(projectName, compiler); + // addXmlConfigFilesToBuild(projectName, compiler); + pause(1000); // delay to allow previous runs build stamps to be OK + lognoln("Building project '" + projectName + "'"); + compiler.build(); + log(""); + checkForErrors(compiler); + log("Build finished, time taken = " + + ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getTimeTaken() + "ms"); + return true; + } + + // public AsmManager getStructureModelFor(String projectName) { + // AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + // returnc compiler.getStructureModelFor(projectName) + // } + + /** Drives a full build **/ + public boolean doFullBuild(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + resetCompilerRecords(compiler); + addSourceFilesToBuild(projectName, compiler); + addXmlConfigFilesToBuild(projectName, compiler); + pause(1000); // delay to allow previous runs build stamps to be OK + lognoln("Building project '" + projectName + "'"); + compiler.buildFresh(); + log(""); + checkForErrors(compiler); + log("Build finished, time taken = " + + ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getTimeTaken() + "ms"); + return true; + } + + /** + * Clears any maps associated with the compiler + */ + private void resetCompilerRecords(AjCompiler compiler) { + ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).reset(); + ((MultiProjTestMessageHandler) compiler.getMessageHandler()).reset(); + } + + /** + * Find the source files associated with the given project and add them to the list of projectSourceFiles in the + * MultiProjTestCompilerConfiguration to be used in the subsequent build + */ + private void addSourceFilesToBuild(String pname, AjCompiler compiler) { + File projectBase = new File(sandboxDir, pname); + ICompilerConfiguration icc = compiler.getCompilerConfiguration(); + List currentFiles = icc.getProjectSourceFiles(); + List filesForCompilation = new ArrayList(); + collectUpFiles(projectBase, projectBase, filesForCompilation); + boolean changed = false; + for (int i = 0; i < filesForCompilation.size(); i++) { + if (!currentFiles.contains(filesForCompilation.get(i))) { + changed = true; + } + } + for (int i = 0; i < currentFiles.size(); i++) { + if (!filesForCompilation.contains(currentFiles.get(i))) { + changed = true; + } + } + if (changed) { + ((MultiProjTestCompilerConfiguration) icc).setProjectSourceFiles(filesForCompilation); + } + } + + private void addXmlConfigFilesToBuild(String pname, AjCompiler compiler) { + File projectBase = new File(sandboxDir, pname); + ICompilerConfiguration icc = compiler.getCompilerConfiguration(); + List currentXmlFiles = icc.getProjectXmlConfigFiles(); + List collector = new ArrayList(); + collectUpXmlFiles(projectBase, projectBase, collector); + boolean changed = false; + for (int i = 0; i < collector.size(); i++) { + if (!currentXmlFiles.contains(collector.get(i))) { + changed = true; + } + } + for (int i = 0; i < currentXmlFiles.size(); i++) { + if (!collector.contains(currentXmlFiles.get(i))) { + changed = true; + } + } + if (changed) { + ((MultiProjTestCompilerConfiguration) icc).setProjectXmlConfigFiles(collector); + } + } + + private void collectUpFiles(File location, File base, List collectionPoint) { + String contents[] = location.list(); + if (contents == null) { + return; + } + for (int i = 0; i < contents.length; i++) { + String string = contents[i]; + File f = new File(location, string); + if (f.isDirectory()) { + collectUpFiles(f, base, collectionPoint); + } else if (f.isFile() && (f.getName().endsWith(".aj") || f.getName().endsWith(".java"))) { + String fileFound; + try { + fileFound = f.getCanonicalPath(); + collectionPoint.add(fileFound); + // String toRemove = base.getCanonicalPath(); + // if (!fileFound.startsWith(toRemove)) throw new RuntimeException("eh? "+fileFound+" "+toRemove); + // collectionPoint.add(fileFound.substring(toRemove.length()+1));//+1 captures extra separator + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + private void collectUpXmlFiles(File location, File base, List collectionPoint) { + String contents[] = location.list(); + if (contents == null) { + return; + } + for (int i = 0; i < contents.length; i++) { + String string = contents[i]; + File f = new File(location, string); + if (f.isDirectory()) { + collectUpXmlFiles(f, base, collectionPoint); + } else if (f.isFile() && f.getName().endsWith(".xml")) { + String fileFound; + try { + fileFound = f.getCanonicalPath(); + collectionPoint.add(fileFound); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * Make sure no errors have been recorded + */ + private void checkForErrors(AjCompiler compiler) { + MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); + if (handler.hasErrorMessages()) { + System.err.println("Build errors:"); + for (IMessage message: handler.getErrorMessages()) { + System.err.println(message); + } + System.err.println("---------"); + } + } + + public List getErrorMessages(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages(); + } + + public List getWarningMessages(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWarningMessages(); + } + + public List getWeavingMessages(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages(); + } + + public List getCompilerErrorMessages(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors(); + } + + public void checkForError(String projectName, String anError) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + List messages = ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages(); + for (Iterator iter = messages.iterator(); iter.hasNext();) { + IMessage element = iter.next(); + if (element.getMessage().indexOf(anError) != -1) { + return; + } + } + fail("Didn't find the error message:\n'" + anError + "'.\nErrors that occurred:\n" + messages); + } + + private void pause(int millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException ie) { + } + } + + // Methods for querying what happened during a build and accessing information + // about the build: + + /** + * Helper method for dumping info about which files were compiled and woven during the last build. + */ + public String printCompiledAndWovenFiles(String projectName) { + StringBuffer sb = new StringBuffer(); + if (getCompiledFiles(projectName).size() == 0 && getWovenClasses(projectName).size() == 0) { + sb.append("No files were compiled or woven\n"); + } + for (String element: getCompiledFiles(projectName)) { + sb.append("compiled: " + element + "\n"); + } + for (String element: getWovenClasses(projectName)) { + sb.append("woven: " + element + "\n"); + } + return sb.toString(); + } + + /** + * Summary report on what happened in the most recent build + */ + public void printBuildReport(String projectName) { + System.out.println("\n====== BUILD REPORT (Project " + projectName + ") ==========="); + System.out.println("Build took: " + getTimeTakenForBuild(projectName) + "ms"); + List compiled = getCompiledFiles(projectName); + System.out.println("Compiled: " + compiled.size() + " files"); + for (Iterator iter = compiled.iterator(); iter.hasNext();) { + System.out.println(" :" + iter.next()); + } + List woven = getWovenClasses(projectName); + System.out.println("Wove: " + woven.size() + " files"); + for (Iterator iter = woven.iterator(); iter.hasNext();) { + System.out.println(" :" + iter.next()); + } + if (wasFullBuild()) { + System.out.println("It was a batch (full) build"); + } + System.out.println("============================================="); + } + + /** + * Check we compiled/wove the right number of files, passing '-1' indicates you don't care about that number. + */ + public void checkCompileWeaveCount(String projectName, int expCompile, int expWoven) { + if (expCompile != -1 && getCompiledFiles(projectName).size() != expCompile) { + fail("Expected compilation of " + expCompile + " files but compiled " + getCompiledFiles(projectName).size() + "\n" + + printCompiledAndWovenFiles(projectName)); + } + if (expWoven != -1 && getWovenClasses(projectName).size() != expWoven) { + fail("Expected weaving of " + expWoven + " files but wove " + getWovenClasses(projectName).size() + "\n" + + printCompiledAndWovenFiles(projectName)); + } + } + + public void checkWasntFullBuild() { + assertTrue("Shouldn't have been a full (batch) build", !wasFullBuild()); + } + + public void checkWasFullBuild() { + assertTrue("Should have been a full (batch) build", wasFullBuild()); + } + + public boolean wasFullBuild() { + // alternatives: statelistener is debug interface, progressmonitor is new proper interface (see pr145689) + // return MyBuildProgressMonitor.wasFullBuild(); + return MyStateListener.wasFullBuild(); + } + + public long getTimeTakenForBuild(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getTimeTaken(); + } + + public List getCompiledFiles(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getCompiledFiles(); + } + + public AsmManager getModelFor(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return compiler.getModel(); + } + + public List getWovenClasses(String projectName) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + return ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getWovenClasses(); + } + + // Infrastructure below here + + private static void log(String msg) { + if (VERBOSE) { + System.out.println(msg); + } + } + + private static void lognoln(String msg) { + if (VERBOSE) { + System.out.print(msg); + } + } + + /** Return the *full* path to this file which is taken relative to the project dir */ + protected static String getFile(String projectName, String path) { + return new File(sandboxDir, projectName + File.separatorChar + path).getAbsolutePath(); + } + + static class MyStateListener extends AbstractStateListener { + + private static MyStateListener _instance = new MyStateListener(); + + private MyStateListener() { + reset(); + } + + public static MyStateListener getInstance() { + return _instance; + } + + public static boolean informedAboutKindOfBuild; + public static boolean fullBuildOccurred; + public static List detectedDeletions = new ArrayList(); + public static StringBuffer decisions = new StringBuffer(); + + public static void reset() { + informedAboutKindOfBuild = false; + decisions = new StringBuffer(); + fullBuildOccurred = false; + if (detectedDeletions != null) { + detectedDeletions.clear(); + } + } + + public boolean pathChange = false; + + public void pathChangeDetected() { + pathChange = true; + } + + public void aboutToCompareClasspaths(List oldClasspath, List newClasspath) { + } + + public void detectedClassChangeInThisDir(File f) { + recordDecision("Detected class change in this directory: " + f.toString()); + } + + public void detectedAspectDeleted(File f) { + detectedDeletions.add(f.toString()); + } + + public void buildSuccessful(boolean wasFullBuild) { + informedAboutKindOfBuild = true; + fullBuildOccurred = wasFullBuild; + } + + public static String getDecisions() { + return decisions.toString(); + } + + public static boolean wasFullBuild() { + if (!informedAboutKindOfBuild) { + throw new RuntimeException("I never heard about what kind of build it was!!"); + } + return fullBuildOccurred; + } + + // not needed just yet... + // public void recordInformation(String s) { decisions.append(s).append("\n");} + public void recordDecision(String s) { + decisions.append(s).append("\n"); + log(s); + } + }; +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbedLauncher.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbedLauncher.java new file mode 100644 index 000000000..6b431c1df --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbedLauncher.java @@ -0,0 +1,47 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Adrian Colyer Initial implementation + * Helen Hawkins Converted to new interface (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + + +/** + * command-line launcher for Ajde-like aspectj runs for use with + * profiling tools. + */ +public class AjdeInteractionTestbedLauncher extends + MultiProjectIncrementalTests { + + /** + * usage: AjdeInteractionTestbedLauncher srcDir projectName + * @param args workspace_root_dir project_name + */ + public static void main(String[] args) throws Exception { + AjdeInteractionTestbedLauncher.testdataSrcDir = args[0]; + AjdeInteractionTestbedLauncher launcher = new AjdeInteractionTestbedLauncher(args[1]); + launcher.setUp(); + launcher.buildProject(args[1]); + //launcher.printBuildReport(); + launcher.tearDown(); + } + + public AjdeInteractionTestbedLauncher(String projectName) { + String classPath = System.getProperty("java.class.path"); + ((MultiProjTestCompilerConfiguration)getCompilerForProjectWithName(projectName) + .getCompilerConfiguration()).setClasspath(classPath); + } + + private void buildProject(String projectName) { + initialiseProject(projectName); + build(projectName); + } + + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java new file mode 100644 index 000000000..78d671946 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2014 Contributors + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import org.aspectj.util.FileUtil; + +public class AnnotationProcessingTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { + + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + new File("Advise_aaa.java").delete(); + new File("Advise_ccc.java").delete(); + new File("Advise_boo.java").delete(); + new File("Advise_too.java").delete(); + new File("AroundAdvise_aaa.java").delete(); + new File("AroundAdvise_ccc.java").delete(); + if (new File("../run-all-junit-tests/generated/test/SomeCallbacks.java").exists()) { + FileUtil.deleteContents(new File("../run-all-junit-tests/generated")); + new File("../run-all-junit-tests/generated").delete(); + } + } + + // Basic test: turns on annotation processing and tries to run the DemoProcessor + public void testAnnotationProcessing1() throws Exception { + createAndBuildAnnotationProcessorProject("ProcessorProject"); + initialiseProject("ProcessorConsumer1"); + configureProcessorOptions("ProcessorConsumer1","DemoProcessor"); + configureNonStandardCompileOptions("ProcessorConsumer1", "-showWeaveInfo"); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.processAnnotations","enabled"); + configureJavaOptionsMap("ProcessorConsumer1", javaOptions); + + configureNewProjectDependency("ProcessorConsumer1", "ProcessorProject"); + configureNonStandardCompileOptions("ProcessorConsumer1", "-showWeaveInfo"); + build("ProcessorConsumer1"); + checkWasFullBuild(); + checkCompiledFiles("ProcessorConsumer1","Advise_ccc.java","Advise_aaa.java","Code.java"); + assertEquals(2,getWeavingMessages("ProcessorConsumer1").size()); + String out = runMethod("ProcessorConsumer1", "Code", "runner"); + assertEquals("aaa running\nccc running\n",out); + } + + // services file in processor project + public void testAnnotationProcessing2() throws Exception { + createAndBuildAnnotationProcessorProject("ProcessorProject2"); // This has a META-INF services entry for DemoProcessor + + initialiseProject("ProcessorConsumer2"); + // Paths here are the path to DemoProcessor (compiled into the output folder of the ProcessorProject2) and the path to + // the META-INF file declaring DemoProcessor (since it is not copied to that same output folder) - this exists in the test src + // folder for ProcessorProject2 + configureProcessorPath("ProcessorConsumer2", getCompilerForProjectWithName("ProcessorProject2").getCompilerConfiguration().getOutputLocationManager().getDefaultOutputLocation().toString()+File.pathSeparator+ + new File(testdataSrcDir + File.separatorChar + "ProcessorProject2" + File.separatorChar + "base"+File.separatorChar+"src").toString()); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.processAnnotations","enabled"); + configureJavaOptionsMap("ProcessorConsumer2", javaOptions); + initialiseProject("ProcessorConsumer2"); + configureNewProjectDependency("ProcessorConsumer2", "ProcessorProject"); + configureNonStandardCompileOptions("ProcessorConsumer2", "-showWeaveInfo"); + build("ProcessorConsumer2"); + checkWasFullBuild(); + checkCompiledFiles("ProcessorConsumer2","Advise_ccc.java","Advise_aaa.java","Code.java"); + assertEquals(2,getWeavingMessages("ProcessorConsumer2").size()); + String out = runMethod("ProcessorConsumer2", "Code", "runner"); + assertEquals("aaa running\nccc running\n",out); + } + + // Two processors + public void testAnnotationProcessing3() throws Exception { + createAndBuildAnnotationProcessorProject("ProcessorProject2"); + createAndBuildAnnotationProcessorProject("ProcessorProject3"); + initialiseProject("ProcessorConsumer1"); + // Paths here are the path to DemoProcessor/DemoProcessor2 compiled code and the path to + // the META-INF file declaring DemoProcessor/DemoProcessor2 (since they are not copied to that same output folder) - + // these exists in the test src folders for ProcessorProject2/ProcessorProject3 + configureProcessorPath("ProcessorConsumer1", + getCompilerForProjectWithName("ProcessorProject3").getCompilerConfiguration().getOutputLocationManager().getDefaultOutputLocation().toString()+File.pathSeparator+ + new File(testdataSrcDir + File.separatorChar + "ProcessorProject3" + File.separatorChar + "base"+File.separatorChar+"src").toString() + +File.pathSeparator+ + getCompilerForProjectWithName("ProcessorProject2").getCompilerConfiguration().getOutputLocationManager().getDefaultOutputLocation().toString()+File.pathSeparator+ + new File(testdataSrcDir + File.separatorChar + "ProcessorProject2" + File.separatorChar + "base"+File.separatorChar+"src").toString() + ); + + // The order here is DemoProcessor2 then DemoProcessor - to get the second one to run I changed DemoProcessor2 to operate on a + // specific annotation (java.lang.SuppressWarnings) and return false at the end + + configureNonStandardCompileOptions("ProcessorConsumer1", "-showWeaveInfo"); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.processAnnotations","enabled"); + configureJavaOptionsMap("ProcessorConsumer1", javaOptions); + + configureNewProjectDependency("ProcessorConsumer1", "ProcessorProject"); + configureNonStandardCompileOptions("ProcessorConsumer1", "-showWeaveInfo"); + build("ProcessorConsumer1"); + checkWasFullBuild(); + checkCompiledFiles("ProcessorConsumer1","Advise_ccc.java","Advise_aaa.java","Code.java","AroundAdvise_ccc.java","AroundAdvise_aaa.java"); + assertEquals(4,getWeavingMessages("ProcessorConsumer1").size()); + String out = runMethod("ProcessorConsumer1", "Code", "runner"); + assertEquals("aaa running\nAround advice on aaa running\nccc running\nAround advice on ccc running\n",out); + } + + // Tests: + // TODO Incremental compilation - what does that mean with annotation processors? + + // --- + + private void createAndBuildAnnotationProcessorProject(String processorProjectName) { + initialiseProject(processorProjectName); + build(processorProjectName); + checkWasFullBuild(); + assertNoErrors(processorProjectName); + } + + private void configureProcessorOptions(String projectName, String processor) { + configureProcessor(projectName, "DemoProcessor"); + // Assume all processors from processor project + configureProcessorPath(projectName, getCompilerForProjectWithName("ProcessorProject").getCompilerConfiguration().getOutputLocationManager().getDefaultOutputLocation().toString()); + } + + private void checkCompiledFiles(String projectName, String... expectedCompiledFiles) { + List compiledFiles = new ArrayList(getCompiledFiles(projectName)); + if (compiledFiles.size()!=expectedCompiledFiles.length) { + fail("Expected #"+expectedCompiledFiles.length+" files to be compiled but found that #"+compiledFiles.size()+" files were compiled.\nCompiled="+compiledFiles); + } + for (String expectedCompiledFile: expectedCompiledFiles) { + String toRemove = null; + for (String compiledFile: compiledFiles) { + String cfile = compiledFile.substring(compiledFile.lastIndexOf("/")+1); + if (cfile.equals(expectedCompiledFile)) { + toRemove = compiledFile; + break; + } + } + if (toRemove!=null) compiledFiles.remove(toRemove); + } + // Anything left in compiledFiles wasn't expected to be built + if (compiledFiles.size()!=0) { + fail("These were not expected to be compiled: "+compiledFiles); + } + } + + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/CompilerFactory.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/CompilerFactory.java new file mode 100644 index 000000000..3b243d5b8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/CompilerFactory.java @@ -0,0 +1,58 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.util.Collection; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +import org.aspectj.ajde.core.AjCompiler; + +/** + * Manages the different compilers for the different projects within one test run + */ +public class CompilerFactory { + + private static Map compilerMap = new Hashtable<>(); + + /** + * If an AjCompiler exists for the given projectDir then returns + * that, otherwise creates a new one. + */ + public static AjCompiler getCompilerForProjectWithDir(String projectDir) { + if (compilerMap.containsKey(projectDir)) { + return (AjCompiler) compilerMap.get(projectDir); + } + + AjCompiler compiler = new AjCompiler( + projectDir, + new MultiProjTestCompilerConfiguration(projectDir), + new MultiProjTestBuildProgressMonitor(), + new MultiProjTestMessageHandler()); + compilerMap.put(projectDir,compiler); + return compiler; + } + + /** + * Clears the current map - before doing so clears the state of + * each compiler (this ensures everything is cleaned up in the + * IncrementalStateManager) + */ + public static void clearCompilerMap() { + Collection compilers = compilerMap.values(); + for (AjCompiler compiler: compilers) { + compiler.clearLastState(); + } + compilerMap.clear(); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java new file mode 100644 index 000000000..c3e44bcbc --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java @@ -0,0 +1,994 @@ +/******************************************************************** + * Copyright (c) 2010 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement (SpringSource) initial implementation + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.util.List; +import java.util.Set; + +import org.aspectj.ajde.core.AjCompiler; +import org.aspectj.ajde.core.internal.AjdeCoreBuildManager; +import org.aspectj.ajdt.internal.core.builder.AjBuildManager; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.internal.AspectJElementHierarchy; +import org.aspectj.weaver.AnnotationAJ; +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ReferenceTypeDelegate; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.World; +import org.aspectj.weaver.World.TypeMap; + +/** + * Incremental compilation tests. MultiProjectIncrementalTests was getting unwieldy - started this new test class for 1.6.10. + * + * @author Andy Clement + * @since 1.6.10 + */ +public class IncrementalCompilationTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + TypeMap.useExpendableMap = true; + } + + public void testAdditionalDependencies328649_1() throws Exception { + String p = "pr328649_1"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + assertEquals(0, getErrorMessages(p).size()); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + checkCompileWeaveCount(p, 1, 1); + assertEquals(0, getErrorMessages(p).size()); + alter(p, "inc2"); + AjCompiler compiler = getCompilerForProjectWithName(p); + String s = getFile(p, "src/B.java"); + assertNotNull(s); + // add in a dependency where there really isn't one... + boolean b = compiler.addDependencies(new File(s), new String[] { "A" }); + assertTrue(b); + build(p); + checkWasntFullBuild(); + // now A rebuilds, then A and B rebuild due to that extra dependency + checkCompileWeaveCount(p, 3, 3); + assertEquals(0, getErrorMessages(p).size()); + alter(p, "inc2"); + compiler = getCompilerForProjectWithName(p); + s = getFile(p, "src/B.java"); + assertNotNull(s); + } + + /** + * Build a pair of files, then change the throws clause in the first one (add a throws clause where there wasnt one). The second + * file should now have a 'unhandled exception' error on it. + */ + public void testModifiedThrowsClauseShouldTriggerError_318884() throws Exception { + String p = "pr318884_1"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains("B.java:4:0::0 Unhandled exception type IOException", getErrorMessages(p).get(0)); + } + + public void testITIT_336158() throws Exception { + String p = "pr336158"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + checkCompileWeaveCount(p, 3, 4); + } + + public void testITIT_336147() throws Exception { + String p = "pr336147"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + checkCompileWeaveCount(p, 1, 3); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertNoErrors(p); + checkCompileWeaveCount(p, 1, 1); + } + + public void testITIT_336147_2() throws Exception { + String p = "pr336147_2"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + checkCompileWeaveCount(p, 2, 3); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertNoErrors(p); + checkCompileWeaveCount(p, 1, 1); + } + + public void testITIT_336147_3() throws Exception { + AjdeInteractionTestbed.VERBOSE = true; + String p = "pr336147_3"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + checkCompileWeaveCount(p, 3, 4); + } + + public void testDeclareFieldMinus() throws Exception { + String p = "annoRemoval"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + AspectJElementHierarchy model = (AspectJElementHierarchy) getModelFor(p).getHierarchy(); + IProgramElement ipe = null; + ipe = model.findElementForHandleOrCreate("=annoRemoval;", ipe.getCorrespondingTypeSignature()); + assertEquals("java.util.List", ipe.getCorrespondingType(true)); + + // method(java.lang.String) [method] 4 hid:=pr333123 paramSigs = ipe.getParameterSignatures(); + assertEquals("La/b/Code;", new String(paramSigs.get(0))); + assertEquals("Ljava/lang/String;", new String(paramSigs.get(1))); + assertEquals("J", new String(paramSigs.get(2))); + + assertEquals("a.b.Code", ipe.getCorrespondingType(true)); + assertEquals("La/b/Code;", ipe.getCorrespondingTypeSignature()); + + ipe = model.findElementForHandle("=pr333123;"); + assertEquals("(Ljava/util/List;)Ljava/util/List;", ipe.getBytecodeSignature()); + paramSigs = ipe.getParameterSignatures(); + assertEquals("Ljava/util/List;", new String(paramSigs.get(0))); + assertEquals("java.util.List", ipe.getCorrespondingType(true)); + assertEquals("Ljava/util/List;", ipe.getCorrespondingTypeSignature()); + + } + + // changing method return type parameterization + public void testModifiedMethodReturnTypeGenericTypeParameterShouldTriggerError_318884_3() throws Exception { + String p = "pr318884_3"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains("The return type is incompatible with B.foo()", getErrorMessages(p).get(0)); + } + + // changing method parameter type parameterization + public void testModifiedMethodParameterGenericTypeParameterShouldTriggerError_318884_4() throws Exception { + String p = "pr318884_4"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains( + "Name clash: The method foo(List) of type A has the same erasure as foo(List) of type B but does not override it", + getErrorMessages(p).get(0)); + } + + // changing constructor parameter type parameterization + public void testModifiedConstructorParameterGenericTypeParameterShouldTriggerError_318884_5() throws Exception { + String p = "pr318884_5"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains("The constructor B(List) is undefined", getErrorMessages(p).get(0)); + } + + // changing field type parameterization + public void testModifiedFieldTypeGenericTypeParameterShouldTriggerError_318884_6() throws Exception { + String p = "pr318884_6"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains("Type mismatch: cannot convert from element type Integer to String", getErrorMessages(p).get(0)); + } + + // removing static inner class + public void testInnerClassChanges_318884_7() throws Exception { + String p = "pr318884_7"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 3); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains("B.C cannot be resolved to a type", getErrorMessages(p).get(0)); + } + + // removing constructor from a static inner class + public void testInnerClassChanges_318884_9() throws Exception { + String p = "pr318884_9"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 3); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertContains("The constructor B.C(String) is undefined", getErrorMessages(p).get(0)); + } + + // removing class + public void testInnerClassChanges_318884_10() throws Exception { + String p = "pr318884_10"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 2, 2); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(2, getErrorMessages(p).size()); + assertContains("B cannot be resolved to a type", getErrorMessages(p).get(0)); + } + + // deleting unaffected model entries + public void testDeletion_278496() throws Exception { + String p = "PR278496_1"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:minimalModel=true"); + build(p); + checkWasFullBuild(); + // Here is the model without deletion. The node for 'Code.java' can safely be deleted as it contains + // no types that are the target of relationships. + // PR278496_1 [build configuration file] hid:=PR278496_1 + // a.b.c [package] hid:=PR278496_1 [advice] 4 hid:=PR278496_1 [advice] 4 hid:;", fields[2].getGenericReturnType().getSignature()); + assertEquals("Ljava/util/List;", fields[3].getSignature()); + assertEquals("Pjava/util/List;", fields[3].getGenericReturnType().getSignature()); + } + + /** + * This test is verifying the treatment of array types (here, String[]). These should be expendable but because the + * ArrayReferenceType wasnt overriding isExposedToWeaver() an array had an apparent null delegate - this caused the isExpendable + * check to fail when choosing whether to put something in the permanent or expendable map. Leaving something in the permanent + * map that would never be cleared out. + */ + public void testWorldDemotion_278496_10() throws Exception { + String p = "PR278496_10"; + TypeMap.useExpendableMap = false; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:typeDemotion=true,typeDemotionDebug=true"); + build(p); + checkWasFullBuild(); + AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + World w = ajBuildManager.getWorld(); + + assertNotInTypeMap(w, "Lcom/Foo;"); + assertNotInTypeMap(w, "[Ljava/lang/String;"); + assertInTypeMap(w, "Lcom/Asp;"); + assertInTypeMap(w, "[I"); + assertInTypeMap(w, "[[F"); + } + + public void testWorldDemotion_278496_11() throws Exception { + String asp = "PR278496_11_a"; + initialiseProject(asp); + build(asp); + + String p = "PR278496_11"; + TypeMap.useExpendableMap = false; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:typeDemotion=true,typeDemotionDebug=true"); + configureAspectPath(p, getProjectRelativePath(asp, "bin")); + build(p); + checkWasFullBuild(); + AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + World w = ajBuildManager.getWorld(); + + assertNotInTypeMap(w, "Lcom/Foo;"); + assertInTypeMap(w, "Lcom/Asp;"); + assertNotInTypeMap(w, "Lcom/Dibble;"); + } + + public void testWorldDemotion_278496_6() throws Exception { + String p = "PR278496_6"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:typeDemotion=true"); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + World w = ajBuildManager.getWorld(); + ReferenceTypeDelegate delegate = null; + delegate = w.resolveToReferenceType("com.Meths").getDelegate(); + // assertTrue(delegate instanceof CompactTypeStructureDelegate); + ResolvedMember[] methods = delegate.getDeclaredMethods(); + assertEquals("void com.Meths.()", methods[0].toString()); + assertEquals("void com.Meths.m()", methods[1].toString()); + assertEquals("java.util.List com.Meths.n(int, long, java.util.List)", methods[2].toString()); + + System.out.println(stringify(methods[0].getAnnotations())); + System.out.println(stringify(methods[1].getAnnotations())); + System.out.println(stringify(methods[2].getAnnotations())); + assertEquals("[Anno[Lcom/Anno; rVis]]", stringify(methods[1].getAnnotations())); + // assertNotNull(fields[2].getAnnotationOfType(UnresolvedType.forSignature("Lcom/Anno;"))); + // assertNull(fields[2].getAnnotationOfType(UnresolvedType.forSignature("Lcom/Anno2;"))); + // assertTrue(fields[2].hasAnnotation(UnresolvedType.forSignature("Lcom/Anno;"))); + // assertFalse(fields[2].hasAnnotation(UnresolvedType.forSignature("Ljava/lang/String;"))); + // assertEquals(0,fields[1].getAnnotations().length); + // assertEquals("[com.Anno2 com.Anno]",stringify(fields[3].getAnnotationTypes())); + // assertEquals("[]",stringify(fields[1].getAnnotationTypes())); + // assertEquals("[Anno[Lcom/Anno2; rVis a=(int)42] Anno[Lcom/Anno; rVis]]",stringify(fields[3].getAnnotations())); + // assertEquals("[]",stringify(fields[1].getAnnotations())); + // + // assertEquals("I",fields[0].getSignature()); + // assertEquals("Ljava/lang/String;",fields[1].getSignature()); + // assertEquals("Ljava/util/List;",fields[2].getSignature()); + // assertEquals("Pjava/util/List;",fields[2].getGenericReturnType().getSignature()); + // assertEquals("Ljava/util/List;",fields[3].getSignature()); + // assertEquals("Pjava/util/List;",fields[3].getGenericReturnType().getSignature()); + } + + // public void testWorldDemotion_278496_7() throws Exception { + // boolean demotion = true; + // AjdeInteractionTestbed.VERBOSE=true; + // String p = "PR278496_7"; + // TypeMap.useExpendableMap=false; + // initialiseProject(p); + // if (demotion) { + // configureNonStandardCompileOptions(p, "-Xset:typeDemotion=true,typeDemotionDebug=true"); + // } + // build(p); + // checkWasFullBuild(); + // assertNoErrors(p); + // alter(p,"inc1"); + // build(p); + // checkWasntFullBuild(); + // assertNoErrors(p); + // + // AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + // AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + // World w = ajBuildManager.getWorld(); + // } + + public void testWorldDemotion_278496_4() throws Exception { + String p = "PR278496_4"; + // Setting this ensures types are forced out when demoted - we are not at the mercy of weak reference GC + TypeMap.useExpendableMap = false; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:typeDemotion=true,typeDemotionDebug=true"); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + + AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + World w = ajBuildManager.getWorld(); + + // Confirm demoted: + assertNotInTypeMap(w, "Lcom/foo/Bar;"); + + ReferenceType rt = null; + ReferenceTypeDelegate delegate = null; + rt = w.resolveToReferenceType("com.foo.Bar"); + delegate = rt.getDelegate(); + // Should have been demoted to a CTSD + assertEquals(0, delegate.getAnnotations().length); + assertEquals(0, delegate.getAnnotationTypes().length); + assertEquals(0, delegate.getDeclaredInterfaces().length); + assertEquals("java.lang.Object", delegate.getSuperclass().toString()); + assertNull(delegate.getRetentionPolicy()); + assertFalse(delegate.isInterface()); + assertTrue(delegate.isClass()); + assertFalse(delegate.isEnum()); + // assertFalse(rtd.isWeavable()); + // try { + // assertTrue(delegate.hasBeenWoven()); + // fail("expected exception"); + // } catch (IllegalStateException ise) { + // // success + // } + + // Confirm demoted: + assertNull(w.getTypeMap().get("Lcom/foo/Color;")); + rt = w.resolveToReferenceType("com.foo.Color"); + delegate = rt.getDelegate(); + assertFalse(delegate.isInterface()); + assertTrue(delegate.isEnum()); + + // Aspects are never demoted and so never have a per clause, declares or type mungers + assertNull(delegate.getPerClause()); + assertEquals(0, delegate.getDeclares().size()); + assertEquals(0, delegate.getTypeMungers().size()); + assertFalse(delegate.isAspect()); + assertEquals(0, delegate.getPrivilegedAccesses().size()); + assertEquals(0, delegate.getDeclaredPointcuts().length); + assertFalse(delegate.isAnnotationStyleAspect()); + assertFalse(delegate.isAnnotationWithRuntimeRetention()); + + // Confirm demoted: + assertNull(w.getTypeMap().get("Lcom/foo/Extender;")); + rt = w.resolveToReferenceType("com.foo.Extender"); + delegate = rt.getDelegate(); + assertEquals("[com.foo.Marker]", stringify(delegate.getDeclaredInterfaces())); + assertEquals("com.foo.Super", delegate.getSuperclass().toString()); + + // this has one fixed annotation that is a well known one + // Confirm demoted: + ResolvedType annoType = w.getTypeMap().get("Lcom/foo/Anno;"); + assertNull(annoType); + rt = w.resolveToReferenceType("com.foo.Anno"); + delegate = rt.getDelegate(); + assertEquals("[Anno[Ljava/lang/annotation/Retention; rVis value=E(Ljava/lang/annotation/RetentionPolicy; RUNTIME)]]", + stringify(delegate.getAnnotations())); + assertEquals("[java.lang.annotation.Retention]", stringify(delegate.getAnnotationTypes())); + assertTrue(delegate.isAnnotationWithRuntimeRetention()); + assertEquals("RUNTIME", delegate.getRetentionPolicy()); + + // this has a bunch of well known ones + rt = w.resolveToReferenceType("com.foo.Anno2"); + delegate = rt.getDelegate(); + assertEquals( + "[Anno[Ljava/lang/Deprecated; rVis] Anno[Ljava/lang/annotation/Inherited; rVis] Anno[Ljava/lang/annotation/Retention; rVis value=E(Ljava/lang/annotation/RetentionPolicy; CLASS)]]", + stringify(delegate.getAnnotations())); + assertEquals("[java.lang.Deprecated java.lang.annotation.Inherited java.lang.annotation.Retention]", + stringify(delegate.getAnnotationTypes())); + assertFalse(delegate.isAnnotationWithRuntimeRetention()); + assertEquals("CLASS", delegate.getRetentionPolicy()); + assertTrue(delegate.hasAnnotation(UnresolvedType.forSignature("Ljava/lang/annotation/Inherited;"))); + assertTrue(delegate.hasAnnotation(UnresolvedType.forSignature("Ljava/lang/annotation/Retention;"))); + assertFalse(delegate.hasAnnotation(UnresolvedType.forSignature("Lcom/foo/Anno;"))); + + // this has a well known one and a non-well known one + rt = w.resolveToReferenceType("com.foo.Anno3"); + delegate = rt.getDelegate(); + System.out.println(stringify(delegate.getAnnotations())); + assertEquals( + "[Anno[Lcom/foo/Anno; rVis] Anno[Ljava/lang/annotation/Retention; rVis value=E(Ljava/lang/annotation/RetentionPolicy; SOURCE)]]", + stringify(delegate.getAnnotations())); + assertEquals("[com.foo.Anno java.lang.annotation.Retention]", stringify(delegate.getAnnotationTypes())); + assertFalse(delegate.isAnnotationWithRuntimeRetention()); + assertEquals("SOURCE", delegate.getRetentionPolicy()); + + // this has two non-well known ones + rt = w.resolveToReferenceType("com.foo.Anno4"); + delegate = rt.getDelegate(); + assertEquals("[Anno[Lcom/foo/Anno2; rInvis] Anno[Lcom/foo/Anno; rVis]]", stringify(delegate.getAnnotations())); + assertEquals("[com.foo.Anno2 com.foo.Anno]", stringify(delegate.getAnnotationTypes())); + assertFalse(delegate.isAnnotationWithRuntimeRetention()); + assertNull(delegate.getRetentionPolicy()); + assertTrue(delegate.hasAnnotation(UnresolvedType.forSignature("Lcom/foo/Anno;"))); + + rt = w.resolveToReferenceType("com.foo.Colored"); + delegate = rt.getDelegate(); + AnnotationAJ annotation = delegate.getAnnotations()[0]; // should be ColorAnno(c=Color.G) + assertTrue(annotation.hasNamedValue("c")); + assertFalse(annotation.hasNamedValue("value")); + assertTrue(annotation.hasNameValuePair("c", "Lcom/foo/Color;G")); + assertFalse(annotation.hasNameValuePair("c", "Lcom/foo/Color;B")); + assertFalse(annotation.hasNameValuePair("d", "xxx")); + assertNull(annotation.getStringFormOfValue("d")); + assertEquals("Lcom/foo/Color;G", annotation.getStringFormOfValue("c")); + assertEquals(0, annotation.getTargets().size()); + assertTrue(delegate.isCacheable()); + + assertFalse(delegate.isExposedToWeaver()); + + // assertEquals(w.resolve(UnresolvedType.forSignature("Lcom/foo/Colored;")),delegate.getResolvedTypeX()); + + assertEquals("com/foo/Colored.java", delegate.getSourcefilename()); + + // Anno5 has an @Target annotation + rt = w.resolveToReferenceType("com.foo.Anno5"); + delegate = rt.getDelegate(); + annotation = delegate.getAnnotations()[0]; // should be @Target(TYPE,FIELD) + Set ss = annotation.getTargets(); + assertEquals(2, ss.size()); + assertTrue(ss.contains("FIELD")); + assertTrue(ss.contains("TYPE")); + // AnnotationTargetKind[] kinds = delegate.getAnnotationTargetKinds(); + // assertEquals("FIELD",kinds[0].getName()); + // assertEquals("TYPE",kinds[1].getName()); + + rt = w.resolveToReferenceType("com.foo.Inners$Inner"); + delegate = rt.getDelegate(); + assertTrue(delegate.isNested()); + assertEquals("com.foo.Inners", delegate.getOuterClass().getName()); + + rt = w.resolveToReferenceType("com.foo.Inners$1"); + delegate = rt.getDelegate(); + assertTrue(delegate.isAnonymous()); + assertTrue(delegate.isNested()); + + // delegate = w.resolveToReferenceType("com.foo.Anno6").getDelegate(); + // kinds = delegate.getAnnotationTargetKinds(); + // assertEquals(6,kinds.length); + // String s = stringify(kinds); + // assertTrue(s.contains("ANNOTATION_TYPE")); + // assertTrue(s.contains("LOCAL_VARIABLE")); + // assertTrue(s.contains("METHOD")); + // assertTrue(s.contains("PARAMETER")); + // assertTrue(s.contains("PACKAGE")); + // assertTrue(s.contains("CONSTRUCTOR")); + + delegate = w.resolveToReferenceType("com.foo.Marker").getDelegate(); + assertTrue(delegate.isInterface()); + + } + + private void assertNotInTypeMap(World w, String string) { + assertNull(w.getTypeMap().get(string)); + } + + private void assertInTypeMap(World w, String string) { + assertNotNull(w.getTypeMap().get(string)); + } + + private String stringify(Object[] arr) { + StringBuilder s = new StringBuilder(); + for (int i = 0; i < arr.length; i++) { + s.append(arr[i]); + s.append(" "); + } + return "[" + s.toString().trim() + "]"; + } + + public void testDeletionInnerAspects_278496_4() throws Exception { + String p = "PR278496_4"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:minimalModel=true"); + build(p); + checkWasFullBuild(); + // printModel(p); + // Here is the model without deletion. + // PR278496_4 [build configuration file] hid:=PR278496_4 + // foo [package] hid:=PR278496_4 [advice] 8 + // hid:=PR278496_4() {..} [class] 20 + // hid:=PR278496_8() {..} [class] 5 hid:=PR278496_8) [method] 15 + // hid:=PR278496_8; + // DeleteAction.java [java source file] 1 hid:=PR278496_8) [inter-type method] 13 + // hid:=PR278496_8; + // Demo.Demo(int) [inter-type constructor] 17 hid:=PR278496_8; + // Hid:11:(targets=8) =PR278496_8; (declared on) + // =PR278496_8 allOutputDirs; + + public MyOutputLocationManager(String projectName, int numberOfSrcDirs) { + projectDir = getWorkingDir() + File.separator + projectName; + this.numberOfSrcDirs = numberOfSrcDirs; + } + + public void reportFileWrite(String outputfile, int filetype) { + } + + public void reportFileRemove(String outputfile, int filetype) { + } + + public Map getInpathMap() { + return Collections.emptyMap(); + } + + public File getOutputLocationForClass(File compilationUnit) { + String path = compilationUnit.getAbsolutePath(); + int index = path.indexOf("src"); + String number = path.substring(index + 3, index + 4); + File ret = new File(projectDir + File.separator + "bin" + number); + if (!ret.exists()) { + ret.mkdirs(); + } + return ret; + } + + public File getOutputLocationForResource(File resource) { + return getOutputLocationForClass(resource); + } + + public List getAllOutputLocations() { + if (allOutputDirs == null) { + allOutputDirs = new ArrayList<>(); + for (int i = 0; i < numberOfSrcDirs + 1; i++) { + File f = null; + if (i == 0) { + f = new File(projectDir + File.separator + "bin"); + } else { + f = new File(projectDir + File.separator + "bin" + i); + } + allOutputDirs.add(f); + } + } + return allOutputDirs; + } + + public File getDefaultOutputLocation() { + return new File(projectDir + File.separator + "bin"); + } + + public String getSourceFolderForFile(File sourceFile) { + return null; + } + + public int discoverChangesSince(File dir, long buildtime) { + // TODO Auto-generated method stub + return 0; + } + + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java new file mode 100644 index 000000000..428c037d8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java @@ -0,0 +1,174 @@ +/******************************************************************** + * Copyright (c) 2008 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement initial implementation + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.IOException; + +import org.aspectj.ajde.core.ICompilerConfiguration; + +/** + * Testing the performance of incremental compilation as it would be in AJDT. + * + * @author AndyClement + */ +public class IncrementalPerformanceTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { + + /** + * Build a project of 64 source files and no aspects.
+ *

    + *
  • First build is a full build. + *
  • Second build is an incremental build with no changes at all. + *
  • Third build is an incremental build with just a source file touched (not changed). + *
+ * + *

+ * 162-dev, 28Aug08 times: Thinkpad T61p: 3203/3140/3234/3156 173/172/172/172 313/297/297/312 + */ + public void testBuildingProject64Files() { + String proj = "Proj64"; + + // A full build: + initialiseProject(proj); + build(proj); + checkWasFullBuild(); + long fullbuildtime = getTimeTakenForBuild(proj); + System.out.println("Full build time: " + fullbuildtime + "ms"); + + // An incremental build with no source file changes at all. What should happen? + // We need to determine that nothing has to be done as fast as possible, this is all about + // determining from the configuration that nothing has changed and returning as fast as possible. Any + // delays here are unnecessary burden that will hurt every other kind of compilation. + build(proj); + checkWasntFullBuild(); + checkCompileWeaveCount(proj, 0, 0); + long nochangebuild = getTimeTakenForBuild(proj); + System.out.println("Incr build time for no changes at all: " + nochangebuild + "ms"); + + // An incremental build with no source file changes at all *and* we tell the compiler there are + // no source changes (so it doesn't need to check timestamps). super fast + addProjectSourceFileChanged(proj, null); + build(proj); + checkWasntFullBuild(); + checkCompileWeaveCount(proj, 0, 0); + long nochangebuildandDoTellCompiler = getTimeTakenForBuild(proj); + System.out.println("Incr build time for no changes at all and telling the compiler that: " + nochangebuildandDoTellCompiler + + "ms"); + + // Now we touch a file (C0.java) and call build. What should happen? + // We need to determine what has changed, we'll do that by walking over the set of input files and + // checking their last modified stamps. So although we won't rebuild a buildConfig object, we will + // call lastModifiedTime() a lot to determine which file has changed. + alter(proj, "inc1"); + build(proj); + checkWasntFullBuild(); + checkCompileWeaveCount(proj, 1, 1); + long whitespacechangeDontTellCompiler = getTimeTakenForBuild(proj); + System.out.println("Incr build time for whitespace change: " + whitespacechangeDontTellCompiler + "ms"); + + // Similar to previous test, touch that file, but this time tell the compiler which file has changed. What should happen? + // As we are telling the compiler what has changed, it will not jump through hoops checking the last mod time of + // every source file in the project configuration. + alter(proj, "inc1"); + addProjectSourceFileChanged(proj, getProjectRelativePath(proj, "src/out/C0.java")); + build(proj); + checkWasntFullBuild(); + checkCompileWeaveCount(proj, 1, 1); + long whitespacechangeDoTellCompiler = getTimeTakenForBuild(proj); + System.out.println("Incr build time for whitespace change (where we tell the compiler what changed): " + + whitespacechangeDoTellCompiler + "ms"); + + // Lets assert what really ought to be true + assertTrue(nochangebuild < fullbuildtime); + assertTrue(whitespacechangeDontTellCompiler < fullbuildtime); + assertTrue(whitespacechangeDoTellCompiler < fullbuildtime); + + assertTrue(nochangebuild < whitespacechangeDontTellCompiler); + // assertTrue(nochangebuild < whitespacechangeDoTellCompiler); + + // assertTrue(whitespacechangeDoTellCompiler < whitespacechangeDontTellCompiler); + } + + /** + * Project dependencies are captured by using classpath. The dependee project has the bin folder for the project upon which it + * depends on its classpath. This can make it expensive when determining whether to build the dependee project as we may need to + * analyse all the classpath entries, we don't know which are project related. However, a new API in ICompilerConfiguration + * called getClasspathElementsWithModifiedContents() can be returned by an implementor to tell us which parts of the classpath + * to check. + */ + public void testBuildingTwoProjects() { + AjdeInteractionTestbed.VERBOSE = true; + + String projA = "Proj64"; + String projB = "Dependee"; + + // A full build: + initialiseProject(projA); + initialiseProject(projB); + configureNewProjectDependency(projB, projA); + build(projA); + checkWasFullBuild(); + build(projB); + checkWasFullBuild(); + + alter(projA, "C43changeOne"); // C43 made package private + build(projA); + setNextChangeResponse(projB, ICompilerConfiguration.EVERYTHING); + build(projB); + long timeTakenWhenFullyAnalysingClasspath = getTimeTakenForBuild(projB); + checkWasntFullBuild(); + + alter(projA, "C43changeOne"); // C43 made package private + build(projA); + addClasspathEntryChanged(projB, getProjectRelativePath(projA, "bin").getPath()); + // waitForReturn(); + build(projB); + long timeTakenWhenFullyToldSpecifically = getTimeTakenForBuild(projB); + // waitFor10(); + checkWasntFullBuild(); + + System.out.println("Without: " + timeTakenWhenFullyAnalysingClasspath + "ms With: " + timeTakenWhenFullyToldSpecifically + + "ms"); + + } + + // --- helper code --- + + @SuppressWarnings("unused") + private void waitFor10() { + try { + Thread.sleep(10000); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unused") + private void waitForReturn() { + try { + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + testdataSrcDir = "../tests/incrementalPerformance"; + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + testdataSrcDir = "../tests/multiIncremental"; + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java new file mode 100644 index 000000000..c35b88610 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -0,0 +1,382 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.aspectj.ajde.core.IOutputLocationManager; +import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; +import org.aspectj.ajdt.internal.core.builder.AjState; +import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager; +import org.aspectj.util.FileUtil; +import org.aspectj.weaver.bcel.UnwovenClassFile; + +/** + * Similar to OutputLocationManagerTests, however, tests the different scenarios when no outputDir is set but instead there is an + * OutputLocationManager which returns the same output location for all files and resources. + * + * There are eight places where AjBuildConfig.getOutputDir() is called that are tested here: + * + * AjBuildManager.getOutputClassFileName(..) - testCorrectInfoWhenNoOutputPath AjBuildManager.initBcelWorld(..) - + * testPathResolutionWithInpathDirAndNoOutputPath testPathResolutionWithInpathJarAndNoOutputPath AjBuildManager.writeManifest(..) - + * testCopyManifest AjBuildManager.writeOutxml(..) - testOutxml - testOutXmlForAspectsWithDifferentOutputDirs + * AjState.createUnwovenClassFile(..) - testPathResolutionAfterChangeInClassOnInpath AjState.deleteResources(..) - + * testAjStateDeleteResources AjState.maybeDeleteResources(..) - testAjStateDeleteResourcesInInputDir + * AjState.removeAllResultsOfLastBuild(..) - testAllResourcesAreDeletedCorrectlyOnPathChange + * IncrementalStateManager.findStateManagingOutputLocation(..) - testFindStateManagingOutputLocation + * + * The other three places are not tested here because they were implemented when OutputLocationManager was introduced. + * + */ +public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { + + private String inpathTestingDir; + private String expectedOutputDir; + + @Override + protected void setUp() throws Exception { + super.setUp(); + initialiseProject("inpathTesting"); + inpathTestingDir = getWorkingDir() + File.separator + "inpathTesting"; + expectedOutputDir = inpathTestingDir + File.separator + "bin"; + configureOutputLocationManager("inpathTesting", new SingleDirOutputLocMgr(inpathTestingDir)); + } + + /** + * Tests that the UnwovenClassFiles have the correct path when there is no outputDir but there is an OutputLocationManager. Is a + * simple project that has no inpath setting + */ + public void testCorrectInfoWhenNoOutputPath() { + build("inpathTesting"); + AjState state = getState(); + + Map classNameToFileMap = state.getClassNameToFileMap(); + assertFalse("expected there to be classes ", classNameToFileMap.isEmpty()); + Set> entrySet = classNameToFileMap.entrySet(); + for (Iterator> iterator = entrySet.iterator(); iterator.hasNext();) { + Map.Entry entry = iterator.next(); + String className = entry.getKey(); + String fullClassName = expectedOutputDir + File.separator + className.replace('.', File.separatorChar) + ".class"; + File file = entry.getValue(); + assertEquals("expected file to have path \n" + fullClassName + ", but" + " found path \n" + file.getAbsolutePath(), + fullClassName, file.getAbsolutePath()); + } + } + + /** + * Tests that can retieve the state that manages a given output location when there is no outputDir set + */ + public void testFindStateManagingOutputLocation() { + build("inpathTesting"); + AjState state = IncrementalStateManager.findStateManagingOutputLocation(new File(expectedOutputDir)); + assertNotNull("Expected to find a state that managed output location " + expectedOutputDir + ", but did not", state); + + } + + /** + * Tests that the UnwovenClassFiles corresponding to classes on the inpath have the correct class name when there is no output + * directory (ultimately tests AjBuildManager.initBcelWorld() when there is a jar on the inpath). Only does one build. + */ + public void testPathResolutionWithInpathDirAndNoOutputPath() { + String inpathDir = inpathTestingDir + File.separator + "injarBin" + File.separator + "pkg"; + addInpathEntry(inpathDir); + build("inpathTesting"); + + // expect to compile the aspect in 'inpathTesting' project and weave + // both the aspect and the class on the inpath. + checkCompileWeaveCount("inpathTesting", 1, 2); + + // get hold of the state for this project - expect to find one + AjState state = getState(); + + // the classes onthe inpath are recorded against the AjBuildManager + // (they are deleted from the ajstate whilst cleaning up after a build) + Map> binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); + assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); + + List unwovenClassFiles = binarySources.get(inpathDir + File.separator + "InpathClass.class"); + List fileNames = new ArrayList<>(); + // the unwovenClassFiles should have filenames that point to the output dir + // (which in this case is the sandbox dir) and not where they came from. + for (UnwovenClassFile ucf: unwovenClassFiles) { + if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + fileNames.add(ucf.getFilename()); + } + } + assertTrue("expected to find UnwovenClassFile from directory\n" + expectedOutputDir + ", \n but found files " + fileNames, + fileNames.isEmpty()); + } + + /** + * Tests that the UnwovenClassFiles corresponding to classes on the inpath have the correct class name when there is no output + * directory (ultimately tests AjState.createUnwovenClassFile(BinarySourceFile) and ensures the unwovenClassFile has the correct + * name. Makes a change to a class file on the inpath to ensure we enter this method (there is a check that says are we the + * first build)) + */ + public void testPathResolutionAfterChangeInClassOnInpath() throws Exception { + String inpathDir = inpathTestingDir + File.separator + "injarBin" + File.separator + "pkg"; + addInpathEntry(inpathDir); + build("inpathTesting"); + + // build again so that we enter + // AjState.createUnwovenClassFile(BinarySourceFile) + File from = new File(testdataSrcDir + File.separatorChar + "inpathTesting" + File.separatorChar + "newInpathClass" + + File.separatorChar + "InpathClass.class"); + File destination = new File(inpathDir + File.separatorChar + "InpathClass.class"); + FileUtil.copyFile(from, destination); + + // get hold of the state for this project - expect to find one + AjState state = getState(); + AjBuildConfig buildConfig = state.getBuildConfig(); + state.prepareForNextBuild(buildConfig); + + Map> binarySources = state.getBinaryFilesToCompile(true); + assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); + + List unwovenClassFiles = binarySources.get(inpathDir + File.separator + "InpathClass.class"); + List fileNames = new ArrayList<>(); + // the unwovenClassFiles should have filenames that point to the output dir + // (which in this case is the sandbox dir) and not where they came from. + for (UnwovenClassFile ucf: unwovenClassFiles) { + if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + fileNames.add(ucf.getFilename()); + } + } + assertTrue("expected to find UnwovenClassFile from directory\n" + expectedOutputDir + ", \n but found files " + fileNames, + fileNames.isEmpty()); + } + + /** + * Tests that the UnwovenClassFiles corresponding to jars on the inpath have the correct class name when there is no output path + * (ultimately tests AjBuildManager.initBcelWorld() when there is a jar on the inpath). Only does one build. + */ + public void testPathResolutionWithInpathJarAndNoOutputPath() { + String inpathDir = inpathTestingDir + File.separator + "inpathJar.jar"; + addInpathEntry(inpathDir); + build("inpathTesting"); + // expect to compile the aspect in 'inpathTesting' project and weave + // both the aspect and the class in the jar on the inpath. + checkCompileWeaveCount("inpathTesting", 1, 2); + + AjState state = getState(); + + // tests AjState.createUnwovenClassFile(BinarySourceFile) + Map> binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); + assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); + + List unwovenClassFiles = binarySources.get(inpathDir); + List fileNames = new ArrayList<>(); + + for (UnwovenClassFile ucf: unwovenClassFiles) { + if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + fileNames.add(ucf.getFilename()); + } + } + assertTrue("expected to find UnwovenClassFile from directory\n" + expectedOutputDir + ", \n but found files " + fileNames, + fileNames.isEmpty()); + + } + + /** + * A manifest file is in the jar on the inpath - check that it's copied to the correct place + */ + public void testCopyManifest() { + String inpathDir = inpathTestingDir + File.separator + "inpathJar.jar"; + addInpathEntry(inpathDir); + + build("inpathTesting"); + String resource = expectedOutputDir + File.separator + "META-INF" + File.separator + "MANIFEST.MF"; + File f = new File(resource); + assertTrue("expected file " + resource + " to exist but it did not", f.exists()); + } + + /** + * "resources" are contained within inpath jars - check that a text file contained within a jar is copied and then deleted + * correctly. Essentially tests AjState.deleteResources(). + */ + // see 243376: for now don't do this, waste of cpu - ajdt better for handling resources - but is that true for inpath resources? + // public void testAjStateDeleteResources() { + // String inpathDir = inpathTestingDir + File.separator + "inpathJar.jar"; + // addInpathEntry(inpathDir); + // + // build("inpathTesting"); + // + // AjState state = getState(); + // + // String resource = expectedOutputDir + File.separator + "inpathResource.txt"; + // File f = new File(resource); + // assertTrue("expected file " + resource + " to exist but it did not",f.exists()); + // // this call should delete the resources + // state.getFilesToCompile(true); + // assertFalse("did not expect the file " + resource + " to exist but it does",f.exists()); + // } + /** + * Can set to copy resources that are in inpath dirs - check that a text file contained within such a dir is copied and then + * deleted correctly. Essentially tests AjState.maybeDeleteResources(). + */ + // see 243376: for now don't do this, waste of cpu - ajdt better for handling resources - but is that true for inpath resources? + // public void testAjStateDeleteResourcesInInputDir() { + // // temporary problem with this on linux, think it is a filesystem lastmodtime issue + // if (System.getProperty("os.name","").toLowerCase().equals("linux")) return; + // if (System.getProperty("os.name","").toLowerCase().indexOf("mac")!=-1) return; + // + // AjBuildManager.COPY_INPATH_DIR_RESOURCES = true; + // try { + // String inpathDir = inpathTestingDir + File.separator + "injarBin" + // + File.separator + "pkg"; + // addInpathEntry(inpathDir); + // build("inpathTesting"); + // AjState state = getState(); + // String resource = "inDirResource.txt"; + // assertTrue("expected state to have resource " + resource + "but it did not", + // state.hasResource(resource)); + // // this call should delete the resources - tests AjState.deleteResources() + // state.getFilesToCompile(true); + // assertFalse("did not expect state to have resource " + resource + + // " but found that it did", state.hasResource(resource)); + // } finally { + // AjBuildManager.COPY_INPATH_DIR_RESOURCES = false; + // } + // + // } + /** + * Changing inpath entry from a jar to a directory between builds means that AjState should realise somethings changed. This + * causes all resources (Manifest and txt files) to be deleted. Also should be a full build. Essentially tests + * AjState.removeAllResultsFromLastBuild(). + */ + public void testAllResourcesAreDeletedCorrectlyOnPathChange() { + String inpathJar = inpathTestingDir + File.separator + "inpathJar.jar"; + + addInpathEntry(inpathJar); + build("inpathTesting"); + + String resource = expectedOutputDir + File.separator + "inpathResource.txt"; + File f = new File(resource); + assertTrue("expected file " + resource + " to exist but it did not", f.exists()); + + // this should force a change and the file is deleted + // tests AjState.removeAllResultsFromLastBuild() + addInpathEntry(null); + build("inpathTesting"); + assertFalse("did not expect the file " + resource + " to exist but it does", f.exists()); + + checkWasFullBuild(); + } + + public void testOutxml() { + configureNonStandardCompileOptions("inpathTesting", "-outxml"); + build("inpathTesting"); + String resource = expectedOutputDir + File.separator + "META-INF" + File.separator + "aop-ajc.xml"; + File f = new File(resource); + assertTrue("expected file " + resource + " to exist but it did not", f.exists()); + } + + public void testAspectsRecordedOnlyOnceInState() { + configureNonStandardCompileOptions("inpathTesting", "-outxml"); + build("inpathTesting"); + AjState state = getState(); + Map m = state.getAspectNamesToFileNameMap(); + assertEquals("Expected only one aspect recored in the state but found " + m.size(), 1, m.size()); + build("inpathTesting"); + m = state.getAspectNamesToFileNameMap(); + assertEquals("Expected only one aspect recored in the state but found " + m.size(), 1, m.size()); + } + + private AjState getState() { + // get hold of the state for this project - expect to find one + AjState state = IncrementalStateManager.retrieveStateFor(inpathTestingDir); + assertNotNull("expected to find AjState for build config " + inpathTestingDir + " but didn't", state); + return state; + } + + private void addInpathEntry(String entry) { + if (entry == null) { + configureInPath("inpathTesting", (Set)null); + return; + } + File f = new File(entry); + Set s = new HashSet<>(); + s.add(f); + configureInPath("inpathTesting", s); + } + + /** + * Sends all output to the same directory + */ + private static class SingleDirOutputLocMgr implements IOutputLocationManager { + + private File classOutputLoc; + private File resourceOutputLoc; + private String testProjectOutputPath; + private List allOutputLocations; + private File outputLoc; + + public SingleDirOutputLocMgr(String testProjectPath) { + this.testProjectOutputPath = testProjectPath + File.separator + "bin"; + outputLoc = new File(testProjectOutputPath); + + allOutputLocations = new ArrayList<>(); + allOutputLocations.add(outputLoc); + } + + @Override + public File getOutputLocationForClass(File compilationUnit) { + return outputLoc; + } + + @Override + public Map getInpathMap() { + return Collections.emptyMap(); + } + + + @Override + public File getOutputLocationForResource(File resource) { + return outputLoc; + } + + @Override + public List getAllOutputLocations() { + return allOutputLocations; + } + + @Override + public File getDefaultOutputLocation() { + return outputLoc; + } + + @Override + public void reportFileWrite(String outputfile, int filetype) { + } + + @Override + public void reportFileRemove(String outputfile, int filetype) { + } + + @Override + public String getSourceFolderForFile(File sourceFile) { + return null; // no impl + } + + @Override + public int discoverChangesSince(File dir, long buildtime) { + return 0; // no impl + } + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestBuildProgressMonitor.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestBuildProgressMonitor.java new file mode 100644 index 000000000..6218ce3e4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestBuildProgressMonitor.java @@ -0,0 +1,91 @@ +/******************************************************************** + * Copyright (c) 2007 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.util.ArrayList; +import java.util.List; + +import org.aspectj.ajde.core.IBuildProgressMonitor; + +/** + * IBuildProgressMonitor that records how many files were compiled and woven as well as whether or not the build was a full build. + * Will print progress information to the screen if VERBOSE is true. + */ +public class MultiProjTestBuildProgressMonitor implements IBuildProgressMonitor { + + public boolean VERBOSE = false; + + private List compiledFiles = new ArrayList(); + private List wovenClasses = new ArrayList(); + + private long starttime = 0; + private long totaltimetaken = 0; + private boolean wasFullBuild = true; + + public void finish(boolean wasFullBuild) { + log("IBuildProgressMonitor.finish(" + wasFullBuild + ")"); + this.wasFullBuild = wasFullBuild; + totaltimetaken = (System.currentTimeMillis() - starttime); + } + + public boolean isCancelRequested() { + log("IBuildProgressMonitor.isCancelRequested()"); + return false; + } + + public void setProgress(double percentDone) { + log("IBuildProgressMonitor.setProgress(" + percentDone + ")"); + } + + public void setProgressText(String text) { + log("BuildProgressMonitor.setProgressText(" + text + ")"); + if (text.startsWith("compiled: ")) { + compiledFiles.add(text.substring(10)); + } else if (text.startsWith("woven class ")) { + wovenClasses.add(text.substring(12)); + } else if (text.startsWith("woven aspect ")) { + wovenClasses.add(text.substring(13)); + } + } + + public void begin() { + starttime = System.currentTimeMillis(); + log("IBuildProgressMonitor.start()"); + } + + public List getCompiledFiles() { + return compiledFiles; + } + + public List getWovenClasses() { + return wovenClasses; + } + + public void log(String s) { + if (VERBOSE) { + System.out.println(s); + } + } + + public long getTimeTaken() { + return totaltimetaken; + } + + public boolean wasFullBuild() { + return wasFullBuild; + } + + public void reset() { + wasFullBuild = true; + compiledFiles.clear(); + wovenClasses.clear(); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java new file mode 100644 index 000000000..cd80218b2 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java @@ -0,0 +1,275 @@ +/******************************************************************** + * Copyright (c) 2007 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.aspectj.ajde.core.ICompilerConfiguration; +import org.aspectj.ajde.core.IOutputLocationManager; +import org.aspectj.util.LangUtil; + +/** + * ICompilerConfiguration which mirrors the way AJDT behaves. Always returns that its 1.5 compliant and enables the setting of all + * options except output jar. + */ +public class MultiProjTestCompilerConfiguration implements ICompilerConfiguration { + + private boolean verbose = false; + + private String classPath = ""; + private Set aspectPath = null; + private Map sourcePathResources = null; + private IOutputLocationManager outputLocationManager = null; + private List dependants; + private Map javaOptionsMap; + private Set inpath; + private String encoding = null; + private String outjar; + private String processor; + private String processorPath; + private String nonstandardoptions; + private List modifiedFiles; + private List modifiedDirs; + private List projectSourceFiles = new ArrayList<>(); + private List xmlConfigFiles = new ArrayList<>(); + private String projectPath; + + int changed; + + public MultiProjTestCompilerConfiguration(String projectPath) { + this.projectPath = projectPath; + } + + public Set getAspectPath() { + log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")"); + return aspectPath; + } + + public String getClasspath() { + log("ICompilerConfiguration.getClasspath()"); + // AJDT has all the output directories on it's classpath + StringBuffer sb = new StringBuffer(); + List allOutputPaths = getOutputLocationManager().getAllOutputLocations(); + for (File dir: allOutputPaths) { + sb.append(File.pathSeparator + dir.getAbsolutePath()); + } + String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator + + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../runtime/bin" + File.pathSeparator + + this.classPath + File.pathSeparator + System.getProperty("aspectjrt.path") + File.pathSeparator + + "../lib/junit/junit.jar" + "c:/batik/batik-1.6/lib/batik-util.jar;" + + "c:/batik/batik-1.6/lib/batik-awt-util.jar;" + "c:/batik/batik-1.6/lib/batik-dom.jar;" + + "c:/batik/batik-1.6/lib/batik-svggen.jar;" + File.pathSeparator + ".." + File.separator + "lib" + File.separator + + "test" + File.separator + "aspectjrt.jar"; + if (LangUtil.is19VMOrGreater()) { + cp = LangUtil.getJrtFsFilePath() + File.pathSeparator + cp; + } + + // look at dependant projects + if (dependants != null) { + for (String dependant: dependants) { + cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp; + } + } + // System.err.println("For project "+projectPath+" getClasspath() returning "+cp); + return cp; + } + + public Set getInpath() { + log("ICompilerConfiguration.getInPath()"); + return inpath; + } + + public Map getJavaOptionsMap() { + log("ICompilerConfiguration.getJavaOptionsMap()"); + if (javaOptionsMap != null && !javaOptionsMap.isEmpty()) + return javaOptionsMap; + + Hashtable ht = new Hashtable(); + ht.put("org.eclipse.jdt.core.compiler.compliance", "1.5"); + ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5"); + ht.put("org.eclipse.jdt.core.compiler.source", "1.5"); + return ht; + } + + public String getNonStandardOptions() { + log("ICompilerConfiguration.getNonStandardOptions( " + nonstandardoptions + ")"); + return nonstandardoptions; + } + + public String getOutJar() { + log("ICompilerConfiguration.getOutJar()"); + return null; + } + + public IOutputLocationManager getOutputLocationManager() { + log("ICompilerConfiguration.getOutputLocationManager()"); + if (outputLocationManager == null) { + outputLocationManager = new MultiProjTestOutputLocationManager(projectPath); + } + return outputLocationManager; + } + + public List getProjectSourceFiles() { + log("ICompilerConfiguration.getProjectSourceFiles()"); + return projectSourceFiles; + } + + public List getProjectXmlConfigFiles() { + return xmlConfigFiles; + } + + public List getProjectSourceFilesChanged() { + log("ICompilerConfiguration.getProjectSourceFilesChanged()"); + return modifiedFiles; + } + + public Map getSourcePathResources() { + log("ICompilerConfiguration.getSourcePathResources()"); + return sourcePathResources; + } + + public void log(String s) { + if (verbose) + System.out.println(s); + } + + public void addDependancy(String projectItDependsOn) { + if (dependants == null) { + dependants = new ArrayList(); + } + dependants.add(projectItDependsOn); + } + + // -------------------- setter methods useful for testing --------------- + public void setAspectPath(Set aspectPath) { + this.aspectPath = aspectPath; + this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED; + } + + public void setInpath(Set inpath) { + this.inpath = inpath; + this.changed |= ICompilerConfiguration.INPATH_CHANGED; + } + + public void setOutjar(String outjar) { + this.outjar = outjar; + this.changed |= ICompilerConfiguration.OUTJAR_CHANGED; + } + + public void setProcessor(String processor) { + this.processor = processor; + this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED; + } + + public void setProcessorPath(String processorPath) { + this.processorPath = processorPath; + this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED; + } + + public void setJavaOptions(Map javaOptions) { + this.javaOptionsMap = javaOptions; + this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED; + } + + public void setNonStandardOptions(String options) { + this.nonstandardoptions = options; + this.changed |= ICompilerConfiguration.NONSTANDARDOPTIONS_CHANGED; + } + + public void setProjectSourceFiles(List projectSourceFiles) { + this.projectSourceFiles = projectSourceFiles; + this.changed |= ICompilerConfiguration.PROJECTSOURCEFILES_CHANGED; + } + + public void setProjectXmlConfigFiles(List xmlConfigFiles) { + this.xmlConfigFiles = xmlConfigFiles; + this.changed |= ICompilerConfiguration.XMLCONFIG_CHANGED; + } + + public void addProjectSourceFileChanged(File f) { + if (this.modifiedFiles == null) { + this.modifiedFiles = new ArrayList(); + } + if (f != null) { + modifiedFiles.add(f); + } + } + + public void addClasspathEntryChanged(String f) { + if (this.modifiedDirs == null) { + this.modifiedDirs = new ArrayList(); + } + if (f != null) { + modifiedDirs.add(f); + } + } + + public void setSourcePathResources(Map sourcePathResources) { + this.sourcePathResources = sourcePathResources; + this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED; + } + + public void setOutputLocationManager(IOutputLocationManager manager) { + this.outputLocationManager = manager; + } + + public void setClasspath(String path) { + this.classPath = path; + this.changed |= ICompilerConfiguration.CLASSPATH_CHANGED; + } + + public int getConfigurationChanges() { + return changed; + // return EVERYTHING; + } + + public void configurationRead() { + changed = NO_CHANGES; + modifiedFiles = null; + modifiedDirs = null; + } + + public List getClasspathElementsWithModifiedContents() { + return modifiedDirs; + } + + public void setProjectEncoding(String encoding) { + this.encoding = encoding; + } + + public String getProjectEncoding() { + return this.encoding; + } + + public String getProcessor() { + return this.processor; + } + + public String getProcessorPath() { + return this.processorPath; + } + + @Override + public String getModulepath() { + return null; + } + + @Override + public String getModuleSourcepath() { + return null; + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java new file mode 100644 index 000000000..fa66bede7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java @@ -0,0 +1,133 @@ +/******************************************************************** + * Copyright (c) 2007 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.util.ArrayList; +import java.util.List; + +import org.aspectj.ajde.core.IBuildMessageHandler; +import org.aspectj.bridge.AbortException; +import org.aspectj.bridge.IMessage; +import org.aspectj.bridge.IMessage.Kind; + +/** + * IMessageHandler which by default ignores INFO and WEAVEINFO messages. Records the warning, weaving, compiler errors and error + * messages and provides methods to get them. + */ +public class MultiProjTestMessageHandler implements IBuildMessageHandler { + + private final boolean VERBOSE = false; + + private boolean receivedNonIncrementalBuildMessage = false; + private boolean receivedBatchBuildMessage = false; + + private List errorMessages; + private List warningMessages; + private List weavingMessages; + private List compilerErrors; + private List ignoring; + + public MultiProjTestMessageHandler() { + ignoring = new ArrayList<>(); + errorMessages = new ArrayList(); + warningMessages = new ArrayList(); + weavingMessages = new ArrayList(); + compilerErrors = new ArrayList<>(); + ignore(IMessage.INFO); + ignore(IMessage.WEAVEINFO); + } + + public boolean handleMessage(IMessage message) throws AbortException { + IMessage.Kind kind = message.getKind(); + if (isIgnoring(kind)) { + return true; + } + if (kind.equals(IMessage.ABORT) || message.getThrown() != null) { + log("> AjCompiler error: " + message.getMessage() + ", " + message.getThrown() + ")"); //$NON-NLS-1$ + message.getThrown().printStackTrace(); + compilerErrors.add(message + ", (" + message.getThrown() + ")"); + if (VERBOSE && (message.getThrown() != null)) { + message.getThrown().printStackTrace(); + } + return true; + } + if (message.getKind() == IMessage.ERROR) { + errorMessages.add(message); + } + if (message.getKind() == IMessage.WARNING) { + warningMessages.add(message); + } + if (message.getKind() == IMessage.WEAVEINFO) { + weavingMessages.add(message); + } + log("IMessageHandler.handleMessage(" + message + ")"); + return true; + } + + public void dontIgnore(Kind kind) { + if (null != kind) { + ignoring.remove(kind); + } + } + + public boolean isIgnoring(Kind kind) { + return ((null != kind) && (ignoring.contains(kind))); + } + + public void ignore(Kind kind) { + if ((null != kind) && (!ignoring.contains(kind))) { + ignoring.add(kind); + } + } + + public boolean hasWarning() { + return !warningMessages.isEmpty(); + } + + public boolean hasErrorMessages() { + return !errorMessages.isEmpty(); + } + + public boolean hasCompilerErrorMessages() { + return !compilerErrors.isEmpty(); + } + + public List getErrorMessages() { + return errorMessages; + } + + public List getWarningMessages() { + return warningMessages; + } + + public List getWeavingMessages() { + return weavingMessages; + } + + public List getCompilerErrors() { + return compilerErrors; + } + + public void log(String s) { + if (VERBOSE) { + System.out.println(s); + } + } + + public void reset() { + receivedNonIncrementalBuildMessage = false; + receivedBatchBuildMessage = false; + errorMessages.clear(); + warningMessages.clear(); + weavingMessages.clear(); + compilerErrors.clear(); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java new file mode 100644 index 000000000..bb04e515b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java @@ -0,0 +1,120 @@ +/******************************************************************** + * Copyright (c) 2007 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.aspectj.ajde.core.IOutputLocationManager; + +/** + * An IOutputLocationManager which by default sends all output to the testProjectPath\bin directory. However, there are getter + * methods which enable sending resources and classes to different output dirs. Doesn't enable sending different classes to + * different output locations. + */ +public class MultiProjTestOutputLocationManager implements IOutputLocationManager { + + private final String testProjectOutputPath; + private File classOutputLoc; + private File resourceOutputLoc; + private final Map sourceFolders = new HashMap(); + private List allOutputLocations; + + public MultiProjTestOutputLocationManager(String testProjectPath) { + this.testProjectOutputPath = testProjectPath + File.separator + "bin"; + } + + public File getOutputLocationForClass(File compilationUnit) { + initLocations(); + return classOutputLoc; + } + + public Map getInpathMap() { + return Collections.EMPTY_MAP; + } + + + public File getOutputLocationForResource(File resource) { + initLocations(); + return resourceOutputLoc; + } + + public List getAllOutputLocations() { + if (allOutputLocations == null) { + allOutputLocations = new ArrayList<>(); + initLocations(); + allOutputLocations.add(classOutputLoc); + if (!classOutputLoc.equals(resourceOutputLoc)) { + allOutputLocations.add(resourceOutputLoc); + } + } + return allOutputLocations; + } + + public File getDefaultOutputLocation() { + return classOutputLoc; + } + + private void initLocations() { + if (classOutputLoc == null) { + classOutputLoc = new File(testProjectOutputPath); + } + if (resourceOutputLoc == null) { + resourceOutputLoc = new File(testProjectOutputPath); + } + } + + // -------------- setter methods useful for testing ------------- + public void setOutputLocForClass(File f) { + classOutputLoc = f; + } + + public void setSourceFolderFor(File sourceFile, String sourceFolder) { + try { + sourceFolders.put(sourceFile.getCanonicalPath(), sourceFolder); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + public void setOutputLocForResource(File f) { + resourceOutputLoc = f; + } + + public String getSourceFolderForFile(File sourceFile) { + try { + String f = (String) sourceFolders.get(sourceFile.getCanonicalPath()); + return f; + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + public void reportFileWrite(String outputfile, int filetype) { + // System.err.println(">>>" + outputfile); + } + + public void reportFileRemove(String outputfile, int filetype) { + } + + public int discoverChangesSince(File dir, long buildtime) { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java new file mode 100644 index 000000000..779143bd1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -0,0 +1,4038 @@ +/******************************************************************** + * Copyright (c) 2005 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement initial implementation + * Helen Hawkins Converted to new interface (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.aspectj.ajde.core.ICompilerConfiguration; +import org.aspectj.ajde.core.TestOutputLocationManager; +import org.aspectj.ajde.core.internal.AjdeCoreBuildManager; +import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; +import org.aspectj.ajdt.internal.core.builder.AjBuildManager; +import org.aspectj.ajdt.internal.core.builder.AjState; +import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IProgramElement.Kind; +import org.aspectj.asm.IRelationship; +import org.aspectj.asm.IRelationshipMap; +import org.aspectj.asm.internal.ProgramElement; +import org.aspectj.asm.internal.Relationship; +import org.aspectj.bridge.IMessage; +import org.aspectj.bridge.ISourceLocation; +import org.aspectj.bridge.Message; +import org.aspectj.tools.ajc.Ajc; +import org.aspectj.util.FileUtil; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.World; + +/** + * The superclass knows all about talking through Ajde to the compiler. The superclass isn't in charge of knowing how to simulate + * overlays for incremental builds, that is in here. As is the ability to generate valid build configs based on a directory + * structure. To support this we just need access to a sandbox directory - this sandbox is managed by the superclass (it only + * assumes all builds occur in // ) + * + * The idea is you can initialize multiple projects in the sandbox and they can all be built independently, hopefully exploiting + * incremental compilation. Between builds you can alter the contents of a project using the alter() method that overlays some set + * of new files onto the current set (adding new files/changing existing ones) - you can then drive a new build and check it behaves + * as expected. + */ +public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { + + public void testIncremental_344326() throws Exception { + AjdeInteractionTestbed.VERBOSE = true; + String p = "pr344326"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + checkCompileWeaveCount(p, 3, 4); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + checkCompileWeaveCount(p, 1, 1); + } + + public void testMissingRel_328121() throws Exception { + String p = "pr328121"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + // Check the annotations: + runMethod(p, "TestRequirements.TestRequirements", "foo"); + assertEquals(4, getRelationshipCount(p)); + } + + public void testEncoding_pr290741() throws Exception { + String p = "pr290741"; + initialiseProject(p); + setProjectEncoding(p, "UTF-8"); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + runMethod(p, "demo.ConverterTest", "run"); + } + + public void testRogueConstantReference() throws Exception { + String p = "pr404345"; + initialiseProject(p); + setProjectEncoding(p, "UTF-8"); + build(p); + checkWasFullBuild(); + // Should both indicate that Location cannot be resolved + assertEquals(2,getErrorMessages(p).size()); + } + + public void testIncrementalITDInners4() throws Exception { + String p = "prInner4"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + // touch the aspect making the ITD member type + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertNoErrors(p); + } + + public void testIncrementalITDInners3() throws Exception { + AjdeInteractionTestbed.VERBOSE = true; + String p = "prInner3"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + // touch the aspect making the ITD member type + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + // touch the aspect making the ITD that depends on the member type + alter(p, "inc2"); + build(p); + checkWasntFullBuild(); + // touch the type affected by the ITDs + alter(p, "inc3"); + build(p); + checkWasntFullBuild(); + } + + // mixing ITDs with inner type intertypes + public void testIncrementalITDInners2() throws Exception { + String p = "prInner2"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + // touch the aspect making the ITD member type + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + // touch the aspect making the ITD that depends on the member type + alter(p, "inc2"); + build(p); + checkWasntFullBuild(); + // touch the type affected by the ITDs + alter(p, "inc3"); + build(p); + checkWasntFullBuild(); + } + + public void testIncrementalITDInners() throws Exception { + String p = "prInner"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + } + + /* + * public void testIncrementalAspectWhitespace() throws Exception { AjdeInteractionTestbed.VERBOSE = true; String p = "xxx"; + * initialiseProject(p); configureNonStandardCompileOptions(p, "-showWeaveInfo"); configureShowWeaveInfoMessages(p, true); + * build(p); + * + * List weaveMessages = getWeavingMessages(p); if (weaveMessages.size() != 0) { for (Iterator iterator = + * weaveMessages.iterator(); iterator.hasNext();) { Object object = iterator.next(); System.out.println(object); } } + * checkWasFullBuild(); assertNoErrors(p); alter(p, "inc1"); build(p); checkWasntFullBuild(); assertNoErrors(p); } + */ + + public void testIncrementalGenericItds_pr280676() throws Exception { + String p = "pr280676"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + alter(p, "inc1"); // remove type variables from ITD field + build(p); + checkWasFullBuild(); + assertNoErrors(p); + alter(p, "inc2"); // remove type variables from ITD method + build(p); + checkWasFullBuild(); + assertNoErrors(p); + alter(p, "inc3"); // readded type variables on ITD method + build(p); + checkWasFullBuild(); + assertNoErrors(p); + } + + public void testIncrementalGenericItds_pr280676_2() throws Exception { + String p = "pr280676_2"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + alter(p, "inc1"); // remove type variables from target type + build(p); + List errors = getErrorMessages(p); + // Build errors: + // error at N:\temp\ajcSandbox\aspectj16_3\ajcTest60379.tmp\pr280676_2\src\p\A.java:8:0::0 a.ls cannot be resolved or is not + // a field + // error at N:\temp\ajcSandbox\aspectj16_3\ajcTest60379.tmp\pr280676_2\src\p\Foo.aj:8:0::0 Type parameters can not be + // specified in the ITD target type - the target type p.A is not generic. + // error at N:\temp\ajcSandbox\aspectj16_3\ajcTest60379.tmp\pr280676_2\src\p\Foo.aj:12:0::0 Type parameters can not be + // specified in the ITD target type - the target type p.A is not generic. + // error at N:\temp\ajcSandbox\aspectj16_3\ajcTest60379.tmp\pr280676_2\src\p\Foo.aj:8:0::0 Type parameters can not be + // specified in the ITD target type - the target type p.A is not generic. + // error at N:\temp\ajcSandbox\aspectj16_3\ajcTest60379.tmp\pr280676_2\src\p\Foo.aj:12:0::0 Type parameters can not be + // specified in the ITD target type - the target type p.A is not generic. + assertEquals(5, errors.size()); + } + + public void testAdviceHandles_pr284771() throws Exception { + String p = "pr284771"; + initialiseProject(p); + build(p); + IRelationshipMap irm = getModelFor(p).getRelationshipMap(); + List rels = irm.get("=pr284771 rels = irm.get("=pr329111<{AJ.java'AJ`declare soft"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ2.java'AJ2`declare soft"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ2.java'AJ2`declare soft!2"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ2.java'AJ2`declare soft!3"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ3.java'AJ3`declare warning"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ3.java'AJ3`declare warning!2"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ3.java'AJ3`declare error"); + assertNotNull(rels); + rels = irm.get("=pr329111<{AJ3.java'AJ3`declare error!2"); + assertNotNull(rels); + } + + /** + * Test that the declare parents in the super aspect gets a relationship from the type declaring it. + */ + public void testAspectInheritance_322446() throws Exception { + String p = "pr322446"; + initialiseProject(p); + build(p); + IRelationshipMap irm = getModelFor(p).getRelationshipMap(); + // Hid:1:(targets=1) =pr322446<{Class.java[Class (aspect declarations) =pr322446<{AbstractAspect.java'AbstractAspect`declare + // parents + // Hid:2:(targets=1) =pr322446<{AbstractAspect.java'AbstractAspect`declare parents (declared on) =pr322446<{Class.java[Class + List rels = irm.get("=pr322446<{AbstractAspect.java'AbstractAspect`declare parents"); + assertNotNull(rels); + } + + public void testAspectInheritance_322446_2() throws Exception { + String p = "pr322446_2"; + initialiseProject(p); + build(p); + IProgramElement thisAspectNode = getModelFor(p).getHierarchy().findElementForType("", "Sub"); + assertEquals("{Code=[I]}", thisAspectNode.getDeclareParentsMap().toString()); + } + + public void testBinaryAspectsAndTheModel_343001() throws Exception { + String lib = "pr343001_lib"; + initialiseProject(lib); + build(lib); + + // Check the 'standard build' - the library also has a type affected by the decp so we can check what happens on an 'all + // source' build + IProgramElement theAspect = getModelFor(lib).getHierarchy().findElementForHandleOrCreate("=pr343001_lib<{Super.java'Super", + false); + assertNotNull(theAspect); + IProgramElement sourcelevelDecp = getModelFor(lib).getHierarchy().findElementForHandleOrCreate( + "=pr343001_lib<{Super.java'Super`declare parents", false); + assertNotNull(sourcelevelDecp); + assertEquals("[java.io.Serializable]", sourcelevelDecp.getParentTypes().toString()); + + String p = "pr343001"; + initialiseProject(p); + configureAspectPath(p, getProjectRelativePath(lib, "bin")); + build(p); + + IProgramElement theBinaryAspect = getModelFor(p).getHierarchy().findElementForHandleOrCreate( + "=pr343001/binaries<(Super.class'Super", false); + assertNotNull(theBinaryAspect); + IProgramElement binaryDecp = getModelFor(p).getHierarchy().findElementForHandleOrCreate( + "=pr343001/binaries<(Super.class'Super`declare parents", false); + assertNotNull(binaryDecp); + assertEquals("[java.io.Serializable]", (binaryDecp.getParentTypes() == null ? "" : binaryDecp.getParentTypes().toString())); + } + + // found whilst looking at 322446 hence that is the testdata name + public void testAspectInheritance_322664() throws Exception { + AjdeInteractionTestbed.VERBOSE = true; + String p = "pr322446_3"; + initialiseProject(p); + build(p); + assertNoErrors(p); + alter(p, "inc1"); + build(p); + // should be some errors: + // error at N:\temp\ajcSandbox\aspectj16_1\ajcTest3209787521625191676.tmp\pr322446_3\src\AbstractAspect.java:5:0::0 can't + // bind type name 'T' + // error at N:\temp\ajcSandbox\aspectj16_1\ajcTest3209787521625191676.tmp\pr322446_3\src\AbstractAspect.java:8:0::0 + // Incorrect number of arguments for type AbstractAspect; it cannot be parameterized with arguments + List errors = getErrorMessages(p); + assertTrue(errors != null && errors.size() > 0); + alter(p, "inc2"); + build(p); + // that build would contain an exception if the bug were around + assertNoErrors(p); + } + + // TODO (asc) these tests don't actually verify anything! + // public void testAtDeclareParents_280658() throws Exception { + // AjdeInteractionTestbed.VERBOSE = true; + // String lib = "pr280658_decp"; + // initialiseProject(lib); + // build(lib); + // checkWasFullBuild(); + // + // String cli = "pr280658_target"; + // initialiseProject(cli); + // + // configureAspectPath(cli, getProjectRelativePath(lib, "bin")); + // build(cli); + // checkWasFullBuild(); + // printModel(cli); + // } + // + // public void testAtDeclareMixin_280651() throws Exception { + // AjdeInteractionTestbed.VERBOSE = true; + // String lib = "pr280651_decmix"; + // initialiseProject(lib); + // build(lib); + // checkWasFullBuild(); + // + // String cli = "pr280658_target"; + // initialiseProject(cli); + // + // configureAspectPath(cli, getProjectRelativePath(lib, "bin")); + // build(cli); + // checkWasFullBuild(); + // printModel(cli); + // } + + // Testing that declare annotation model entries preserve the fully qualified type of the annotation + public void testDecAnnoState_pr286539() throws Exception { + String p = "pr286539"; + initialiseProject(p); + build(p); + printModel(p); + IProgramElement decpPE = getModelFor(p).getHierarchy().findElementForHandle( + "=pr286539 rels = irm.get("=pr322039 rels = irm.get("=pr280383 rels = irm.get("=pr283657<{Aspect.java'Aspect,Target.foo"); + assertNotNull(rels); + rels = irm.get("=pr283657<{Aspect.java'Aspect)Target.foo!2"); + assertNotNull(rels); + } + + public void testIncrementalAnnotationMatched_276399() throws Exception { + String p = "pr276399"; + initialiseProject(p); + addSourceFolderForSourceFile(p, getProjectRelativePath(p, "src/X.aj"), "src"); + addSourceFolderForSourceFile(p, getProjectRelativePath(p, "src/C.java"), "src"); + build(p); + IRelationshipMap irm = getModelFor(p).getRelationshipMap(); + IRelationship ir = irm.get("=pr276399/src<*X.aj'X&after").get(0); + assertNotNull(ir); + alter(p, "inc1"); + build(p); + printModel(p); + irm = getModelFor(p).getRelationshipMap(); + List rels = irm.get("=pr276399/src<*X.aj'X&after"); // should be gone after the inc build + assertNull(rels); + } + + public void testHandleCountDecA_pr278255() throws Exception { + String p = "pr278255"; + initialiseProject(p); + build(p); + printModelAndRelationships(p); + IRelationshipMap irm = getModelFor(p).getRelationshipMap(); + List l = irm.get("=pr278255<{A.java'X`declare \\@type"); + assertNotNull(l); + IRelationship ir = l.get(0); + assertNotNull(ir); + } + + public void testIncrementalItdDefaultCtor() { + String p = "pr275032"; + initialiseProject(p); + build(p); + assertEquals(0, getErrorMessages(p).size()); + alter(p, "inc1"); + build(p); + // error is: inter-type declaration from X conflicts with existing member: void A.() + // List ms = + getErrorMessages(p); + assertEquals(4, getErrorMessages(p).size()); + // Why 4 errors? I believe the problem is: + // 2 errors are reported when there is a clash - one against the aspect, one against the affected target type. + // each of the two errors are recorded against the compilation result for the aspect and the target + // So it comes out as 4 - but for now I am tempted to leave it because at least it shows there is a problem... + assertTrue("Was:" + getErrorMessages(p).get(0), getErrorMessages(p).get(0).toString().indexOf("conflicts") != -1); + } + + public void testOutputLocationCallbacks2() { + String p = "pr268827_ol_res"; + initialiseProject(p); + Map m = new HashMap(); + m.put("a.txt", new File(getFile(p, "src/a.txt"))); + configureResourceMap(p, m); + CustomOLM olm = new CustomOLM(getProjectRelativePath(p, ".").toString()); + configureOutputLocationManager(p, olm); + build(p); + checkCompileWeaveCount(p, 2, 2); + assertEquals(3, olm.writeCount); + alter(p, "inc1"); // this contains a new B.java that doesn't have the aspect inside it + build(p); + checkCompileWeaveCount(p, 3, 1); + assertEquals(1, olm.removeCount); // B.class removed + } + + public void testOutputLocationCallbacks() { + String p = "pr268827_ol"; + initialiseProject(p); + CustomOLM olm = new CustomOLM(getProjectRelativePath(p, ".").toString()); + configureOutputLocationManager(p, olm); + build(p); + checkCompileWeaveCount(p, 2, 3); + alter(p, "inc1"); // this contains a new Foo.java that no longer has Extra class in it + build(p); + checkCompileWeaveCount(p, 1, 1); + assertEquals(1, olm.removeCount); + } + + public void testOutputLocationCallbacksFileAdd() { + String p = "pr268827_ol2"; + initialiseProject(p); + CustomOLM olm = new CustomOLM(getProjectRelativePath(p, ".").toString()); + configureOutputLocationManager(p, olm); + build(p); + assertEquals(3, olm.writeCount); + olm.writeCount = 0; + checkCompileWeaveCount(p, 2, 3); + alter(p, "inc1"); // this contains a new file Boo.java + build(p); + assertEquals(1, olm.writeCount); + checkCompileWeaveCount(p, 1, 1); + // assertEquals(1, olm.removeCount); + } + + static class CustomOLM extends TestOutputLocationManager { + + public int writeCount = 0; + public int removeCount = 0; + + public CustomOLM(String testProjectPath) { + super(testProjectPath); + } + + @Override + public void reportFileWrite(String outputfile, int filetype) { + super.reportFileWrite(outputfile, filetype); + writeCount++; + System.out.println("Written " + outputfile); + // System.out.println("Written " + outputfile + " " + filetype); + } + + @Override + public void reportFileRemove(String outputfile, int filetype) { + super.reportFileRemove(outputfile, filetype); + removeCount++; + System.out.println("Removed " + outputfile); + // System.out.println("Removed " + outputfile + " " + filetype); + } + + } + + public void testBrokenCodeDeca_268611() { + String p = "pr268611"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertEquals(1, getErrorMessages(p).size()); + assertTrue(((Message) getErrorMessages(p).get(0)).getMessage().indexOf( + "Syntax error on token \")\", \"name pattern\" expected") != -1); + } + + public void testIncrementalMixin() { + String p = "mixin"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + assertEquals(0, getErrorMessages(p).size()); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertEquals(0, getErrorMessages(p).size()); + } + + public void testUnusedPrivates_pr266420() { + String p = "pr266420"; + initialiseProject(p); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.problem.unusedPrivateMember", "warning"); + configureJavaOptionsMap(p, javaOptions); + + build(p); + checkWasFullBuild(); + List warnings = getWarningMessages(p); + assertEquals(0, warnings.size()); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + warnings = getWarningMessages(p); + assertEquals(0, warnings.size()); + } + + public void testExtendingITDAspectOnClasspath_PR298704() throws Exception { + String base = "pr298704_baseaspects"; + String test = "pr298704_testaspects"; + initialiseProject(base); + initialiseProject(test); + configureNewProjectDependency(test, base); + + build(base); + build(test); + checkWasFullBuild(); + assertNoErrors(test); + IRelationshipMap irm = getModelFor(test).getRelationshipMap(); + assertEquals(7, irm.getEntries().size()); + } + + public void testPR265729() { + AjdeInteractionTestbed.VERBOSE = true; + String lib = "pr265729_lib"; + initialiseProject(lib); + // addClasspathEntryChanged(lib, getProjectRelativePath(p1, + // "bin").toString()); + build(lib); + checkWasFullBuild(); + + String cli = "pr265729_client"; + initialiseProject(cli); + + // addClasspathEntry(cli, new File("../lib/junit/junit.jar")); + configureAspectPath(cli, getProjectRelativePath(lib, "bin")); + build(cli); + checkWasFullBuild(); + + IProgramElement root = getModelFor(cli).getHierarchy().getRoot(); + + // dumptree(root, 0); + // PrintWriter pw = new PrintWriter(System.out); + // try { + // getModelFor(cli).dumprels(pw); + // pw.flush(); + // } catch (Exception e) { + // } + IRelationshipMap irm = getModelFor(cli).getRelationshipMap(); + IRelationship ir = irm.get("=pr265729_client ptypes = binaryITDM.getParameterTypes(); + assertEquals("int", new String((char[]) ptypes.get(0))); + assertEquals("java.util.List", new String((char[]) ptypes.get(1))); + assertEquals("java.io.Serializable", new String((char[]) ptypes.get(2))); + + // param names not set + // List pnames = binaryITDM.getParameterNames(); + // assertEquals("i", new String((char[]) pnames.get(0))); + // assertEquals("list", new String((char[]) pnames.get(1))); + // assertEquals("b", new String((char[]) pnames.get(2))); + + assertEquals("java.lang.String", binaryITDM.getCorrespondingType(true)); + } + + public void testXmlConfiguredProject() { + AjdeInteractionTestbed.VERBOSE = true; + String p = "xmlone"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-showWeaveInfo");// -xmlConfigured"); + configureShowWeaveInfoMessages(p, true); + addXmlConfigFile(p, getProjectRelativePath(p, "p/aop.xml").toString()); + build(p); + checkWasFullBuild(); + List weaveMessages = getWeavingMessages(p); + if (weaveMessages.size() != 1) { + for (Iterator iterator = weaveMessages.iterator(); iterator.hasNext();) { + Object object = iterator.next(); + System.out.println(object); + } + fail("Expected just one weave message. The aop.xml should have limited the weaving"); + } + + } + + public void testDeclareParentsInModel() { + String p = "decps"; + initialiseProject(p); + build(p); + IProgramElement decp = getModelFor(p).getHierarchy().findElementForHandle("=decps ps = decp.getParentTypes(); + assertNotNull(ps); + assertEquals(2, ps.size()); + int count = 0; + for (Iterator iterator = ps.iterator(); iterator.hasNext();) { + String type = iterator.next(); + if (type.equals("java.io.Serializable")) { + count++; + } + if (type.equals("a.Goo")) { + count++; + } + } + assertEquals("Should have found the two types in: " + ps, 2, count); + } + + public void testConstructorAdvice_pr261380() throws Exception { + String p = "261380"; + initialiseProject(p); + build(p); + IRelationshipMap irm = getModelFor(p).getRelationshipMap(); + IRelationship ir = irm.get("=261380 targets = ir.getTargets(); + assertEquals(1, targets.size()); + System.out.println(targets.get(0)); + String handle = (String) targets.get(0); + assertEquals("Expected the handle for the code node inside the constructor decl", + "=261380())", handle); + } + + /* + * A.aj package pack; public aspect A { pointcut p() : call( C.method before() : p() { // line 7 } } + * + * C.java package pack; public class C { public void method1() { method2(); // line 6 } public void method2() { } public void + * method3() { method2(); // line 13 } + * + * } + */ + public void testDontLoseAdviceMarkers_pr134471() { + try { + // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; + initialiseProject("P4"); + build("P4"); + Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after full build where advice is applying"); + // should be 4 relationship entries + + // In inc1 the first advised line is 'commented out' + alter("P4", "inc1"); + build("P4"); + checkWasntFullBuild(); + Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after inc build where first advised line is gone"); + // should now be 2 relationship entries + + // This will be the line 6 entry in C.java + IProgramElement codeElement = findCode(checkForNode(getModelFor("P4"), "pack", "C", true)); + + // This will be the line 7 entry in A.java + IProgramElement advice = findAdvice(checkForNode(getModelFor("P4"), "pack", "A", true)); + + IRelationshipMap asmRelMap = getModelFor("P4").getRelationshipMap(); + assertEquals("There should be two relationships in the relationship map", 2, asmRelMap.getEntries().size()); + + for (Iterator iter = asmRelMap.getEntries().iterator(); iter.hasNext();) { + String sourceOfRelationship = (String) iter.next(); + IProgramElement ipe = getModelFor("P4").getHierarchy().findElementForHandle(sourceOfRelationship); + assertNotNull("expected to find IProgramElement with handle " + sourceOfRelationship + " but didn't", ipe); + if (ipe.getKind().equals(IProgramElement.Kind.ADVICE)) { + assertEquals("expected source of relationship to be " + advice.toString() + " but found " + ipe.toString(), + advice, ipe); + } else if (ipe.getKind().equals(IProgramElement.Kind.CODE)) { + assertEquals( + "expected source of relationship to be " + codeElement.toString() + " but found " + ipe.toString(), + codeElement, ipe); + } else { + fail("found unexpected relationship source " + ipe + " with kind " + ipe.getKind() + + " when looking up handle: " + sourceOfRelationship); + } + List relationships = asmRelMap.get(ipe); + assertNotNull("expected " + ipe.getName() + " to have some " + "relationships", relationships); + for (Iterator iterator = relationships.iterator(); iterator.hasNext();) { + Relationship rel = (Relationship) iterator.next(); + List targets = rel.getTargets(); + for (Iterator iterator2 = targets.iterator(); iterator2.hasNext();) { + String t = (String) iterator2.next(); + IProgramElement link = getModelFor("P4").getHierarchy().findElementForHandle(t); + if (ipe.getKind().equals(IProgramElement.Kind.ADVICE)) { + assertEquals( + "expected target of relationship to be " + codeElement.toString() + " but found " + + link.toString(), codeElement, link); + } else if (ipe.getKind().equals(IProgramElement.Kind.CODE)) { + assertEquals( + "expected target of relationship to be " + advice.toString() + " but found " + link.toString(), + advice, link); + } else { + fail("found unexpected relationship source " + ipe.getName() + " with kind " + ipe.getKind()); + } + } + } + } + + } finally { + // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true; + // configureBuildStructureModel(false); + } + } + + public void testPr148285() { + String p = "PR148285_2"; + initialiseProject(p); // Single source file A.aj defines A and C + build(p); + checkWasFullBuild(); + alter(p, "inc1"); // Second source introduced C.java, defines C + build(p); + checkWasntFullBuild(); + List msgs = getErrorMessages(p); + assertEquals("error message should be 'The type C is already defined' ", "The type C is already defined", + ((IMessage) msgs.get(0)).getMessage()); + alter("PR148285_2", "inc2"); // type C in A.aj is commented out + build("PR148285_2"); + checkWasntFullBuild(); + msgs = getErrorMessages(p); + assertTrue("There should be no errors reported:\n" + getErrorMessages(p), msgs.isEmpty()); + } + + public void testIncrementalAndAnnotations() { + initialiseProject("Annos"); + build("Annos"); + checkWasFullBuild(); + checkCompileWeaveCount("Annos", 4, 4); + AsmManager model = getModelFor("Annos"); + assertEquals("Should be 3 relationships ", 3, model.getRelationshipMap().getEntries().size()); + + alter("Annos", "inc1"); // Comment out the annotation on Parent + build("Annos"); + checkWasntFullBuild(); + assertEquals("Should be no relationships ", 0, model.getRelationshipMap().getEntries().size()); + checkCompileWeaveCount("Annos", 3, 3); + + alter("Annos", "inc2"); // Add the annotation back onto Parent + build("Annos"); + checkWasntFullBuild(); + assertEquals("Should be 3 relationships ", 3, model.getRelationshipMap().getEntries().size()); + checkCompileWeaveCount("Annos", 3, 3); + } + + // package a.b.c; + // + // public class A { + // } + // + // aspect X { + // B A.foo(C c) { return null; } + // declare parents: A implements java.io.Serializable; + // } + // + // class B {} + // class C {} + public void testITDFQNames_pr252702() { + String p = "itdfq"; + AjdeInteractionTestbed.VERBOSE = true; + initialiseProject(p); + build(p); + AsmManager model = getModelFor(p); + dumptree(model.getHierarchy().getRoot(), 0); + IProgramElement root = model.getHierarchy().getRoot(); + ProgramElement theITD = (ProgramElement) findElementAtLine(root, 7); + Map m = theITD.kvpairs; + for (Iterator iterator = m.keySet().iterator(); iterator.hasNext();) { + String type = iterator.next(); + System.out.println(type + " = " + m.get(type)); + } + // return type of the ITD + assertEquals("a.b.c.B", theITD.getCorrespondingType(true)); + List ptypes = theITD.getParameterTypes(); + for (Iterator iterator = ptypes.iterator(); iterator.hasNext();) { + char[] object = iterator.next(); + System.out.println("p = " + new String(object)); + } + ProgramElement decp = (ProgramElement) findElementAtLine(root, 8); + m = decp.kvpairs; + for (Iterator iterator = m.keySet().iterator(); iterator.hasNext();) { + String type = iterator.next(); + System.out.println(type + " = " + m.get(type)); + } + List l = decp.getParentTypes(); + assertEquals("java.io.Serializable", l.get(0)); + ProgramElement ctorDecp = (ProgramElement) findElementAtLine(root, 16); + String ctordecphandle = ctorDecp.getHandleIdentifier(); + assertEquals("=itdfq l = getCompilerErrorMessages(p); + assertEquals("Unexpected compiler error", 0, l.size()); + } + + public void testDeclareAnnotationNPE_298504() { + AjdeInteractionTestbed.VERBOSE = true; + String p = "pr298504"; + initialiseProject(p); + build(p); + List l = getErrorMessages(p); + assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); + // checkWasFullBuild(); + alter(p, "inc1"); + build(p); + // checkWasntFullBuild(); + List compilerErrors = getCompilerErrorMessages(p); + assertTrue(compilerErrors.toString().indexOf("NullPointerException") == -1); + l = getErrorMessages(p); + assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); + } + + public void testIncrementalAnnoStyle_pr286341() { + AjdeInteractionTestbed.VERBOSE = true; + String base = "pr286341_base"; + initialiseProject(base); + build(base); + checkWasFullBuild(); + String p = "pr286341"; + initialiseProject(p); + configureAspectPath(p, getProjectRelativePath(base, "bin")); + addClasspathEntry(p, getProjectRelativePath(base, "bin")); + build(p); + checkWasFullBuild(); + assertNoErrors(p); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + assertNoErrors(p); + } + + public void testImports_pr263487() { + String p2 = "importProb2"; + initialiseProject(p2); + build(p2); + checkWasFullBuild(); + + String p = "importProb"; + initialiseProject(p); + build(p); + configureAspectPath(p, getProjectRelativePath(p2, "bin")); + checkWasFullBuild(); + build(p); + build(p); + build(p); + alter(p, "inc1"); + addProjectSourceFileChanged(p, getProjectRelativePath(p, "src/p/Code.java")); + // addProjectSourceFileChanged(p, getProjectRelativePath(p, + // "src/q/Asp.java")); + build(p); + checkWasntFullBuild(); + List l = getCompilerErrorMessages(p); + assertEquals("Unexpected compiler error", 0, l.size()); + } + + public void testBuildingBrokenCode_pr263323() { + AjdeInteractionTestbed.VERBOSE = true; + String p = "brokenCode"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); // break the aspect + build(p); + checkWasntFullBuild(); + alter(p, "inc2"); // whitespace change on affected file + build(p); + checkWasntFullBuild(); + List l = getCompilerErrorMessages(p); + assertEquals("Unexpected compiler error", 0, l.size()); + } + + /* + * public void testNPEGenericCtor_pr260944() { AjdeInteractionTestbed.VERBOSE = true; String p = "pr260944"; + * initialiseProject(p); build(p); checkWasFullBuild(); alter(p, "inc1"); build(p); checkWasntFullBuild(); List l = + * getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } + */ + + public void testItdProb() { + AjdeInteractionTestbed.VERBOSE = true; + String p = "itdprob"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + List l = getCompilerErrorMessages(p); + assertEquals("Unexpected compiler error", 0, l.size()); + } + + /* + * public void testGenericITD_pr262257() throws IOException { String p = "pr262257"; initialiseProject(p); build(p); + * checkWasFullBuild(); + * + * dumptree(getModelFor(p).getHierarchy().getRoot(), 0); PrintWriter pw = new PrintWriter(System.out); + * getModelFor(p).dumprels(pw); pw.flush(); } + */ + public void testAnnotations_pr262154() { + String p = "pr262154"; + initialiseProject(p); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); + build(p); + List l = getCompilerErrorMessages(p); + assertEquals("Unexpected compiler error", 0, l.size()); + } + + public void testAnnotations_pr255555() { + String p = "pr255555"; + initialiseProject(p); + build(p); + checkCompileWeaveCount(p, 2, 1); + } + + public void testSpacewarHandles() { + // String p = "SpaceWar"; + String p = "Simpler"; + initialiseProject(p); + build(p); + dumptree(getModelFor(p).getHierarchy().getRoot(), 0); + // incomplete + } + + /** + * Test what is in the model for package declarations and import statements. Package Declaration nodes are new in AspectJ 1.6.4. + * Import statements are contained with an 'import references' node. + */ + public void testImportHandles() { + String p = "Imports"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:minimalModel=false"); + build(p); + + IProgramElement root = getModelFor(p).getHierarchy().getRoot(); + + // Looking for 'package p.q' + IProgramElement ipe = findFile(root, "Example.aj");// findElementAtLine(root, 1); + ipe = ipe.getChildren().get(0); // package decl is first entry in the type + assertEquals(IProgramElement.Kind.PACKAGE_DECLARATION, ipe.getKind()); + assertEquals("package p.q;", ipe.getSourceSignature()); + assertEquals("=Imports s = new HashSet(); + s.add(f); + configureAspectPath("P1", s); + build("P1"); // This first build will be batch + checkForError("P1", "invalid aspectpath entry"); + } + + // incorrect use of '?' when it should be '*' + public void testAspectPath_pr242797_c46() { + String bug = "pr242797_1"; + String bug2 = "pr242797_2"; + initialiseProject(bug); + initialiseProject(bug2); + configureAspectPath(bug2, getProjectRelativePath(bug, "bin")); + build(bug); + build(bug2); + } + + public void testAspectPath_pr247742_c16() throws IOException { + String bug = "AspectPathOne"; + String bug2 = "AspectPathTwo"; + addSourceFolderForSourceFile(bug2, getProjectRelativePath(bug2, "src/C.java"), "src"); + initialiseProject(bug); + initialiseProject(bug2); + configureAspectPath(bug2, getProjectRelativePath(bug, "bin")); + build(bug); + build(bug2); + dumptree(getModelFor(bug2).getHierarchy().getRoot(), 0); + PrintWriter pw = new PrintWriter(System.out); + getModelFor(bug2).dumprels(pw); + pw.flush(); + IProgramElement root = getModelFor(bug2).getHierarchy().getRoot(); + assertEquals("=AspectPathTwo/binaries kids = start.getChildren(); + if (kids != null) { + for (int i = 0; i < kids.size(); i++) { + IProgramElement found = getChild((IProgramElement) kids.get(i), name); + if (found != null) { + return found; + } + } + } + return null; + } + + public void testHandleQualification_pr265993() throws IOException { + String p = "pr265993"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:minimalModel=false"); + build(p); + IProgramElement root = getModelFor(p).getHierarchy().getRoot(); + // dumptree(getModelFor(p).getHierarchy().getRoot(), 0); + // PrintWriter pw = new PrintWriter(System.out); + // getModelFor(p).dumprels(pw); + // pw.flush(); + assertEquals("=pr265993<{A.java[A~m~QString;~Qjava.lang.String;", findElementAtLine(root, 3).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m2~QList;", findElementAtLine(root, 5).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m3~Qjava.util.ArrayList;", findElementAtLine(root, 6).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m4~QMap\\;", findElementAtLine(root, 8).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m5~Qjava.util.Map\\;", findElementAtLine(root, 9) + .getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m6~QMap\\<\\[IQList;>;", findElementAtLine(root, 10).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m7~\\[I", findElementAtLine(root, 11).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m8~\\[Qjava.lang.String;", findElementAtLine(root, 12).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m9~\\[QString;", findElementAtLine(root, 13).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m10~\\[\\[QList\\;", findElementAtLine(root, 14).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m11~Qjava.util.List\\;", findElementAtLine(root, 15).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m12~\\[QT;", findElementAtLine(root, 16).getHandleIdentifier()); + assertEquals("=pr265993<{A.java[A~m13~QClass\\;~QObject;~QString;", findElementAtLine(root, 17).getHandleIdentifier()); + } + + public void testHandlesForAnnotationStyle_pr269286() throws IOException { + String p = "pr269286"; + initialiseProject(p); + build(p); + IProgramElement root = getModelFor(p).getHierarchy().getRoot(); + dumptree(getModelFor(p).getHierarchy().getRoot(), 0); + PrintWriter pw = new PrintWriter(System.out); + getModelFor(p).dumprels(pw); + pw.flush(); + assertEquals("=pr269286<{Logger.java[Logger", findElementAtLine(root, 4).getHandleIdentifier()); // type + assertEquals("=pr269286<{Logger.java[Logger~boo", findElementAtLine(root, 7).getHandleIdentifier()); // before + assertEquals("=pr269286<{Logger.java[Logger~aoo", findElementAtLine(root, 11).getHandleIdentifier()); // after + assertEquals("=pr269286<{Logger.java[Logger~aroo", findElementAtLine(root, 15).getHandleIdentifier()); // around + + // pointcuts are not fixed - seems to buggy handling of them internally + assertEquals("=pr269286<{Logger.java[Logger\"ooo", findElementAtLine(root, 20).getHandleIdentifier()); + + // DeclareWarning + assertEquals("=pr269286<{Logger.java[Logger^message", findElementAtLine(root, 24).getHandleIdentifier()); + + // DeclareError + assertEquals("=pr269286<{Logger.java[Logger^message2", findElementAtLine(root, 27).getHandleIdentifier()); + } + + public void testHandleCountersForAdvice() throws IOException { + String p = "prx"; + initialiseProject(p); + build(p); + // System.out.println("Handle Counters For Advice Output"); + IProgramElement root = getModelFor(p).getHierarchy().getRoot(); + // dumptree(getModelFor(p).getHierarchy().getRoot(), 0); + // PrintWriter pw = new PrintWriter(System.out); + // getModelFor(p).dumprels(pw); + // pw.flush(); + IProgramElement ff = findFile(root, "ProcessAspect.aj"); + assertEquals("=prx + * Managing the aspectpath is hard. We want to do a minimal build of this project which means recognizing what kind of changes + * have occurred on the aspectpath. Was it a regular class or an aspect? Was it a structural change to that aspect? + *

+ * The filenames for .class files created that contain aspects is stored in the AjState.aspectClassFiles field. When a change is + * detected we can see who was managing the location where the change occurred and ask them if the .class file contained an + * aspect. Right now a change detected like this will cause a full build. We might improve the detection logic here but it isn't + * trivial: + *

    + *
  • Around advice is inlined. Changing the body of an around advice would not normally be thought of as a structural change + * (as it does not change the signature of the class) but due to inlining it is a change we would need to pay attention to as it + * will affect types previously woven with that advice. + *
  • Annotation style aspects include pointcuts in strings. Changes to these are considered non-structural but clearly they do + * affect what might be woven. + *
+ */ + public void testAspectPath_pr249212_c1() throws IOException { + String p1 = "AspectPathOne"; + String p2 = "AspectPathTwo"; + addSourceFolderForSourceFile(p2, getProjectRelativePath(p2, "src/C.java"), "src"); + initialiseProject(p1); + initialiseProject(p2); + configureAspectPath(p2, getProjectRelativePath(p1, "bin")); + build(p1); + build(p2); + + alter(p1, "inc1"); + build(p1); // Modify the aspect Asp2 to include staticinitialization() + // advice + checkWasFullBuild(); + Set s = getModelFor(p1).getModelChangesOnLastBuild(); + assertTrue("Should be empty as was full build:" + s, s.isEmpty()); + + // prod the build of the second project with some extra info to tell it + // more precisely about the change: + addClasspathEntryChanged(p2, getProjectRelativePath(p1, "bin").toString()); + configureAspectPath(p2, getProjectRelativePath(p1, "bin")); + build(p2); + checkWasFullBuild(); + + // dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + // PrintWriter pw = new PrintWriter(System.out); + // AsmManager.getDefault().dumprels(pw); + // pw.flush(); + + // Not incremental + assertTrue("Should be empty as was full build:" + s, s.isEmpty()); + // Set s = AsmManager.getDefault().getModelChangesOnLastBuild(); + // checkIfContainsFile(AsmManager.getDefault().getModelChangesOnLastBuild + // (), "C.java", true); + } + + // public void testAspectPath_pr242797_c41() { + // String bug = "pr242797_3"; + // String bug2 = "pr242797_4"; + // initialiseProject(bug); + // initialiseProject(bug2); + // configureAspectPath(bug2, getProjectRelativePath(bug, "bin")); + // build(bug); + // build(bug2); + // } + + /** + * Build a project containing a resource - then mark the resource readOnly(), then do an inc-compile, it will report an error + * about write access to the resource in the output folder being denied + */ + /* + * public void testProblemCopyingResources_pr138171() { initialiseProject("PR138171"); + * + * File f=getProjectRelativePath("PR138171","res.txt"); Map m = new HashMap(); m.put("res.txt",f); + * AjdeInteractionTestbed.MyProjectPropertiesAdapter .getInstance().setSourcePathResources(m); build("PR138171"); File f2 = + * getProjectOutputRelativePath("PR138171","res.txt"); boolean successful = f2.setReadOnly(); + * + * alter("PR138171","inc1"); AjdeInteractionTestbed.MyProjectPropertiesAdapter .getInstance().setSourcePathResources(m); + * build("PR138171"); List msgs = MyTaskListManager.getErrorMessages(); assertTrue("there should be one message but there are " + * +(msgs==null?0:msgs.size())+":\n"+msgs,msgs!=null && msgs.size()==1); IMessage msg = (IMessage)msgs.get(0); String exp = + * "unable to copy resource to output folder: 'res.txt'"; assertTrue("Expected message to include this text [" + * +exp+"] but it does not: "+msg,msg.toString().indexOf(exp)!=-1); } + */ + + // Make simple changes to a project, adding a class + public void testSimpleChanges() { + initialiseProject("P1"); + build("P1"); // This first build will be batch + alter("P1", "inc1"); // adds a single class + build("P1"); + checkCompileWeaveCount("P1", 1, -1); + build("P1"); + checkCompileWeaveCount("P1", 0, -1); + } + + // Make simple changes to a project, adding a class and an aspect + public void testAddingAnAspect() { + initialiseProject("P1"); + build("P1"); // build 1, weave 1 + alter("P1", "inc1"); // adds a class + alter("P1", "inc2"); // adds an aspect + build("P1"); // build 1, + long timeTakenForFullBuildAndWeave = getTimeTakenForBuild("P1"); + checkWasFullBuild(); // it *will* be a full build under the new + // "back-to-the-source strategy + checkCompileWeaveCount("P1", 5, 3); // we compile X and A (the delta) + // find out that + // an aspect has changed, go back to the source + // and compile X,A,C, then weave the all. + build("P1"); + long timeTakenForSimpleIncBuild = getTimeTakenForBuild("P1"); + // I don't think this test will have timing issues as the times should + // be *RADICALLY* different + // On my config, first build time is 2093ms and the second is 30ms + assertTrue("Should not take longer for the trivial incremental build! first=" + timeTakenForFullBuildAndWeave + + "ms second=" + timeTakenForSimpleIncBuild + "ms", timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave); + } + + public void testBuildingTwoProjectsInTurns() { + initialiseProject("P1"); + initialiseProject("P2"); + build("P1"); + build("P2"); + build("P1"); + checkWasntFullBuild(); + build("P2"); + checkWasntFullBuild(); + } + + public void testBuildingBrokenCode_pr240360() { + initialiseProject("pr240360"); + // configureNonStandardCompileOptions("pr240360","-proceedOnError"); + build("pr240360"); + checkWasFullBuild(); + checkCompileWeaveCount("pr240360", 5, 4); + assertTrue("There should be an error:\n" + getErrorMessages("pr240360"), !getErrorMessages("pr240360").isEmpty()); + + Set s = getModelFor("pr240360").getRelationshipMap().getEntries(); + int relmapLength = s.size(); + + // Delete the erroneous type + String f = getWorkingDir().getAbsolutePath() + File.separatorChar + "pr240360" + File.separatorChar + "src" + + File.separatorChar + "test" + File.separatorChar + "Error.java"; + (new File(f)).delete(); + build("pr240360"); + checkWasntFullBuild(); + checkCompileWeaveCount("pr240360", 0, 0); + assertEquals(relmapLength, getModelFor("pr240360").getRelationshipMap().getEntries().size()); + + // Readd the erroneous type + alter("pr240360", "inc1"); + build("pr240360"); + checkWasntFullBuild(); + checkCompileWeaveCount("pr240360", 1, 0); + assertEquals(relmapLength, getModelFor("pr240360").getRelationshipMap().getEntries().size()); + + // Change the advice + alter("pr240360", "inc2"); + build("pr240360"); + checkWasFullBuild(); + checkCompileWeaveCount("pr240360", 6, 4); + assertEquals(relmapLength, getModelFor("pr240360").getRelationshipMap().getEntries().size()); + + } + + public void testBrokenCodeCompilation() { + initialiseProject("pr102733_1"); + // configureNonStandardCompileOptions("pr102733_1","-proceedOnError"); + build("pr102733_1"); + checkWasFullBuild(); + checkCompileWeaveCount("pr102733_1", 1, 0); + assertTrue("There should be an error:\n" + getErrorMessages("pr102733_1"), !getErrorMessages("pr102733_1").isEmpty()); + build("pr102733_1"); // incremental + checkCompileWeaveCount("pr102733_1", 0, 0); + checkWasntFullBuild(); + alter("pr102733_1", "inc1"); // fix the error + build("pr102733_1"); + checkWasntFullBuild(); + checkCompileWeaveCount("pr102733_1", 1, 1); + assertTrue("There should be no errors:\n" + getErrorMessages("pr102733_1"), getErrorMessages("pr102733_1").isEmpty()); + alter("pr102733_1", "inc2"); // break it again + build("pr102733_1"); + checkWasntFullBuild(); + checkCompileWeaveCount("pr102733_1", 1, 0); + assertTrue("There should be an error:\n" + getErrorMessages("pr102733_1"), !getErrorMessages("pr102733_1").isEmpty()); + } + + // public void testDeclareAtType_pr149293() { + // configureBuildStructureModel(true); + // initialiseProject("PR149293_1"); + // build("PR149293_1"); + // checkCompileWeaveCount(4,5); + // assertNoErrors(); + // alter("PR149293_1","inc1"); + // build("PR149293_1"); + // assertNoErrors(); + // } + + public void testRefactoring_pr148285() { + // configureBuildStructureModel(true); + + initialiseProject("PR148285"); + build("PR148285"); + alter("PR148285", "inc1"); + build("PR148285"); + } + + /** + * In order for this next test to run, I had to move the weaver/world pair we keep in the AjBuildManager instance down into the + * state object - this makes perfect sense - otherwise when reusing the state for another project we'd not be switching to the + * right weaver/world for that project. + */ + public void testBuildingTwoProjectsMakingSmallChanges() { + + initialiseProject("P1"); + initialiseProject("P2"); + + build("P1"); + build("P2"); + build("P1"); + checkWasntFullBuild(); + + build("P2"); + checkWasntFullBuild(); + + alter("P1", "inc1"); // adds a class + alter("P1", "inc2"); // adds an aspect + build("P1"); + checkWasFullBuild(); // adding an aspect makes us go back to the source + } + + public void testPr134371() { + initialiseProject("PR134371"); + build("PR134371"); + alter("PR134371", "inc1"); + build("PR134371"); + assertTrue("There should be no exceptions handled:\n" + getErrorMessages("PR134371"), getErrorMessages("PR134371") + .isEmpty()); + + } + + /** + * This test is verifying the behaviour of the code that iterates through the type hierarchy for some type. There are two ways + * to do it - an approach that grabs all the information up front or an approach that works through iterators and only processes + * as much data as necessary to satisfy the caller. The latter approach could be much faster - especially if the matching + * process typically looks for a method in the declaring type. + */ + public void xtestOptimizedMemberLookup() { + String p = "oml"; + initialiseProject(p); + build(p); + + AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + World w = ajBuildManager.getWorld(); + // Type A has no hierarchy (well, Object) and defines 3 methods + checkType(w, "com.foo.A"); + // Type B extends B2. Two methods in B2, three in B + checkType(w, "com.foo.B"); + // Type C implements an interface + checkType(w, "com.foo.C"); + // Type CC extends a class that implements an interface + checkType(w, "com.foo.CC"); + // Type CCC implements an interface that extends another interface + checkType(w, "com.foo.CCC"); + // Type CCC implements an interface that extends another interface + checkType(w, "com.foo.CCC"); + checkType(w, "GenericMethodInterface"); + checkType(w, "GenericInterfaceChain"); + + // Some random classes from rt.jar that did reveal some problems: + checkType(w, "java.lang.StringBuffer"); + checkType(w, "com.sun.corba.se.impl.encoding.CDRInputObject"); + checkTypeHierarchy(w, "com.sun.corba.se.impl.interceptors.PIHandlerImpl$RequestInfoStack", true); + checkType(w, "com.sun.corba.se.impl.interceptors.PIHandlerImpl$RequestInfoStack"); + checkType(w, "DeclareWarningAndInterfaceMethodCW"); + checkType(w, "ICanGetSomething"); + checkType(w, "B"); + checkType(w, "C"); + + // checkRtJar(w); // only works if the JDK path is setup ok in checkRtJar + + // speedCheck(w); + } + + // private void checkRtJar(World w) { + // System.out.println("Processing everything in rt.jar: ~16000 classes"); + // try { + // ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); + // Enumeration e = zf.entries(); + // int count = 1; + // while (e.hasMoreElements()) { + // ZipEntry ze = (ZipEntry) e.nextElement(); + // String n = ze.getName(); + // if (n.endsWith(".class")) { + // n = n.replace('/', '.'); + // n = n.substring(0, n.length() - 6); + // if ((count % 100) == 0) { + // System.out.print(count + " "); + // } + // if ((count % 1000) == 0) { + // System.out.println(); + // } + // checkType(w, n); + // count++; + // } + // } + // zf.close(); + // } catch (IOException t) { + // t.printStackTrace(); + // fail(t.toString()); + // } + // System.out.println(); + // } + + /** + * Compare time taken to grab them all and look at them and iterator through them all. + */ + private void speedCheck(World w) { + long stime = System.currentTimeMillis(); + try { + ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); + Enumeration e = zf.entries(); + while (e.hasMoreElements()) { + ZipEntry ze = (ZipEntry) e.nextElement(); + String n = ze.getName(); + if (n.endsWith(".class")) { + n = n.replace('/', '.'); + n = n.substring(0, n.length() - 6); + ResolvedType typeA = w.resolve(n); + assertFalse(typeA.isMissing()); + List viaIteratorList = getThemAll(typeA.getMethods(true, true)); + viaIteratorList = getThemAll(typeA.getMethods(false, true)); + } + } + zf.close(); + } catch (IOException t) { + t.printStackTrace(); + fail(t.toString()); + } + long etime = System.currentTimeMillis(); + System.out.println("Time taken for 'iterator' approach: " + (etime - stime) + "ms"); + stime = System.currentTimeMillis(); + try { + ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); + Enumeration e = zf.entries(); + while (e.hasMoreElements()) { + ZipEntry ze = (ZipEntry) e.nextElement(); + String n = ze.getName(); + if (n.endsWith(".class")) { + n = n.replace('/', '.'); + n = n.substring(0, n.length() - 6); + ResolvedType typeA = w.resolve(n); + assertFalse(typeA.isMissing()); + List viaIteratorList = typeA.getMethodsWithoutIterator(false, true, true); + viaIteratorList = typeA.getMethodsWithoutIterator(false, true, false); + } + } + zf.close(); + } catch (IOException t) { + t.printStackTrace(); + fail(t.toString()); + } + etime = System.currentTimeMillis(); + System.out.println("Time taken for 'grab all up front' approach: " + (etime - stime) + "ms"); + + } + + private void checkType(World w, String name) { + checkTypeHierarchy(w, name, true); + checkTypeHierarchy(w, name, false); + checkMethods(w, name, true); + checkMethods(w, name, false); + } + + private void checkMethods(World w, String name, boolean wantGenerics) { + ResolvedType typeA = w.resolve(name); + assertFalse(typeA.isMissing()); + List viaIteratorList = getThemAll(typeA.getMethods(wantGenerics, true)); + List directlyList = typeA.getMethodsWithoutIterator(true, true, wantGenerics); + Collections.sort(viaIteratorList, new ResolvedMemberComparator()); + Collections.sort(directlyList, new ResolvedMemberComparator()); + compare(viaIteratorList, directlyList, name); + // System.out.println(toString(viaIteratorList, directlyList, genericsAware)); + } + + private static class ResolvedMemberComparator implements Comparator { + public int compare(ResolvedMember o1, ResolvedMember o2) { + return o1.toString().compareTo(o2.toString()); + } + } + + private void checkTypeHierarchy(World w, String name, boolean wantGenerics) { + ResolvedType typeA = w.resolve(name); + assertFalse(typeA.isMissing()); + List viaIteratorList = exhaustTypeIterator(typeA.getHierarchy(wantGenerics, false)); + List typeDirectlyList = typeA.getHierarchyWithoutIterator(true, true, wantGenerics); + assertFalse(viaIteratorList.isEmpty()); + List directlyList = new ArrayList(); + for (ResolvedType type : typeDirectlyList) { + String n = type.getName(); + if (!directlyList.contains(n)) { + directlyList.add(n); + } + } + Collections.sort(viaIteratorList); + Collections.sort(directlyList); + compareTypeLists(viaIteratorList, directlyList); + // System.out.println("ShouldBeGenerics?" + wantGenerics + "\n" + typeListsToString(viaIteratorList, directlyList)); + } + + private void compare(List viaIteratorList, List directlyList, String typename) { + assertEquals(typename + "\n" + toString(directlyList), typename + "\n" + toString(viaIteratorList)); + } + + private void compareTypeLists(List viaIteratorList, List directlyList) { + assertEquals(typeListToString(directlyList), typeListToString(viaIteratorList)); + } + + private String toString(List list) { + StringBuffer sb = new StringBuffer(); + for (ResolvedMember m : list) { + sb.append(m).append("\n"); + } + return sb.toString(); + } + + private String typeListToString(List list) { + StringBuffer sb = new StringBuffer(); + for (String m : list) { + sb.append(m).append("\n"); + } + return sb.toString(); + } + + private String toString(List one, List two, boolean shouldIncludeGenerics) { + StringBuffer sb = new StringBuffer(); + sb.append("Through iterator\n"); + for (ResolvedMember m : one) { + sb.append(m).append("\n"); + } + sb.append("Directly retrieved\n"); + for (ResolvedMember m : one) { + sb.append(m).append("\n"); + } + return sb.toString(); + } + + private String typeListsToString(List one, List two) { + StringBuffer sb = new StringBuffer(); + sb.append("Through iterator\n"); + for (String m : one) { + sb.append(">" + m).append("\n"); + } + sb.append("Directly retrieved\n"); + for (String m : one) { + sb.append(">" + m).append("\n"); + } + return sb.toString(); + } + + private List getThemAll(Iterator methods) { + List allOfThem = new ArrayList(); + while (methods.hasNext()) { + allOfThem.add(methods.next()); + } + return allOfThem; + } + + private List exhaustTypeIterator(Iterator types) { + List allOfThem = new ArrayList(); + while (types.hasNext()) { + allOfThem.add(types.next().getName()); + } + return allOfThem; + } + + /** + * Setup up two simple projects and build them in turn - check the structure model is right after each build + */ + public void testBuildingTwoProjectsAndVerifyingModel() { + initialiseProject("P1"); + initialiseProject("P2"); + configureNonStandardCompileOptions("P1", "-Xset:minimalModel=false"); + configureNonStandardCompileOptions("P2", "-Xset:minimalModel=false"); + + build("P1"); + checkForNode(getModelFor("P1"), "pkg", "C", true); + + build("P2"); + checkForNode(getModelFor("P2"), "pkg", "C", false); + + build("P1"); + checkForNode(getModelFor("P1"), "pkg", "C", true); + + build("P2"); + checkForNode(getModelFor("P2"), "pkg", "C", false); + } + + // Setup up two simple projects and build them in turn - check the + // structure model is right after each build + public void testBuildingTwoProjectsAndVerifyingStuff() { + initialiseProject("P1"); + initialiseProject("P2"); + configureNonStandardCompileOptions("P1", "-Xset:minimalModel=false"); + configureNonStandardCompileOptions("P2", "-Xset:minimalModel=false"); + + build("P1"); + checkForNode(getModelFor("P1"), "pkg", "C", true); + + build("P2"); + checkForNode(getModelFor("P2"), "pkg", "C", false); + + build("P1"); + checkForNode(getModelFor("P1"), "pkg", "C", true); + + build("P2"); + checkForNode(getModelFor("P2"), "pkg", "C", false); + } + + /** + * Complex. Here we are testing that a state object records structural changes since the last full build correctly. We build a + * simple project from scratch - this will be a full build and so the structural changes since last build count should be 0. We + * then alter a class, adding a new method and check structural changes is 1. + */ + public void testStateManagement1() { + + File binDirectoryForP1 = new File(getFile("P1", "bin")); + + initialiseProject("P1"); + build("P1"); // full build + AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirectoryForP1); + assertTrue("There should be a state object for project P1", ajs != null); + assertTrue( + "Should be no structural changes as it was a full build but found: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + + alter("P1", "inc3"); // adds a method to the class C.java + build("P1"); + checkWasntFullBuild(); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P1", "bin"))); + assertTrue("There should be state for project P1", ajs != null); + checkWasntFullBuild(); + assertTrue( + "Should be one structural changes as it was a full build but found: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 1); + + } + + /** + * Complex. Here we are testing that a state object records structural changes since the last full build correctly. We build a + * simple project from scratch - this will be a full build and so the structural changes since last build count should be 0. We + * then alter a class, changing body of a method, not the structure and check struc changes is still 0. + */ + public void testStateManagement2() { + File binDirectoryForP1 = new File(getFile("P1", "bin")); + + initialiseProject("P1"); + alter("P1", "inc3"); // need this change in here so 'inc4' can be + // applied without making + // it a structural change + build("P1"); // full build + AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirectoryForP1); + assertTrue("There should be state for project P1", ajs != null); + assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + + alter("P1", "inc4"); // changes body of main() method but does *not* + // change the structure of C.java + build("P1"); + checkWasntFullBuild(); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P1", "bin"))); + assertTrue("There should be state for project P1", ajs != null); + checkWasntFullBuild(); + assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + } + + /** + * The C.java file modified in this test has an inner class - this means the inner class has a this$0 field and (C) ctor + * to watch out for when checking for structural changes + * + */ + public void testStateManagement3() { + File binDirForInterproject1 = new File(getFile("interprojectdeps1", "bin")); + + initialiseProject("interprojectdeps1"); + build("interprojectdeps1"); // full build + AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirForInterproject1); + assertTrue("There should be state for project P1", ajs != null); + assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + + alter("interprojectdeps1", "inc1"); // adds a space to C.java + build("interprojectdeps1"); + checkWasntFullBuild(); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("interprojectdeps1", "bin"))); + assertTrue("There should be state for project interprojectdeps1", ajs != null); + checkWasntFullBuild(); + assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + } + + /** + * The C.java file modified in this test has an inner class - which has two ctors - this checks how they are mangled with an + * instance of C. + * + */ + public void testStateManagement4() { + File binDirForInterproject2 = new File(getFile("interprojectdeps2", "bin")); + + initialiseProject("interprojectdeps2"); + build("interprojectdeps2"); // full build + AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirForInterproject2); + assertTrue("There should be state for project interprojectdeps2", ajs != null); + assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + + alter("interprojectdeps2", "inc1"); // minor change to C.java + build("interprojectdeps2"); + checkWasntFullBuild(); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("interprojectdeps2", "bin"))); + assertTrue("There should be state for project interprojectdeps1", ajs != null); + checkWasntFullBuild(); + assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + } + + /** + * The C.java file modified in this test has an inner class - it has two ctors but also a reference to C.this in it - which will + * give rise to an accessor being created in C + * + */ + public void testStateManagement5() { + File binDirForInterproject3 = new File(getFile("interprojectdeps3", "bin")); + + initialiseProject("interprojectdeps3"); + build("interprojectdeps3"); // full build + AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirForInterproject3); + assertTrue("There should be state for project interprojectdeps3", ajs != null); + assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + + alter("interprojectdeps3", "inc1"); // minor change to C.java + build("interprojectdeps3"); + checkWasntFullBuild(); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("interprojectdeps3", "bin"))); + assertTrue("There should be state for project interprojectdeps1", ajs != null); + checkWasntFullBuild(); + assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + } + + /** + * Now the most complex test. Create a dependancy between two projects. Building one may affect whether the other does an + * incremental or full build. The structural information recorded in the state object should be getting used to control whether + * a full build is necessary... + */ + public void testBuildingDependantProjects() { + initialiseProject("P1"); + initialiseProject("P2"); + configureNewProjectDependency("P2", "P1"); + + build("P1"); + build("P2"); // now everything is consistent and compiled + alter("P1", "inc1"); // adds a second class + build("P1"); + build("P2"); // although a second class was added - P2 can't be using + // it, so we don't full build here :) + checkWasntFullBuild(); + alter("P1", "inc3"); // structurally changes one of the classes + build("P1"); + build("P2"); // build notices the structural change, but is incremental + // of I and J as they depend on C + checkWasntFullBuild(); + alter("P1", "inc4"); + build("P1"); + build("P2"); // build sees a change but works out its not structural + checkWasntFullBuild(); + } + + public void testPr85132() { + initialiseProject("PR85132"); + build("PR85132"); + alter("PR85132", "inc1"); + build("PR85132"); + } + + // parameterization of generic aspects + public void testPr125405() { + initialiseProject("PR125405"); + build("PR125405"); + checkCompileWeaveCount("PR125405", 1, 1); + alter("PR125405", "inc1"); + build("PR125405"); + // "only abstract aspects can have type parameters" + checkForError("PR125405", "only abstract aspects can have type parameters"); + alter("PR125405", "inc2"); + build("PR125405"); + checkCompileWeaveCount("PR125405", 1, 1); + assertTrue("Should be no errors, but got " + getErrorMessages("PR125405"), getErrorMessages("PR125405").size() == 0); + } + + public void testPr128618() { + initialiseProject("PR128618_1"); + initialiseProject("PR128618_2"); + configureNewProjectDependency("PR128618_2", "PR128618_1"); + assertTrue("there should be no warning messages before we start", getWarningMessages("PR128618_1").isEmpty()); + assertTrue("there should be no warning messages before we start", getWarningMessages("PR128618_2").isEmpty()); + + build("PR128618_1"); + build("PR128618_2"); + List l = getWarningMessages("PR128618_2"); + + // there should be one warning against "PR128618_2" + List warnings = getWarningMessages("PR128618_2"); + assertTrue("Should be one warning, but there are #" + warnings.size(), warnings.size() == 1); + IMessage msg = (getWarningMessages("PR128618_2").get(0)); + assertEquals("warning should be against the FFDC.aj resource", "FFDC.aj", msg.getSourceLocation().getSourceFile().getName()); + + alter("PR128618_2", "inc1"); + build("PR128618_2"); + + checkWasntFullBuild(); + IMessage msg2 = (getWarningMessages("PR128618_2").get(0)); + assertEquals("warning should be against the FFDC.aj resource", "FFDC.aj", msg2.getSourceLocation().getSourceFile() + .getName()); + assertFalse("a new warning message should have been generated", msg.equals(msg2)); + } + + public void testPr92837() { + initialiseProject("PR92837"); + build("PR92837"); + alter("PR92837", "inc1"); + build("PR92837"); + } + + // See open generic itd bug mentioning 119570 + // public void testPr119570() { + // initialiseProject("PR119570"); + // build("PR119570"); + // assertNoErrors("PR119570"); + // } + + // public void testPr119570_212783_2() { + // initialiseProject("PR119570_2"); + // build("PR119570_2"); + // List l = getWarningMessages("PR119570_2"); + // assertTrue("Should be no warnings, but got "+l,l.size()==0); + // assertNoErrors("PR119570_2"); + // } + // + // public void testPr119570_212783_3() { + // initialiseProject("pr119570_3"); + // build("pr119570_3"); + // List l = getWarningMessages("pr119570_3"); + // assertTrue("Should be no warnings, but got "+l,l.size()==0); + // assertNoErrors("pr119570_3"); + // } + + // If you fiddle with the compiler options - you must manually reset the + // options at the end of the test + public void testPr117209() { + try { + initialiseProject("pr117209"); + configureNonStandardCompileOptions("pr117209", "-proceedOnError"); + build("pr117209"); + checkCompileWeaveCount("pr117209", 6, 5); + } finally { + // MyBuildOptionsAdapter.reset(); + } + } + + public void testPr114875() { + // temporary problem with this on linux, think it is a filesystem + // lastmodtime issue + if (System.getProperty("os.name", "").toLowerCase().equals("linux")) { + return; + } + initialiseProject("pr114875"); + build("pr114875"); + alter("pr114875", "inc1"); + build("pr114875"); + checkWasFullBuild(); + alter("pr114875", "inc2"); + build("pr114875"); + checkWasFullBuild(); // back to the source for an aspect change + } + + public void testPr117882() { + // AjdeInteractionTestbed.VERBOSE=true; + // AjdeInteractionTestbed.configureBuildStructureModel(true); + initialiseProject("PR117882"); + build("PR117882"); + checkWasFullBuild(); + alter("PR117882", "inc1"); + build("PR117882"); + // This should be an incremental build now - because of the changes + // under 259649 + checkWasntFullBuild(); // back to the source for an aspect + // AjdeInteractionTestbed.VERBOSE=false; + // AjdeInteractionTestbed.configureBuildStructureModel(false); + } + + public void testPr117882_2() { + // AjdeInteractionTestbed.VERBOSE=true; + // AjdeInteractionTestbed.configureBuildStructureModel(true); + initialiseProject("PR117882_2"); + build("PR117882_2"); + checkWasFullBuild(); + alter("PR117882_2", "inc1"); + build("PR117882_2"); + checkWasFullBuild(); // back to the source... + // checkCompileWeaveCount(1,4); + // fullBuild("PR117882_2"); + // checkWasFullBuild(); + // AjdeInteractionTestbed.VERBOSE=false; + // AjdeInteractionTestbed.configureBuildStructureModel(false); + } + + public void testPr115251() { + // AjdeInteractionTestbed.VERBOSE=true; + initialiseProject("PR115251"); + build("PR115251"); + checkWasFullBuild(); + alter("PR115251", "inc1"); + build("PR115251"); + checkWasFullBuild(); // back to the source + } + + public void testPr220255_InfiniteBuildHasMember() { + initialiseProject("pr220255"); + configureNonStandardCompileOptions("pr220255", "-XhasMember"); + build("pr220255"); + checkWasFullBuild(); + alter("pr220255", "inc1"); + build("pr220255"); + checkWasntFullBuild(); + } + + public void testPr157054() { + initialiseProject("PR157054"); + configureNonStandardCompileOptions("PR157054", "-showWeaveInfo"); + configureShowWeaveInfoMessages("PR157054", true); + build("PR157054"); + checkWasFullBuild(); + List weaveMessages = getWeavingMessages("PR157054"); + assertTrue("Should be two weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 2); + alter("PR157054", "inc1"); + build("PR157054"); + weaveMessages = getWeavingMessages("PR157054"); + assertTrue("Should be three weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 3); + checkWasntFullBuild(); + fullBuild("PR157054"); + weaveMessages = getWeavingMessages("PR157054"); + assertTrue("Should be three weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 3); + } + + /** + * Checks we aren't leaking mungers across compiles (accumulating multiple instances of the same one that all do the same + * thing). On the first compile the munger is added late on - so at the time we set the count it is still zero. On the + * subsequent compiles we know about this extra one. + */ + public void testPr141956_IncrementallyCompilingAtAj() { + initialiseProject("PR141956"); + build("PR141956"); + assertTrue("Should be zero but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 0); + alter("PR141956", "inc1"); + build("PR141956"); + assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + alter("PR141956", "inc1"); + build("PR141956"); + assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + alter("PR141956", "inc1"); + build("PR141956"); + assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + alter("PR141956", "inc1"); + build("PR141956"); + assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + } + + // public void testPr124399() { + // AjdeInteractionTestbed.VERBOSE=true; + // configureBuildStructureModel(true); + // initialiseProject("PR124399"); + // build("PR124399"); + // checkWasFullBuild(); + // alter("PR124399","inc1"); + // build("PR124399"); + // checkWasntFullBuild(); + // } + + public void testPr121384() { + // AjdeInteractionTestbed.VERBOSE=true; + // AsmManager.setReporting("c:/foo.txt",true,true,true,false); + initialiseProject("pr121384"); + configureNonStandardCompileOptions("pr121384", "-showWeaveInfo"); + build("pr121384"); + checkWasFullBuild(); + alter("pr121384", "inc1"); + build("pr121384"); + checkWasntFullBuild(); + } + + /* + * public void testPr111779() { super.VERBOSE=true; initialiseProject("PR111779"); build("PR111779"); alter("PR111779","inc1"); + * build("PR111779"); } + */ + + public void testPr93310_1() { + initialiseProject("PR93310_1"); + build("PR93310_1"); + checkWasFullBuild(); + String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR93310_1" + File.separatorChar + "src" + + File.separatorChar + "pack" + File.separatorChar + "C2.java"; + (new File(fileC2)).delete(); + alter("PR93310_1", "inc1"); + build("PR93310_1"); + checkWasFullBuild(); + int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size(); + assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1); + String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); + assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java")); + } + + public void testPr93310_2() { + initialiseProject("PR93310_2"); + build("PR93310_2"); + checkWasFullBuild(); + String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR93310_2" + File.separatorChar + "src" + + File.separatorChar + "pack" + File.separatorChar + "C2.java"; + (new File(fileC2)).delete(); + alter("PR93310_2", "inc1"); + build("PR93310_2"); + checkWasFullBuild(); + int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size(); + assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1); + String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); + assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java")); + } + + // Stage1: Compile two files, pack.A and pack.A1 - A1 sets a protected field + // in A. + // Stage2: make the field private in class A > gives compile error + // Stage3: Add a new aspect whilst there is a compile error ! + public void testPr113531() { + initialiseProject("PR113531"); + build("PR113531"); + assertTrue("build should have compiled ok", getErrorMessages("PR113531").isEmpty()); + alter("PR113531", "inc1"); + build("PR113531"); + assertEquals("error message should be 'foo cannot be resolved to a variable' ", "foo cannot be resolved to a variable", + (getErrorMessages("PR113531").get(0)).getMessage()); + alter("PR113531", "inc2"); + build("PR113531"); + assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR113531"), + getCompilerErrorMessages("PR113531").isEmpty()); + assertEquals("error message should be 'foo cannot be resolved to a variable' ", "foo cannot be resolved to a variable", + (getErrorMessages("PR113531").get(0)).getMessage()); + } + + // Stage 1: Compile the 4 files, pack.A2 extends pack.A1 (aspects) where + // A2 uses a protected field in A1 and pack.C2 extends pack.C1 (classes) + // where C2 uses a protected field in C1 + // Stage 2: make the field private in class C1 ==> compile errors in C2 + // Stage 3: make the field private in aspect A1 whilst there's the compile + // error. + // There shouldn't be a BCException saying can't find delegate for pack.C2 + public void testPr119882() { + initialiseProject("PR119882"); + build("PR119882"); + assertTrue("build should have compiled ok", getErrorMessages("PR119882").isEmpty()); + alter("PR119882", "inc1"); + build("PR119882"); + // fullBuild("PR119882"); + List errors = getErrorMessages("PR119882"); + assertTrue("Should be at least one error, but got none", errors.size() == 1); + assertEquals("error message should be 'i cannot be resolved to a variable' ", "i cannot be resolved to a variable", + ((IMessage) errors.get(0)).getMessage()); + alter("PR119882", "inc2"); + build("PR119882"); + assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR119882"), + getCompilerErrorMessages("PR119882").isEmpty()); + assertEquals("error message should be 'i cannot be resolved to a variable' ", "i cannot be resolved to a variable", + ((IMessage) errors.get(0)).getMessage()); + + } + + public void testPr112736() { + initialiseProject("PR112736"); + build("PR112736"); + checkWasFullBuild(); + String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR112736" + File.separatorChar + "src" + + File.separatorChar + "pack" + File.separatorChar + "A.java"; + (new File(fileC2)).delete(); + alter("PR112736", "inc1"); + build("PR112736"); + checkWasFullBuild(); + } + + /** + * We have problems with multiple rewrites of a pointcut across incremental builds. + */ + public void testPr113257() { + initialiseProject("PR113257"); + build("PR113257"); + alter("PR113257", "inc1"); + build("PR113257"); + checkWasFullBuild(); // back to the source + alter("PR113257", "inc1"); + build("PR113257"); + } + + public void testPr123612() { + initialiseProject("PR123612"); + build("PR123612"); + alter("PR123612", "inc1"); + build("PR123612"); + checkWasFullBuild(); // back to the source + } + + // Bugzilla Bug 152257 - Incremental compiler doesn't handle exception + // declaration correctly + public void testPr152257() { + initialiseProject("PR152257"); + configureNonStandardCompileOptions("PR152257", "-XnoInline"); + build("PR152257"); + List errors = getErrorMessages("PR152257"); + assertTrue("Should be no warnings, but there are #" + errors.size(), errors.size() == 0); + checkWasFullBuild(); + alter("PR152257", "inc1"); + build("PR152257"); + errors = getErrorMessages("PR152257"); + assertTrue("Should be no warnings, but there are #" + errors.size(), errors.size() == 0); + checkWasntFullBuild(); + } + + public void testPr128655() { + initialiseProject("pr128655"); + configureNonStandardCompileOptions("pr128655", "-showWeaveInfo"); + configureShowWeaveInfoMessages("pr128655", true); + build("pr128655"); + List firstBuildMessages = getWeavingMessages("pr128655"); + assertTrue("Should be at least one message about the dec @type, but there were none", firstBuildMessages.size() > 0); + alter("pr128655", "inc1"); + build("pr128655"); + checkWasntFullBuild(); // back to the source + List secondBuildMessages = getWeavingMessages("pr128655"); + // check they are the same + for (int i = 0; i < firstBuildMessages.size(); i++) { + IMessage m1 = (IMessage) firstBuildMessages.get(i); + IMessage m2 = (IMessage) secondBuildMessages.get(i); + if (!m1.toString().equals(m2.toString())) { + System.err.println("Message during first build was: " + m1); + System.err.println("Message during second build was: " + m1); + fail("The two messages should be the same, but are not: \n" + m1 + "!=" + m2); + } + } + } + + // Similar to above, but now the annotation is in the default package + public void testPr128655_2() { + initialiseProject("pr128655_2"); + configureNonStandardCompileOptions("pr128655_2", "-showWeaveInfo"); + configureShowWeaveInfoMessages("pr128655_2", true); + build("pr128655_2"); + List firstBuildMessages = getWeavingMessages("pr128655_2"); + assertTrue("Should be at least one message about the dec @type, but there were none", firstBuildMessages.size() > 0); + alter("pr128655_2", "inc1"); + build("pr128655_2"); + checkWasntFullBuild(); // back to the source + List secondBuildMessages = getWeavingMessages("pr128655_2"); + // check they are the same + for (int i = 0; i < firstBuildMessages.size(); i++) { + IMessage m1 = (IMessage) firstBuildMessages.get(i); + IMessage m2 = (IMessage) secondBuildMessages.get(i); + if (!m1.toString().equals(m2.toString())) { + System.err.println("Message during first build was: " + m1); + System.err.println("Message during second build was: " + m1); + fail("The two messages should be the same, but are not: \n" + m1 + "!=" + m2); + } + } + } + + // test for comment #31 - NPE + public void testPr129163() { + initialiseProject("PR129613"); + build("PR129613"); + alter("PR129613", "inc1"); + build("PR129613"); + assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR129613"), + getCompilerErrorMessages("PR129613").isEmpty()); + assertEquals("warning message should be 'no match for this type name: File [Xlint:invalidAbsoluteTypeName]' ", + "no match for this type name: File [Xlint:invalidAbsoluteTypeName]", + (getWarningMessages("PR129613").get(0)).getMessage()); + } + + // test for comment #0 - adding a comment to a class file shouldn't + // cause us to go back to source and recompile everything. To force this + // to behave like AJDT we need to include the aspect in 'inc1' so that + // when AjState looks at its timestamp it thinks the aspect has been + // modified. + // The logic within CrosscuttingMembers should then work out correctly + // that there haven't really been any changes within the aspect and so + // we shouldn't go back to source. + public void testPr129163_2() { + // want to behave like AJDT + initialiseProject("pr129163_2"); + build("pr129163_2"); + checkWasFullBuild(); + alter("pr129163_2", "inc1"); + build("pr129163_2"); + checkWasntFullBuild(); // shouldn't be a full build because the + // aspect hasn't changed + } + + public void testIncrementalIntelligence_Scenario01() { + AjdeInteractionTestbed.VERBOSE = true; + initialiseProject("Project1"); + initialiseProject("Project2"); + configureNewProjectDependency("Project2", "Project1"); + build("Project1"); + build("Project2"); + + alter("Project1", "inc1"); // white space change to ClassA - no impact + build("Project1"); + build("Project2"); + checkWasntFullBuild(); // not a structural change so ignored + + alter("Project1", "inc2"); // structural change to ClassB - new method! + build("Project1"); + build("Project2"); + checkWasntFullBuild(); // not a type that Project2 depends on so ignored + + alter("Project1", "inc3"); // structural change to ClassA + build("Project1"); + setNextChangeResponse("Project2", ICompilerConfiguration.EVERYTHING); // See + // pr245566 + // comment + // 3 + build("Project2"); + checkWasntFullBuild(); // Just need to recompile ClassAExtender + checkCompileWeaveCount("Project2", 1, 1); + checkCompiled("Project2", "ClassAExtender"); + + alter("Project2", "inc1"); // New type that depends on ClassAExtender + build("Project1"); + build("Project2"); + checkWasntFullBuild(); // Just build ClassAExtenderExtender + + alter("Project1", "inc4"); // another structural change to ClassA + build("Project1"); + setNextChangeResponse("Project2", ICompilerConfiguration.EVERYTHING); // See + // pr245566 + // comment + // 3 + build("Project2"); + checkWasntFullBuild(); // Should rebuild ClassAExtender and + // ClassAExtenderExtender + checkCompileWeaveCount("Project2", 2, 2); + checkCompiled("Project2", "ClassAExtenderExtender"); + + } + + private void checkCompiled(String projectName, String typeNameSubstring) { + List files = getCompiledFiles(projectName); + boolean found = false; + for (String object: files) { + if (object.indexOf(typeNameSubstring) != -1) { + found = true; + } + } + assertTrue("Did not find '" + typeNameSubstring + "' in list of compiled files", found); + } + + // Case001: renaming a private field in a type + /* + * public void testPrReducingDependentBuilds_001_221427() { AjdeInteractionTestbed.VERBOSE=true; + * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_1"); initialiseProject("P221427_2"); + * configureNewProjectDependency("P221427_2","P221427_1"); + * + * build("P221427_1"); build("P221427_2"); alter("P221427_1","inc1"); // rename private class in super project + * MyStateListener.reset(); build("P221427_1"); build("P221427_2"); + * + * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_1","bin"))); + * assertTrue("There should be state for project P221427_1",ajs!=null); + * //System.out.println(MyStateListener.getInstance().getDecisions()); checkWasntFullBuild(); + * assertTrue("Should be one structural change but there were "+ ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + * ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); + * + * } + * + * // Case002: changing a class to final that is extended in a dependent project public void + * testPrReducingDependentBuilds_002_221427() { AjdeInteractionTestbed.VERBOSE=true; + * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_3"); initialiseProject("P221427_4"); + * configureNewProjectDependency("P221427_4","P221427_3"); + * + * build("P221427_3"); build("P221427_4"); // build OK, type in super project is non-final alter("P221427_3","inc1"); // change + * class declaration in super-project to final MyStateListener.reset(); build("P221427_3"); build("P221427_4"); // build FAIL, + * type in super project is now final + * + * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_3","bin"))); + * assertTrue("There should be state for project P221427_3",ajs!=null); + * System.out.println(MyStateListener.getInstance().getDecisions()); + * + * List errors = getErrorMessages("P221427_4"); if (errors.size()!=1) { if (errors.size()==0) + * fail("Expected error about not being able to extend final class"); for (Iterator iterator = errors.iterator(); + * iterator.hasNext();) { Object object = (Object) iterator.next(); System.out.println(object); } + * fail("Expected 1 error but got "+errors.size()); } // assertTrue("Shouldn't be one structural change but there were "+ // + * ajs.getNumberOfStructuralChangesSinceLastFullBuild(), // ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); + * + * } + */ + // test for comment #6 - simulates AJDT core builder test testBug99133a - + // changing the contents of a method within a class shouldn't force a + // full build of a dependant project. To force this to behave like AJDT + // 'inc1' of the dependant project should just be a copy of 'base' so that + // AjState thinks somethings changed within the dependant project and + // we do a build. Similarly, 'inc1' of the project depended on should + // include the aspect even though nothing's changed within it. This causes + // AjState to think that the aspect has changed. Together its then up to + // logic within CrosscuttingMembers and various equals methods to decide + // correctly that we don't have to go back to source. + public void testPr129163_3() { + initialiseProject("PR129163_4"); + build("PR129163_4"); + checkWasFullBuild(); // should be a full build because initializing + // project + initialiseProject("PR129163_3"); + configureNewProjectDependency("PR129163_3", "PR129163_4"); + build("PR129163_3"); + checkWasFullBuild(); // should be a full build because initializing + // project + alter("PR129163_4", "inc1"); + build("PR129163_4"); + checkWasntFullBuild(); // should be an incremental build because + // although + // "inc1" includes the aspect A1.aj, it actually hasn't + // changed so we shouldn't go back to source + alter("PR129163_3", "inc1"); + build("PR129163_3"); + checkWasntFullBuild(); // should be an incremental build because nothing + // has + // changed within the class and no aspects have changed + // within the running of the test + } + + public void testPr133117() { + // System.gc(); + // System.exit(); + initialiseProject("PR133117"); + configureNonStandardCompileOptions("PR133117", "-Xlint:warning"); + build("PR133117"); + assertTrue("There should only be one xlint warning message reported:\n" + getWarningMessages("PR133117"), + getWarningMessages("PR133117").size() == 1); + alter("PR133117", "inc1"); + build("PR133117"); + List warnings = getWarningMessages("PR133117"); + List noGuardWarnings = new ArrayList<>(); + for (IMessage warning: warnings) { + if (warning.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { + noGuardWarnings.add(warning); + } + } + assertTrue("There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + noGuardWarnings, + noGuardWarnings.size() == 2); + } + + public void testPr131505() { + initialiseProject("PR131505"); + configureNonStandardCompileOptions("PR131505", "-outxml"); + build("PR131505"); + checkWasFullBuild(); + String outputDir = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR131505" + File.separatorChar + "bin"; + // aop.xml file shouldn't contain any aspects + checkXMLAspectCount("PR131505", "", 0, outputDir); + // add a new aspect A which should be included in the aop.xml file + alter("PR131505", "inc1"); + build("PR131505"); + checkWasFullBuild(); + checkXMLAspectCount("PR131505", "", 1, outputDir); + checkXMLAspectCount("PR131505", "A", 1, outputDir); + // make changes to the class file which shouldn't affect the contents + // of the aop.xml file + alter("PR131505", "inc2"); + build("PR131505"); + checkWasntFullBuild(); + checkXMLAspectCount("PR131505", "", 1, outputDir); + checkXMLAspectCount("PR131505", "A", 1, outputDir); + // add another new aspect A1 which should also be included in the + // aop.xml file + // ...there should be no duplicate entries in the file + alter("PR131505", "inc3"); + build("PR131505"); + checkWasFullBuild(); + checkXMLAspectCount("PR131505", "", 2, outputDir); + checkXMLAspectCount("PR131505", "A1", 1, outputDir); + checkXMLAspectCount("PR131505", "A", 1, outputDir); + // delete aspect A1 which meanss that aop.xml file should only contain A + File a1 = new File(getWorkingDir().getAbsolutePath() + File.separatorChar + "PR131505" + File.separatorChar + "A1.aj"); + a1.delete(); + build("PR131505"); + checkWasFullBuild(); + checkXMLAspectCount("PR131505", "", 1, outputDir); + checkXMLAspectCount("PR131505", "A1", 0, outputDir); + checkXMLAspectCount("PR131505", "A", 1, outputDir); + // add another aspect called A which is in a different package, both A + // and pkg.A should be included in the aop.xml file + alter("PR131505", "inc4"); + build("PR131505"); + checkWasFullBuild(); + checkXMLAspectCount("PR131505", "", 2, outputDir); + checkXMLAspectCount("PR131505", "A", 1, outputDir); + checkXMLAspectCount("PR131505", "pkg.A", 1, outputDir); + } + + public void testPr136585() { + initialiseProject("PR136585"); + build("PR136585"); + alter("PR136585", "inc1"); + build("PR136585"); + assertTrue("There should be no errors reported:\n" + getErrorMessages("PR136585"), getErrorMessages("PR136585").isEmpty()); + } + + public void testPr133532() { + initialiseProject("PR133532"); + build("PR133532"); + alter("PR133532", "inc1"); + build("PR133532"); + alter("PR133532", "inc2"); + build("PR133532"); + assertTrue("There should be no errors reported:\n" + getErrorMessages("PR133532"), getErrorMessages("PR133532").isEmpty()); + } + + public void testPr133532_2() { + initialiseProject("pr133532_2"); + build("pr133532_2"); + alter("pr133532_2", "inc2"); + build("pr133532_2"); + assertTrue("There should be no errors reported:\n" + getErrorMessages("pr133532_2"), getErrorMessages("pr133532_2") + .isEmpty()); + String decisions = AjdeInteractionTestbed.MyStateListener.getDecisions(); + String expect = "Need to recompile 'A.aj'"; + assertTrue("Couldn't find build decision: '" + expect + "' in the list of decisions made:\n" + decisions, + decisions.indexOf(expect) != -1); + } + + public void testPr133532_3() { + initialiseProject("PR133532_3"); + build("PR133532_3"); + alter("PR133532_3", "inc1"); + build("PR133532_3"); + assertTrue("There should be no errors reported:\n" + getErrorMessages("PR133532_3"), getErrorMessages("PR133532_3") + .isEmpty()); + } + + public void testPr134541() { + initialiseProject("PR134541"); + build("PR134541"); + assertEquals("[Xlint:adviceDidNotMatch] should be associated with line 5", 5, (getWarningMessages("PR134541").get(0)) + .getSourceLocation().getLine()); + alter("PR134541", "inc1"); + build("PR134541"); + // if (getModelFor("PR134541").getHandleProvider().dependsOnLocation()) + // checkWasFullBuild(); // the line number has changed... but nothing + // // structural about the code + // else + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code + assertEquals("[Xlint:adviceDidNotMatch] should now be associated with line 7", 7, (getWarningMessages("PR134541").get(0)) + .getSourceLocation().getLine()); + } + + public void testJDTLikeHandleProviderWithLstFile_pr141730() { + // IElementHandleProvider handleProvider = + // AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new + // JDTLikeHandleProvider()); + // try { + // The JDTLike-handles should start with the name + // of the buildconfig file + initialiseProject("JDTLikeHandleProvider"); + build("JDTLikeHandleProvider"); + IHierarchy top = getModelFor("JDTLikeHandleProvider").getHierarchy(); + IProgramElement pe = top.findElementForType("pkg", "A"); + String expectedHandle = "=JDTLikeHandleProvider"); + // add a line which shouldn't change the handle + alter("JDTLikeHandleProvider", "inc1"); + build("JDTLikeHandleProvider"); + checkWasntFullBuild(); + IHierarchy top2 = getModelFor("JDTLikeHandleProvider").getHierarchy(); + IProgramElement pe2 = top + .findElementForLabel(top2.getRoot(), IProgramElement.Kind.ADVICE, "before(): "); + assertEquals("expected advice to be on line " + pe.getSourceLocation().getLine() + 1 + " but was on " + + pe2.getSourceLocation().getLine(), pe.getSourceLocation().getLine() + 1, pe2.getSourceLocation().getLine()); + assertEquals( + "expected advice to have handle " + pe.getHandleIdentifier() + " but found handle " + pe2.getHandleIdentifier(), + pe.getHandleIdentifier(), pe2.getHandleIdentifier()); + // } finally { + // AsmManager.getDefault().setHandleProvider(handleProvider); + // } + } + + public void testSwappingAdviceAndHandles_pr141730() { + // IElementHandleProvider handleProvider = + // AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new + // JDTLikeHandleProvider()); + // try { + initialiseProject("JDTLikeHandleProvider"); + build("JDTLikeHandleProvider"); + IHierarchy top = getModelFor("JDTLikeHandleProvider").getHierarchy(); + + IProgramElement call = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "after(): callPCD.."); + IProgramElement exec = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "after(): execPCD.."); + // swap the two after advice statements over. This forces + // a full build which means 'after(): callPCD..' will now + // be the second after advice in the file and have the same + // handle as 'after(): execPCD..' originally did. + alter("JDTLikeHandleProvider", "inc2"); + build("JDTLikeHandleProvider"); + checkWasFullBuild(); + + IHierarchy top2 = getModelFor("JDTLikeHandleProvider").getHierarchy(); + IProgramElement newCall = top2.findElementForLabel(top2.getRoot(), IProgramElement.Kind.ADVICE, "after(): callPCD.."); + IProgramElement newExec = top2.findElementForLabel(top2.getRoot(), IProgramElement.Kind.ADVICE, "after(): execPCD.."); + + assertEquals("after swapping places, expected 'after(): callPCD..' " + "to be on line " + + newExec.getSourceLocation().getLine() + " but was on line " + call.getSourceLocation().getLine(), newExec + .getSourceLocation().getLine(), call.getSourceLocation().getLine()); + assertEquals("after swapping places, expected 'after(): callPCD..' " + "to have handle " + exec.getHandleIdentifier() + + " (because was full build) but had " + newCall.getHandleIdentifier(), exec.getHandleIdentifier(), + newCall.getHandleIdentifier()); + // } finally { + // AsmManager.getDefault().setHandleProvider(handleProvider); + // } + } + + public void testInitializerCountForJDTLikeHandleProvider_pr141730() { + // IElementHandleProvider handleProvider = + // AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new + // JDTLikeHandleProvider()); + // try { + initialiseProject("JDTLikeHandleProvider"); + build("JDTLikeHandleProvider"); + String expected = "=JDTLikeHandleProvider relatedElements = getRelatedElements(model, nodeForAdvice, 1); + + // Step3. Check the advice applying at the first 'code' join point + // in pkg.C is from aspect pkg.A, line 7 + IProgramElement programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true))); + int line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + + // Step4. Simulate the aspect being saved but with no change at all + // in it + alter("PR134471", "inc1"); + build("PR134471"); + model = getModelFor("PR134471"); + + // Step5. Quick check that the advice points to something... + nodeForTypeA = checkForNode(model, "pkg", "A", true); + nodeForAdvice = findAdvice(nodeForTypeA); + relatedElements = getRelatedElements(model, nodeForAdvice, 1); + + // Step6. Check the advice applying at the first 'code' join point + // in pkg.C is from aspect pkg.A, line 7 + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true))); + line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + } finally { + // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true; + } + } + + // now the advice moves down a few lines - hopefully the model will + // notice... see discussion in 134471 + public void testPr134471_MovingAdvice() { + + // Step1. build the project + initialiseProject("PR134471_2"); + configureNonStandardCompileOptions("PR134471_2", "-showWeaveInfo -emacssym"); + configureShowWeaveInfoMessages("PR134471_2", true); + build("PR134471_2"); + AsmManager model = getModelFor("PR134471_2"); + // Step2. confirm advice is from correct location + IProgramElement programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true))); + int line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + + // Step3. No structural change to the aspect but the advice has moved + // down a few lines... (change in source location) + alter("PR134471_2", "inc1"); + build("PR134471_2"); + model = getModelFor("PR134471_2"); + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code + + // checkWasFullBuild(); // this is true whilst we consider + // sourcelocation in the type/shadow munger equals() method - have + // to until the handles are independent of location + + // Step4. Check we have correctly realised the advice moved to line 11 + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true))); + line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 11 - but is at line " + line, line == 11); + } + + public void testAddingAndRemovingDecwWithStructureModel() { + initialiseProject("P3"); + build("P3"); + alter("P3", "inc1"); + build("P3"); + assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("P3"), getCompilerErrorMessages("P3") + .isEmpty()); + alter("P3", "inc2"); + build("P3"); + assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("P3"), getCompilerErrorMessages("P3") + .isEmpty()); + } + + // same as first test with an extra stage that asks for C to be recompiled, + // it should still be advised... + public void testPr134471_IncrementallyRecompilingTheAffectedClass() { + try { + // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; + // Step1. build the project + initialiseProject("PR134471"); + configureNonStandardCompileOptions("PR134471", "-showWeaveInfo -emacssym"); + configureShowWeaveInfoMessages("PR134471", true); + build("PR134471"); + AsmManager model = getModelFor("PR134471"); + // Step2. confirm advice is from correct location + IProgramElement programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true))); + int line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + + // Step3. No change to the aspect at all + alter("PR134471", "inc1"); + build("PR134471"); + model = getModelFor("PR134471"); + // Step4. Quick check that the advice points to something... + IProgramElement nodeForTypeA = checkForNode(model, "pkg", "A", true); + IProgramElement nodeForAdvice = findAdvice(nodeForTypeA); + List relatedElements = getRelatedElements(model, nodeForAdvice, 1); + + // Step5. No change to the file C but it should still be advised + // afterwards + alter("PR134471", "inc2"); + build("PR134471"); + checkWasntFullBuild(); + model = getModelFor("PR134471"); + + // Step6. confirm advice is from correct location + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true))); + line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + } finally { + // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true; + } + + } + + // similar to previous test but with 'declare warning' as well as advice + public void testPr134471_IncrementallyRecompilingAspectContainingDeclare() { + + // Step1. build the project + initialiseProject("PR134471_3"); + configureNonStandardCompileOptions("PR134471_3", "-showWeaveInfo -emacssym"); + configureShowWeaveInfoMessages("PR134471_3", true); + build("PR134471_3"); + checkWasFullBuild(); + + AsmManager model = getModelFor("PR134471_3"); + // Step2. confirm declare warning is from correct location, decw matches + // line 7 in pkg.C + IProgramElement programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + int line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 10 - but is at line " + line, line == 10); + + // Step3. confirm advice is from correct location, advice matches line 6 + // in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 6)); + line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + + // Step4. Move declare warning in the aspect + alter("PR134471_3", "inc1"); + build("PR134471_3"); + model = getModelFor("PR134471_3"); + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code + + // checkWasFullBuild(); + + // Step5. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + + // Step6. Now just simulate 'resave' of the aspect, nothing has changed + alter("PR134471_3", "inc2"); + build("PR134471_3"); + checkWasntFullBuild(); + model = getModelFor("PR134471_3"); + // Step7. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + } + + // similar to previous test but with 'declare warning' as well as advice + public void testPr134471_IncrementallyRecompilingTheClassAffectedByDeclare() { + + // Step1. build the project + initialiseProject("PR134471_3"); + configureNonStandardCompileOptions("PR134471_3", "-showWeaveInfo -emacssym"); + configureShowWeaveInfoMessages("PR134471_3", true); + build("PR134471_3"); + checkWasFullBuild(); + AsmManager model = getModelFor("PR134471_3"); + // Step2. confirm declare warning is from correct location, decw matches + // line 7 in pkg.C + IProgramElement programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + int line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 10 - but is at line " + line, line == 10); + + // Step3. confirm advice is from correct location, advice matches line 6 + // in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 6)); + line = programElement.getSourceLocation().getLine(); + assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + + // Step4. Move declare warning in the aspect + alter("PR134471_3", "inc1"); + build("PR134471_3"); + model = getModelFor("PR134471_3"); + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code + + // checkWasFullBuild(); + + // Step5. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + + // Step6. Now just simulate 'resave' of the aspect, nothing has changed + alter("PR134471_3", "inc2"); + build("PR134471_3"); + checkWasntFullBuild(); + model = getModelFor("PR134471_3"); + // Step7. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + + // Step8. Now just simulate resave of the pkg.C type - no change at + // all... are relationships gonna be repaired OK? + alter("PR134471_3", "inc3"); + build("PR134471_3"); + checkWasntFullBuild(); + + // Step9. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(model, findCode(checkForNode(model, "pkg", "C", true), 7)); + line = programElement.getSourceLocation().getLine(); + assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + } + + public void testDontLoseXlintWarnings_pr141556() { + initialiseProject("PR141556"); + configureNonStandardCompileOptions("PR141556", "-Xlint:warning"); + build("PR141556"); + checkWasFullBuild(); + String warningMessage = "can not build thisJoinPoint " + "lazily for this advice since it has no suitable guard " + + "[Xlint:noGuardForLazyTjp]"; + assertEquals("warning message should be '" + warningMessage + "'", warningMessage, + (getWarningMessages("PR141556").get(0)).getMessage()); + + // add a space to the Aspect but dont do a build + alter("PR141556", "inc1"); + // remove the space so that the Aspect is exactly as it was + alter("PR141556", "inc2"); + // build the project and we should not have lost the xlint warning + build("PR141556"); + checkWasntFullBuild(); + assertTrue("there should still be a warning message ", !getWarningMessages("PR141556").isEmpty()); + assertEquals("warning message should be '" + warningMessage + "'", warningMessage, + (getWarningMessages("PR141556").get(0)).getMessage()); + } + + public void testAdviceDidNotMatch_pr152589() { + initialiseProject("PR152589"); + build("PR152589"); + List warnings = getWarningMessages("PR152589"); + assertTrue("There should be no warnings:\n" + warnings, warnings.isEmpty()); + alter("PR152589", "inc1"); + build("PR152589"); + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code + + // checkWasFullBuild(); + warnings = getWarningMessages("PR152589"); + assertTrue("There should be no warnings after adding a whitespace:\n" + warnings, warnings.isEmpty()); + } + + // see comment #11 of bug 154054 + public void testNoFullBuildOnChangeInSysOutInAdviceBody_pr154054() { + initialiseProject("PR154054"); + build("PR154054"); + alter("PR154054", "inc1"); + build("PR154054"); + checkWasntFullBuild(); + } + + public void testIncrementalBuildAdviceChange_456801() throws Exception { + initialiseProject("456801"); + build("456801"); + String output = runMethod("456801", "Code", "run"); + assertEquals("advice runnning\nrun() running\n",output); + alter("456801", "inc1"); + build("456801"); + output = runMethod("456801", "Code", "run"); + assertEquals("advice running\nrun() running\n",output); + checkCompileWeaveCount("456801", 1, 1); + checkWasntFullBuild(); + } + + // change exception type in around advice, does it notice? + public void testShouldFullBuildOnExceptionChange_pr154054() { + initialiseProject("PR154054_2"); + build("PR154054_2"); + alter("PR154054_2", "inc1"); + build("PR154054_2"); + checkWasFullBuild(); + } + + public void testPR158573() { + // IElementHandleProvider handleProvider = + // AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new + // JDTLikeHandleProvider()); + initialiseProject("PR158573"); + build("PR158573"); + List warnings = getWarningMessages("PR158573"); + assertTrue("There should be no warnings:\n" + warnings, warnings.isEmpty()); + alter("PR158573", "inc1"); + build("PR158573"); + + checkWasntFullBuild(); + warnings = getWarningMessages("PR158573"); + assertTrue("There should be no warnings after changing the value of a " + "variable:\n" + warnings, warnings.isEmpty()); + // AsmManager.getDefault().setHandleProvider(handleProvider); + } + + /** + * If the user has specified that they want Java 6 compliance and kept the default classfile and source file level settings + * (also 6.0) then expect an error saying that we don't support java 6. + */ + public void testPR164384_1() { + initialiseProject("PR164384"); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); + configureJavaOptionsMap("PR164384", javaOptions); + + build("PR164384"); + List errors = getErrorMessages("PR164384"); + + if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { + assertTrue("There should be no errors:\n" + errors, errors.isEmpty()); + } else { + String expectedError = "Java 6.0 compliance level is unsupported"; + String found = ((IMessage) errors.get(0)).getMessage(); + assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, + expectedError, found); + // This is because the 'Java 6.0 compliance' error is an 'error' + // rather than an 'abort'. Aborts are really for compiler + // exceptions. + assertTrue("expected there to be more than the one compliance level" + " error but only found that one", + errors.size() > 1); + } + + } + + /** + * If the user has specified that they want Java 6 compliance and selected classfile and source file level settings to be 5.0 + * then expect an error saying that we don't support java 6. + */ + public void testPR164384_2() { + initialiseProject("PR164384"); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.5"); + configureJavaOptionsMap("PR164384", javaOptions); + + build("PR164384"); + List errors = getErrorMessages("PR164384"); + if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { + assertTrue("There should be no errors:\n" + errors, errors.isEmpty()); + } else { + String expectedError = "Java 6.0 compliance level is unsupported"; + String found = ((IMessage) errors.get(0)).getMessage(); + assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, + expectedError, found); + // This is because the 'Java 6.0 compliance' error is an 'error' + // rather than an 'abort'. Aborts are really for compiler + // exceptions. + assertTrue("expected there to be more than the one compliance level" + " error but only found that one", + errors.size() > 1); + } + } + + /** + * If the user has specified that they want Java 6 compliance and set the classfile level to be 6.0 and source file level to be + * 5.0 then expect an error saying that we don't support java 6. + */ + public void testPR164384_3() { + initialiseProject("PR164384"); + + Hashtable javaOptions = new Hashtable(); + javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.5"); + configureJavaOptionsMap("PR164384", javaOptions); + + build("PR164384"); + List errors = getErrorMessages("PR164384"); + + if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { + assertTrue("There should be no errros:\n" + errors, errors.isEmpty()); + } else { + String expectedError = "Java 6.0 compliance level is unsupported"; + String found = ((IMessage) errors.get(0)).getMessage(); + assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, + expectedError, found); + // This is because the 'Java 6.0 compliance' error is an 'error' + // rather than an 'abort'. Aborts are really for compiler + // exceptions. + assertTrue("expected there to be more than the one compliance level" + " error but only found that one", + errors.size() > 1); + } + } + + public void testPr168840() throws Exception { + initialiseProject("inpathTesting"); + + String inpathTestingDir = getWorkingDir() + File.separator + "inpathTesting"; + String inpathDir = inpathTestingDir + File.separator + "injarBin" + File.separator + "pkg"; + String expectedOutputDir = inpathTestingDir + File.separator + "bin"; + + // set up the inpath to have the directory on it's path + File f = new File(inpathDir); + Set s = new HashSet(); + s.add(f); + configureInPath("inpathTesting", s); + build("inpathTesting"); + // the declare warning matches one place so expect one warning message + List warnings = getWarningMessages("inpathTesting"); + assertTrue("Expected there to be one warning message but found " + warnings.size() + ": " + warnings, warnings.size() == 1); + + // copy over the updated version of the inpath class file + File from = new File(testdataSrcDir + File.separatorChar + "inpathTesting" + File.separatorChar + "newInpathClass" + + File.separatorChar + "InpathClass.class"); + File destination = new File(inpathDir + File.separatorChar + "InpathClass.class"); + FileUtil.copyFile(from, destination); + + build("inpathTesting"); + checkWasntFullBuild(); + // the newly copied inpath class means the declare warning now matches + // two + // places, therefore expect two warning messages + warnings = getWarningMessages("inpathTesting"); + assertTrue("Expected there to be two warning message but found " + warnings.size() + ": " + warnings, warnings.size() == 2); + } + + // warning about cant change parents of Object is fine + public void testInpathHandles_271201() throws Exception { + AjdeInteractionTestbed.VERBOSE = true; + String p = "inpathHandles"; + initialiseProject(p); + + String inpathTestingDir = getWorkingDir() + File.separator + "inpathHandles"; + String inpathDir = inpathTestingDir + File.separator + "binpath"; + + // set up the inpath to have the directory on it's path + System.out.println(inpathDir); + File f = new File(inpathDir); + Set s = new HashSet(); + s.add(f); + configureInPath(p, s); + build(p); + + IProgramElement root = getModelFor(p).getHierarchy().getRoot(); + + // alter(p,"inc1"); + // build(p); + dumptree(root, 0); + PrintWriter pw = new PrintWriter(System.out); + try { + getModelFor(p).dumprels(pw); + pw.flush(); + } catch (Exception e) { + } + List l = getModelFor(p).getRelationshipMap().get("=inpathHandles/; s = new HashSet(); + s.add(f); + configureInPath(p, s); + + // This build will weave a declare parents into the inpath class codep.Code + build(p); + assertNotNull(getModelFor(p).getRelationshipMap().get("=inpathHandles/; s = new HashSet(); + s.add(f); + Map m = new HashMap(); + m.put(f, "wibble"); + configureOutputLocationManager(p, new TestOutputLocationManager(getProjectRelativePath(p, ".").toString(), m)); + + configureInPath(p, s); + build(p); + + IProgramElement root = getModelFor(p).getHierarchy().getRoot(); + + // alter(p,"inc1"); + // build(p); + dumptree(root, 0); + PrintWriter pw = new PrintWriter(System.out); + try { + getModelFor(p).dumprels(pw); + pw.flush(); + } catch (Exception e) { + } + List l = getModelFor(p).getRelationshipMap().get("=inpathHandles/;wibble getRelatedElements(AsmManager model, IProgramElement programElement, int expected) { + List relatedElements = getRelatedElements(model, programElement); + StringBuffer debugString = new StringBuffer(); + if (relatedElements != null) { + for (String element : relatedElements) { + debugString.append(model.getHierarchy().findElementForHandle(element).toLabelString()).append("\n"); + } + } + assertTrue("Should be " + expected + " element" + (expected > 1 ? "s" : "") + " related to this one '" + programElement + + "' but found :\n " + debugString, relatedElements != null && relatedElements.size() == 1); + return relatedElements; + } + + private IProgramElement getFirstRelatedElement(AsmManager model, IProgramElement programElement) { + List rels = getRelatedElements(model, programElement, 1); + return model.getHierarchy().findElementForHandle((String) rels.get(0)); + } + + private List getRelatedElements(AsmManager model, IProgramElement advice) { + List output = null; + IRelationshipMap map = model.getRelationshipMap(); + List rels = map.get(advice); + if (rels == null) { + fail("Did not find any related elements!"); + } + for (Iterator iter = rels.iterator(); iter.hasNext();) { + IRelationship element = iter.next(); + List targets = element.getTargets(); + if (output == null) { + output = new ArrayList(); + } + output.addAll(targets); + } + return output; + } + + private IProgramElement findAdvice(IProgramElement ipe) { + return findAdvice(ipe, 1); + } + + private IProgramElement findAdvice(IProgramElement ipe, int whichOne) { + if (ipe.getKind() == IProgramElement.Kind.ADVICE) { + whichOne = whichOne - 1; + if (whichOne == 0) { + return ipe; + } + } + List kids = ipe.getChildren(); + for (IProgramElement kid: kids) { + IProgramElement found = findAdvice(kid, whichOne); + if (found != null) { + return found; + } + } + return null; + } + + /** + * Finds the first 'code' program element below the element supplied - will return null if there aren't any + */ + private IProgramElement findCode(IProgramElement ipe) { + return findCode(ipe, -1); + } + + /** + * Searches a hierarchy of program elements for a 'code' element at the specified line number, a line number of -1 means just + * return the first one you find + */ + private IProgramElement findCode(IProgramElement ipe, int linenumber) { + if (ipe.getKind() == IProgramElement.Kind.CODE) { + if (linenumber == -1 || ipe.getSourceLocation().getLine() == linenumber) { + return ipe; + } + } + List kids = ipe.getChildren(); + for (IProgramElement kid: kids) { + IProgramElement found = findCode(kid, linenumber); + if (found != null) { + return found; + } + } + return null; + } + + // other possible tests: + // - memory usage (freemem calls?) + // - relationship map + + // -------------------------------------------------------------------------- + // ------------------------- + + private IProgramElement checkForNode(AsmManager model, String packageName, String typeName, boolean shouldBeFound) { + IProgramElement ipe = model.getHierarchy().findElementForType(packageName, typeName); + if (shouldBeFound) { + if (ipe == null) { + printModel(model); + } + assertTrue("Should have been able to find '" + packageName + "." + typeName + "' in the asm", ipe != null); + } else { + if (ipe != null) { + printModel(model); + } + assertTrue("Should have NOT been able to find '" + packageName + "." + typeName + "' in the asm", ipe == null); + } + return ipe; + } + + private void printModel(AsmManager model) { + try { + AsmManager.dumptree(model.getHierarchy().getRoot(), 0); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void log(String msg) { + if (VERBOSE) { + System.out.println(msg); + } + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java new file mode 100644 index 000000000..333495399 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java @@ -0,0 +1,165 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Adrian Colyer initial implementation + * Helen Hawkins Converted to new interface (bug 148190) + *******************************************************************/ +package org.aspectj.systemtest.incremental.tools; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.aspectj.ajde.core.IOutputLocationManager; + +/** + * Test the OutputLocationManager support used to enable multiple output folders. These aren't true "multi-project incremental" + * tests, but that superclass has some handy methods over and above AjdeInteractionTestCase that I want to use. + */ +public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { + + private static final String PROJECT_NAME = "MultipleOutputFolders"; + private MyOutputLocationManager outputLocationManager; + + protected void setUp() throws Exception { + super.setUp(); + initialiseProject(PROJECT_NAME); + this.outputLocationManager = new MyOutputLocationManager(new File(getFile(PROJECT_NAME, ""))); + configureOutputLocationManager(PROJECT_NAME, this.outputLocationManager); + } + + public void testDefaultOutputLocationUsedWhenNoOutputLocationManager() { + configureOutputLocationManager(PROJECT_NAME, null); + build(PROJECT_NAME); + assertFileExists(PROJECT_NAME, "bin/a/A.class"); + assertFileExists(PROJECT_NAME, "bin/b/B.class"); + } + + public void testTwoSourceRootsWithSeparateOutputLocations() { + build(PROJECT_NAME); + assertFileExists(PROJECT_NAME, "target/main/classes/a/A.class"); + assertFileExists(PROJECT_NAME, "target/test/classes/b/B.class"); + } + + public void testResourceCopying() { + Map resourceMap = new HashMap<>(); + resourceMap.put("resourceOne.txt", new File(getFile(PROJECT_NAME, "srcRootOne/resourceOne.txt"))); + resourceMap.put("resourceTwo.txt", new File(getFile(PROJECT_NAME, "srcRootTwo/resourceTwo.txt"))); + configureResourceMap(PROJECT_NAME, resourceMap); + build(PROJECT_NAME); + assertFileExists(PROJECT_NAME, "target/main/classes/resourceOne.txt"); + assertFileExists(PROJECT_NAME, "target/test/classes/resourceTwo.txt"); + } + + public void testGeneratedClassesPlacedInAppropriateOutputFolder() { + configureNonStandardCompileOptions(PROJECT_NAME, "-XnoInline"); + build(PROJECT_NAME); + assertFileExists(PROJECT_NAME, "target/main/classes/a/A.class"); + assertFileExists(PROJECT_NAME, "target/main/classes/a/A$AjcClosure1.class"); + } + + /** + * Tests the case when we have two aspects, each of which are sent to a different output location. There should be an aop.xml + * file in each of the two output directories. + */ + public void testOutXmlForAspectsWithDifferentOutputDirs() { + configureNonStandardCompileOptions(PROJECT_NAME, "-outxml"); + build(PROJECT_NAME); + assertFileExists(PROJECT_NAME, "target/main/classes/META-INF/aop-ajc.xml"); + assertFileExists(PROJECT_NAME, "target/test/classes/META-INF/aop-ajc.xml"); + // aop.xml file should exist even if there aren't any aspects (mirrors + // what happens when there's one output dir) + checkXMLAspectCount(PROJECT_NAME, "", 0, getFile(PROJECT_NAME, "target/anotherTest/classes")); + // add aspects to the srcRootThree src dir and they should appear in the + // corresponding aop.xml file + alter(PROJECT_NAME, "inc1"); + build(PROJECT_NAME); + checkXMLAspectCount(PROJECT_NAME, "c.C$AnAspect", 1, getFile(PROJECT_NAME, "target/anotherTest/classes")); + } + + protected void assertFileExists(String project, String relativePath) { + assertTrue("file " + relativePath + " should have been created as a result of building " + project, new File(getFile( + project, relativePath)).exists()); + } + + private static class MyOutputLocationManager implements IOutputLocationManager { + + private File projectHome; + private List allOutputDirs; + + public MyOutputLocationManager(File projectHome) { + this.projectHome = projectHome; + + } + + public void reportFileWrite(String outputfile, int filetype) { + } + + public void reportFileRemove(String outputfile, int filetype) { + } + + public Map getInpathMap() { + return Collections.emptyMap(); + } + + + public File getOutputLocationForClass(File compilationUnit) { + String relativePath = ""; + String compilationUnitName = compilationUnit.getAbsolutePath(); + if (compilationUnitName.indexOf("srcRootOne") != -1) { + relativePath = "target/main/classes"; + } else if (compilationUnitName.indexOf("srcRootTwo") != -1) { + relativePath = "target/test/classes"; + } else if (compilationUnitName.indexOf("srcRootThree") != -1) { + relativePath = "target/anotherTest/classes"; + } + File ret = new File(projectHome, relativePath); + if (!ret.exists()) { + ret.mkdirs(); + } + return ret; + } + + public File getOutputLocationForResource(File resource) { + return getOutputLocationForClass(resource); + } + + public List getAllOutputLocations() { + if (allOutputDirs == null) { + allOutputDirs = new ArrayList<>(); + allOutputDirs.add(new File(projectHome, "target/main/classes")); + allOutputDirs.add(new File(projectHome, "target/test/classes")); + allOutputDirs.add(new File(projectHome, "target/anotherTest/classes")); + } + return allOutputDirs; + } + + public File getDefaultOutputLocation() { + return new File(projectHome, "target/main/classes"); + } + + public String getSourceFolderForFile(File sourceFile) { + return null; + } + + public int discoverChangesSince(File dir, long buildtime) { + // TODO Auto-generated method stub + return 0; + } + } + + public void reportFileWrite(String outputfile, int filetype) { + } + + public void reportFileRemove(String outputfile, int filetype) { + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/inpath/InPathTests.java b/tests/src/test/java/org/aspectj/systemtest/inpath/InPathTests.java new file mode 100644 index 000000000..ec2fd8d7b --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/inpath/InPathTests.java @@ -0,0 +1,97 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.inpath; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class InPathTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(InPathTests.class); + } + + protected File getSpecFile() { + return getClassResource("inpath.xml"); + } + + + public void test001(){ + runTest("source for options -injars"); + } + + public void test002(){ + runTest("options -injars"); + } + + public void test003(){ + runTest("options -injars checking declare parents interactions"); + } + +// test removed from suite since aspects are *always* generated reweavable +// public void test004(){ +// runTest("The compiler crashes when using aspect libraries created without using -terminateAfterCompilation"); +// } + + public void test005(){ + runTest("declare warnings on main"); + } + + public void test006(){ + runTest("declare warnings on binary javac 1.4 classes"); + } + + public void test007(){ + runTest("declare warnings on binary ajc 1.1 classes"); + } + + public void test008(){ + runTest("Weaving rt.jar results in stack overflow"); + } + + public void test009(){ + runTest("Weaving failure when using injars (no jars)"); + } + + public void test010(){ + runTest("Weaving failure when using injars (on aspectpath)"); + } + + public void test011(){ + runTest("Weaving failure when using injars (on classpath)"); + } + + public void test012(){ + runTest("Weaving failure when using injars (actual injars)"); + } + + public void test013(){ + runTest("Introduced abstract method on interface not implemented by subtype (injars)"); + } + + public void test014(){ + runTest("error Type mismatch: cannot convert from java.lang.String to java.lang.String"); + } + + public void test015(){ + runTest("declare error binary-weaving NPE"); + } + + public void test016(){ + runTest("declare error binary-weaving NPE"); + } + + public void test017(){ + runTest("Regression from 1.1: NPE in CompilationResult"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/inpath/inpath-tests.xml b/tests/src/test/java/org/aspectj/systemtest/inpath/inpath-tests.xml new file mode 100644 index 000000000..46fe869c1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/inpath/inpath-tests.xml @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/inpath/inpath.xml b/tests/src/test/java/org/aspectj/systemtest/inpath/inpath.xml new file mode 100644 index 000000000..2c0eac4c7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/inpath/inpath.xml @@ -0,0 +1,11 @@ + +]> + + + + + +&tests; + + diff --git a/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java b/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java new file mode 100644 index 000000000..d71b2ba4f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java @@ -0,0 +1,127 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.java14; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.LangUtil; + +public class Java14Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Java14Tests.class); + } + + protected File getSpecFile() { + return getClassResource("java14.xml"); + } + + + public void test001(){ + runTest("assert flow"); + } + + public void test002(){ + runTest("assert flow - 2"); + } + + public void test003(){ + runTest("assert typing"); + } + +// bug in eclipse compiler, moved to ajcTestsFailing.xml +// public void test004(){ +// runTest("assert coverage tests [requires 1.4]"); +// } + +// bug in eclipse compiler, moved to ajcTestsFailing.xml +// public void test005(){ +// runTest("assert coverage tests in one package [requires 1.4]"); +// } + + public void test006(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 006 not >=1.4");return;} + runTest("compiling asserts in methods"); + } + + public void test007(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 007 not >=1.4");return;} + runTest("asserts"); + } + + public void test008(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 008 not >=1.4");return;} + runTest("asserts in aspect and declared methods [requires 1.4]"); + } + + public void test009(){ + runTest("Does the matrix coverage thing for the new method signatures"); + } + + public void test010(){ + runTest("correct types of parameters at call-sites"); + } + + public void test011(){ + runTest("target type matching with messy interface hierarchies"); + } + + public void test012(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 012 not >=1.4");return;} + runTest("assert tests in introduction [requires 1.4]"); + } + + public void test013(){ + runTest("various forms of package name pattern matching work"); + } + + public void test014(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 014 not >=1.4");return;} + runTest("assert statement in advice coverage [requires 1.4]"); + } + + public void test015(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 015 not >=1.4");return;} + runTest("assert statement in advice [requires 1.4]"); + } + + public void test016(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 016 not >=1.4");return;} + runTest("assert and pertarget crashes compiler"); + } + + public void test017(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 017 not >=1.4");return;} + runTest("testing that assert works like .class"); + } + + public void test018(){ + runTest("JoinPoint Optimization when targetting 1.4"); + } + + public void test019(){ + runTest("XLint warning for call PCD's using subtype of defining type (-1.4 -Xlint:ignore)"); + } + + // public void test020(){ + // runTest("XLint warning for call PCD's using subtype of defining type (-1.4)"); + // } + + public void test021(){ + if (!LangUtil.is14VMOrGreater()) { System.err.println("Skipping test 021 not >=1.4");return;} + runTest("Class Literals as non final fields (also assert, and this$0)"); + } + + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/java14/java14-tests.xml b/tests/src/test/java/org/aspectj/systemtest/java14/java14-tests.xml new file mode 100644 index 000000000..364c28e4f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/java14/java14-tests.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/java14/java14.xml b/tests/src/test/java/org/aspectj/systemtest/java14/java14.xml new file mode 100644 index 000000000..c25b999cf --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/java14/java14.xml @@ -0,0 +1,11 @@ + +]> + + + + + +&tests; + + diff --git a/tests/src/test/java/org/aspectj/systemtest/knownfailures/KnownfailuresTests.java b/tests/src/test/java/org/aspectj/systemtest/knownfailures/KnownfailuresTests.java new file mode 100644 index 000000000..52a626545 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/knownfailures/KnownfailuresTests.java @@ -0,0 +1,37 @@ +/* ******************************************************************* +* Copyright (c) 2005 Contributors +* 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: +* Andrew Huff initial implementation +* ******************************************************************/ +package org.aspectj.systemtest.knownfailures; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class KnownfailuresTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(KnownfailuresTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/knownfailures/knownfailures.xml"); + } + + + public void test001(){ + runTest("NullPointerException in jdt when using generics and inpath"); + // the NPE goes away if you don't use generics + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/knownfailures/knownfailures.xml b/tests/src/test/java/org/aspectj/systemtest/knownfailures/knownfailures.xml new file mode 100644 index 000000000..e2e2343dc --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/knownfailures/knownfailures.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/knownlimitations/KnownLimitationsTests.java b/tests/src/test/java/org/aspectj/systemtest/knownlimitations/KnownLimitationsTests.java new file mode 100644 index 000000000..556c66f1e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/knownlimitations/KnownLimitationsTests.java @@ -0,0 +1,144 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.knownlimitations; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class KnownLimitationsTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(KnownLimitationsTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/knownlimitations/knownlimitations.xml"); + } + + + public void test001(){ + runTest("DEPRECATED: introduce of variables"); + } + + public void test002(){ + runTest("checking the contra-variant errors for typing of proceed"); + } + + public void test003(){ + runTest("introduction of static methods and fields on classes and interfaces"); + } + + public void test004(){ + runTest("advice on catch clauses"); + } + + public void test005(){ + runTest("holding onto proceed calls in a closure-like way"); + } + + public void test006(){ + runTest("PR#458 Compiler was incorrectly flagging error in advice on initialization and static initialization"); + } + + public void test007(){ + runTest("Introduced type unavailable to instanceof expressions in introduced methods"); + } + + public void test008(){ + runTest("enclosing join point not exported properly in pre-initialization join point"); + } + + public void test009(){ + runTest("cyclic pointcut definitions"); + } + + public void test010(){ + runTest("package typepattern with no packages (in default package)"); + } + + public void test011(){ + runTest("flag errors when binding args with indeterminate prefix and suffix"); + } + + public void test012(){ + runTest("around and return types + inlining optimizations"); + } + + public void test013(){ + runTest("source locations within expressions (hard case of constructor start)"); + } + + public void test014(){ + runTest("declaring method on superclass and subclass"); + } + + public void test015(){ + runTest("illegal name binding in around cflow"); + } + + public void test016(){ + runTest("incrementally change string size and wire in injar classes"); + } + + public void test017(){ + runTest("before():execution(new(..)) does not throw NoAspectBoundException"); + } + + public void test018(){ + runTest("declare error on handler/method execution with no code on binary ajc 1.1 classes"); + } + + public void test019(){ + runTest("declare error on handler/method execution with no code on binary javac 1.4 classes"); + } + + public void test020(){ + runTest("CLE: -help usage"); + } + + public void test021(){ + runTest("declare warnings on main - constructor execution"); + } + + public void test022(){ + runTest("declare warnings on binary javac 1.4 main - constructor execution"); + } + + public void test023(){ + runTest("declare warnings on binary ajc 1.1 main - constructor execution"); + } + + public void test024(){ + runTest("advice on handler join points should not throw unpermitted checked exceptions"); + } + + public void test025(){ + runTest("-nowarn suppresses XLint warnings"); + } + + public void test026(){ + runTest("warn:none suppresses XLint warnings"); + } + + public void test027(){ + runTest("-nowarn suppresses declare warnings"); + } + + public void test028(){ + runTest("-warn:none suppresses declare warnings"); + } + + public void test029(){ + runTest("insertion of lots of advice code can make branch offset for if too large"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations-tests.xml b/tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations-tests.xml new file mode 100644 index 000000000..d420885de --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations-tests.xml @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations.xml b/tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations.xml new file mode 100644 index 000000000..25d99f6e4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/knownlimitations/knownLimitations.xml @@ -0,0 +1,11 @@ + +]> + + + + + +&tests; + + diff --git a/tests/src/test/java/org/aspectj/systemtest/model/Model5Tests.java b/tests/src/test/java/org/aspectj/systemtest/model/Model5Tests.java new file mode 100644 index 000000000..3176803e4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/model/Model5Tests.java @@ -0,0 +1,93 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.systemtest.model; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.World; + +/** + * Tests the model when there is a requirement on Java5 features. + * + * @see org.aspectj.systemtest.model.ModelTestCase + */ +public class Model5Tests extends ModelTestCase { + + static { + // Switch this to true for a single iteration if you want to reconstruct the + // 'expected model' files. + regenerate = false; + // Switch this to true if you want to debug the comparison + debugTest = false; + } + + public void testDeclareAtTypeInStructureModel_pr115607() { + runModelTest("declare at type appears correctly in structure model", "pr115607"); + } + + public void testStructureModelForGenericITD_pr131932() { + runModelTest("structure model for generic itd", "pr131932"); + } + + public void testDeclareAnnotationAppearsInStructureModel_pr132130() { + runModelTest("declare annotation appears in structure model when in same file", "pr132130"); + } + + public void testAtAspectDEOWInStructureModel_pr120356() { + runModelTest("@AJ deow appear correctly when structure model is generated", "pr120356"); + } + + public void testDeclareAtMethodRelationship_pr143924() { + runModelTest("declare @method relationship", "pr143924"); + } + + public void testNewIProgramElementMethodsForGenerics_pr141730() { + runModelTest("new iprogramelement methods for generics", "pr141730_2"); + } + + // if not filling in the model for classes contained in jar files then + // want to ensure that the relationship map is correct and has nodes + // which can be used in AJDT - ensure no NPE occurs for the end of + // the relationship with inpath + public void testAspectPathRelWhenNotFillingInModel_pr141730() { + World.createInjarHierarchy = false; + try { + // the aspect used for this test has advice, declare parents, deow, + // and declare @type, @constructor, @field and @method. We only expect + // there to be relationships in the map for declare parents and declare @type + // (provided the model isn't being filled in) because the logic in the other + // addXXXRelationship methods use AspectJElementHierarchy.findElementForType(). + // This method which returns null because there is no such ipe. The relationship is + // therefore not added to the model. Adding declare @type and declare parents + // uses AspectJElementHierarchy.findElementForHandle() which returns the file + // node ipe if it can't find one for the given handle. Therefore the relationships + // are added against the file node. Before change to using ipe's to create handles + // we also had the deow relationship, however, now we don't because this also + // uses findElementForType to find the targetNode which in the inpath case is null. + runModelTest("ensure inpath injar relationships are correct when not filling in model", "pr141730_4"); + } finally { + World.createInjarHierarchy = true; + } + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Model5Tests.class); + } + + protected File getSpecFile() { + return getClassResource("model.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java new file mode 100644 index 000000000..0e443c3d3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java @@ -0,0 +1,218 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.systemtest.model; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IElementHandleProvider; +import org.aspectj.asm.IModelFilter; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.FileUtil; + +/** + * This class provides an extension to the XMLBasedAjcTestCase to manage testing the model. It assumes the testdata is in + * ../tests/model/ and that the expected model against which to do the comparison is in the file + * ../tests/model/expected/.txt. One test ensures that both the model and the relationship map are as expected for the given + * testdata. + * + * To write a testcase, create a testdata directory containing the data for the test run and a file containing the expected model + * (this can be generated by setting the regenerate flag to true). Add the required configuration to model.xml. Finally, create a + * testcase in either ModelTests or Model5Tests (depending on whether the testcase has a requirement on Java5) and call + * runModelTest(,<testid>). + */ +public abstract class ModelTestCase extends XMLBasedAjcTestCase { + + protected static boolean regenerate = false; + protected static boolean debugTest = false; + + private final String expectedOutDir = "../tests/model/expected" + File.separator; + private String testid; + + private String modelFilename; + + private IElementHandleProvider handleProvider; + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + // using the JDTLikeHandleProvider because this produces consistent handles + // over different compiles + // We are about to create a sandbox for the model output file, don't let the + // following compile wipe it. + ajc.setShouldEmptySandbox(false); + // report all information - model, relationships delta processing + modelFilename = ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "model.txt"; + AsmManager.setReporting(modelFilename, true, true, true, false, + new TestFilter(ajc.getSandboxDirectory().getCanonicalPath())); + } + + static class TestFilter implements IModelFilter { + String sandboxDirectory; + + public TestFilter(String sandboxDirectory) { + this.sandboxDirectory = sandboxDirectory; + } + + public String processFilelocation(String loc) { + if (loc.toLowerCase().startsWith(sandboxDirectory.toLowerCase())) { + String sub = loc.substring(sandboxDirectory.length()); + int forwardSlash = sub.indexOf("/"); + // replace all "/" with "\" - to ensure platform independence + if (forwardSlash != -1) { + sub = sub.replace('/', '\\'); + } + // don't report the column number since this is sometimes + // different on windows and linux + int column = sub.lastIndexOf(':'); + if (column != -1) { + return "TEST_SANDBOX" + sub.substring(0, column); + } + return "TEST_SANDBOX" + sub; + } + return loc; + } + + public boolean wantsHandleIds() { + return false; + } + } + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + AsmManager.setDontReport(); + ajc.setShouldEmptySandbox(true); + } + + /** + * Firstly sets the testid which is both the name of the expected output file and the name of the testdata directory. It then + * invokes XMLBasedAjcTestCase.runTest(String) with the given title and finally verifies that the model file created from this + * test run is the same as the expected output (includes model information, the relationship map and various properties about + * the model) contained in ../tests/model/expected/<testid>.txt + */ + protected void runModelTest(String title, String testid) { + this.testid = testid; + runTest(title); + verifyModel(); + } + + private void verifyModel() { + File expectedOutput = new File(expectedOutDir + testid + ".txt"); + if (regenerate) { + // Create the file + saveModel(expectedOutput); + } else { + // Verify the file matches what we have + compareModel(expectedOutput); + } + } + + private void compareModel(File expectedF) { + if (debugTest) + System.out.println("comparing with model in file " + expectedF.getAbsolutePath()); + List<String> fileContents = new ArrayList<String>(); + try { + // String sandboxDir = ajc.getSandboxDirectory().getAbsolutePath(); + String modelOutput = modelFilename; + // Load the file with the expected output + BufferedReader expect = new BufferedReader(new FileReader(expectedF)); + // String tempDir = expect.readLine(); + String expectedLine = null; + while ((expectedLine = expect.readLine()) != null) { + fileContents.add(expectedLine); + } + List<String> expectedFileContents = new ArrayList<String>(); + expectedFileContents.addAll(fileContents); + + // Load the file with the output from this test run + BufferedReader found = new BufferedReader(new FileReader(new File(modelOutput))); + String foundLine = null; + List<String> foundFileContents = new ArrayList<String>(); + while ((foundLine = found.readLine()) != null) { + // int i = foundLine.indexOf(sandboxDir); + // if (i == -1) { + // int j = foundLine.indexOf("(targets="); + // if (j == -1) { + foundFileContents.add(foundLine); + // } else { + // foundFileContents.add(foundLine.substring(j)); + // } + // } else { + // String newLine = foundLine.substring(0,i) + tempDir + // + foundLine.substring(i + sandboxDir.length()); + // foundFileContents.add(newLine); + // } + } + + // iterate over what we found + for (Iterator<String> iter = foundFileContents.iterator(); iter.hasNext();) { + String line = (String) iter.next(); + if (debugTest) + System.err.println("looking at model entry: " + line); + if (!fileContents.contains(line)) { + // if (!((String)fileContents.get(lineNumber)).equals(line)) { + + if (debugTest) { + System.err.println("couldn't find: " + line); + for (Iterator<String> iterator = fileContents.iterator(); iterator.hasNext();) { + String element = (String) iterator.next(); + System.err.println("compared with: " + element); + } + } + + // StringBuffer errorData = new StringBuffer(); + // errorData.append("Problem with comparison at line number: "+) + fail("couldn't find model entry '" + line + "' in expected output"); + } else { + fileContents.remove(line); + } + } + + if (debugTest && !fileContents.isEmpty()) { + for (Iterator<String> iter = fileContents.iterator(); iter.hasNext();) { + String element = (String) iter.next(); + System.err.println("remaining: " + element); + } + } + assertTrue("should have found all expected model output: " + fileContents, fileContents.isEmpty()); + } catch (Exception e) { + fail("Unexpected exception comparing model files:" + e); + } + } + + private void saveModel(File f) { + if (debugTest) + System.out.println("Saving model into " + f.getAbsolutePath()); + File modelFile = new File(modelFilename); + try { + FileUtil.copyFile(modelFile, f); + } catch (IOException ioe) { + ioe.printStackTrace(); + fail("Couldn't copy file to " + f.toString()); + } + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/model/ModelTests.java b/tests/src/test/java/org/aspectj/systemtest/model/ModelTests.java new file mode 100644 index 000000000..26b3887f7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/model/ModelTests.java @@ -0,0 +1,114 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.systemtest.model; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.World; + +/** + * Tests the model when there is no requirement on Java5 features. + * + * @see org.aspectj.systemtest.model.ModelTestCase + */ +public class ModelTests extends ModelTestCase { + + static { + // Switch this to true for a single iteration if you want to reconstruct the + // 'expected model' files. + regenerate = false; + // Switch this to true if you want to debug the comparison + debugTest = false; + } + + public void testAdviceInStructureModelWithAnonymousInnerClass_pr77269() { + runModelTest("advice in structure model with anonymous inner class", "pr77269_1"); + } + + public void testAdviceInStructureModelWithNamedInnerClass_pr77269() { + runModelTest("advice in structure model with named inner class", "pr77269_2"); + } + + public void testDWInStructureModelWithAnonymousInnerClass_pr77269() { + runModelTest("declare warning in structure model with anonymous inner class", "pr77269_3"); + } + + public void testNewIProgramElementMethods_pr141730() { + runModelTest("new iprogramelement methods", "pr141730_1"); + } + + // if not filling in the model for aspects contained in jar files then + // want to ensure that the relationship map is correct and has nodes + // which can be used in AJDT - ensure no NPE occurs for the end of + // the relationship with aspectpath + public void testAspectPathRelWhenNotFillingInModel_pr141730() { + World.createInjarHierarchy = false; + try { + runModelTest("ensure aspectpath injar relationships are correct when not filling in model", "pr141730_3"); + } finally { + World.createInjarHierarchy = true; + } + } + + // + // public void testPCDInClassAppearsInModel_pr148027() { + // boolean b = AsmHierarchyBuilder.shouldAddUsesPointcut; + // AsmHierarchyBuilder.shouldAddUsesPointcut = true; + // World.createInjarHierarchy = false; + // try { + // runModelTest("ensure pcd declare in class appears in model", "pr148027"); + // } finally { + // World.createInjarHierarchy = true; + // AsmHierarchyBuilder.shouldAddUsesPointcut = b; + // } + // } + + // public void testInpathAdvisedCode_prX() { runModelTest("inpath advised elements","prX"); } + + public void testSourceLocationAndJarFile_pr145963() { + runModelTest("sourcelocation and jar file", "pr145963_1"); + } + + public void testSourceLocationAndClassFile_pr145963() { + runModelTest("sourcelocation and class file", "pr145963_2"); + } + + public void testAspectInDefaultPackage_pr145963() { + runModelTest("aspect in default package", "pr145963_3"); + } + + public void testAspectInJavaFile_pr145963() { + runModelTest("aspect in java file", "pr145963_4"); + } + + public void testAbstractAspectsAndAdvice_pr160469() { + runModelTest("ensure advice from abstract aspects appear correctly in the model", "pr160469_1"); + } + + public void testAbstractAspectsAndDeow_pr160469() { + runModelTest("ensure deow from abstract aspects appear correctly in the model", "pr160469_2"); + } + + // public void testMultipleIdenticalJpsOnOneLine_pr238054() { runModelTest("multiple identical jps on one line","pr238054");} + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(ModelTests.class); + } + + protected File getSpecFile() { + return getClassResource("model.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/model/model.xml b/tests/src/test/java/org/aspectj/systemtest/model/model.xml new file mode 100644 index 000000000..811b78254 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/model/model.xml @@ -0,0 +1,115 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<!-- Model and Hierarchy Tests --> +<suite> +<!-- non-AspectJ 5 specific tests --> + + <ajc-test dir="model/pr238054" title="multiple identical jps on one line"> + <compile files="pr238054.aj" options="-emacssym"/> + </ajc-test> + + + + <ajc-test dir="model/pr77269_1" title="advice in structure model with anonymous inner class"> + <compile files="pack/pr77269.aj" options="-emacssym -Xset:minimalModel=false"/> + </ajc-test> + + <ajc-test dir="model/pr77269_2" title="advice in structure model with named inner class"> + <compile files="pr77269b.aj" options="-emacssym -Xset:minimalModel=false"/> + </ajc-test> + + <ajc-test dir="model/pr77269_3" title="declare warning in structure model with anonymous inner class"> + <compile files="pack/pr77269c.aj" options="-emacssym -Xset:minimalModel=false"> + <message kind="warning" line="8" text="blah blah blah"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr145963_1" title="sourcelocation and jar file"> + <compile files="C.java, SourceAspect.aj" aspectpath="simple.jar" options="-emacssym"> + <message kind="warning" line="6" text="There should be no printlns"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr145963_2" title="sourcelocation and class file"> + <compile files="C.java, SourceAspect.aj" aspectpath="pkg" options="-emacssym"> + <message kind="warning" line="6" text="There should be no printlns"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr145963_3" title="aspect in default package"> + <compile files="C.java" aspectpath="simple.jar" options="-emacssym -Xset:minimalModel=false"> + <message kind="warning" line="6" text="There should be no printlns"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr145963_4" title="aspect in java file"> + <compile files="C.java" aspectpath="simple.jar" options="-emacssym -Xset:minimalModel=false"> + <message kind="warning" line="6" text="There should be no printlns"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr141730_1" title="new iprogramelement methods"> + <compile files="pr141730.aj" options="-emacssym"/> + </ajc-test> + + <ajc-test dir="model/pr141730_3" title="ensure aspectpath injar relationships are correct when not filling in model"> + <compile files="MyFoo.java" aspectpath="aspectpath.jar" options="-emacssym"/> + </ajc-test> + + <ajc-test dir="model/pr148027" title="ensure pcd declare in class appears in model"> + <compile files="A.aj, C.aj" options="-emacssym"/> + </ajc-test> + + <ajc-test dir="model/pr160469_1" title="ensure advice from abstract aspects appear correctly in the model"> + <compile files="Simple.java" options="-emacssym" aspectpath="aspects.jar"/> + </ajc-test> + + <ajc-test dir="model/pr160469_2" title="ensure deow from abstract aspects appear correctly in the model"> + <compile files="Simple.java" options="-emacssym -Xset:minimalModel=false" aspectpath="aspects.jar"> + <message kind="warning" line="5" text="warning"/> + </compile> + </ajc-test> + +<!-- AspectJ 5 specific tests --> + + <ajc-test dir="model/pr115607" title="declare at type appears correctly in structure model"> + <compile files="pr115607.java" options="-1.5,-emacssym,-Xset:minimalModel=false"/> + </ajc-test> + + <ajc-test dir="model/pr131932" title="structure model for generic itd"> + <compile files="pr131932.aj" options="-1.5 -emacssym"/> + </ajc-test> + + <ajc-test dir="model/pr132130" title="declare annotation appears in structure model when in same file"> + <compile files="pr132130.aj" options="-1.5 -emacssym -Xset:minimalModel=false"/> + </ajc-test> + + <ajc-test dir="model/pr120356" title="@AJ deow appear correctly when structure model is generated"> + <compile files="C.java, A.java" options="-1.5, -emacssym -Xset:minimalModel=false"> + <message kind="error" line="8" text="error"/> + <message kind="warning" line="5" text="warning"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr143924" title="declare @method relationship"> + <compile files="pr143924.aj" options="-1.5 -showWeaveInfo -emacssym -Xset:minimalModel=false"> + <message kind="weave" text="'public void BankAccount.debit(String,long)' (pr143924.aj:7) is annotated with @Secured"/> + </compile> + </ajc-test> + + <ajc-test dir="model/pr141730_2" title="new iprogramelement methods for generics"> + <compile files="pr141730.aj" options="-1.5 -emacssym"/> + </ajc-test> + + <ajc-test dir="model/pr141730_4" title="ensure inpath injar relationships are correct when not filling in model"> + <compile files="MyBar.aj, MyAnnotation.java, NewClass.java" inpath="inpath.jar" options="-1.5 -emacssym -Xset:minimalModel=false"> + <message kind="warning" line="20" text="System.out should not be called"/> + </compile> + </ajc-test> + + <ajc-test dir="model/prX" title="inpath advised elements"> + <compile files="X.java" inpath="inpath.jar" options="-1.5 -emacssym"/> + </ajc-test> + + +</suite> diff --git a/tests/src/test/java/org/aspectj/systemtest/options/OptionsTests.java b/tests/src/test/java/org/aspectj/systemtest/options/OptionsTests.java new file mode 100644 index 000000000..80710a6ed --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/options/OptionsTests.java @@ -0,0 +1,44 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.options; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class OptionsTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(OptionsTests.class); + } + + protected File getSpecFile() { + return getClassResource("options.xml"); + } + + + public void test001(){ + runTest("options -warn:deprecation"); + } + + public void test002(){ + runTest("options -warn:deprecation not enabled"); + } + + public void test003(){ + runTest("setting -warn:constructorName works"); + } + + public void test004(){ + runTest("-deprecation not working?"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/options/options-tests.xml b/tests/src/test/java/org/aspectj/systemtest/options/options-tests.xml new file mode 100644 index 000000000..d109cd2d0 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/options/options-tests.xml @@ -0,0 +1,37 @@ +<!-- Options Tests --> + + <!-- .................................... option tests --> + <!-- .................................... -warn tests --> + <ajc-test dir="options/deprecated" + title="options -warn:deprecation"> + <compile files="WarnDeprecated.java,OldStuff.java" + options="!eclipse,-warn:deprecation"> + <message kind="warning" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="options/deprecated" + title="options -warn:deprecation not enabled"> + <compile files="WarnDeprecated.java,OldStuff.java" + options="!eclipse"> + </compile> + </ajc-test> + + + <ajc-test dir="harness" + title="setting -warn:constructorName works"> + <compile files="ConstructorNameWarning.java" + options="-warn:constructorName"> + <message kind="warning" line="5" text="constructor name"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/deprecated" pr="54098" + title="-deprecation not working?" > + <compile files="Deprecation.java, Deprecated.java" options="-deprecation"> + <message kind="warning" line="5"/> + <message kind="warning" line="6"/> + </compile> + </ajc-test> + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/options/options.xml b/tests/src/test/java/org/aspectj/systemtest/options/options.xml new file mode 100644 index 000000000..d877da040 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/options/options.xml @@ -0,0 +1,10 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[ +<!ENTITY tests SYSTEM "../tests/src/org/aspectj/systemtest/options/options-tests.xml"> +]> +<!-- Options Tests --> + +<suite> + +&tests; + +</suite> \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/pre10x/AjcPre10xTests.java b/tests/src/test/java/org/aspectj/systemtest/pre10x/AjcPre10xTests.java new file mode 100644 index 000000000..be240a9be --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/pre10x/AjcPre10xTests.java @@ -0,0 +1,316 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.pre10x; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class AjcPre10xTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AjcPre10xTests.class); + } + + protected File getSpecFile() { + return getClassResource("pre10x.xml"); + } + + + public void test001(){ + runTest("Using 'aspect' as identifier is legal TODO"); + } + + public void test002(){ + runTest("Using 'pointcut' as identifier is legal TODO"); + } + + public void test003(){ + runTest("CF expected when enclosing class superclass used as this qualifier in inner class"); + } + + public void test004(){ + runTest("enclosing class may be used as this qualifier in inner class"); + } + + public void test005(){ + runTest("reasonable error for crosscut reference with no formals specified"); + } + + public void test006(){ + runTest("reasonable error for introduction on type whose source isn't found"); + } + + public void test007(){ + runTest("handle errors in crosscut designators, insist that they end with a semicolon"); + } + + public void test008(){ + runTest("try to return from a before, after, after throwing and after returning"); + } + + public void test009(){ + runTest("the designator has a wildcard for method name but no return type specified"); + } + + public void test010(){ + runTest("the designator for the introduction has no type after the | charcter"); + } + + public void test011(){ + runTest("crosscut signature does not match"); + } + + public void test012(){ + runTest("proper exit conditions when errors fall through to javac"); + } + + public void test013(){ + runTest("mismatched parens on advice (wasn't binding Tester)"); + } + + public void test014(){ + runTest("Non-static advice silently ignored"); + } + + public void test015(){ + runTest("extra closing brace"); + } + + public void test016(){ + runTest("decent errors for around return type not matching target point"); + } + + public void test017(){ + runTest("eachobject: can't call new on an aspect of"); + } + + public void test018(){ + runTest("eachobject: only zero-argument constructors allowed in an aspect"); + } + + public void test019(){ + runTest("eachobject: can't extend a concrete aspect"); + } + + public void test020(){ + runTest("instanceof used without a class"); + } + + public void test021(){ + runTest("wildcard used for returns clause"); + } + + public void test022(){ + runTest("no return statement in around advice"); + } + + public void test023(){ + runTest("inner aspects must be static (no longer matches PR#286)"); + } + + public void test024(){ + runTest("Casting class declarations as interfaces"); + } + + public void test025(){ + runTest("omits a variable name and crashes with a null pointer"); + } + + public void test026(){ + runTest("Not generating an error for using new as a method name"); + } + + public void test027(){ + runTest("ClassCastException on the int literal"); + } + + public void test028(){ + runTest("Wrong strictfp keyword usage in interface function prototype [TODO: move to errors]"); + } + + public void test029(){ + runTest("Wrong strictfp keyword usage in field declaration [TODO: move to errors]"); + } + + public void test030(){ + runTest("Wrong strictfp keyword usage in constructor declaration [TODO: move to errors]"); + } + + public void test031(){ + runTest("Incorrect static casts to primitively foldable arguments should not crash the compiler."); + } + + public void test032(){ + runTest("Dominates with commas should signal an error."); + } + + public void test033(){ + runTest("stack overflow with recursive crosscut specifier"); + } + + public void test034(){ + runTest("Throwing a NullPointerException when formals can't be bound in named pointcut"); + } + + public void test035(){ + runTest("disallow defining more than one pointcut with the same name"); + } + + public void test036(){ + runTest("pre 0.7 introduction form outside aspect body causes an EmptyStackException"); + } + + public void test037(){ + runTest("a class can't extend an aspect"); + } + + public void test038(){ + runTest("a before() clause at the class-level causes an EmptyStackException"); + } + + public void test039(){ + runTest("an after() clause at the class-level causes an EmptyStackException"); + } + + public void test040(){ + runTest("an around() clause at the class-level causes an EmptyStackException"); + } + + public void test041(){ + runTest("Doesn't detect cyclic inheritance of aspects."); + } + + public void test042(){ + runTest("Binds the pointcut formals to member variables instead of pointcut formals."); + } + + public void test043(){ + runTest("ambiguous formal in formals pattern"); + } + + public void test044(){ + runTest("good error for field name instead of type name"); + } + + public void test045(){ + runTest("errors in aspect inheritance - 1"); + } + + public void test046(){ + runTest("errors in aspect inheritance - 2"); + } + + public void test047(){ + runTest("errors in aspect inheritance - 3"); + } + + public void test048(){ + runTest("errors in aspect inheritance - 4"); + } + + public void test049(){ + runTest("circular dominates leading to irresolvable advice precedence"); + } + + public void test050(){ + runTest("Should issue an error for using 'class' instead of 'aspect'"); + } + + public void test051(){ + runTest("Should signal an error when we need an exposed value but don't provide it"); + } + + public void test052(){ + runTest("StackOverFlowException with circular +implements's."); + } + + public void test053(){ + runTest("Introducing protected methods is causing a crash"); + } + + public void test054(){ + runTest("Introducing protected fields is causing a crash"); + } + + public void test055(){ + runTest("two classes with the same fully-qualified names [eachjvm]"); + } + + public void test056(){ + runTest("Undefined pointcuts were throwing exceptions in 07b11 [callsto]"); + } + + public void test057(){ + runTest("advice on abstract pointcuts"); + } + + public void test058(){ + runTest("Whoops, I forgot to put a class in the field access PCD."); + } + + public void test059(){ + runTest("the arounds return something but there is no returns statement"); + } + + public void test060(){ + runTest("multiple conflicting introductions"); + } + + public void test061(){ + runTest("referencing non-static pointcuts in outer aspects"); + } + + public void test062(){ + runTest("javac correct compiler error if there is no return in around returning result"); + } + + public void test063(){ + runTest("should give an error for introducing two members with the same name"); + } + + public void test064(){ + runTest("wimpy test for undeclared and uncaught exceptions"); + } + + public void test065(){ + runTest("Given non-matching TypePattern, CE flags use of non-introduced method rather than failure to introduce"); + } + + public void test066(){ + runTest("Compiler should suggest using aspect when advice, pointcuts, or introduction is in a class"); + } + + public void test067(){ + runTest("declare error working with pointcut and-not (amp,amp,bang)"); + } + + public void test068(){ + runTest("aspect as member of interface (private and protected)"); + } + + public void test069(){ + runTest("introduced inner interfaces - compile should fail to bind interface name outside of Aspect or if implementing method is not public"); + } + + public void test070(){ + runTest("aspects may not implement Serializable or Cloneable"); + } + + public void test071(){ + runTest("explicit constructor calls can throw exceptions"); + } + + public void test072(){ + runTest("bad proceed args good error messages"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x-tests.xml b/tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x-tests.xml new file mode 100644 index 000000000..9b0837dbe --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x-tests.xml @@ -0,0 +1,638 @@ +<!-- AspectJ v0.8 - 0.99 Tests --> + + + <ajc-test dir="pureJava" title="Using 'aspect' as identifier is legal TODO" + keywords="from-java" comment="keep this test in main suite"> + <compile files="KeywordAspect.java"/> + <run class="KeywordAspect"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Using 'pointcut' as identifier is legal TODO" + keywords="from-java" comment="keep this test in main suite"> + <compile files="KeywordPointcut.java"/> + <run class="KeywordPointcut"/> + </ajc-test> + + <ajc-test dir="new/introTypeMissing" + title="CF expected when enclosing class superclass used as this qualifier in inner class" + keywords="from-java"> + <compile files="TargetClassCF.java,Util.java"> + <message kind="error" line="22"/> + <message kind="error" line="23"/> + <message kind="error" line="27"/> + <message kind="error" line="28"/> + </compile> + </ajc-test> + + <ajc-test dir="new/introTypeMissing" + title="enclosing class may be used as this qualifier in inner class" + keywords="from-java"> + <compile files="TargetClassCP.java,Util.java"/> + <run class="TargetClassCP"/> + </ajc-test> + + <ajc-test dir="errors" + title="reasonable error for crosscut reference with no formals specified" + keywords="from-errors"> + <compile files="NoFormalsCrosscut.java"> + <message kind="error" line="6"/> + <message kind="error" line="7"/> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="reasonable error for introduction on type whose source isn't found" + keywords="from-errors"> + <compile files="NoSource.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + + <ajc-test dir="errors" + title="handle errors in crosscut designators, insist that they end with a semicolon" + keywords="from-errors"> + <compile files="BadDesignator.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + + <ajc-test dir="errors" + title="try to return from a before, after, after throwing and after returning" + keywords="from-errors"> + <compile files="InvalidReturn.java"> + <message kind="error" line="12"/> + <message kind="error" line="16"/> + <message kind="error" line="19"/> + <message kind="error" line="22"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="130" + title="the designator has a wildcard for method name but no return type specified" + keywords="from-errors"> + <compile files="NoReturnTypeInDesignator.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="the designator for the introduction has no type after the | charcter" + keywords="from-errors"> + <compile files="BadIntroductionDesignator.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="140" title="crosscut signature does not match" + keywords="from-errors"> + <compile files="BadCCutSig.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="proper exit conditions when errors fall through to javac" + keywords="from-errors"> + <compile files="FromJavac.java"> + <message kind="error" line="11"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="213" + title="mismatched parens on advice (wasn't binding Tester)" + keywords="from-errors"> + <compile files="MismatchedParens.java"> + <message kind="error" line="16"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="209" title="Non-static advice silently ignored" + keywords="from-errors"> + <compile files="BadPointcutName.java"> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="219" title="extra closing brace" + keywords="from-errors"> + <compile files="ExtraClosingBrace.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="244" + title="decent errors for around return type not matching target point" + keywords="from-errors"> + <compile files="AroundReturnType.java" options="-1.4"> + <message kind="error" line="2"/> + <message kind="error" line="6"/> + <message kind="error" line="7"/> + <message kind="error" line="16"/> + <message kind="error" line="21"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="eachobject: can't call new on an aspect of" + keywords="from-errors"> + <compile files="CantCallConstructorOnAspects.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="eachobject: only zero-argument constructors allowed in an aspect" + keywords="from-errors,fail-unimplemented"> + <compile files="AspectsCantHaveYesArgumentConstructors.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="eachobject: can't extend a concrete aspect" + keywords="from-errors,fail-unimplemented"> + <compile files="SubAspectsCantExtendNonAbstractAspects.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="271" title="instanceof used without a class" + keywords="from-errors"> + <compile files="InstanceofWithoutClass.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="280" title="wildcard used for returns clause" + keywords="from-errors"> + <compile files="WildcardForReturns.java"> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="280" title="no return statement in around advice" + keywords="from-errors,new-messages-vary"> + <compile files="NoReturnStatement.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="286" + title="inner aspects must be static (no longer matches PR#286)" + keywords="from-errors,fail-unimplemented"> + <compile files="AbstractAspectOf.java"> + <message kind="error" line="12"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Casting class declarations as interfaces" + keywords="from-errors"> + <compile files="InterfaceCast.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="omits a variable name and crashes with a null pointer" + keywords="from-errors"> + <compile files="BindingNullPointer.java"> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Not generating an error for using new as a method name" + keywords="from-errors"> + <compile files="New.java"> + <message kind="error" line="12"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="ClassCastException on the int literal" + keywords="from-errors"> + <compile files="IntLiteral.java"> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="Wrong strictfp keyword usage in interface function prototype [TODO: move to errors]" + keywords="from-errors"> + <compile files="StrictFpCErr1.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="Wrong strictfp keyword usage in field declaration [TODO: move to errors]" + keywords="from-errors"> + <compile files="StrictFpCErr2.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="Wrong strictfp keyword usage in constructor declaration [TODO: move to errors]" + keywords="from-errors"> + <compile files="StrictFpCErr3.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Incorrect static casts to primitively foldable arguments should not crash the compiler." + keywords="from-errors"> + <compile files="BadStaticCast.java"> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Dominates with commas should signal an error." + keywords="from-errors"> + <compile files="DominatesWithCommas.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="95" + title="stack overflow with recursive crosscut specifier" + keywords="from-errors"> + <compile files="RecursiveCCutSpecifier.java"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Throwing a NullPointerException when formals can't be bound in named pointcut" + keywords="from-errors"> + <compile files="BadFormalsToCalls.java"> + <message kind="error" line="22"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="385" + title="disallow defining more than one pointcut with the same name" + keywords="from-errors,fail-unimplemented"> + <compile files="OverloadedPointcuts.java"> + <message kind="error" line="4"/> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="pre 0.7 introduction form outside aspect body causes an EmptyStackException" + keywords="from-errors"> + <compile files="BadIntroduction.java"> + <message kind="error" line="1" /> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="a class can't extend an aspect" + keywords="from-errors,fail-unimplemented"> + <compile files="ClassExtendingAspect.java"> + <message kind="error" line="19"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="a before() clause at the class-level causes an EmptyStackException" + keywords="from-errors"> + <compile files="TopLevelBefore.java"> + <message kind="error" line="1"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="an after() clause at the class-level causes an EmptyStackException" + keywords="from-errors"> + <compile files="TopLevelAfter.java"> + <message kind="error" line="1"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="an around() clause at the class-level causes an EmptyStackException" + keywords="from-errors"> + <compile files="TopLevelAround.java"> + <message kind="error" line="1"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Doesn't detect cyclic inheritance of aspects." + keywords="from-errors"> + <compile files="CircularExtendsAspect.java"> + <message kind="error" line="18"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Binds the pointcut formals to member variables instead of pointcut formals." + keywords="from-errors"> + <compile files="PointcutFormals.java" options="-Xlint:warning"> + <message kind="error" line="14"/> + <message kind="error" line="15"/> + <message kind="warning" line="16"/> + <message kind="warning" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="ambiguous formal in formals pattern" + keywords="from-errors"> + <compile files="AmbiguousFormal.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="good error for field name instead of type name" + keywords="from-errors"> + <compile files="BadTypeName.java"> + <message kind="error" line="2"/> + <message kind="error" line="4"/> + <message kind="error" line="6"/> + <message kind="error" line="8"/> + <message kind="error" line="10"/> + <message kind="error" line="12"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="errors in aspect inheritance - 1" + keywords="from-errors"> + <compile files="AspectInheritance1.java"> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="errors in aspect inheritance - 2" + keywords="from-errors"> + <compile files="AspectInheritance2.java"> + <message kind="error" line="8"/> + <message kind="error" line="16"/> + <message kind="error" line="20"/> + <message kind="error" line="26"/> + <message kind="error" line="30"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="errors in aspect inheritance - 3" + keywords="from-errors"> + <compile files="AspectInheritance3.java"> + <message kind="error" line="19"/> + <message kind="error" line="24"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="errors in aspect inheritance - 4" + keywords="from-errors"> + <compile files="AspectInheritance4.java"> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="circular dominates leading to irresolvable advice precedence" + keywords="from-errors"> + <compile files="CircularDominates.java" options="-1.4"> + <message kind="error" line="12"/> + <message kind="error" line="16"/> + <message kind="error" line="20"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Should issue an error for using 'class' instead of 'aspect'" + keywords="from-errors"> + <compile files="NoAspect.java"> + <message kind="error" line="1" text="Syntax error on token "{", ; expected"/> + <message kind="error" line="12" text="Syntax error on token "{", pointcut expected after this token"/> + <message kind="error" line="12" text="Syntax error, insert ";" to complete ClassBodyDeclarations"/> + <message kind="error" line="12" text="Syntax error on token "{", delete this token"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Should signal an error when we need an exposed value but don't provide it" + keywords="from-errors"> + <compile files="MissingExposure.java"> + <message kind="error" line="13"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="StackOverFlowException with circular +implements's." + keywords="from-errors"> + <compile files="CircularPlusImplementsIntros.java"> + <message kind="error" line="19"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Introducing protected methods is causing a crash" + keywords="from-errors"> + <compile files="ProtectedIntro.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Introducing protected fields is causing a crash" + keywords="from-errors"> + <compile files="ProtectedFieldIntro.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="388" + title="two classes with the same fully-qualified names [eachjvm]" + keywords="from-errors" + comment="XXX error not flagging initial type"> + <compile files="DuplicatedNames.java"> + <message kind="error" line="3"/> + <message kind="error" line="5"/> + <message kind="error" line="7"/> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="396" + title="Undefined pointcuts were throwing exceptions in 07b11 [callsto]" + keywords="from-errors"> + <compile files="UndefinedPointCut_PR396.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="240" title="advice on abstract pointcuts" + keywords="from-errors"> + <compile files="StaticAdviceOnAbstract.java"> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Whoops, I forgot to put a class in the field access PCD." + keywords="from-errors"> + <compile files="BadGetPCD.java"> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="138" + title="the arounds return something but there is no returns statement" + keywords="from-errors"> + <compile files="MissingReturns.java"> + <message kind="error" line="14"/> + <message kind="error" line="20"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="multiple conflicting introductions" + keywords="from-errors"> + <compile files="MultipleIntros.java"> + <message kind="error" line="5"/> + <message kind="error" line="16"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + <message kind="error" line="22"/> + <message kind="error" line="27"/> + <message kind="error" line="30"/> + <!-- new error due to 275032 - other end of itd clash has error recorded against it --> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="referencing non-static pointcuts in outer aspects" + keywords="from-errors"> + <compile files="StaticPointcutRefs.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="javac correct compiler error if there is no return in around returning result" + keywords="from-errors"> + <compile files="NoReturnInProceed.java"> + <message kind="error" line="16"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="should give an error for introducing two members with the same name" + keywords="from-errors"> + <compile files="TwoIntros.java"> + <message kind="error" line="10"/> + <message kind="error" line="14"/> + <message kind="error" line="16"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="wimpy test for undeclared and uncaught exceptions" + keywords="from-errors"> + <compile files="UndeclaredThrows.java"> + <message kind="error" line="12"/> + <message kind="error" line="18"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="Given non-matching TypePattern, CE flags use of non-introduced method rather than failure to introduce" + keywords="from-errors"> + <compile + files="typepatternmatch/pack1/IntroErrorLocation.java,typepatternmatch/pack2/TargetClass.java"> + <message kind="error" line="28" + file="pack1/IntroErrorLocation.java" + text="TargetClass cannot be resolved"/> + <message kind="warning" line="33" + file="pack1/IntroErrorLocation.java" + text="no match for this type name: TargetClass"/> + <message kind="error" line="39" + file="pack1/IntroErrorLocation.java" + text="undefined for the type TargetClass"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="457" + title="Compiler should suggest using aspect when advice, pointcuts, or introduction is in a class" + keywords="from-errors,poorErrorMessages"> + <compile files="RecognizeAspectCE.java"> + <message kind="error" line="3" + file="RecognizeAspectCE.java" + text="Syntax error on token "}", pointcut expected after this token"/> + <message kind="error" line="2" + file="RecognizeAspectCE.java" + text="Syntax error"/> + <message kind="error" line="6" + file="RecognizeAspectCE.java" + text="Syntax error"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="declare error working with pointcut and-not (amp,amp,bang)" + keywords="from-errors"> + <compile files="DeclareError.java"> + <message kind="error" line="5"/> + <message kind="error" line="19"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="534" + title="aspect as member of interface (private and protected)" + keywords="from-errors"> + <compile files="AspectInInterfaceCF.java"> + <message kind="error" line="11"/> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="494" + title="introduced inner interfaces - compile should fail to bind interface name outside of Aspect or if implementing method is not public" + keywords="from-errors"> + <compile files="IntroduceInnerInterfaceCF.java" options="-Xlint:ignore"> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + <message kind="error" line="20"/> + <message kind="error" line="24"/> + <message kind="error" line="42"/> + <message kind="error" line="45"/> + <message kind="error" line="48"/> + <message kind="error" line="50"/> + <message kind="error" line="58"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="aspects may not implement Serializable or Cloneable" + keywords="from-errors"> + <compile files="AspectInterfaces.java"> + <message kind="error" line="4"/> + <message kind="error" line="5"/> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="explicit constructor calls can throw exceptions" + keywords="from-errors"> + <compile files="ExplicitConstructorThrows.java"> + <message kind="error" line="3"/> + <message kind="error" line="12"/> + <message kind="error" line="18"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="664" title="bad proceed args good error messages" + keywords="from-errors"> + <compile files="ProceedArgsCE.java"> + <message kind="error" line="13"/> + <message kind="error" line="16"/> + <message kind="error" line="19"/> + </compile> + </ajc-test> + + diff --git a/tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x.xml b/tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x.xml new file mode 100644 index 000000000..cfaa7480d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/pre10x/pre10x.xml @@ -0,0 +1,10 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[ +<!ENTITY tests SYSTEM "../tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml"> +]> +<!-- AspectJ v0.8 - 0.99 Tests --> + +<suite> + +&tests; + +</suite> \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/purejava/PureJavaTests.java b/tests/src/test/java/org/aspectj/systemtest/purejava/PureJavaTests.java new file mode 100644 index 000000000..05f2774a5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/purejava/PureJavaTests.java @@ -0,0 +1,992 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.purejava; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class PureJavaTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(PureJavaTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/pureJava/pureJava.xml"); + } + + + public void test001(){ + runTest("unicodes and literals"); + } + + public void test002(){ + runTest("For Statement"); + } + + public void test003(){ + runTest("correct super call lookup for method().name()"); + } + + public void test004(){ + runTest("combined logic expression (handling coericions vs. parens)"); + } + + public void test005(){ + runTest("comment after class closes (with no new line at end)"); + } + + public void test006(){ + runTest("multi-dimensional array initializers"); + } + + public void test007(){ + runTest("probelm with the generated names of exceptions"); + } + + public void test008(){ + runTest("checks if the class field can be used on all of the primitive types"); + } + + public void test009(){ + runTest("Doesn't parse an array-returning method that throws an exception"); + } + + public void test010(){ + runTest("check that nested constructions of local classes work"); + } + + public void test011(){ + runTest("Make sure anonymous classes can have non-nullary constructors"); + } + + public void test012(){ + runTest("Full names are dropped from inner interfaces"); + } + + public void test013(){ + runTest("Making sure full names stay on static inner classes"); + } + + public void test014(){ + runTest("Not binding constructor when using more than one compilation"); + } + + public void test015(){ + runTest("return;;; is not really legal"); + } + + public void test016(){ + runTest("ajc treating Throwable as checked, issuing error if not found"); + } + + public void test017(){ + runTest("package protected classes becoming public"); + } + + public void test018(){ + runTest("IOException on windows if nul used as identifier"); + } + + public void test019(){ + runTest("NullPointerException (not compiler error) when extending non-static inner class"); + } + + public void test020(){ + runTest("compiler flags final static variable as indefinite in member assignment."); + } + + public void test021(){ + runTest("confirm no IOException on windows if nul used as identifier"); + } + + public void test022(){ + runTest("final constructor parameter causes incorrect compiler error"); + } + + public void test023(){ + runTest("Error expected for field of type void"); + } + + public void test024(){ + runTest("Error expected for constructor in interfaces"); + } + + public void test025(){ + runTest("class name for identifier as String should provoke error"); + } + + public void test026(){ + runTest("cyclic interface inheritance not detected if no classes implement the interfaces"); + } + + public void test027(){ + runTest("cyclic class inheritance"); + } + + public void test028(){ + runTest("type and package name conflicts are resolved happily (1a)"); + } + + public void test029(){ + runTest("(fails in USEJAVAC) type and package name conflicts are resolved happily (1b)"); + } + + public void test030(){ + runTest("type and package name conflicts caught as errors (1)"); + } + + public void test031(){ + runTest("flow analysis where final variable set in another constructor"); + } + + public void test032(){ + runTest("Can construct inner classes using qualified expressions"); + } + + public void test033(){ + runTest("subclass unable to access protected static methods using type-qualified references"); + } + + public void test034(){ + runTest("Undefined inner class constructor"); + } + + public void test035(){ + runTest("classes that are package prefixes are illegal"); + } + + public void test036(){ + runTest("valid type expressions for introduced type testing"); + } + + public void test037(){ + runTest("PR591 compiler error expected when directly calling unimplemented abstract method using super"); + } + + public void test038(){ + runTest("suggested by Jacks 15.28-qualified-namestr tests"); + } + + public void test039(){ + runTest("suggested by jacks 3.7-15 all comments must be closed"); + } + + public void test040(){ + runTest("package class access not enforced outside of package"); + } + + public void test041(){ + runTest("expecting CE for ambiguous reference"); + } + + public void test042(){ + runTest("try without catch or finally"); + } + + public void test043(){ + runTest("invalid floating-point constant"); + } + + public void test044(){ + runTest("concrete aspect unable to access abstract package-private method in parent for overriding"); + } + + public void test045(){ + runTest("super reference used to disambiguate names of different but compatible types"); + } + + public void test046(){ + runTest("anonymous explicit inner constructors"); + } + + public void test047(){ + runTest("Overruning the lineStarts buffer, DO NOT EDIT THIS FILE!!!!"); + } + + public void test048(){ + runTest("no CE for unambiguous type reference"); + } + + public void test049(){ + runTest("CE for ambiguous type reference (imports)"); + } + + public void test050(){ + runTest("CE for ambiguous type reference (two type declarations)"); + } + + public void test051(){ + runTest("CE for ambiguous type reference (two inner types)"); + } + + public void test052(){ + runTest("final assignment in loop"); + } + + public void test053(){ + runTest("private super access in inners"); + } + + public void test054(){ + runTest("nested interface does not require new qualifier (8)"); + } + + public void test055(){ + runTest("nested interface does not require new qualifier (9)"); + } + + public void test056(){ + runTest("nested interface does not require new qualifier (10)"); + } + + public void test057(){ + runTest("nested interface does not require new qualifier (14)"); + } + + public void test058(){ + runTest("nested interface does not require new qualifier (15)"); + } + + public void test059(){ + runTest("nested interface does not require new qualifier (16)"); + } + + public void test060(){ + runTest("check that constructor name's match the enclosing type"); + } + + public void test061(){ + runTest("errors for not applicable or accessible methods"); + } + + public void test062(){ + runTest("import statement within class body crashes compiler"); + } + + public void test063(){ + runTest("Accessing instance fields and instance methods statically."); + } + + public void test064(){ + runTest("Crashes when a cast is within another cast"); + } + + public void test065(){ + runTest("Crashes when a cast of the form )int) appears"); + } + + public void test066(){ + runTest("Crashes when the closing brace is reversed"); + } + + public void test067(){ + runTest("Crashes when a method name is missing in a call -- e.g. 'System.out.();'"); + } + + public void test068(){ + runTest("Crashes when a bad r-value appears."); + } + + public void test069(){ + runTest("Two underscores as a variables causes a crash"); + } + + public void test070(){ + runTest("Crashes when assigning to a final static in an intializer and declaration"); + } + + public void test071(){ + runTest("Crashes when two dots appear instead of one"); + } + + public void test072(){ + runTest("Crashes when there're stray dots"); + } + + public void test073(){ + runTest("Stray characters cause a crash"); + } + + public void test074(){ + runTest("Colon instead of a semi-colon causes a crash"); + } + + public void test075(){ + runTest("type error in initializer caught by ajc, not javac"); + } + + public void test076(){ + runTest("Circular inheritance with classes causes a stack overflow."); + } + + public void test077(){ + runTest("Missing ;"); + } + + public void test078(){ + runTest("cast expressions should not allow casts between ifaces and array types"); + } + + public void test079(){ + runTest("parsing errors for various bad forms of NewArrayExprs."); + } + + public void test080(){ + runTest("good error for bad field and inner class references"); + } + + public void test081(){ + runTest("Implementing a non-interface used to crash the compiler."); + } + + public void test082(){ + runTest("error of no return statement detected not by ajc but by javac (line 4)"); + } + + public void test083(){ + runTest("class and interface extension"); + } + + public void test084(){ + runTest("types in throws clauses"); + } + + public void test085(){ + runTest("bad switch syntax"); + } + + public void test086(){ + runTest("Referencing various things from static contexts"); + } + + public void test087(){ + runTest("Some expressions are illegal expression statements"); + } + + public void test088(){ + runTest("illegal forward reference"); + } + + public void test089(){ + runTest("protected accessibility"); + } + + public void test090(){ + runTest("parse-time illegal modifiers"); + } + + public void test091(){ + runTest("check-time illegal modifiers"); + } + + public void test092(){ + runTest("illegal synchronized stmts"); + } + + public void test093(){ + runTest("modifiers on interface members"); + } + + public void test094(){ + runTest("good errors (and not too many) for missing members"); + } + + public void test095(){ + runTest("expecting compile failures with subclass narrowing scope of superclass methods or accessing private superclass variables"); + } + + public void test096(){ + runTest("inner classes may not have static non-constant members"); + } + + public void test097(){ + runTest("flow analysis with local types"); + } + + public void test098(){ + runTest("PR584 Can construct inner classes using qualified expressions"); + } + + public void test099(){ + runTest("incrementing objects, arrays - 2"); + } + + public void test100(){ + runTest("incrementing objects, arrays CE"); + } + + public void test101(){ + runTest("incrementing objects, arrays - 3"); + } + + public void test102(){ + runTest("incrementing objects, arrays"); + } + + public void test103(){ + runTest("no circularity errors simply because of inners (1)"); + } + + public void test104(){ + runTest("no circularity errors simply because of inners (2)"); + } + + public void test105(){ + runTest("should have circular inheritance errors (1)"); + } + + public void test106(){ + runTest("should have circular inheritance errors (2)"); + } + + public void test107(){ + runTest("interface using preceding subinterface in its definition"); + } + + public void test108(){ + runTest("Parent interface using public inner interface of child in same file"); + } + + public void test109(){ + runTest("a type is not allowed to extend or implement its own innner type"); + } + + public void test110(){ + runTest("try requires block JLS 14.19"); + } + + public void test111(){ + runTest("loop expressions not declarations"); + } + + public void test112(){ + runTest("no error when public class is in file of a different name"); + } + + public void test113(){ + runTest("local variables must be final to be accessed from inner class"); + } + + public void test114(){ + runTest("final local variables may be accessed from inner class"); + } + + public void test115(){ + runTest("missing package identifier"); + } + + public void test116(){ + runTest("CE for ambiguous type reference (two files in package)"); + } + + public void test117(){ + runTest("initializer can throw so long as all constructors declare so"); + } + + public void test118(){ + runTest("interfaces may not contain initializers (bug found by jacks)"); + } + + public void test119(){ + runTest("initializers must be able to complete normally (found by jacks)"); + } + + public void test120(){ + runTest("more tests of super alone"); + } + + public void test121(){ + runTest("subclass access to enclosing super class private members"); + } + + public void test122(){ + runTest("various tests of switch bounds"); + } + + public void test123(){ + runTest("VerifyError if nested sync returning result"); + } + + public void test124(){ + runTest("assert flow"); + } + + public void test125(){ + runTest("assert flow - 2"); + } + + public void test126(){ + runTest("assert typing"); + } + + public void test127(){ + runTest("assert coverage tests [requires 1.4]"); + } + + public void test128(){ + runTest("assert coverage tests in one package [requires 1.4]"); + } + + public void test129(){ + runTest("compiling asserts in methods"); + } + + public void test130(){ + runTest("import of a class in the default package"); + } + + public void test131(){ + runTest("Referencing static interfaces with import statements"); + } + + public void test132(){ + runTest("Referencing static interfaces with import statements stars"); + } + + public void test133(){ + runTest("Referencing static interfaces with import statements stars 2"); + } + + public void test134(){ + runTest("Referencing static interfaces with import statements stars 3"); + } + + public void test135(){ + runTest("Referencing interfaces with import statements"); + } + + public void test136(){ + runTest("Referencing interfaces with import statements stars"); + } + + public void test137(){ + runTest("Referencing interfaces with import statements stars 2"); + } + + public void test138(){ + runTest("Referencing interfaces with import statements stars 3"); + } + + public void test139(){ + runTest("import any inner from interface implementor"); + } + + public void test140(){ + runTest("equals method on quoted strings"); + } + + public void test141(){ + runTest("anonymous inner class"); + } + + public void test142(){ + runTest("parsing of parenthesized 'this' (in returns)"); + } + + public void test143(){ + runTest("Strings are folded and interned correctly"); + } + + public void test144(){ + runTest("Cast binds tighter than equality tests"); + } + + public void test145(){ + runTest("Boundary base values can be parsed"); + } + + public void test146(){ + runTest("State is passed correctly across nested annonymous inners"); + } + + public void test147(){ + runTest("?: expressions should typecheck in interesting ways"); + } + + public void test148(){ + runTest("cast expressions should allow casts to/from interfaces at compile-time."); + } + + public void test149(){ + runTest("various anonymous inner classes plus super types tests"); + } + + public void test150(){ + runTest("Various comment syntaxes should be handled."); + } + + public void test151(){ + runTest("Abstract inner classes across package boundaries"); + } + + public void test152(){ + runTest("inner classes accessing outers and some more inner class names"); + } + + public void test153(){ + runTest("remember to cast folded values down to the proper types."); + } + + public void test154(){ + runTest("inner classes can be built using protected constructors in super"); + } + + public void test155(){ + runTest("The current AspectJ compiler cannot parse qualified superclass constructor invocations"); + } + + public void test156(){ + runTest("More thourough test of static members using full names"); + } + + public void test157(){ + runTest("More thourough test of static members using imports"); + } + + public void test158(){ + runTest("Looking in class Java for java.lang.String WITH separate compilation"); + } + + public void test159(){ + runTest("Looking in class Java for java.lang.String WITHOUT separate compilation"); + } + + public void test160(){ + runTest("Looking in class Java for java.lang.String WITH separate compilation with packages"); + } + + public void test161(){ + runTest("Looking in class Java for java.lang.String WITHOUT separate compilation with packages"); + } + + public void test162(){ + runTest("Testing ternary operations."); + } + + public void test163(){ + runTest("Lifting locals in switch statements."); + } + + public void test164(){ + runTest("Getting confused when looking up method signatures"); + } + + public void test165(){ + runTest("Not recognizing the chars '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7'"); + } + + public void test166(){ + runTest("Test chars '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7' with a case statement"); + } + + public void test167(){ + runTest("Checking character values with all the unicode chars."); + } + + public void test168(){ + runTest("Trouble finding methods with the same name and different parameter types"); + } + + public void test169(){ + runTest("Binding non-public static inner classes of interfaces in other packages"); + } + + public void test170(){ + runTest("Not recognizing the octal chars '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7'"); + } + + public void test171(){ + runTest("Members with the same name as their package cause confusion with fully-qualified names."); + } + + public void test172(){ + runTest("Fully-qual'ed names with same start as variable names"); + } + + public void test173(){ + runTest("Fully qualifying inner classes within annonymous classes causes problems."); + } + + public void test174(){ + runTest("Calls to methods in outer annonymous classes are being qual's incorrectly with 'this'"); + } + + public void test175(){ + runTest("Reading inner classes from source and bytecode (1) -- was failing"); + } + + public void test176(){ + runTest("Reading inner classes from source and bytecode (2)"); + } + + public void test177(){ + runTest("Reading inner classes from source and bytecode (3)"); + } + + public void test178(){ + runTest("Not lifting types correctly with bytes and shorts with ternary ops"); + } + + public void test179(){ + runTest("Not looking up methods inside of anonymous declarations correctly."); + } + + public void test180(){ + runTest("Resolving extended classes with array parameters"); + } + + public void test181(){ + runTest("Assignments as second arguments in ternary operators."); + } + + public void test182(){ + runTest("Conflicting inner classes with interfaces."); + } + + public void test183(){ + runTest("confusions of casts and parens"); + } + + public void test184(){ + runTest("default constructors seen by inner classes subtyping outers"); + } + + public void test185(){ + runTest("folding fields set to anonymous instances containing self-references"); + } + + public void test186(){ + runTest("finally at the end of a method that needs to return"); + } + + public void test187(){ + runTest("overriding methods from object in interfaces and multiple-inheritance"); + } + + public void test188(){ + runTest("private fields in an outer class accessed by an inner which also extends the outer"); + } + + public void test189(){ + runTest("breaking out of a labeled block inside of an if"); + } + + public void test190(){ + runTest("abstractifying a method and getting it back through super"); + } + + public void test191(){ + runTest("Packages and static classes with the same name produce compile errors."); + } + + public void test192(){ + runTest("Inner types must generate classfiles with only Public/Default access flags."); + } + + public void test193(){ + runTest("Default constructors have same access as their enclosing type"); + } + + public void test194(){ + runTest("Returning primitive values matching method return type (minimal)"); + } + + public void test195(){ + runTest("Flow analysis and if(true)"); + } + + public void test196(){ + runTest("packages and generated inner types (for I.class)"); + } + + public void test197(){ + runTest("A.this exprs match by exact type matching"); + } + + public void test198(){ + runTest("Implicit this for new inner instance must be avaliable"); + } + + public void test199(){ + runTest("Inners can reference protected fields of their outer's super."); + } + + public void test200(){ + runTest("Primitives that special case for a constant arm should work"); + } + + public void test201(){ + runTest("Parenthesized true and false don't parse"); + } + + public void test202(){ + runTest("Field sets to public fields of private fields of enclosing types"); + } + + public void test203(){ + runTest("Constant values should be stored with the correct type of their fields"); + } + + public void test204(){ + runTest("Local variables in initializers should not be treated as blank final fields"); + } + + public void test205(){ + runTest("Binops aren't allowed as update stmts in for loops"); + } + + public void test206(){ + runTest("Can't avoid doing division in case of div by zero"); + } + + public void test207(){ + runTest("Testing frames w/greater than FF locals and 7F incs (i.e., WIDE instruction)"); + } + + public void test208(){ + runTest("correct numeric literals"); + } + + public void test209(){ + runTest("invalid numeric literals"); + } + + public void test210(){ + runTest("inner types can't have the same simple name as an enclosing type"); + } + + public void test211(){ + runTest("test the unops and binops with various values"); + } + + public void test212(){ + runTest("test + and += for strings and variously typed values"); + } + + public void test213(){ + runTest("test try/catch/finally statements"); + } + + public void test214(){ + runTest("local types can be bound in the signatures of other local types"); + } + + public void test215(){ + runTest("type and package name conflicts are resolved happily (2)"); + } + + public void test216(){ + runTest("try statements work sorta like scoped items for exception flow control"); + } + + public void test217(){ + runTest("qualified this must work exactly, not based on subtypes"); + } + + public void test218(){ + runTest("nested finally blocks have interesting frame location problems"); + } + + public void test219(){ + runTest("nested synchronized blocks have interesting frame location problems"); + } + + public void test220(){ + runTest("anonymous inner classes with inner types"); + } + + public void test221(){ + runTest("qualified super call expr"); + } + + public void test222(){ + runTest("interfaces with non-explicitly static inner classes"); + } + + public void test223(){ + runTest("Operands work correctly"); + } + + public void test224(){ + runTest("simple tests of throws and for stmt typing"); + } + + public void test225(){ + runTest("test for not folding circular constants"); + } + + public void test226(){ + runTest("continue targets must be continuable"); + } + + public void test227(){ + runTest("qualified this to non-inner should be caught"); + } + + public void test228(){ + runTest("Cannot bind a name."); + } + + public void test229(){ + runTest("interface declaration not permitted in local method scope"); + } + + public void test230(){ + runTest("Locals inside other locals, ordering of processing [eh]"); + } + + public void test231(){ + runTest("asserts"); + } + + public void test232(){ + runTest("non-constant static final fields marked as final in .class"); + } + + public void test233(){ + runTest("handle multiple nested inner classes"); + } + + public void test234(){ + runTest("advice on a static method"); + } + + public void test235(){ + runTest("inner constructor syntax causes compile error"); + } + + public void test236(){ + runTest("widening of method parameters to match javac"); + } + + public void test237(){ + runTest("parenthesized string literals matching primitive type names"); + } + + public void test238(){ + runTest("simple type coercions tests"); + } + + public void test239(){ + runTest("order of type declarations shouldn't matter"); + } + + public void test240(){ + runTest("Scanner non recognizing strictfp."); + } + + public void test241(){ + runTest("Crashes when a lot of zeros are in front of a double variable [!!! purejava]"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/purejava/pureJava-tests.xml b/tests/src/test/java/org/aspectj/systemtest/purejava/pureJava-tests.xml new file mode 100644 index 000000000..9864ffe79 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/purejava/pureJava-tests.xml @@ -0,0 +1,1894 @@ +<!-- Pure Java Tests --> + + <ajc-test dir="pureJava/test120" title="unicodes and literals" + keywords="from-base,purejava"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="pureJava/test126" title="For Statement" + keywords="from-base,purejava"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="pureJava/test133" + title="correct super call lookup for method().name()" + keywords="from-base,purejava"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="new" pr="99" + title="combined logic expression (handling coericions vs. parens)" + keywords="from-java,purejava"> + <compile files="CombinedLogic.java"/> + <run class="CombinedLogic"/> + </ajc-test> + + <ajc-test dir="new" pr="99" + title="comment after class closes (with no new line at end)" + keywords="from-java,purejava"> + <compile files="CommentAfterClass.java"/> + <run class="CommentAfterClass"/> + </ajc-test> + + <ajc-test dir="new" pr="108" title="multi-dimensional array initializers" + keywords="from-java,purejava"> + <compile files="MultiArrays.java"/> + <run class="MultiArrays"/> + </ajc-test> + + <ajc-test dir="new" pr="125" + title="probelm with the generated names of exceptions" + keywords="from-java,purejava"> + <compile files="ExceptionNames.java"/> + <run class="ExceptionNames"/> + </ajc-test> + + <ajc-test dir="new" pr="109" + title="checks if the class field can be used on all of the primitive types" + keywords="from-java,purejava"> + <compile files="ClassFieldOnPrimitiveType.java"/> + <run class="ClassFieldOnPrimitiveType"/> + </ajc-test> + + <ajc-test dir="new" + title="Doesn't parse an array-returning method that throws an exception" + keywords="from-java,purejava"> + <compile files="ArrayMethod.java"/> + <run class="ArrayMethod"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="check that nested constructions of local classes work" + keywords="from-java,purejava"> + <compile files="NestedConstructionsOfLocalClasses.java"/> + <run class="NestedConstructionsOfLocalClasses"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Make sure anonymous classes can have non-nullary constructors" + keywords="from-java,purejava"> + <compile files="NonNullaryAnonymous.java"/> + <run class="NonNullaryAnonymous"/> + </ajc-test> + + <ajc-test dir="new" pr="417" + title="Full names are dropped from inner interfaces" + keywords="from-java,purejava"> + <compile files="PR417a.java"/> + <run class="PR417a"/> + </ajc-test> + + <ajc-test dir="new" pr="417" + title="Making sure full names stay on static inner classes" + keywords="from-java,purejava"> + <compile files="PR417b.java"/> + <run class="PR417b"/> + </ajc-test> + + <ajc-test dir="new" pr="408" + title="Not binding constructor when using more than one compilation" + keywords="from-java,purejava"> + <compile files="OuterAbstract_PR408.java"/> + <compile files="ExtendsOuterAbstract_PR408.java"/> + <compile files="ConstructorNotFound_PR408.java"/> + <run class="ConstructorNotFound_PR408"/> + </ajc-test> + + <ajc-test dir="pureJava" title="return;;; is not really legal" + keywords="from-java,purejava"> + <compile files="ReachableEmpty.java"> + <message kind="error" line="5"/> + <message kind="error" line="9"/> + <message kind="error" line="13"/> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="ajc treating Throwable as checked, issuing error if not found" + keywords="from-java,purejava"> + <compile files="FalseThrowsCE.java"/> + <run class="FalseThrowsCE"/> + </ajc-test> + + <ajc-test dir="new" pr="328" + title="package protected classes becoming public" + keywords="from-java,purejava"> + <compile files="PR328.java"/> + <run class="PR328"/> + </ajc-test> + + <ajc-test dir="new" title="IOException on windows if nul used as identifier" + keywords="from-java,purejava"> + <compile files="NulIOException.java"> + <message kind="error" line="12"/> + <message kind="error" line="14"/> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="NullPointerException (not compiler error) when extending non-static inner class" + keywords="from-java,purejava"> + <compile files="ExtendInnerCE.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="compiler flags final static variable as indefinite in member assignment." + keywords="from-java,purejava"> + <compile files="DefiniteStatic.java"/> + <run class="DefiniteStatic"/> + </ajc-test> + + <ajc-test dir="new" + title="confirm no IOException on windows if nul used as identifier" + keywords="from-java,purejava"> + <compile files="NulIOException2.java"/> + <run class="NulIOException2"/> + </ajc-test> + + <ajc-test dir="new" + title="final constructor parameter causes incorrect compiler error" + keywords="from-java,purejava"> + <compile files="FinalConstructorParm.java"/> + <run class="FinalConstructorParm"/> + </ajc-test> + + <ajc-test dir="new" title="Error expected for field of type void" + keywords="from-java,purejava"> + <compile files="VoidField.java"> + <message kind="error" line="2"/> + <message kind="error" line="4"/> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="new" title="Error expected for constructor in interfaces" + keywords="from-java,purejava"> + <compile files="InterfaceConstructor.java"> + <message kind="error" line="2"/> + <message kind="error" line="6"/> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="558" + title="class name for identifier as String should provoke error" + keywords="from-java,purejava"> + <compile files="PR558.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="567" + title="cyclic interface inheritance not detected if no classes implement the interfaces" + keywords="from-java,purejava,messages-vary"> + <compile files="CyclicInterfaceInheritance.java" + options="!eclipse"> + <message kind="error" line="14"/> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="567" title="cyclic class inheritance" + keywords="from-java,purejava"> + <compile files="CyclicClassInheritance.java"> + <message kind="error" line="11"/> + <message kind="error" line="12"/> + </compile> + </ajc-test> + + <!-- broken test - both javac and eclipse give error on line 35 --> + <!-- + <ajc-test dir="pureJava" title="Type names are not expressions on their own" + keywords="from-java,purejava"> + <compile files="TypeExprErrors.java"> + <message kind="error" line="10"/> + <message kind="error" line="17"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + <message kind="error" line="20"/> + <message kind="error" line="21"/> + <message kind="error" line="22"/> + <message kind="error" line="23"/> + <message kind="error" line="24"/> + <message kind="error" line="25"/> + <message kind="error" line="26"/> + <message kind="error" line="27"/> + <message kind="error" line="28"/> + <message kind="error" line="29"/> + <message kind="error" line="30"/> + <message kind="error" line="31"/> + <message kind="error" line="32"/> + <message kind="error" line="33"/> + <message kind="error" line="34"/> + <message kind="error" line="36"/> + <message kind="error" line="37"/> + </compile> + </ajc-test> + --> + + <ajc-test dir="pureJava/nameConflicts" + title="type and package name conflicts are resolved happily (1a)" + keywords="from-java,purejava"> + <compile files="p1/Main1.java,p1/Foo.java,p1/p2.java"/> + <run class="p1.Main1"/> + </ajc-test> + + <ajc-test dir="pureJava/nameConflicts" + title="(fails in USEJAVAC) type and package name conflicts are resolved happily (1b)" + keywords="from-java,purejava"> + <compile files="p1.java,p1/p2/Foo.java"/> + <compile files="p1/Main1.java,p1/Foo.java,p1/p2.java"/> + <run class="p1.Main1"/> + </ajc-test> + + <ajc-test dir="pureJava/nameConflicts" + title="type and package name conflicts caught as errors (1)" + keywords="from-java,purejava"> + <compile files="p1/p2.java,p1/Main1.java,p1/Foo.java,p1/p2/Foo.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="flow analysis where final variable set in another constructor" + keywords="from-java,purejava"> + <compile files="ConstructorFlow.java"/> + <run class="ConstructorFlow"/> + </ajc-test> + + <ajc-test dir="new" pr="584" + title="Can construct inner classes using qualified expressions" + keywords="from-java,purejava"> + <compile files="PR584.java"/> + <run class="PR584"/> + </ajc-test> + + <ajc-test dir="new/protectedStatic" pr="585" + title="subclass unable to access protected static methods using type-qualified references" + keywords="from-java,purejava"> + <compile files="SubClass.java,pack/SuperClass.java"/> + <run class="SubClass"/> + </ajc-test> + + <ajc-test dir="new" pr="588" title="Undefined inner class constructor" + keywords="from-java,purejava"> + <compile files="UndefinedInner.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="new/packagePrefix" pr="574" + title="classes that are package prefixes are illegal" + keywords="from-java,purejava,messages-vary"> + <compile files="p/prefix.java,p/prefix/SomeClass.java" + options="!eclipse"> + <message kind="error" line="2"/> + </compile> + </ajc-test> + + <ajc-test dir="new/introTypeMissing" + title="valid type expressions for introduced type testing" + keywords="from-java,purejava"> + <compile files="TargetClass.java,Util.java"/> + <run class="TargetClass"/> + </ajc-test> + + <ajc-test dir="new" + title="PR591 compiler error expected when directly calling unimplemented abstract method using super" + keywords="from-java,purejava"> + <compile files="AbstractMethodCall.java"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="suggested by Jacks 15.28-qualified-namestr tests" + keywords="from-java,purejava,messages-vary"> + <compile files="NonConstants.java" + options="!eclipse"> + <message kind="error" line="13"/> + <message kind="error" line="14"/> + <message kind="error" line="15"/> + <message kind="error" line="16"/> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="suggested by jacks 3.7-15 all comments must be closed" + keywords="from-java,purejava"> + <compile files="OpenComment.java"> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="new/classaccess" + title="package class access not enforced outside of package" + keywords="from-java,purejava"> + <compile files="main/Main.java,pack1/Target.java"> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="631" title="expecting CE for ambiguous reference" + keywords="from-java,purejava"> + <compile files="AmbiguousClassReference.java"> + <message kind="error" line="11"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="643" title="try without catch or finally" + keywords="from-java,purejava,message-vary"> + <compile files="TryNoCatchCE.java" + options="!eclipse"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="642" title="invalid floating-point constant" + keywords="from-java,purejava,messages-vary"> + <compile files="ParsingFloatCE.java" + options="!eclipse"> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + <ajc-test dir="new/subaspects" pr="647" + title="concrete aspect unable to access abstract package-private method in parent for overriding" + keywords="from-java,purejava,messages-vary" + comment="XXX fix source - package-private"> + <compile files="parent/ParentMethodCE.java,child/ChildMethodCE.java" + options="!eclipse"> + <message kind="warning" line="28"/> + <message kind="error" line="27"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="super reference used to disambiguate names of different but compatible types" + keywords="from-java,purejava"> + <compile files="SuperDisambiguatingType.java"/> + <run class="SuperDisambiguatingType"/> + </ajc-test> + + <ajc-test dir="pureJava" title="anonymous explicit inner constructors" + keywords="from-java,purejava"> + <compile files="QualifiedNewCP.java"/> + <run class="QualifiedNewCP"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Overruning the lineStarts buffer, DO NOT EDIT THIS FILE!!!!" + keywords="from-java,purejava"> + <compile files="AJError.java"/> + <run class="AJError"/> + </ajc-test> + + <ajc-test dir="new" pr="701" title="no CE for unambiguous type reference" + keywords="from-java,purejava"> + <compile files="UnambiguousClassReference3CP.java"/> + <run class="UnambiguousClassReference3CP"/> + </ajc-test> + + <ajc-test dir="new" pr="701" + title="CE for ambiguous type reference (imports)" + keywords="from-java,purejava"> + <compile files="AmbiguousClassReference2CE.java"> + <message kind="error" line="2"/> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="701" + title="CE for ambiguous type reference (two type declarations)" + keywords="from-java,purejava,messages-vary"> + <compile files="AmbiguousClassReference3CE.java" + options="!eclipse"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="701" + title="CE for ambiguous type reference (two inner types)" + keywords="from-java,purejava,messages-vary"> + <compile files="AmbiguousClassReference4CE.java" + options="!eclipse"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="709" title="final assignment in loop" + keywords="from-java,purejava"> + <compile files="FinalInLoop.java"/> + <run class="FinalInLoop"/> + </ajc-test> + + <ajc-test dir="pureJava" title="private super access in inners" + keywords="from-java,purejava"> + <compile files="PrivateSuperInnerAccess.java"/> + <run class="PrivateSuperInnerAccess"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested interface does not require new qualifier (8)" + keywords="from-java,purejava"> + <compile files="InvalidNewQualifier8CE.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested interface does not require new qualifier (9)" + keywords="from-java,purejava"> + <compile files="InvalidNewQualifier9CE.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested interface does not require new qualifier (10)" + keywords="from-java,purejava"> + <compile files="InvalidNewQualifier10CE.java"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested interface does not require new qualifier (14)" + keywords="from-java,purejava"> + <compile files="InvalidNewQualifier14CE.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested interface does not require new qualifier (15)" + keywords="from-java,purejava"> + <compile files="InvalidNewQualifier15CE.java"> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested interface does not require new qualifier (16)" + keywords="from-java,purejava"> + <compile files="InvalidNewQualifier16CE.java"> + <message kind="error" line="16"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="check that constructor name's match the enclosing type" + keywords="from-errors,purejava"> + <compile files="BadConstructorName.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="errors for not applicable or accessible methods" + keywords="from-errors,purejava"> + <compile files="MethodsNotFound.java"> + <message kind="error" line="4"/> + <message kind="error" line="8"/> + <message kind="error" line="12"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" pr="218" + title="import statement within class body crashes compiler" + keywords="from-errors,purejava"> + <compile files="ImportWithinClassBody.java"> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Accessing instance fields and instance methods statically." + keywords="from-errors,purejava"> + <compile files="AccessingInstanceFieldsStatically.java"> + <message kind="error" line="15"/> + <message kind="error" line="16"/> + <message kind="error" line="17"/> + <message kind="error" line="18"/> + <message kind="error" line="26"/> + <message kind="error" line="27"/> + <message kind="error" line="30"/> + <message kind="error" line="38"/> + <message kind="error" line="39"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Crashes when a cast is within another cast" + keywords="from-errors,purejava"> + <compile files="CastInCast.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Crashes when a cast of the form )int) appears" + keywords="from-errors,purejava,messages-vary"> + <compile files="BadCast.java" + options="!eclipse"> + <message kind="error" line="9"/> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Crashes when the closing brace is reversed" + keywords="from-errors,purejava,messages-vary"> + <compile files="ClosingBrace.java" + options="!eclipse"> + <message kind="error" line="11"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Crashes when a method name is missing in a call -- e.g. 'System.out.();'" + keywords="from-errors,purejava"> + <compile files="NoMethodName.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Crashes when a bad r-value appears." + keywords="from-errors,purejava"> + <compile files="BadValue.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Two underscores as a variables causes a crash" + keywords="from-errors,purejava"> + <compile files="BadVar.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Crashes when assigning to a final static in an intializer and declaration" + keywords="from-errors,purejava"> + <compile files="FinalStatic.java"> + <message kind="error" line="13"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Crashes when two dots appear instead of one" + keywords="from-errors,purejava"> + <compile files="TwoDots.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Crashes when there're stray dots" + keywords="from-errors,purejava"> + <compile files="StrayDot.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Stray characters cause a crash" + comment="XXX public class in wrong file" + keywords="from-errors,purejava"> + <compile files="StraySlash.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Colon instead of a semi-colon causes a crash" + comment="XXX public class in wrong file" + keywords="from-errors,purejava"> + <compile files="Colon.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="type error in initializer caught by ajc, not javac" + keywords="from-errors,purejava"> + <compile files="ArrayInitializerType.java"> + <message kind="error" line="2"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Circular inheritance with classes causes a stack overflow." + keywords="from-errors,purejava"> + <compile files="CircularExtends.java"> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="Missing ;" keywords="from-errors,purejava"> + <compile files="PR405.java"> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="cast expressions should not allow casts between ifaces and array types" + keywords="from-errors,purejava"> + <compile files="InterfaceArrayCast.java"> + <message kind="error" line="9"/> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="parsing errors for various bad forms of NewArrayExprs." + keywords="from-errors,purejava"> + <compile files="BadNewArrayExprs.java"> + <message kind="error" line="4"/> + <message kind="error" line="5"/> + <message kind="error" line="6"/> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="good error for bad field and inner class references" + keywords="from-errors,purejava"> + <compile files="BadReferences.java"> + <message kind="error" line="3"/> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Implementing a non-interface used to crash the compiler." + keywords="from-errors,purejava"> + <compile files="PR333.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="error of no return statement detected not by ajc but by javac (line 4)" + keywords="from-errors,purejava"> + <compile files="NoReturnStatementSimple.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="class and interface extension" + keywords="from-errors,purejava,messages-vary"> + <compile files="BadExtension.java" + options="!eclipse"> + <message kind="error" line="7"/> + <message kind="error" line="9"/> + <message kind="error" line="16"/> + <message kind="error" line="17"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + <message kind="error" line="21"/> + <message kind="error" line="35"/> + <message kind="error" line="38"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="types in throws clauses" + keywords="from-errors,purejava"> + <compile files="ThrowsClause.java"> + <message kind="error" line="2"/> + <message kind="error" line="4"/> + <message kind="error" line="13"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="bad switch syntax" + keywords="from-errors,purejava"> + <compile files="Switch.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="Referencing various things from static contexts" + keywords="from-errors,purejava"> + <compile files="StaticContexts.java"> + <message kind="error" line="11"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + <message kind="error" line="20"/> + <message kind="error" line="21"/> + <message kind="error" line="27"/> + <message kind="error" line="28"/> + <message kind="error" line="31"/> + <message kind="error" line="35"/> + <message kind="error" line="36"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="Some expressions are illegal expression statements" + keywords="from-errors,purejava"> + <compile files="BadExpressionStatement.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="illegal forward reference" + keywords="from-errors,purejava"> + <compile files="IllegalForwardReference.java"> + <message kind="error" line="9"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="protected accessibility" + keywords="from-errors,purejava"> + <compile files="protectedAccess/Main.java,protectedAccess/p1/C1.java"> + <message kind="error" line="26"/> + <message kind="error" line="28"/> + <message kind="error" line="29"/> + <message kind="error" line="31"/> + <message kind="error" line="37"/> + <message kind="error" line="45"/> + <message kind="error" line="46"/> + <message kind="error" line="54"/> + <message kind="error" line="55"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="parse-time illegal modifiers" + keywords="from-errors,purejava"> + <compile files="Modifiers1.java"> + <message kind="error" line="2"/> + <message kind="error" line="3"/> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="check-time illegal modifiers" + keywords="from-errors,purejava"> + <compile files="Modifiers.java"> + <message kind="error" line="2"/> + <message kind="error" line="3"/> + <message kind="error" line="4"/> + <message kind="error" line="6"/> + <message kind="error" line="7"/> + <message kind="error" line="8"/> + <message kind="error" line="9"/> + <message kind="error" line="11"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" title="illegal synchronized stmts" + keywords="from-errors,purejava,messages-vary"> + <compile files="BadSynchronized.java" + options="!eclipse"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="modifiers on interface members" + keywords="from-errors,purejava"> + <compile files="InterfaceMembers.java"> + <message kind="error" line="2"/> + <message kind="error" line="3"/> + <message kind="error" line="4"/> + <message kind="error" line="5"/> + <message kind="error" line="7"/> + <message kind="error" line="8"/> + <message kind="error" line="9"/> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="good errors (and not too many) for missing members" + comment="XXX import of class in default package" + + keywords="from-errors,purejava"> + <compile files="NotFound.java"> + <message kind="error" line="1"/> + <message kind="error" line="2"/> + <message kind="error" line="6"/> + <message kind="error" line="9"/> + <message kind="error" line="10"/> + <message kind="error" line="14"/> + <message kind="error" line="16"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="536" + title="expecting compile failures with subclass narrowing scope of superclass methods or accessing private superclass variables" + keywords="from-errors,purejava"> + <compile files="RestrictingVisibilityCF.java"> + <message kind="error" line="27"/> + <message kind="error" line="29"/> + <message kind="error" line="31"/> + <message kind="error" line="39"/> + <message kind="error" line="41"/> + <message kind="error" line="46"/> + <message kind="error" line="48"/> + <message kind="error" line="53"/> + </compile> + </ajc-test> + + <ajc-test dir="errors" + title="inner classes may not have static non-constant members" + keywords="from-errors,purejava"> + <compile files="InnerMembers.java"> + <message kind="error" line="8"/> + <message kind="error" line="9"/> + <message kind="error" line="10"/> + <message kind="error" line="11"/> + <message kind="error" line="16"/> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="flow analysis with local types" + keywords="from-errors,purejava"> + <compile files="InnerFlow.java"> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="PR584 Can construct inner classes using qualified expressions" + keywords="from-resolved_10rc3,purejava"> + <compile files="PR584.java"/> + <run class="PR584"/> + </ajc-test> + + <ajc-test dir="new" pr="715" title="incrementing objects, arrays - 2" + keywords="from-resolved_104,purejava"> + <compile files="ArrayInc2CE.java"> + <message kind="error" line="12"/> + <message kind="error" line="13"/> + <message kind="error" line="14"/> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="715" title="incrementing objects, arrays CE" + keywords="from-resolved_104,purejava,messages-vary"> + <compile files="ArrayIncCE.java" + options="!eclipse"> + <message kind="error" line="15"/> + <message kind="error" line="16"/> + <message kind="error" line="17"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="715" title="incrementing objects, arrays - 3" + keywords="from-resolved_104,purejava"> + <compile files="ArrayInc3CE.java"> + <message kind="error" line="15"/> + <message kind="error" line="16"/> + <message kind="error" line="17"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + </compile> + </ajc-test> + + <ajc-test dir="new" pr="715" title="incrementing objects, arrays" + keywords="from-resolved_104,purejava"> + <compile files="ArrayInc.java"/> + <run class="ArrayInc"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="737" + title="no circularity errors simply because of inners (1)" + keywords="from-resolved_105,purejava"> + <compile files="circle/Test1CP.java"/> + <run class="circle.Test1CP"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="737" + title="no circularity errors simply because of inners (2)" + keywords="from-resolved_105,purejava"> + <compile files="circle/Test2CP.java"/> + <run class="circle.Test2CP"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="737" + title="should have circular inheritance errors (1)" + keywords="from-resolved_105,purejava,messages-vary"> + <compile files="circle/Test1CF.java" + options="!eclipse"> + <message kind="error" line="7"/> + <message kind="error" line="15"/> + <message kind="error" line="17"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="737" + title="should have circular inheritance errors (2)" + keywords="from-resolved_105,purejava,messages-vary"> + <compile files="circle/Test2CF.java" + options="!eclipse"> + <message kind="error" line="6"/> + <message kind="error" line="10"/> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="728" + title="interface using preceding subinterface in its definition" + keywords="from-resolved_105,purejava"> + <compile files="ParentUsingChild.java"/> + <run class="ParentUsingChild"/> + </ajc-test> + + <ajc-test dir="new" pr="645" + title="Parent interface using public inner interface of child in same file" + keywords="from-resolved_105,purejava"> + <compile files="ParentInterfaceUsingChildInnerInterface.java"/> + <run class="ParentInterfaceUsingChildInnerInterface"/> + </ajc-test> + + <ajc-test dir="errors" + title="a type is not allowed to extend or implement its own innner type" + keywords="from-resolved_105,purejava"> + <compile files="NestedInterfaceTest.java"> + <message kind="error" line="1"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="try requires block JLS 14.19" + keywords="from-resolved_105,purejava,messages-vary"> + <compile files="TryBlockRequiredCE.java" + options="!eclipse"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="722" title="loop expressions not declarations" + keywords="from-resolved_105,purejava,messages-vary"> + <compile files="DeclarationsInLoopsCE.java" + options="!eclipse"> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + + + + + + + + <ajc-test dir="new" pr="663" + title="no error when public class is in file of a different name" + keywords="from-resolved_105,purejava"> + <compile options="-strict" files="PublicClassWrongFilename.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="739" + title="local variables must be final to be accessed from inner class" + keywords="from-resolved_105,purejava"> + <compile files="LocalsFromInnerCE.java"> + <message kind="error" line="6"/> + <message kind="error" line="13"/> + <message kind="error" line="19"/> + <message kind="error" line="25"/> + <message kind="error" line="32"/> + <message kind="error" line="40"/> + <message kind="error" line="51"/> + <message kind="error" line="61"/> + <message kind="error" line="67"/> + <message kind="error" line="75"/> + <message kind="error" line="81"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="739" + title="final local variables may be accessed from inner class" + keywords="from-resolved_105,purejava"> + <compile files="LocalsFromInnerCP.java"/> + <run class="LocalsFromInnerCP"/> + </ajc-test> + + + <ajc-test dir="pureJava" pr="723" title="missing package identifier" + keywords="from-resolved_105,purejava"> + <compile files="MissingPackageCE.java"> + <message kind="error" line="2"/> + </compile> + </ajc-test> + <ajc-test dir="new" pr="701" + title="CE for ambiguous type reference (two files in package)" + keywords="from-resolved_105,purejava"> + <compile + files="ambiguousClass/AmbiguousReferent.java,ambiguousClass/AmbiguousClassReference.java"> + <message kind="error" line="5"/> + </compile> + </ajc-test> + + + <ajc-test dir="new" + title="initializer can throw so long as all constructors declare so" + keywords="from-resolved_105,purejava"> + <compile files="InitializerWithThrow.java"/> + <run class="InitializerWithThrow"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="interfaces may not contain initializers (bug found by jacks)" + keywords="from-resolved_105,purejava"> + <compile files="InterfaceMembersCf.java"> + <message kind="error" line="2"/> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="initializers must be able to complete normally (found by jacks)" + keywords="from-resolved_105,purejava,messages-vary"> + <compile files="InitializerFlowCf.java" + options="!eclipse"> + <message kind="error" line="2"/> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="more tests of super alone" + keywords="from-resolved_105,purejava"> + <compile files="SuperIsWeird.java"> + <message kind="error" line="9"/> + <message kind="error" line="13"/> + <message kind="error" line="20"/> + <message kind="error" line="21"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="752" + title="subclass access to enclosing super class private members" + keywords="from-resolved_105,purejava,fail-unimplemented"> + <compile files="SubclassAccessToEnclosingSuperClassPrivate.java"/> + <run class="SubclassAccessToEnclosingSuperClassPrivate"/> + </ajc-test> + + <ajc-test dir="pureJava" title="various tests of switch bounds" + keywords="from-resolved_106,purejava"> + <compile files="SwitchBounds.java"/> + <run class="SwitchBounds"/> + </ajc-test> + + <ajc-test dir="new" pr="601" + title="VerifyError if nested sync returning result" + comment="XXX inconsistent behavior?" + keywords="from-resolved_10final,purejava"> + <compile files="NestedSyncWithResult.java"/> + <run class="NestedSyncWithResult"/> + </ajc-test> + + + <ajc-test dir="new" pr="134" + title="import of a class in the default package" + keywords="from-broken14usejavac,purejava"> + <compile files="ImportFromUnnamed.java,DeclaredExcs.java"/> + <run class="ImportFromUnnamed"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing static interfaces with import statements" + keywords="from-broken14usejavac,purejava"> + <compile files="ClassWithStaticInnerInterfaces.java"/> + <compile files="ImportingStaticInnerInterfaces_PR386.java"/> + <run class="ImportingStaticInnerInterfaces_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing static interfaces with import statements stars" + keywords="purejava,from-broken14usejavac"> + <compile files="ClassWithStaticInnerInterfaces.java"/> + <compile files="ImportingStaticInnerInterfacesStars_PR386.java"/> + <run class="ImportingStaticInnerInterfacesStars_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing static interfaces with import statements stars 2" + keywords="purejava,from-broken14usejavac"> + <compile files="ClassWithStaticInnerInterfaces.java"/> + <compile files="ImportingStaticInnerInterfacesStars2_PR386.java"/> + <run class="ImportingStaticInnerInterfacesStars2_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing static interfaces with import statements stars 3" + keywords="purejava,from-broken14usejavac"> + <compile files="ClassWithStaticInnerInterfaces.java"/> + <compile files="ImportingStaticInnerInterfacesStars3_PR386.java"/> + <run class="ImportingStaticInnerInterfacesStars3_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing interfaces with import statements" + keywords="purejava,from-broken14usejavac"> + <compile + files="ClassWithInnerInterfaces.java,ImportingInnerInterfaces_PR386.java"/> + <run class="ImportingInnerInterfaces_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing interfaces with import statements stars" + keywords="purejava,from-broken14usejavac"> + <compile + files="ClassWithInnerInterfaces.java,ImportingInnerInterfacesStars_PR386.java"/> + <run class="ImportingInnerInterfacesStars_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing interfaces with import statements stars 2" + keywords="purejava,from-broken14usejavac"> + <compile + files="ClassWithInnerInterfaces.java,ImportingInnerInterfacesStars2_PR386.java"/> + <run class="ImportingInnerInterfacesStars2_PR386"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="386" + title="Referencing interfaces with import statements stars 3" + keywords="purejava,from-broken14usejavac"> + <compile + files="ClassWithInnerInterfaces.java,ImportingInnerInterfacesStars3_PR386.java"/> + <run class="ImportingInnerInterfacesStars3_PR386"/> + </ajc-test> + + <ajc-test dir="new/PR862" pr="862" + title="import any inner from interface implementor" + keywords="purejava"> + <compile files="pack/ImportInnerFromInterfaceImplementor.java"> + <dir-changes added="pack.ImportInnerFromInterfaceImplementor"/> + </compile> + <run class="pack.ImportInnerFromInterfaceImplementor"/> + </ajc-test> + + <ajc-test dir="pureJava/equalsMethOnStr" pr="214" + title="equals method on quoted strings" keywords="from-java"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="pureJava/anonInnerClass" pr="294" + title="anonymous inner class" keywords="from-java"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="parsing of parenthesized 'this' (in returns)" keywords="from-java"> + <compile files="ReturnThis.java"/> + <run class="ReturnThis"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Strings are folded and interned correctly" + keywords="from-java"> + <compile files="StringFold.java"/> + <run class="StringFold"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Cast binds tighter than equality tests" + keywords="from-java"> + <compile files="CastAndBinary.java"/> + <run class="CastAndBinary"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Boundary base values can be parsed" + keywords="from-java"> + <compile files="BoundaryNums.java"/> + <run class="BoundaryNums"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="State is passed correctly across nested annonymous inners" + keywords="from-java"> + <compile files="NestedInners.java"/> + <run class="NestedInners"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="?: expressions should typecheck in interesting ways" + keywords="from-java"> + <compile files="TriTestTypecheck.java"/> + <run class="TriTestTypecheck"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="cast expressions should allow casts to/from interfaces at compile-time." + keywords="from-java"> + <compile files="InterfaceCast.java"/> + <run class="InterfaceCast"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="various anonymous inner classes plus super types tests" + keywords="from-java"> + <compile files="InnerSuper.java"/> + <run class="InnerSuper"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Various comment syntaxes should be handled." + keywords="from-java"> + <compile files="CommentSyntax.java"/> + <run class="CommentSyntax"/> + </ajc-test> + + <ajc-test dir="pureJava/abstractInner" + title="Abstract inner classes across package boundaries" + keywords="from-java"> + <compile files="C.java,pkg/A.java"/> + <run class="C"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="inner classes accessing outers and some more inner class names" + keywords="from-java"> + <compile files="InnerAccess.java"/> + <run class="InnerAccess"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="remember to cast folded values down to the proper types." + keywords="from-java"> + <compile files="CastingFoldedValues.java"/> + <run class="CastingFoldedValues"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="inner classes can be built using protected constructors in super" + keywords="from-java"> + <compile files="VariousConstructors.java"/> + <run class="VariousConstructors"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="401" + title="The current AspectJ compiler cannot parse qualified superclass constructor invocations" + keywords="from-java"> + <compile files="QualifiedSuperClassConstructorInvocations_PR401.java"/> + <run class="QualifiedSuperClassConstructorInvocations_PR401"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="421" + title="More thourough test of static members using full names" + keywords="from-java"> + <compile + files="Statics.java,StaticMembers_PR421.java,p1/C1.java,p1/P1Statics.java,p1/subp1/SubC1.java,p1/p2/P1P2Statics.java"/> + <run class="StaticMembers_PR421"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="421" + title="More thourough test of static members using imports" + keywords="from-java"> + <compile + files="Statics.java,StaticMembersImports_PR421.java,p1/C1.java,p1/P1Statics.java,p1/subp1/SubC1.java,p1/p2/P1P2Statics.java"/> + <run class="StaticMembersImports_PR421"/> + </ajc-test> + + <ajc-test dir="pureJava/conflictingPackageNames" pr="437" + title="Looking in class Java for java.lang.String WITH separate compilation" + keywords="from-java"> + <compile files="Java.java"/> + <compile files="Main.java"/> + <run class="Main"/> + </ajc-test> + + <ajc-test dir="pureJava/conflictingPackageNames" pr="437" + title="Looking in class Java for java.lang.String WITHOUT separate compilation" + keywords="from-java"> + <compile files="Main.java,Java.java"/> + <run class="Main"/> + </ajc-test> + + <ajc-test dir="pureJava/conflictingPackageNamesWithPackages" pr="437" + title="Looking in class Java for java.lang.String WITH separate compilation with packages" + keywords="from-java"> + <compile files="Java.java"/> + <compile files="Main.java"/> + <run class="conflictingPackageNamesWithPackages.Main"/> + </ajc-test> + + <ajc-test dir="pureJava/conflictingPackageNamesWithPackages" pr="437" + title="Looking in class Java for java.lang.String WITHOUT separate compilation with packages" + keywords="from-java"> + <compile files="Main.java,Java.java"/> + <run class="conflictingPackageNamesWithPackages.Main"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Testing ternary operations." + keywords="from-java"> + <compile files="MultiTernaryOps.java"/> + <run class="MultiTernaryOps"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Lifting locals in switch statements." + keywords="from-java"> + <compile files="SwitchStmtLocals.java"/> + <run class="SwitchStmtLocals"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Getting confused when looking up method signatures" + keywords="from-java"> + <compile files="MethodSigs.java"/> + <run class="MethodSigs"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Not recognizing the chars '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7'" + keywords="from-java"> + <compile files="Chars.java"/> + <run class="Chars"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Test chars '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7' with a case statement" + keywords="from-java"> + <compile files="CaseClauses.java"/> + <run class="CaseClauses"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Checking character values with all the unicode chars." + keywords="from-java"> + <compile files="CharsUnicode.java"/> + <run class="CharsUnicode"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Trouble finding methods with the same name and different parameter types" + keywords="from-java"> + <compile files="MethodsWithTheSameName.java"/> + <run class="MethodsWithTheSameName"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Binding non-public static inner classes of interfaces in other packages" + keywords="from-java"> + <compile + files="StaticClassesInInterfaces.java,anotherPackage/AnotherPackageInterface.java"/> + <run class="StaticClassesInInterfaces"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Not recognizing the octal chars '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7'" + keywords="from-java"> + <compile files="OctalChars.java"/> + <run class="OctalChars"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Members with the same name as their package cause confusion with fully-qualified names." + keywords="from-java"> + <compile files="samenames/Main.java,samenames/Other.java"/> + <run class="samenames.Main"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Fully-qual'ed names with same start as variable names" + keywords="from-java"> + <compile files="FullNames.java"/> + <run class="FullNames"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Fully qualifying inner classes within annonymous classes causes problems." + keywords="from-java"> + <compile files="InnerClassesInAnnonymousClasses.java"/> + <run class="InnerClassesInAnnonymousClasses"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Calls to methods in outer annonymous classes are being qual's incorrectly with 'this'" + keywords="from-java"> + <compile files="MisplacedThisInAnnonymousInnerClasses.java"/> + <run class="MisplacedThisInAnnonymousInnerClasses"/> + </ajc-test> + + <ajc-test dir="pureJava/innersFromSourceAndBytecode" + title="Reading inner classes from source and bytecode (1) -- was failing" + keywords="from-java"> + <compile files="C.java,D.java"/> + <compile files="Main.java,C.java" + includeClassesDir="true"/> + <run class="Main"/> + </ajc-test> + + <ajc-test dir="pureJava/innersFromSourceAndBytecode" + title="Reading inner classes from source and bytecode (2)" + keywords="from-java"> + <compile files="Main.java,C.java,D.java"/> + <run class="Main"/> + </ajc-test> + + <ajc-test dir="pureJava/innersFromSourceAndBytecode" + title="Reading inner classes from source and bytecode (3)" + keywords="from-java"> + <compile files="C.java,D.java"/> + <compile files="Main.java,C.java,D.java" + includeClassesDir="true"/> + <run class="Main"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Not lifting types correctly with bytes and shorts with ternary ops" + keywords="from-java"> + <compile files="TernaryPrimitiveOps.java"/> + <run class="TernaryPrimitiveOps"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Not looking up methods inside of anonymous declarations correctly." + keywords="from-java"> + <compile files="AnonymousMethodLookup.java"/> + <run class="AnonymousMethodLookup"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Resolving extended classes with array parameters" + keywords="from-java"> + <compile files="ResolvingArrayParameters.java"/> + <run class="ResolvingArrayParameters"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Assignments as second arguments in ternary operators." + keywords="from-java"> + <compile files="TernaryAssignments.java"/> + <run class="TernaryAssignments"/> + </ajc-test> + + + <ajc-test dir="pureJava" title="Conflicting inner classes with interfaces." + keywords="from-java"> + <compile files="PR413.java"/> + <run class="PR413"/> + </ajc-test> + + <ajc-test dir="pureJava" title="confusions of casts and parens" + keywords="from-java"> + <compile files="CastVsParen.java"/> + <run class="CastVsParen"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="default constructors seen by inner classes subtyping outers" + keywords="from-java"> + <compile files="DefaultConsAndInner.java"/> + <run class="DefaultConsAndInner"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="folding fields set to anonymous instances containing self-references" + keywords="from-java"> + <compile files="AnonFolding.java"/> + <run class="AnonFolding"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="finally at the end of a method that needs to return" + keywords="from-java"> + <compile files="FinallyAndReturns.java"/> + <run class="FinallyAndReturns"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="overriding methods from object in interfaces and multiple-inheritance" + keywords="from-java"> + <compile files="InterfaceAndObject.java"/> + <run class="InterfaceAndObject"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="private fields in an outer class accessed by an inner which also extends the outer" + keywords="from-java"> + <compile files="PrivateFields.java"/> + <run class="PrivateFields"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="breaking out of a labeled block inside of an if" + keywords="from-java"> + <compile files="Breaks.java"/> + <run class="Breaks"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="abstractifying a method and getting it back through super" + keywords="from-java"> + <compile files="Abstracts.java"/> + <run class="Abstracts"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Packages and static classes with the same name produce compile errors." + keywords="from-java"> + <compile files="PackagesAndStaticClassesWithTheSameName.java"/> + <run class="PackagesAndStaticClassesWithTheSameName"/> + </ajc-test> + + <ajc-test dir="pureJava/innerTypeModifiers" + title="Inner types must generate classfiles with only Public/Default access flags." + keywords="from-java"> + <compile files="pkg1/Main.java,pkg2/Foo.java"/> + <run class="pkg1.Main"/> + </ajc-test> + + <ajc-test dir="pureJava/innerDefaultConstructors" + title="Default constructors have same access as their enclosing type" + keywords="from-java"> + <compile files="pkg1/Main.java,pkg2/Foo.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="Returning primitive values matching method return type (minimal)" + keywords="from-java"> + <compile files="ReturnTypes.java"/> + <run class="ReturnTypes"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Flow analysis and if(true)" + keywords="from-java"> + <compile files="Flow.java"/> + <run class="Flow"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="packages and generated inner types (for I.class)" + keywords="from-java"> + <compile files="InterfaceAndClass.java"/> + <run class="p.InterfaceAndClass"/> + </ajc-test> + + <ajc-test dir="pureJava" title="A.this exprs match by exact type matching" + keywords="from-java"> + <compile files="QualifiedThisMatchesExactly.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="Implicit this for new inner instance must be avaliable" + keywords="from-java"> + <compile files="ImplicitThisMissing.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="Inners can reference protected fields of their outer's super." + keywords="from-java"> + <compile + files="protectedFieldRefInInner/Main.java,protectedFieldRefInInner/p1/C.java"/> + <run class="protectedFieldRefInInner.Main"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Primitives that special case for a constant arm should work" + keywords="from-java"> + <compile files="OneArmedPrimitiveTests.java"/> + <run class="OneArmedPrimitiveTests"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Parenthesized true and false don't parse" + keywords="from-java"> + <compile files="ParenKeywords.java"/> + <run class="ParenKeywords"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Field sets to public fields of private fields of enclosing types" + keywords="from-java"> + <compile files="InnerFieldRef.java"/> + <run class="InnerFieldRef"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Constant values should be stored with the correct type of their fields" + keywords="from-java"> + <compile files="ConstantValueConversion.java"/> + <run class="ConstantValueConversion"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Local variables in initializers should not be treated as blank final fields" + keywords="from-java"> + <compile files="LocalInitializerVariableNotBlank.java"/> + <run class="LocalInitializerVariableNotBlank"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Binops aren't allowed as update stmts in for loops" + keywords="from-java"> + <compile files="NonStmtInFor.java"> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="Can't avoid doing division in case of div by zero" + keywords="from-java"> + <compile files="DivOpMustHappen.java"/> + <run class="DivOpMustHappen"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="Testing frames w/greater than FF locals and 7F incs (i.e., WIDE instruction)" + keywords="from-java"> + <compile files="BigFrameTest.java"/> + <run class="BigFrameTest"/> + </ajc-test> + + <ajc-test dir="pureJava" title="correct numeric literals" + keywords="from-java"> + <compile files="LiteralsCp.java"/> + <run class="LiteralsCp"/> + </ajc-test> + + <ajc-test dir="pureJava" title="invalid numeric literals" + keywords="from-java"> + <compile files="LiteralsCf.java"> + <message kind="error" line="8"/> + <message kind="error" line="9"/> + <message kind="error" line="10"/> + <message kind="error" line="11"/> + <message kind="error" line="12"/> + <message kind="error" line="17"/> + <message kind="error" line="18"/> + <message kind="error" line="19"/> + <message kind="error" line="20"/> + <message kind="error" line="21"/> + <message kind="error" line="22"/> + <message kind="error" line="23"/> + <message kind="error" line="25"/> + <message kind="error" line="27"/> + <message kind="error" line="28"/> + <message kind="error" line="29"/> + <message kind="error" line="30"/> + <message kind="error" line="32"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" pr="538" + title="inner types can't have the same simple name as an enclosing type" + keywords="from-java"> + <compile files="InnerNameConflictsCf.java"> + <message kind="error" line="9"/> + <message kind="error" line="14"/> + <message kind="error" line="20"/> + <message kind="error" line="21"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="test the unops and binops with various values" keywords="from-java"> + <compile files="BigOps.java"/> + <run class="BigOps"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="test + and += for strings and variously typed values" + keywords="from-java"> + <compile files="BigString.java"/> + <run class="BigString"/> + </ajc-test> + + <ajc-test dir="pureJava" title="test try/catch/finally statements" + keywords="from-java"> + <compile files="TryCatchFinally.java"/> + <run class="TryCatchFinally"/> + </ajc-test> + + + <ajc-test dir="pureJava" pr="547" + title="local types can be bound in the signatures of other local types" + keywords="from-resolved_10rc3,from-java"> + <compile files="LocalInners.java"/> + <run class="LocalInners"/> + </ajc-test> + + <ajc-test dir="pureJava/nameConflicts" + title="type and package name conflicts are resolved happily (2)" + keywords="from-java"> + <compile files="p1/Main2.java,p1/p2/Foo.java"/> + <run class="p1.Main2"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="try statements work sorta like scoped items for exception flow control" + keywords="from-java"> + <compile files="TryWorksLikeEnvironment.java"/> + <run class="TryWorksLikeEnvironment"/> + </ajc-test> + + <ajc-test dir="pureJava" + title="qualified this must work exactly, not based on subtypes" + keywords="from-java"> + <compile files="QualifiedThisExactness.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="nested finally blocks have interesting frame location problems" + keywords="from-java"> + <compile files="NestedFinally.java"/> + <run class="NestedFinally"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="601" + title="nested synchronized blocks have interesting frame location problems" + keywords="from-java"> + <compile files="NestedSynchronized.java"/> + <run class="NestedSynchronized"/> + </ajc-test> + + <ajc-test dir="pureJava" title="anonymous inner classes with inner types" + keywords="from-java"> + <compile files="AnonymousWithInner.java"/> + <run class="AnonymousWithInner"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="651" title="qualified super call expr" + keywords="from-java"> + <compile files="QualifiedSuperCall.java"/> + <run class="QualifiedSuperCall"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="680" + title="interfaces with non-explicitly static inner classes" + keywords="from-java"> + <compile files="InterfaceAndInnerHelper.java"/> + <compile files="InterfaceAndInner.java" + includeClassesDir="true"/> + <run class="InterfaceAndInner"/> + </ajc-test> + + <ajc-test dir="pureJava" title="Operands work correctly" + keywords="from-bigjava"> + <compile files="Ops.java"/> + <run class="Ops"/> + </ajc-test> + + <ajc-test dir="pureJava" title="simple tests of throws and for stmt typing" + keywords="from-errors"> + <compile files="SimpleSpec.java"> + <message kind="error" line="4"/> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="test for not folding circular constants" + keywords="from-errors"> + <compile files="CircularFolding.java"> + <message kind="error" line="6"/> + <message kind="error" line="7"/> + <message kind="error" line="8"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" title="continue targets must be continuable" + keywords="from-errors"> + <compile files="BadContinueTarget.java"> + <message kind="error" line="6"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="qualified this to non-inner should be caught" + keywords="from-errors"> + <compile files="BadQualifiedNew.java"> + <message kind="error" line="4"/> + </compile> + </ajc-test> + + <ajc-test dir="new" + title="Cannot bind a name." keywords="from-resolved_10x,purejava"> + <compile files="CannotReferenceSuper.java"/> + <run class="CannotReferenceSuper"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="721" + title="interface declaration not permitted in local method scope" + keywords="from-resolved_105"> + <compile files="LocalInterfaceCE.java"> + <message kind="error" line="5"/> + <message kind="error" line="8"/> + <message kind="error" line="11"/> + <message kind="error" line="15"/> + </compile> + </ajc-test> + + <ajc-test dir="pureJava" + title="Locals inside other locals, ordering of processing [eh]" + keywords="from-resolved_105"> + <compile files="LocalInners2.java"/> + <run class="LocalInners2"/> + </ajc-test> + + <ajc-test dir="pureJava" pr="866" + title="non-constant static final fields marked as final in .class"> + <compile files="FinalStaticField.java"/> + <run class="FinalStaticField"/> + </ajc-test> + + <ajc-test dir="new" title="handle multiple nested inner classes" + keywords="from-java"> + <compile files="InnerHell.java"/> + <run class="InnerHell"/> + </ajc-test> + + <ajc-test dir="new/volatileKeyword" pr="151" + title="advice on a static method" keywords="from-java"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="new/innerConsSyntax" pr="192" + title="inner constructor syntax causes compile error" keywords="from-java"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="new/paramWidening" pr="195" + title="widening of method parameters to match javac" keywords="from-java"> + <compile files="Driver.java"/> + <run class="Driver"/> + </ajc-test> + + <ajc-test dir="new" pr="313" + title="parenthesized string literals matching primitive type names" + keywords="from-java"> + <compile files="ParenPrimitive.java"/> + <run class="ParenPrimitive"/> + </ajc-test> + + <ajc-test dir="new" title="simple type coercions tests" keywords="from-java"> + <compile files="TypeCoercions.java"/> + <run class="TypeCoercions"/> + </ajc-test> + + <ajc-test dir="new" title="order of type declarations shouldn't matter" + keywords="from-java"> + <compile files="OrderOfTypes.java"/> + <run class="OrderOfTypes"/> + </ajc-test> + + <ajc-test dir="new" title="Scanner non recognizing strictfp." + keywords="from-java"> + <compile files="StrictFp.java"/> + <run class="StrictFp"/> + </ajc-test> + + <ajc-test dir="new" + title="Crashes when a lot of zeros are in front of a double variable [!!! purejava]" + keywords="from-java"> + <compile files="Zeros.java"/> + <run class="Zeros"/> + </ajc-test> + diff --git a/tests/src/test/java/org/aspectj/systemtest/purejava/pureJava.xml b/tests/src/test/java/org/aspectj/systemtest/purejava/pureJava.xml new file mode 100644 index 000000000..1eb4b9f60 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/purejava/pureJava.xml @@ -0,0 +1,10 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[ +<!ENTITY tests SYSTEM "../tests/src/org/aspectj/systemtest/purejava/pureJava-tests.xml"> +]> +<!-- Pure Java Tests --> + +<suite> + +&tests; + +</suite> \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/serialVerUID/SUIDTests.java b/tests/src/test/java/org/aspectj/systemtest/serialVerUID/SUIDTests.java new file mode 100644 index 000000000..50c5dc216 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/serialVerUID/SUIDTests.java @@ -0,0 +1,96 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.serialVerUID; + +import java.io.File; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class SUIDTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SUIDTests.class); + } + + protected File getSpecFile() { + return getClassResource("serialVerUID.xml"); + } + + + public void test001(){ + runTest("SUID: Before execution advice"); + } + + public void test002(){ + runTest("SUID: Around execution advice"); + } + + public void test003(){ + runTest("SUID: Around closure execution advice (-Xlint:ignore)"); + } + + public void test004(){ + runTest("SUID: Around closure execution advice"); + } + + public void test005(){ + runTest("SUID: thisJoinPoint"); + } + + public void test006(){ + runTest("SUID: thisJoinPoint with clinit method"); + } + + public void test007(){ + runTest("SUID: After returning staticinitialization advice"); + } + + public void test008(){ + runTest("SUID: After returning staticinitialization advice with serialVersionUID field"); + } + + public void test009(){ + runTest("SUID: ITD field"); + } + + public void test010(){ + runTest("SUID: ITD method"); + } + + public void test011(){ + runTest("SUID: Declare extends"); + } + + public void test012(){ + runTest("SUID: Declare implements (compile)"); + } + + public void test013(){ + runTest("SUID: Declare implements non-Serializable (compile)"); + } + + public void test014(){ + runTest("SUID: Declare implements Serializable (compile)"); + } + + public void test015(){ + runTest("SUID: Declare implements (weave)"); + } + + public void test016(){ + runTest("SUID: Priviliged aspect"); + } + + public void test017(){ + runTest("SUID: Perthis aspect"); + } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml b/tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml new file mode 100644 index 000000000..d6346ceac --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml @@ -0,0 +1,169 @@ +<!-- SUID Tests --> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Before execution advice" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, BeforeExecutionAdvice.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Around execution advice" comment="OK because around_body private" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, AroundExecutionAdvice.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Around closure execution advice (-Xlint:ignore)" comment="OK because ignoring warnings" + pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, AroundClosureExecutionAdvice.aj" options="-Xlint:ignore"/> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Around closure execution advice" comment="Warning because around_body non-private" + pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, AroundClosureExecutionAdvice.aj" + xlintfile="Xlint.properties"> + <message kind="warning" line="9"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: thisJoinPoint" comment="Warning because of introduced clinit" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile + files="Test.java, Util.java, TJP.aj" options="-Xlint:warning"> + <message kind="warning" line="6"/> + <message kind="warning" line="13"/> + <message kind="warning" line="17"/> + <message kind="warning" line="24"/> + <message kind="warning" line="31"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: thisJoinPoint with clinit method" comment="OK if tjp private and existing clinit" + pr="41181"> + <compile files="ClinitTest.java, Util.java"/> + <run class="ClinitTest"/> + <compile files="ClinitTest.java, Util.java, TJP.aj" options="-Xlint:warning -1.4"> + <message kind="warning" line="24" text="can not build"/> + <message kind="warning" line="31" text="can not build"/> + </compile> + <run class="Util" options="-read"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: After returning staticinitialization advice" comment="Warning because of added clinit" + pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile + files="Test.java, Util.java, AfterReturningStaticinitializationAdvice.aj" options="-Xlint:warning"> + <message kind="warning" line="6"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: After returning staticinitialization advice with serialVersionUID field" + comment="OK because of serialVersionUID field" pr="41181"> + <compile files="SuidTest.java, Util.java" /> + <run class="SuidTest"/> + <compile files="SuidTest.java, Util.java, AfterReturningStaticinitializationAdvice.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: ITD field" comment="Error because added field may not be initialized" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, ITDField.aj" options="-Xlint:error"> + <message kind="error" line="1"/> <!-- two messages about new getter/setter affecting suid for private itd field --> + <message kind="error" line="3"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: ITD method" comment="Warning because of added method" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, ITDMethod.aj" options="-Xlint:warning"> + <message kind="warning" line="3"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare extends" comment="OK" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, DeclareExtends.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements (compile)" comment="Warning because of added interface" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, DeclareImplements.aj" options="-Xlint:warning"> + <message kind="warning" line="3"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements non-Serializable (compile)" comment="OK because not Serializable" + pr="41181"> + <compile files="NonSerializableTest.java, DeclareImplements.aj" options="-Xlint:warning"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements Serializable (compile)" comment="OK because adding Serializable" + pr="41181"> + <compile files="NonSerializableTest.java, DeclareImplementsSerializable.aj" options="-Xlint:warning"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements (weave)" comment="Warning because of added interface" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="injar.jar, DeclareImplements.aj" options="-Xlint:warning"> + <message kind="warning" line="3"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" title="SUID: Priviliged aspect" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, PrivilegedAspect.aj" options="-Xlint:warning"> + <message kind="warning" line="0"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Perthis aspect" + comment="Warning because added of added interface MightHaveAspect. Added field is private transient" + pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, PerThisAspect.aj" options="-Xlint:warning"> + <message kind="warning" line="0"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + diff --git a/tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID.xml b/tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID.xml new file mode 100644 index 000000000..20bfa889d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/serialVerUID/serialVerUID.xml @@ -0,0 +1,10 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[ +<!ENTITY tests SYSTEM "../tests/src/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml"> +]> +<!-- SUID Tests --> + +<suite> + +&tests; + +</suite> diff --git a/tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore b/tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore new file mode 100644 index 000000000..9d3c17f8d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore @@ -0,0 +1 @@ +ajcTestSuite.dtd diff --git a/tests/src/test/java/org/aspectj/systemtest/tracing/TracingTests.java b/tests/src/test/java/org/aspectj/systemtest/tracing/TracingTests.java new file mode 100644 index 000000000..3e8b6d8db --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/tracing/TracingTests.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * 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: + * Matthew Webster - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.tracing; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class TracingTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(TracingTests.class); + } + + protected File getSpecFile() { + return getClassResource("tracing.xml"); + } + + public void testTracing () { + runTest("Tracing"); + } + + public void testDefaultTracing () { + runTest("Default tracing"); + } + + public void testTraceMessages () { + runTest("Trace messages"); + } + + public void testTraceEverything () { + runTest("Trace everything"); + } + + public void testJDK14Tracing_pr159854 () { + runTest("JDK 1.4 tracing"); + } + + public void testTracingFileSystemProperty () { + runTest("Tracing file System Property"); + + File dir = getSandboxDirectory(); + File file = new File(dir,"tracing.txt"); + assertTrue("Missing tracing file: " + file,file.exists()); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/tracing/tracing.xml b/tests/src/test/java/org/aspectj/systemtest/tracing/tracing.xml new file mode 100644 index 000000000..8a6409183 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/tracing/tracing.xml @@ -0,0 +1,99 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<!-- Tracing Tests --> +<suite> + + <ajc-test dir="tracing" title="Tracing" keywords="tracing"> + <compile + files="TracingTest.java" + /> + <ant file="ant.xml" target="Tracing" verbose="true"> + <stdout> + <line text="? TracingTest.main() trace="/> + </stdout> + </ant> + </ajc-test> + + <ajc-test dir="tracing" title="Default tracing" keywords="tracing"> + <compile + files="DefaultTracingTest.java" + /> + <ant file="ant.xml" target="Default tracing" verbose="true"> + <stdout> + <line text="? DefaultTracingTest.main() trace=org.aspectj.weaver.tools.DefaultTrace"/> + </stdout> + </ant> + </ajc-test> + + <ajc-test dir="tracing" title="Trace messages" keywords="tracing"> + <compile + files="HelloWorld.java" + /> + <compile + files="IncludedAspect.aj, ExcludedAspect.aj" + /> + <ant file="ant.xml" target="Trace messages" verbose="true"> + <stdout> + <line text="Hello World!"/> + </stdout> + <!-- + Always get info messages even without -verbose because output determined + by tracing infrastructure. + + Duplicate warning and error messages: first through trace then message + writer + --> + <stderr> + <line text="info AspectJ Weaver Version"/> + <line text="info register classloader"/> + <line text="info using configuration"/> + <line text="info register aspect IncludedAspect"/> + <line text="warning aspect ExcludedAspect exluded"/> + <line text="warning aspect ExcludedAspect exluded"/> + <line text="info define aspect IncludedMissingAspect"/> + <line text="error Cannot find parent aspect"/> + <line text="error Cannot find parent aspect"/> + <line text="error Concrete-aspect 'IncludedMissingAspect' could not be registered"/> + <line text="error Concrete-aspect 'IncludedMissingAspect' could not be registered"/> + <line text="warning failure(s) registering aspects. Disabling weaver for class loader"/> + <line text="warning failure(s) registering aspects. Disabling weaver for class loader"/> + </stderr> + </ant> + </ajc-test> + + <ajc-test dir="tracing" title="Trace everything" keywords="tracing"> + <compile + files="HelloWorld.java" + /> + <compile files="Aspect.aj" options="-outxml -1.4"/> + <ant file="ant.xml" target="Trace everything" verbose="true"> + <stdout> + <line text="Hello World!"/> + </stdout> + </ant> + </ajc-test> + + <ajc-test dir="tracing" title="JDK 1.4 tracing" keywords="tracing"> + <compile + files="HelloWorld.java" + /> + <compile files="Aspect.aj" options="-outxml -1.4"/> + <ant file="ant.xml" target="JDK 1.4 tracing" verbose="true"> + <stdout> + <line text="Hello World!"/> + </stdout> + </ant> + </ajc-test> + + <ajc-test dir="tracing" title="Tracing file System Property" keywords="tracing"> + <compile + files="HelloWorld.java" + /> + <compile files="Aspect.aj" options="-outxml -1.4"/> + <ant file="ant.xml" target="Tracing file System Property" verbose="true"> + <stdout> + <line text="Hello World!"/> + </stdout> + </ant> + </ajc-test> +</suite> diff --git a/tests/src/test/java/org/aspectj/systemtest/xlint/XLint5Tests.java b/tests/src/test/java/org/aspectj/systemtest/xlint/XLint5Tests.java new file mode 100644 index 000000000..35e5b05ca --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/xlint/XLint5Tests.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Matthew Webster Move Java 5 dependent tests + *******************************************************************************/ +package org.aspectj.systemtest.xlint; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class XLint5Tests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(XLint5Tests.class); + } + + protected File getSpecFile() { + return getClassResource("xlint.xml"); + } + + public void testBug99136(){ + runTest("Two Xlint warnings wth cflow?"); + if(ajc.getLastCompilationResult().getWarningMessages().size() != 1){ + fail(); + } + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/xlint/XLintTests.java b/tests/src/test/java/org/aspectj/systemtest/xlint/XLintTests.java new file mode 100644 index 000000000..c5a2b7fdf --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/xlint/XLintTests.java @@ -0,0 +1,169 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * 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 + * + * ******************************************************************/ +package org.aspectj.systemtest.xlint; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.bcel.BcelShadow; + +public class XLintTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(XLintTests.class); + } + + protected File getSpecFile() { + return getClassResource("xlint.xml"); + } + + + public void test001(){ + runTest("options -Xlint args()"); + } + + public void test002(){ + runTest("options declare field on bad type"); + } + + public void test003(){ + runTest("options declare method on bad type"); + } + + public void test004(){ + runTest("options -Xlint declare parent"); + } + + public void test005(){ + runTest("options -Xlint target()"); + } + + public void test006(){ + runTest("options -Xlint this()"); + } + + public void test007(){ + runTest("options negative -Xlint args()"); + } + + public void test008(){ + runTest("options negative -Xlint declare parent"); + } + + public void test009(){ + runTest("options negative -Xlint target()"); + } + + public void test010(){ + runTest("options negative -Xlint this()"); + } + + public void test011(){ + runTest("unmatched type name in a declare parents should result in a warning in -Xlint mode"); + } + + public void test012(){ + runTest("privileged access to code outside the control of the compiler"); + } + + public void test013(){ + runTest("Unexpected Xlint:unresolvableMember warning with withincode"); + } + + public void test014(){ + runTest("valid XLintWarningTest file, default level of warning"); + } + + public void test015(){ + runTest("XLint:ignore suppresses XLint warnings"); + } + + public void test016(){ + runTest("XLint:error promotes XLint warnings to error"); + } + + public void test017(){ + runTest("alias getCause for getWrappedThrowable in SoftException"); + } + +// public void test018(){ +// runTest("XLint warning for call PCD's using subtype of defining type"); +// } + + public void test019(){ + runTest("XLint warning for call PCD's using subtype of defining type (-1.3 -Xlint:ignore)"); + } + + + // the following five tests check various scenarios around the lazyTjp XLint message + public void test020(){ + runTest("no XLint warning: thisJoinPoint potentially lazy and nothing stopping it"); + assertTrue("Something prevented the lazytjp optimization from working??",BcelShadow.appliedLazyTjpOptimization); + } + + public void test021(){ + runTest("XLint warning: thisJoinPoint potentially lazy but stopped by around advice which doesn't use tjp"); + assertFalse("lazytjp optimization should have failed to be applied because of around advice at the jp", + BcelShadow.appliedLazyTjpOptimization); + } + + public void test022(){ + runTest("no XLint warning: thisJoinPoint not lazy (no if PCD) but would have been stopped anyway by around advice"); + assertFalse("lazytjp optimization should have failed to be applied because of around advice *and* before advice has no if() at the jp", + BcelShadow.appliedLazyTjpOptimization); + } + + public void test023(){ + runTest("no XLint warning: thisJoinPoint cannot be built lazily"); + assertFalse("lazytjp optimization should have failed to be applied because before advice has no if() at the jp", + BcelShadow.appliedLazyTjpOptimization); + } + + public void test024(){ + runTest("XLint warning: thisJoinPoint potentially lazy but stopped by around advice which uses tjp"); + assertFalse("lazytjp optimization should have failed to be applied because around advice uses tjp", + BcelShadow.appliedLazyTjpOptimization); + } + + public void test025(){ + runTest("check for xlazytjp warning if actually supplied"); + assertTrue("Something prevented the lazytjp optimization from working??",BcelShadow.appliedLazyTjpOptimization); + } + + public void test026(){ + runTest("lazytjp: warning when around advice uses tjp"); + } + + public void test027() { + runTest("lazytjp: warning when if missing on before advice"); + } + + public void test028() { + runTest("lazytjp: warning when if missing on after advice"); + } + + public void test029() { + runTest("lazytjp: multiple clashing advice preventing lazytjp"); + } + + public void test030() { + runTest("lazytjp: interfering before and around"); + } + + // FIXME asc put this back in ! +// public void test031() { +// if (is15VMOrGreater) +// runTest("7 lint warnings"); +// } + +} + diff --git a/tests/src/test/java/org/aspectj/systemtest/xlint/xlint-tests.xml b/tests/src/test/java/org/aspectj/systemtest/xlint/xlint-tests.xml new file mode 100644 index 000000000..4bbf23841 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/xlint/xlint-tests.xml @@ -0,0 +1,267 @@ +<!-- XLint Tests --> + + <!-- .................................... -Xlint tests --> + <!-- ............... positive -Xlint tests --> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="no XLint warning: thisJoinPoint potentially lazy and nothing stopping it"> + <compile options="-Xlint:warning" files="Scenario1.aj"/> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="XLint warning: thisJoinPoint potentially lazy but stopped by around advice which doesn't use tjp"> + <compile options="-Xlint:warning" files="Scenario2.aj"> + <message kind="warning" line="21" text="can not implement lazyTjp on this joinpoint method-execution(void Test.main(java.lang.String[])) because around advice is used [Xlint:canNotImplementLazyTjp]"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="no XLint warning: thisJoinPoint not lazy (no if PCD) but would have been stopped anyway by around advice"> + <compile options="-Xlint:warning" files="Scenario3.aj"> + <message kind="warning" line="14" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" title="no XLint warning: thisJoinPoint cannot be built lazily"> + <compile options="-Xlint:warning" files="Scenario4.aj"> + <message kind="warning" line="9" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="XLint warning: thisJoinPoint potentially lazy but stopped by around advice which uses tjp"> + <compile options="-Xlint:warning" files="Scenario5.aj"> + <message kind="warning" line="22" text="can not implement lazyTjp on this joinpoint method-execution(void Test.main(java.lang.String[])) because around advice is used [Xlint:canNotImplementLazyTjp]"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="check for xlazytjp warning if actually supplied"> + <compile options="-XlazyTjp -Xlint:warning" files="Scenario1.aj"> + <message kind="warning" text="-XlazyTjp should no longer be used, build tjps lazily is now the default"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="lazytjp: warning when around advice uses tjp"> + <compile options="-Xlint:warning" files="LazyTjpTest1.java"> + <message kind="warning" line="4" text="can not implement lazyTjp on this joinpoint method-execution(void LazyTjpTest1.test2()) because around advice is used [Xlint:canNotImplementLazyTjp]"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="lazytjp: warning when if missing on before advice"> + <compile options="-Xlint:warning" files="LazyTjpTest2.java"> + <message kind="warning" line="16" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="lazytjp: warning when if missing on after advice"> + <compile options="-Xlint:warning" files="LazyTjpTest3.java"> + <message kind="warning" line="17" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="lazytjp: multiple clashing advice preventing lazytjp"> + <compile options="-Xlint:warning" files="LazyTjpTest4.java"> + <message kind="warning" line="13" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard"/> + <message kind="warning" line="3" text="can not implement lazyTjp at joinpoint method-execution(void LazyTjpTest4.test1()) because of advice conflicts, see secondary locations to find conflicting advice"/> + <message kind="warning" line="17" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/lazyTjpXLintWarning" + title="lazytjp: interfering before and around"> + <compile options="-Xlint:warning" files="LazyTjpTest5.java"> + <message kind="warning" line="3" text="can not implement lazyTjp at joinpoint method-execution(void LazyTjpTest5.test1()) because of advice conflicts, see secondary locations to find conflicting advice"/> + <message kind="warning" line="13" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard"/> + </compile> + </ajc-test> + + <ajc-test dir="options" + title="options -Xlint args()" + keywords="lint"> + <compile files="XLintTypeArgsPCD.java"> + <message kind="warning" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="options" + title="options declare field on bad type"> + <compile files="XLintTypeDeclareField.java" options="!eclipse"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="options" + title="options declare method on bad type"> + <compile files="XLintTypeDeclareMethod.java" options="!eclipse"> + <message kind="error" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="options" + title="options -Xlint declare parent" + keywords="lint"> + <compile files="XLintTypeDeclareParent.java"> + <message kind="warning" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="options" + title="options -Xlint target()" + keywords="lint"> + <compile files="XLintTypeTargetPCD.java"> + <message kind="warning" line="10"/> + </compile> + </ajc-test> + + <ajc-test dir="options" + title="options -Xlint this()" + keywords="lint"> + <compile files="XLintTypeThisPCD.java"> + <message kind="warning" line="10"/> + </compile> + </ajc-test> + + <!-- ............... negative -Xlint tests --> + <ajc-test dir="options" + title="options negative -Xlint args()" + keywords="lint"> + <compile files="XLintTypeArgsPCD.java" options="-Xlint:ignore"/> + </ajc-test> + + <ajc-test dir="options" + title="options negative -Xlint declare parent" + keywords="lint"> + <compile files="XLintTypeDeclareParent.java" options="-Xlint:ignore"/> + </ajc-test> + + <ajc-test dir="options" + title="options negative -Xlint target()" + keywords="lint"> + <compile files="XLintTypeTargetPCD.java" options="-Xlint:ignore"/> + </ajc-test> + + <ajc-test dir="options" + title="options negative -Xlint this()" + keywords="lint"> + <compile files="XLintTypeThisPCD.java" options="-Xlint:ignore"/> + </ajc-test> + + + <ajc-test dir="new" + title="unmatched type name in a declare parents should result in a warning in -Xlint mode" + keywords="tofix"> + <compile options="-Xlint" files="MissingTypeInDeclareParents.java"> + <message kind="warning" line="20"/> + </compile> + <run class="MissingTypeInDeclareParents"/> + </ajc-test> + + + <!-- The correct behavior of this program is to produce an Xlint + warning for the lack of access to the needed type, and then + to generate code with link errors that will throw a NoSuchMethodError + when run. + --> + <ajc-test dir="bugs" pr="906" + title="privileged access to code outside the control of the compiler"> + <compile files="PrivilegeBeyondScope.java" options="-Xlint:warning"> + <message kind="warning" line="23"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs" pr="37739" + title="Unexpected Xlint:unresolvableMember warning with withincode"> + <compile files="CatchSig.java"> + </compile> + <run class="CatchSig"/> + </ajc-test> + + + <ajc-test dir="harness" + title="valid XLintWarningTest file, default level of warning"> + <compile files="XLintWarningTest.java" options="-1.4"> + <message kind="warning" line="5" + text="Xlint:invalidAbsoluteTypeName"/> + </compile> + </ajc-test> + + <ajc-test dir="harness" + title="XLint:ignore suppresses XLint warnings"> + <compile files="XLintWarningTest.java" options="-Xlint:ignore"/> + </ajc-test> + + <ajc-test dir="harness" + title="XLint:error promotes XLint warnings to error"> + <compile files="XLintWarningTest.java" options="-Xlint:error"> + <message kind="error" line="5" + text="Xlint:invalidAbsoluteTypeName"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs" pr="49250" + title="alias getCause for getWrappedThrowable in SoftException"> + <compile files="GetCauseOnSoftException.java" options="-Xlint:warning"> + </compile> + <run vm="1.3" class="GetCauseOnSoftException"/> + </ajc-test> + + <ajc-test dir="bugs" + title="XLint warning for call PCD's using subtype of defining type" + pr="41952" + > + <compile + files="DeclaringTypeWarning.java" + options="-1.3" > + <message kind="warning" line="6" text="declaring type"> + <source line="12" file="DeclaringTypeWarning.java" /> + </message> + <message kind="warning" line="6" text="declaring type"> + <source line="14" file="DeclaringTypeWarning.java" /> + </message> + </compile> + </ajc-test> + + <ajc-test dir="bugs" + title="XLint warning for call PCD's using subtype of defining type (-1.3 -Xlint:ignore)" + pr="41952" + > + <compile + options="-Xlint:ignore,-1.3" + files="DeclaringTypeWarning.java" > + </compile> + </ajc-test> + +<!-- + <ajc-test dir="bugs/seven/lint" title="7 lint warnings" pr="91719"> + <compile options="-1.5" files="Main.java"> + <message kind="warning" line="31" text="no match for this type name: java.xxx.Object [Xlint:invalidAbsoluteTypeName]"> + </message> + <message kind="warning" line="34" text="no match for this type name: java.lang.Xxx [Xlint:invalidAbsoluteTypeName]"> + </message> + <message kind="warning" line="41" text="no match for this type name: java.lang.Xxx [Xlint:invalidAbsoluteTypeName]"> + </message> + <message kind="warning" line="69" text="this affected type is not exposed to the weaver: java.lang.Object [Xlint:typeNotExposedToWeaver]"> + </message> + <message kind="warning" line="87" text="does not match because declaring type is java.lang.Object, if match desired use target(Car) [Xlint:unmatchedSuperTypeInCall]"> + </message> + <message kind="warning" line="92" text="advice defined in XlintTest has not been applied [Xlint:adviceDidNotMatch]"> + </message> + <message kind="warning" line="157" text="no interface constructor-execution join point - use java.util.List+ for implementing classes [Xlint:noInterfaceCtorJoinpoint]"> + </message> + </compile> + </ajc-test> +--> + + <ajc-test dir="harness" + title="Two Xlint warnings wth cflow?"> + <compile files="XLintcflow.java" options="-1.5"> + <message kind="warning" line="4" text="advice defined in A has not been applied [Xlint:adviceDidNotMatch]"/> + </compile> + </ajc-test> + + \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/xlint/xlint.xml b/tests/src/test/java/org/aspectj/systemtest/xlint/xlint.xml new file mode 100644 index 000000000..efe2a0014 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/xlint/xlint.xml @@ -0,0 +1,10 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[ +<!ENTITY tests SYSTEM "../tests/src/org/aspectj/systemtest/xlint/xlint-tests.xml"> +]> +<!-- XLint Tests --> + +<suite> + +&tests; + +</suite> \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/testing/Harness.java b/tests/src/test/java/org/aspectj/testing/Harness.java new file mode 100644 index 000000000..e21f924f1 --- /dev/null +++ b/tests/src/test/java/org/aspectj/testing/Harness.java @@ -0,0 +1,39 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This file is part of the compiler and core tools for the AspectJ(tm) + * programming language; see http://aspectj.org + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is AspectJ. + * + * The Initial Developer of the Original Code is Xerox Corporation. Portions + * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. + * All Rights Reserved. + * + * Contributor(s): + */ +package org.aspectj.testing; + +/** + * @see org.aspectj.testing.drivers.Harness + */ +public class Harness { + + private Harness() {} + + /** + * @see org.aspectj.testing.drivers.Harness#main(String[]) + */ + public static void main(String[] args) throws Exception { + org.aspectj.testing.drivers.Harness.main(args); + } +} diff --git a/tests/src/test/java/org/aspectj/testing/Utils.java b/tests/src/test/java/org/aspectj/testing/Utils.java new file mode 100644 index 000000000..92e0ed833 --- /dev/null +++ b/tests/src/test/java/org/aspectj/testing/Utils.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * 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: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.testing; + +import java.io.File; + +import org.aspectj.apache.bcel.Repository; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.util.ClassPath; +import org.aspectj.apache.bcel.util.SyntheticRepository; +import org.aspectj.apache.bcel.verifier.VerificationResult; +import org.aspectj.apache.bcel.verifier.Verifier; +import org.aspectj.apache.bcel.verifier.VerifierFactory; +import org.aspectj.tools.ajc.Ajc; + +/** + * Not quite the right place for this class.. + */ +public class Utils { + + private final static boolean debugVerification=false; + + /** + * Performs verification of a class - the supplied class is expected to exist in the sandbox + * directory so typically this is called after a small compile step has been invoked to build it. + * @param ajc + */ + public static String verifyClass(Ajc ajc, String clazzname) { + JavaClass jc = null; + try { + jc = getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(),clazzname); + } catch (ClassNotFoundException cnfe) { + return "Could not find "+clazzname+" in the sandbox: "+ajc.getSandboxDirectory(); + } + if (jc==null) return "Could not find class "+clazzname; + Repository.setRepository(jc.getRepository()); + Verifier v = VerifierFactory.getVerifier("mypackage.MyAspect"); + VerificationResult vr = v.doPass1(); + if (debugVerification) System.err.println(vr); + + if (vr.getStatus()!=VerificationResult.VERIFIED_OK) + return "Verification not ok: "+vr; + vr = v.doPass2(); + if (debugVerification) System.err.println(vr); + if (vr.getStatus()!=VerificationResult.VERIFIED_OK) + return "Verification not ok: "+vr; + Method[] ms = jc.getMethods(); + for (int i = 0; i < ms.length; i++) { + if (debugVerification) System.err.println("Pass3a for "+ms[i]); + vr = v.doPass3a(i); + if (debugVerification) System.err.println(vr); + if (vr.getStatus()!=VerificationResult.VERIFIED_OK) + return "Verification not ok: "+vr; + if (debugVerification) System.err.println("Pass3b for "+ms[i]); + vr = v.doPass3b(i); + if (debugVerification) System.err.println(vr); + if (vr.getStatus()!=VerificationResult.VERIFIED_OK) + return "Verification not ok: "+vr; + } + return null; + } + + public static JavaClass getClassFrom(String frompath,String clazzname) throws ClassNotFoundException { + SyntheticRepository repos = createRepos(frompath); + return repos.loadClass(clazzname); + } + + public static SyntheticRepository createRepos(String cpentry) { + ClassPath cp = new ClassPath( + cpentry+File.pathSeparator+ + System.getProperty("java.class.path")); + return SyntheticRepository.getInstance(cp); + } +} diff --git a/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java b/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java new file mode 100644 index 000000000..672a95299 --- /dev/null +++ b/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java @@ -0,0 +1,51 @@ +package org.aspectj.tests; + +/* ******************************************************************* + * Copyright (c) 2005 Contributors. + * 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://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wes Isberg initial implementation + * ******************************************************************/ + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.AllTests; +import org.aspectj.systemtest.AllTests14; +import org.aspectj.systemtest.AllTests17; +import org.aspectj.systemtest.AllTests18; +import org.aspectj.systemtest.AllTests19; +import org.aspectj.util.LangUtil; + +public class TestsModuleTests extends TestCase { + + public static Test suite() { + String name = TestsModuleTests.class.getName(); + TestSuite suite = new TestSuite(name); + // compiler tests, wrapped for JUnit + if (LangUtil.is19VMOrGreater()) { + suite.addTest(AllTests19.suite()); + } else if (LangUtil.is18VMOrGreater()) { + suite.addTest(AllTests18.suite()); + } else if (LangUtil.is15VMOrGreater()) { + // suite.addTest(AllTests15.suite()); + suite.addTest(AllTests17.suite()); // there are currently (28/11/06) no tests specific to a 1.6/1.7 vm - so we can do + // this + } else if (LangUtil.is14VMOrGreater()) { + System.err.println("Skipping tests for 1.5"); + // suite.addTest(TestUtil.skipTest("for 1.5")); + suite.addTest(AllTests14.suite()); + } else { + System.err.println("Skipping tests for 1.4 and 1.5"); + // suite.addTest(TestUtil.skipTest("for 1.4 and 1.5")); + suite.addTest(AllTests.suite()); + } + return suite; + } +} -- cgit v1.2.3