From 331a89451d7699ea0babe5501a1b1ec0c6448f1d Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 20 Oct 2008 04:43:01 +0000 Subject: [PATCH] 251277: making asmmanager non-singleton --- .../systemtest/ajc150/Ajc150Tests.java | 1759 ++++++++++------- .../systemtest/ajc150/AnnotationBinding.java | 755 ++++--- .../ajc150/DeclareAnnotationTests.java | 608 +++--- .../systemtest/ajc151/Ajc151Tests.java | 421 ++-- .../ajc151/NewarrayJoinpointTests.java | 133 +- .../systemtest/ajc152/Ajc152Tests.java | 487 +++-- .../ajc152/SynchronizationTests.java | 430 ++-- .../ajc152/SynchronizationTransformTests.java | 474 ++--- .../systemtest/ajc153/Ajc153Tests.java | 692 ++++--- .../ajc153/JDTLikeHandleProviderTests.java | 44 +- .../systemtest/ajc161/Ajc161Tests.java | 279 ++- .../model/IncrementalModelTests.java | 302 ++- .../tools/AjdeInteractionTestbed.java | 21 +- .../tools/MultiProjectIncrementalTests.java | 387 ++-- .../systemtest/model/ModelTestCase.java | 152 +- .../aspectj/systemtest/model/ModelTests.java | 24 +- 16 files changed, 3905 insertions(+), 3063 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index e7d9eaa1c..85b86a303 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -27,751 +27,1018 @@ 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 new File("../tests/src/org/aspectj/systemtest/ajc150/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.getDefault().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 *)"); - } - - 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() { - 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"); - } - - - // helper methods..... - - public SyntheticRepository createRepos(File cpentry) { - ClassPath cp = new ClassPath(cpentry+File.pathSeparator+System.getProperty("java.class.path")); - return SyntheticRepository.getInstance(cp); - } - - protected JavaClass getClassFrom(File where,String clazzname) throws ClassNotFoundException { - SyntheticRepository repos = createRepos(where); - return repos.loadClass(clazzname); - } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc150Tests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/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 *)"); + } + + 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() { + 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"); + } + + // helper methods..... + + public SyntheticRepository createRepos(File cpentry) { + ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path")); + return SyntheticRepository.getInstance(cp); + } + + protected JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException { + SyntheticRepository repos = createRepos(where); + return repos.loadClass(clazzname); + } } \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java index 99c285158..7d5bd2a6b 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java @@ -23,384 +23,379 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class AnnotationBinding extends XMLBasedAjcTestCase { - public static Test suite() { - return XMLBasedAjcTestCase.loadSuite(AnnotationBinding.class); - } - - protected File getSpecFile() { - return new File("../tests/src/org/aspectj/systemtest/ajc150/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()) { - IHierarchy top = AsmManager.getDefault().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 = AsmManager.getDefault().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 = AsmManager.getDefault().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 = AsmManager.getDefault().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()) { - IHierarchy top = AsmManager.getDefault().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 = AsmManager.getDefault().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 = AsmManager.getDefault().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 = AsmManager.getDefault().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()) { - IHierarchy top = AsmManager.getDefault().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 = AsmManager.getDefault().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 = AsmManager.getDefault().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 = AsmManager.getDefault().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"); - } - + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AnnotationBinding.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/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/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java b/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java index f29058381..a5d0b7d8b 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java @@ -22,309 +22,309 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class DeclareAnnotationTests extends XMLBasedAjcTestCase { - public static Test suite() { - return XMLBasedAjcTestCase.loadSuite(DeclareAnnotationTests.class); - } - - protected File getSpecFile() { - return new File("../tests/src/org/aspectj/systemtest/ajc150/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.getDefault().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.getDefault().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.getDefault().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.getDefault().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.getDefault().getRelationshipMap().get(ipe); - assertTrue("Should have a relationship but does not ",l.size()>0); - } - } - - public void testDeclareTypeMisspelled() { - runTest("declare @Type (should be @type)"); - } + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(DeclareAnnotationTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/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/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index cdf61225f..b57998dc1 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -22,171 +22,258 @@ import org.aspectj.testing.XMLBasedAjcTestCase; 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() { - runTest("new IProgramElement methods"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); - - IProgramElement pe = top.findElementForType("pkg","foo"); - 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 pe2 = top.findElementForType("pkg","printParameters"); - 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 new File("../tests/src/org/aspectj/systemtest/ajc151/ajc151.xml"); - } - - + // 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() { + runTest("new IProgramElement methods"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + + IProgramElement pe = top.findElementForType("pkg", "foo"); + 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 pe2 = top.findElementForType("pkg", "printParameters"); + 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 new File("../tests/src/org/aspectj/systemtest/ajc151/ajc151.xml"); + } + } \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java index defe9b9b6..d16271960 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java @@ -37,58 +37,89 @@ import org.aspectj.testing.XMLBasedAjcTestCase; * 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 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.getDefault().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 = ((IProgramElement)kids.get(0)).getChildren(); - assertTrue("Couldn't find nodes below 'main' method",codenodes!=null && codenodes.size()==1); - IProgramElement arrayCtorCallNode = (IProgramElement)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.getDefault().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); - } - - protected File getSpecFile() { - return new File("../tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml"); - } - + // 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 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 = ((IProgramElement) kids.get(0)).getChildren(); + assertTrue("Couldn't find nodes below 'main' method", codenodes != null && codenodes.size() == 1); + IProgramElement arrayCtorCallNode = (IProgramElement) 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); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml"); + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java index edfb6e973..47f459db0 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -23,151 +23,362 @@ 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)","Pjava/util/List;"); - checkGetParamSigOfMethod("genericMethod2(MyGenericClass)","PMyGenericClass;"); - } - -// 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"); + // 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)", "Pjava/util/List;"); + checkGetParamSigOfMethod("genericMethod2(MyGenericClass)", + "PMyGenericClass;"); + } + + // 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 (){ + public void testWeaveinfoMessages() { runTest("weaveinfo messages with include and exclude"); } - // tests that can't be included for some reason + // 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");} + // 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 --------------- - // ---------------- helper methods --------------- - private void checkGetParamSigOfMethod(String ipeLabel, String expectedParm) { - IHierarchy top = AsmManager.getDefault().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 new File("../tests/src/org/aspectj/systemtest/ajc152/ajc152.xml"); - } - - + 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 new File("../tests/src/org/aspectj/systemtest/ajc152/ajc152.xml"); + } + } \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTests.java b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTests.java index dc8a7a6ea..6e9e3dd42 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTests.java @@ -11,223 +11,251 @@ 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.IProgramElement; -import org.aspectj.asm.IRelationship; 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 #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 - * - * + * 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 + * + * 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 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 new File("../tests/src/org/aspectj/systemtest/ajc152/synchronization.xml"); - } - + // 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 new File("../tests/src/org/aspectj/systemtest/ajc152/synchronization.xml"); + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java index 8437fd69d..5b5b8b290 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -24,9 +24,6 @@ import junit.framework.Test; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.asm.AsmManager; -import org.aspectj.asm.IProgramElement; -import org.aspectj.asm.IRelationship; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.util.TestUtil; import org.aspectj.testing.util.TestUtil.LineStream; @@ -38,213 +35,179 @@ 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 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; } + + 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 /*LazyMethodGen*/ methods = lcg.getMethodGens(); - for (Iterator iter = methods.iterator(); iter.hasNext();) { + + 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 /* LazyMethodGen */methods = lcg.getMethodGens(); + for (Iterator iter = methods.iterator(); iter.hasNext();) { LazyMethodGen element = (LazyMethodGen) iter.next(); if (element.getName().equals(methodname)) { return element; } - } - return null; - } - - private BcelObjectType getBcelObjectFor(String clazzname) { + } + 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) { + 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]; @@ -254,98 +217,95 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { } return null; } - - public void dump(String title,String[] strs) { + + 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]); + System.err.println(i + ") " + strs[i]); } } - - private void compareMethod(File f,LazyMethodGen m) { + + private void compareMethod(File f, LazyMethodGen m) { BufferedReader fr; if (!f.exists()) { - fail("Can't find expected output file "+f); + 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[]{}); - + while ((line = fr.readLine()) != null) + originalFileContents.add(line); + String[] fileContents = (String[]) originalFileContents.toArray(new String[] {}); + LineStream ls = new TestUtil.LineStream(); - m.print(ls,null); + 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); + 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); + 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 = (String) iter.next(); - result.append(str);result.append("\n"); + result.append(str); + result.append("\n"); } return result.toString(); } - - - private void saveMethod(File f,LazyMethodGen m) { - System.out.println("Saving method into "+f.getName()); + + private void saveMethod(File f, LazyMethodGen m) { + System.out.println("Saving method into " + f.getName()); try { - m.print(new PrintStream(new FileOutputStream(f)),null); + m.print(new PrintStream(new FileOutputStream(f)), null); } catch (FileNotFoundException e) { e.printStackTrace(); - fail("Couldn't store the method in file "+f); + 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 new File("../tests/src/org/aspectj/systemtest/ajc152/synchronization.xml"); - } - - public void tearDown() { world = null; } - + + // --- 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 new File("../tests/src/org/aspectj/systemtest/ajc152/synchronization.xml"); + } + + public void tearDown() { + world = null; + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java index 295e2aa6b..a6a6484a4 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java @@ -17,280 +17,438 @@ import junit.framework.Test; 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; 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 testFormalCommentsAreSetForConstructorIPEs_pr164340() { - runTest("formal comments are set for constructor ipes"); - IHierarchy top = AsmManager.getDefault().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 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.getDefault().getHierarchy(); - IProgramElement ipe = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.FIELD,"MY_COMPARATOR"); - String expected = "static final Comparator MY_COMPARATOR;\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;\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;\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.getDefault().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() { + // 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 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;\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;\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;\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.getDefault().getHierarchy(); - - IProgramElement ipe = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.IMPORT_REFERENCE,"ABC.StaticImport.Alphabet.A"); + 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.getDefault().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.getDefault().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()); - + 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 new File("../tests/src/org/aspectj/systemtest/ajc153/ajc153.xml"); - } - - + 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 new File("../tests/src/org/aspectj/systemtest/ajc153/ajc153.xml"); + } + } \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index 7c87c2609..cbabfdc67 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -18,25 +18,23 @@ import java.util.List; import junit.framework.Test; import org.aspectj.asm.AsmManager; -import org.aspectj.asm.IElementHandleProvider; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; -import org.aspectj.asm.internal.JDTLikeHandleProvider; import org.aspectj.testing.XMLBasedAjcTestCase; public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { - IElementHandleProvider handleProvider; + // IElementHandleProvider handleProvider; protected void setUp() throws Exception { super.setUp(); - handleProvider = AsmManager.getDefault().getHandleProvider(); - AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); + // handleProvider = AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); } protected void tearDown() throws Exception { super.tearDown(); - AsmManager.getDefault().setHandleProvider(handleProvider); + // AsmManager.getDefault().setHandleProvider(handleProvider); } public void testMoreThanOneNamedPointcut() { @@ -45,7 +43,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testAspectHandle() { runTest("aspect handle"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); + 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)); @@ -248,7 +246,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testIPEsWithSameNameHaveUniqueHandles_get() { runTest("ipes with same name have unique handles - get"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); + 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)); @@ -258,7 +256,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testIPEsWithSameNameHaveUniqueHandles_set() { runTest("ipes with same name have unique handles - set"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); + 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)); @@ -268,13 +266,13 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testTwoPiecesOfBeforeAdviceInInjarAspectHaveUniqueHandles_pr159896() { runTest("advice with same name in injar aspect should have unique handles"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); + 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.getDefault().dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + AsmManager.lastActiveStructureModel.dumptree(AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -283,7 +281,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testTwoDeclareWarningsInInjarAspectHaveUniqueHandles_pr159896() { runTest("declare warnings in injar aspect should have unique handles"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); + 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\"") @@ -297,7 +295,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { // their handle public void testOnlyIncrementSameDeclareTypeFromInjar_pr159896() { runTest("dont increment counter for different declares"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); + 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", @@ -387,7 +385,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testTypeSameAsJDT() { // JDT: =TJP Example/src - 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"); + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IncrementalModelTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/incremental/model/incremental-model.xml"); } - // - 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"); + // 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"); + // } + } - // - 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 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"); + 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"); + } - - - // - 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"); + + 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"); } - - // - 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 { + + 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()); + // AsmManager.ModelInfo mi = AsmManager.ModelInfo.summarizeModel(); + // System.err.println(mi.toString()); super.tearDown(); - + AsmManager.attemptIncrementalModelRepairs = false; } } - diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index 1890a388c..970e497bc 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -53,11 +53,12 @@ public class AjdeInteractionTestbed extends TestCase { 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); + ((MultiProjTestOutputLocationManager) ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()) + .getOutputLocationManager()).setSourceFolderFor(f, sourceFolder); } public void setNextChangeResponse(String projName, int flags) { @@ -167,6 +168,11 @@ public class AjdeInteractionTestbed extends TestCase { 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); @@ -302,11 +308,11 @@ public class AjdeInteractionTestbed extends TestCase { if (getCompiledFiles(projectName).size() == 0 && getWovenClasses(projectName).size() == 0) sb.append("No files were compiled or woven\n"); for (Iterator iter = getCompiledFiles(projectName).iterator(); iter.hasNext();) { - Object element = (Object) iter.next(); + Object element = iter.next(); sb.append("compiled: " + element + "\n"); } for (Iterator iter = getWovenClasses(projectName).iterator(); iter.hasNext();) { - Object element = (Object) iter.next(); + Object element = iter.next(); sb.append("woven: " + element + "\n"); } return sb.toString(); @@ -369,6 +375,11 @@ public class AjdeInteractionTestbed extends TestCase { 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(); diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 1ed8f2669..d751f3798 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -26,12 +26,10 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; 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.IElementHandleProvider; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; import org.aspectj.asm.IRelationship; import org.aspectj.asm.IRelationshipMap; -import org.aspectj.asm.internal.JDTLikeHandleProvider; import org.aspectj.asm.internal.Relationship; import org.aspectj.bridge.IMessage; import org.aspectj.tools.ajc.Ajc; @@ -63,28 +61,28 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; initialiseProject("P4"); build("P4"); - Ajc.dumpAJDEStructureModel("after full build where advice is applying"); + 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("after inc build where first advised line is gone"); + 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("pack", "C", true)); + IProgramElement codeElement = findCode(checkForNode(getModelFor("P4"), "pack", "C", true)); // This will be the line 7 entry in A.java - IProgramElement advice = findAdvice(checkForNode("pack", "A", true)); + IProgramElement advice = findAdvice(checkForNode(getModelFor("P4"), "pack", "A", true)); - IRelationshipMap asmRelMap = AsmManager.getDefault().getRelationshipMap(); + 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 = AsmManager.getDefault().getHierarchy().findElementForHandle(sourceOfRelationship); + 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(), @@ -104,7 +102,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List targets = rel.getTargets(); for (Iterator iterator2 = targets.iterator(); iterator2.hasNext();) { String t = (String) iterator2.next(); - IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(t); + 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); @@ -129,18 +127,19 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("Annos"); checkWasFullBuild(); checkCompileWeaveCount("Annos", 4, 4); - assertEquals("Should be 3 relationships ", 3, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + 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, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + 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, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals("Should be 3 relationships ", 3, model.getRelationshipMap().getEntries().size()); checkCompileWeaveCount("Annos", 3, 3); } @@ -151,9 +150,10 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build(p); // alter(p, "inc2"); // build(p); - dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + AsmManager model = getModelFor(p); + dumptree(model.getHierarchy().getRoot(), 0); - IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot(); + IProgramElement root = model.getHierarchy().getRoot(); IProgramElement ipe = findElementAtLine(root, 4); assertEquals("=BrokenHandles"); - // add a line which shouldn't change the handle - alter("JDTLikeHandleProvider", "inc1"); - build("JDTLikeHandleProvider"); - checkWasntFullBuild(); - IHierarchy top2 = AsmManager.getDefault().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); - } + // IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + // AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); + // try { + initialiseProject("JDTLikeHandleProvider"); + build("JDTLikeHandleProvider"); + checkWasFullBuild(); + IHierarchy top = getModelFor("JDTLikeHandleProvider").getHierarchy(); + IProgramElement pe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "before(): "); + // 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 = AsmManager.getDefault().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 = AsmManager.getDefault().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); - } - } + // 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(); - public void testInitializerCountForJDTLikeHandleProvider_pr141730() { - IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); - AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); - try { - initialiseProject("JDTLikeHandleProvider"); - build("JDTLikeHandleProvider"); - String expected = "=JDTLikeHandleProvider 1 ? "s" : "") + " related to this one '" + programElement @@ -2139,14 +2128,14 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa return relatedElements; } - private IProgramElement getFirstRelatedElement(IProgramElement programElement) { - List rels = getRelatedElements(programElement, 1); - return AsmManager.getDefault().getHierarchy().findElementForHandle((String) rels.get(0)); + private IProgramElement getFirstRelatedElement(AsmManager model, IProgramElement programElement) { + List rels = getRelatedElements(model, programElement, 1); + return model.getHierarchy().findElementForHandle((String) rels.get(0)); } - private List/* IProgramElement */getRelatedElements(IProgramElement advice) { + private List/* IProgramElement */getRelatedElements(AsmManager model, IProgramElement advice) { List output = null; - IRelationshipMap map = AsmManager.getDefault().getRelationshipMap(); + IRelationshipMap map = model.getRelationshipMap(); List/* IRelationship */rels = map.get(advice); if (rels == null) fail("Did not find any related elements!"); @@ -2213,23 +2202,23 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // -------------------------------------------------------------------------- // ------------------------- - private IProgramElement checkForNode(String packageName, String typeName, boolean shouldBeFound) { - IProgramElement ipe = AsmManager.getDefault().getHierarchy().findElementForType(packageName, typeName); + private IProgramElement checkForNode(AsmManager model, String packageName, String typeName, boolean shouldBeFound) { + IProgramElement ipe = model.getHierarchy().findElementForType(packageName, typeName); if (shouldBeFound) { if (ipe == null) - printModel(); + printModel(model); assertTrue("Should have been able to find '" + packageName + "." + typeName + "' in the asm", ipe != null); } else { if (ipe != null) - printModel(); + printModel(model); assertTrue("Should have NOT been able to find '" + packageName + "." + typeName + "' in the asm", ipe == null); } return ipe; } - private void printModel() { + private void printModel(AsmManager model) { try { - AsmManager.dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + AsmManager.dumptree(model.getHierarchy().getRoot(), 0); } catch (IOException e) { e.printStackTrace(); } diff --git a/tests/src/org/aspectj/systemtest/model/ModelTestCase.java b/tests/src/org/aspectj/systemtest/model/ModelTestCase.java index a6df58cb1..2cf4666a7 100644 --- a/tests/src/org/aspectj/systemtest/model/ModelTestCase.java +++ b/tests/src/org/aspectj/systemtest/model/ModelTestCase.java @@ -21,56 +21,53 @@ import java.util.List; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IElementHandleProvider; import org.aspectj.asm.IModelFilter; -import org.aspectj.asm.internal.JDTLikeHandleProvider; 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. + * 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>). + * 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(<title of test>,<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 final String expectedOutDir = "../tests/model/expected" + File.separator; private String testid; - + private String modelFilename; - + private IElementHandleProvider handleProvider; - - /* (non-Javadoc) + + /* + * (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 - handleProvider = AsmManager.getDefault().getHandleProvider(); - AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); // 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())); + AsmManager.setReporting(modelFilename, true, true, true, false, + new TestFilter(ajc.getSandboxDirectory().getCanonicalPath())); } - + static class TestFilter implements IModelFilter { - String sandboxDirectory ; + String sandboxDirectory; + public TestFilter(String sandboxDirectory) { this.sandboxDirectory = sandboxDirectory; } @@ -81,15 +78,15 @@ public abstract class ModelTestCase extends XMLBasedAjcTestCase { int forwardSlash = sub.indexOf("/"); // replace all "/" with "\" - to ensure platform independence if (forwardSlash != -1) { - sub = sub.replace('/','\\'); + 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.substring(0, column); } - return "TEST_SANDBOX"+sub; + return "TEST_SANDBOX" + sub; } return loc; } @@ -98,32 +95,30 @@ public abstract class ModelTestCase extends XMLBasedAjcTestCase { return false; } } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); - AsmManager.getDefault().setHandleProvider(handleProvider); 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 + * 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) { + 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) { @@ -134,88 +129,89 @@ public abstract class ModelTestCase extends XMLBasedAjcTestCase { compareModel(expectedOutput); } } - + private void compareModel(File expectedF) { - if (debugTest) System.out.println("comparing with model in file " + expectedF.getAbsolutePath()); + if (debugTest) + System.out.println("comparing with model in file " + expectedF.getAbsolutePath()); List fileContents = new ArrayList(); 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 tempDir = expect.readLine(); String expectedLine = null; - while((expectedLine=expect.readLine())!=null) { - fileContents.add(expectedLine); + while ((expectedLine = expect.readLine()) != null) { + fileContents.add(expectedLine); } List expectedFileContents = new ArrayList(); 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 foundFileContents = new ArrayList(); - 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); -// } + 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 iter = foundFileContents.iterator(); iter.hasNext();) { String line = (String) iter.next(); - if (debugTest) System.err.println("looking at model entry: " + line); + if (debugTest) + System.err.println("looking at model entry: " + line); if (!fileContents.contains(line)) { -// if (!((String)fileContents.get(lineNumber)).equals(line)) { - - if(debugTest) { + // if (!((String)fileContents.get(lineNumber)).equals(line)) { + + if (debugTest) { System.err.println("couldn't find: " + line); - for (Iterator iterator = fileContents.iterator(); iterator - .hasNext();) { + for (Iterator 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: "+) + + // 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 iter = fileContents.iterator(); iter - .hasNext();) { + for (Iterator 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()); + assertTrue("should have found all expected model output: " + fileContents, fileContents.isEmpty()); } catch (Exception e) { - fail("Unexpected exception comparing model files:"+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); + 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()); + fail("Couldn't copy file to " + f.toString()); } } diff --git a/tests/src/org/aspectj/systemtest/model/ModelTests.java b/tests/src/org/aspectj/systemtest/model/ModelTests.java index 36d042121..3031b2731 100644 --- a/tests/src/org/aspectj/systemtest/model/ModelTests.java +++ b/tests/src/org/aspectj/systemtest/model/ModelTests.java @@ -14,7 +14,6 @@ import java.io.File; import junit.framework.Test; -import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.weaver.World; @@ -62,17 +61,18 @@ public class ModelTests extends ModelTestCase { } } - 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 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"); } -- 2.39.5