You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Ajc152Tests.java 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /*******************************************************************************
  2. * Copyright (c) 2006 IBM
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc152;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.Iterator;
  15. import java.util.List;
  16. import junit.framework.Test;
  17. import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder;
  18. import org.aspectj.asm.AsmManager;
  19. import org.aspectj.asm.IHierarchy;
  20. import org.aspectj.asm.IProgramElement;
  21. import org.aspectj.asm.IRelationshipMap;
  22. import org.aspectj.asm.internal.Relationship;
  23. import org.aspectj.testing.XMLBasedAjcTestCase;
  24. import org.aspectj.util.CharOperation;
  25. import org.aspectj.weaver.World;
  26. public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
  27. // public void testCovarianceAndDecp_pr128443_1() { runTest("covariance and decp - 1"); }
  28. // public void testSuperITDExplosion_pr134425() { runTest("super ITDs");}
  29. // public void testMisbehavingDeclareAnnotation_pr135865() { runTest("misbehaving declare annotation");}
  30. // public void testMisbehavingDeclareAnnotation_pr135865_2() { runTest("misbehaving declare annotation - 2");}
  31. // public void testItdCallingGenericMethod_pr145391() { runTest("itd calling generic method");}
  32. // public void testItdCallingGenericMethod_pr145391_2() { runTest("itd calling generic method - 2");}
  33. // public void testClassCastForInvalidAnnotationValue_pr148537() { runTest("classcast annotation value");}
  34. // tests added post 152rc1 and before final
  35. public void testSeparateCallAspectOf_pr148727() { runTest("separate compilation calling aspectOf and hasAspect"); }
  36. public void testIntegratedCallAspectOf_pr148727() { runTest("integrated compilation calling aspectOf and hasAspect"); }
  37. public void testFreakyNewArrayJoinpoint_pr148786() { runTest("freaky new array joinpoint"); }
  38. // tests adding during 152 development
  39. public void testPrivilegeGeneric_pr148545() { runTest("nosuchmethoderror for privileged aspect");}
  40. public void testPrivilegeGeneric_pr148545_2() { runTest("nosuchmethoderror for privileged aspect - 2");}
  41. public void testUnknownAnnotationNPE() { runTest("NPE for unknown annotation");}
  42. public void testDuplicateBridgeMethods_pr147801_1() { runTest("duplicate bridge methods");}
  43. public void testPackageIgnoredForException_pr147701_1() { runTest("package for exception ignored");}
  44. public void testPackageIgnoredForException_pr147701_2() { runTest("package for exception ignored - 2");}
  45. public void testPackageIgnoredForException_pr147701_3() { runTest("package for exception ignored - 3");}
  46. public void testBrokenAddSerialVersionUID_pr145950() {runTest("fails to discover Serializable");}
  47. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_1() {runTest("no unnecessary declaration of thrown exception warning - 1");}
  48. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_2() {runTest("no unnecessary declaration of thrown exception warning - 2");}
  49. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_3() {runTest("no unnecessary declaration of thrown exception warning - 3");}
  50. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_4() {runTest("no unnecessary declaration of thrown exception warning - 4");}
  51. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_5() {runTest("no unnecessary declaration of thrown exception warning - 5");}
  52. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_6() {runTest("no unnecessary declaration of thrown exception warning - 6");}
  53. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_7() {runTest("no unnecessary declaration of thrown exception warning - 7");}
  54. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_8() {runTest("no unnecessary declaration of thrown exception warning - 8");}
  55. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_9() {runTest("no unnecessary declaration of thrown exception warning - 9");}
  56. public void testNoUnnecessaryDeclarationOfThrownExcp_pr129282_10() {runTest("no unnecessary declaration of thrown exception warning - 10");}
  57. public void testAtAJVerificationError_pr144602() { runTest("atAJ perthis aspect verification error");}
  58. public void testLTWAndGeneratingSUID_pr144465() { runTest("ltw with serialversionUID creation"); }
  59. public void testAspects14PerSingleton_pr122253() { runTest("aspects14 - persingleton");}
  60. public void testAspects14PerCflow_pr122253() { runTest("aspects14 - percflow");}
  61. public void testAspects14PerThis_pr122253() { runTest("aspects14 - perthis");}
  62. public void testAspects14PerTypeWithin_pr122253() { runTest("aspects14 - pertypewithin");}
  63. public void testFunkyGenericErrorWithITDs_pr126355() { runTest("bizarre generic error with itds");}
  64. public void testConcretizingAbstractMethods_pr142466() { runTest("aop.xml aspect inheriting but not concretizing abstract method");}
  65. public void testConcretizingAbstractMethods_pr142466_2() { runTest("aop.xml aspect inheriting but not concretizing abstract method - 2");}
  66. public void testComplexGenericDecl_pr137568() { runTest("complicated generics declaration");}
  67. public void testItdOnInnerTypeOfGenericType_pr132349() { runTest("ITD on inner type of generic type");}
  68. public void testItdOnInnerTypeOfGenericType_pr132349_2() { runTest("ITD on inner type of generic type - 2");}
  69. public void testItdOnInnerTypeOfGenericType_pr132349_3() { runTest("ITD on inner type of generic type - 3");}
  70. public void testLTWGeneratedAspectAbstractMethod_pr125480() { runTest("aop.xml aspect inheriting abstract method ");}
  71. public void testLTWGeneratedAspectAbstractMethod_pr125480_2() { runTest("aop.xml aspect inheriting abstract method - code style");}
  72. public void testCompletelyBrokenAopConcretization_pr142165_1() { runTest("broken concretization");}
  73. public void testCompletelyBrokenAopConcretization_pr142165_2() { runTest("broken concretization - 2");}
  74. public void testCompletelyBrokenAopConcretization_pr142165_3() { runTest("broken concretization - 3");}
  75. public void testVerifyErrorLTW_pr135068() { runTest("ltw verifyerror");}
  76. public void testVerifyErrorLTW_pr135068_2() { runTest("ltw verifyerror - 2");}
  77. public void testVerifyErrorLTW_pr135068_3() { runTest("ltw verifyerror - 3");}
  78. public void testVerifyErrorLTW_pr135068_4() { runTest("ltw verifyerror - 4");}
  79. public void testVerifyErrorForComplexCflow_pr136026() { runTest("verifyerror");}
  80. public void testVerifyErrorForComplexCflow_pr136026_2() { runTest("verifyerror - 2");}
  81. public void testAnnotationsAndGenericsBCException_pr129704() { runTest("annotations and generics leading to BCException");}
  82. public void testMethodTooBigAfterWeaving_pr138384() { runTest("method too big"); }
  83. public void testNotAtWithincode_pr138158_1() { runTest("not at withincode - 1");}
  84. public void testNotAtWithincode_pr138158_2() { runTest("not at withincode - 2");}
  85. public void testNotAtWithincode_pr138158_3() { runTest("not at within - 3");}
  86. public void testNpeOnDup_pr138143() { runTest("npe on duplicate method with ataj");}
  87. public void testPointcutsAndGenerics_pr137496_1() { runTest("pointcuts and generics - B");}
  88. public void testPointcutsAndGenerics_pr137496_2() { runTest("pointcuts and generics - D");}
  89. public void testPointcutsAndGenerics_pr137496_3() { runTest("pointcuts and generics - E");}
  90. public void testPointcutsAndGenerics_pr137496_4() { runTest("pointcuts and generics - F");}
  91. public void testPointcutsAndGenerics_pr137496_5() { runTest("pointcuts and generics - G");}
  92. public void testPointcutsAndGenerics_pr137496_6() { runTest("pointcuts and generics - H");}
  93. public void testAspectLibrariesAndASM_pr135001() { runTest("aspect libraries and asm");}
  94. public void testStackOverflow_pr136258() { runTest("stack overflow");}
  95. public void testIncorrectOverridesEvaluation13() { runTest("incorrect overrides evaluation - 1.3"); }
  96. public void testIncorrectOverridesEvaluation15() { runTest("incorrect overrides evaluation - 1.5"); }
  97. public void testAtWithinCodeBug_pr138798() { runTest("atWithinCodeBug"); }
  98. public void testReferencePCutInDeclareWarning_pr138215() { runTest("Reference pointcut fails inside @DeclareWarning");}
  99. public void testReferencePCutInPerClause_pr138219() { runTest("Can't use a FQ Reference pointcut in any pointcut expression referenced by a per-clause");}
  100. public void testReferencePCutInPerClause_pr130722() { runTest("FQ Reference pointcut from perclause ref pc"); }
  101. public void testDoubleAnnotationMatching_pr138223() { runTest("Double at annotation matching (no binding)");}
  102. public void testSuperCallsInAtAspectJAdvice_pr139749() { runTest("Super calls in @AspectJ advice");}
  103. public void testNoClassCastExceptionWithPerThis_pr138286() { runTest("No ClassCastException with perThis");}
  104. public void testGenericAspectHierarchyWithBounds_pr147845() { runTest("Generic abstract aspect hierarchy with bounds"); }
  105. public void testJRockitBooleanReturn_pr148007() { runTest("jrockit boolean fun");}
  106. public void testJRockitBooleanReturn2_pr148007() { runTest("jrockit boolean fun (no aspects)");}
  107. public void testSyntheticAjcMembers_pr147711() { runTest("synthetic ajc$ members"); }
  108. public void testDeclareAtMethodRelationship_pr143924() {
  109. //AsmManager.setReporting("c:/debug.txt",true,true,true,true);
  110. runTest("declare @method relationship");
  111. IHierarchy top = AsmManager.getDefault().getHierarchy();
  112. // get the IProgramElements corresponding to the different code entries
  113. IProgramElement decam = top.findElementForLabel(top.getRoot(),
  114. IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,
  115. "declare @method: * debit(..) : @Secured(role = \"supervisor\")");
  116. assertNotNull("Couldn't find 'declare @method' element in the tree",decam);
  117. IProgramElement method = top.findElementForLabel(top.getRoot(),
  118. IProgramElement.Kind.METHOD,"debit(java.lang.String,long)");
  119. assertNotNull("Couldn't find the 'debit(String,long)' method element in the tree",method);
  120. List matches = AsmManager.getDefault().getRelationshipMap().get(decam);
  121. assertNotNull("'declare @method' should have some relationships but does not",matches);
  122. assertTrue("'declare @method' should have one relationships but has " + matches.size(),matches.size()==1);
  123. List matchesTargets = ((Relationship)matches.get(0)).getTargets();
  124. assertTrue("'declare @method' should have one targets but has" + matchesTargets.size(),matchesTargets.size()==1);
  125. IProgramElement target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)matchesTargets.get(0));
  126. assertEquals("target of relationship should be the 'debit(java.lang.String,long)' method but is IPE with label "
  127. + target.toLabelString(),method,target);
  128. // check that the debit method has an annotated by relationship with the declare @method
  129. matches = AsmManager.getDefault().getRelationshipMap().get(method);
  130. assertNotNull("'debit(java.lang.String,long)' should have some relationships but does not",matches);
  131. assertTrue("'debit(java.lang.String,long)' should have one relationships but has " + matches.size(),matches.size()==1);
  132. matchesTargets = ((Relationship)matches.get(0)).getTargets();
  133. assertTrue("'debit(java.lang.String,long)' should have one targets but has" + matchesTargets.size(),matchesTargets.size()==1);
  134. target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)matchesTargets.get(0));
  135. assertEquals("target of relationship should be the 'declare @method' ipe but is IPE with label "
  136. + target.toLabelString(),decam,target);
  137. }
  138. // this next one reported as a bug by Rob Harrop, but I can't reproduce the failure yet...
  139. //public void testAtAspectWithReferencePCPerClause_pr138220() { runTest("@Aspect with reference pointcut in perclause");}
  140. public void testJarChecking_pr137235_1() { runTest("directory with .jar extension: source and outjar"); }
  141. public void testJarChecking_pr137235_2() { runTest("directory with .jar extension"); }
  142. public void testMakePreMethodNPE_pr136393() { runTest("NPE in makePreMethod");}
  143. public void testGetParameterHandles_pr141730() {
  144. runTest("new IProgramElement handle methods");
  145. checkParametersForIPE("intMethod(int)",IProgramElement.Kind.METHOD,"I",true);
  146. checkParametersForIPE("stringMethod(java.lang.String)",IProgramElement.Kind.METHOD,"Ljava/lang/String;",true);
  147. checkParametersForIPE("myClassMethod(MyClass)",IProgramElement.Kind.METHOD,"LMyClass;",true);
  148. checkParametersForIPE("genericMethod(java.util.List<java.lang.String>)",IProgramElement.Kind.METHOD,"Pjava/util/List<Ljava/lang/String;>;",true);
  149. checkParametersForIPE("genericMethod2(MyGenericClass<java.lang.String,MyClass>)",IProgramElement.Kind.METHOD,"PMyGenericClass<Ljava/lang/String;LMyClass;>;",true);
  150. checkParametersForIPE("main(java.lang.String[])",IProgramElement.Kind.METHOD,"[Ljava/lang/String;",true);
  151. checkParametersForIPE("multiMethod(java.lang.String[][])",IProgramElement.Kind.METHOD,"[[Ljava/lang/String;",true);
  152. checkParametersForIPE("intArray(int[])",IProgramElement.Kind.METHOD,"[I",true);
  153. IHierarchy top = AsmManager.getDefault().getHierarchy();
  154. IProgramElement twoArgsMethod = top.findElementForLabel(
  155. top.getRoot(),IProgramElement.Kind.METHOD,"twoArgsMethod(int,java.lang.String)");
  156. assertNotNull("Couldn't find 'twoArgsMethod(int,java.lang.String)' element in the tree",twoArgsMethod);
  157. List l = twoArgsMethod.getParameterSignatures();
  158. assertEquals("",((char[])l.get(0))[0],'I');
  159. boolean eq = CharOperation.equals(((char[])l.get(1)),"Ljava/lang/String;".toCharArray());
  160. assertTrue("expected parameter to be 'Ljava/lang/String;' but found '" +
  161. new String(((char[])l.get(1))) + "'",eq);
  162. }
  163. public void testGetParameterTypes_pr141730() {
  164. runTest("new IProgramElement handle methods");
  165. checkParametersForIPE("intMethod(int)",IProgramElement.Kind.METHOD,"int",false);
  166. checkParametersForIPE("stringMethod(java.lang.String)",IProgramElement.Kind.METHOD,"java.lang.String",false);
  167. checkParametersForIPE("myClassMethod(MyClass)",IProgramElement.Kind.METHOD,"MyClass",false);
  168. checkParametersForIPE("genericMethod(java.util.List<java.lang.String>)",IProgramElement.Kind.METHOD,"java.util.List<java.lang.String>",false);
  169. checkParametersForIPE("genericMethod2(MyGenericClass<java.lang.String,MyClass>)",IProgramElement.Kind.METHOD,"MyGenericClass<java.lang.String,MyClass>",false);
  170. checkParametersForIPE("main(java.lang.String[])",IProgramElement.Kind.METHOD,"java.lang.String[]",false);
  171. checkParametersForIPE("multiMethod(java.lang.String[][])",IProgramElement.Kind.METHOD,"java.lang.String[][]",false);
  172. checkParametersForIPE("intArray(int[])",IProgramElement.Kind.METHOD,"int[]",false);
  173. }
  174. public void testToSignatureString_pr141730() {
  175. runTest("new IProgramElement handle methods");
  176. checkSignatureOfIPE("main(java.lang.String[])",IProgramElement.Kind.METHOD);
  177. checkSignatureOfIPE("C",IProgramElement.Kind.CLASS);
  178. checkSignatureOfIPE("C()",IProgramElement.Kind.CONSTRUCTOR);
  179. checkSignatureOfIPE("method()",IProgramElement.Kind.METHOD);
  180. checkSignatureOfIPE("p()",IProgramElement.Kind.POINTCUT);
  181. checkSignatureOfIPE("before(): p..",IProgramElement.Kind.ADVICE,"before()");
  182. checkSignatureOfIPE("MyClass.method()",IProgramElement.Kind.INTER_TYPE_METHOD);
  183. checkSignatureOfIPE("multiMethod(java.lang.String[][])",IProgramElement.Kind.METHOD);
  184. checkSignatureOfIPE("intArray(int[])",IProgramElement.Kind.METHOD);
  185. checkSignatureOfIPE("MyClass.MyClass()",IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
  186. }
  187. // if not filling in the model for aspects contained in jar files then
  188. // want to ensure that the relationship map is correct and has nodes
  189. // which can be used in AJDT - ensure no NPE occurs for the end of
  190. // the relationship with aspectpath
  191. public void testAspectPathRelWhenNotFillingInModel_pr141730() {
  192. World.createInjarHierarchy = false;
  193. try {
  194. runTest("ensure aspectpath injar relationships are correct when not filling in model");
  195. // expecting:
  196. // sourceOfRelationship main in MyFoo.java
  197. // relationship advised by
  198. // target MyBar.aj
  199. //
  200. // and
  201. //
  202. // sourceOfRelationship MyBar.aj
  203. // relationship advises
  204. // target main in MyFoo.java
  205. IHierarchy top = AsmManager.getDefault().getHierarchy();
  206. IRelationshipMap asmRelMap = AsmManager.getDefault().getRelationshipMap();
  207. assertEquals("expected two sources of relationships but only found "
  208. + asmRelMap.getEntries().size(),2,asmRelMap.getEntries().size());
  209. for (Iterator iter = asmRelMap.getEntries().iterator(); iter.hasNext();) {
  210. String sourceOfRelationship = (String) iter.next();
  211. IProgramElement ipe = top.findElementForHandle(sourceOfRelationship);
  212. List relationships = asmRelMap.get(ipe);
  213. if (ipe.getName().equals("MyBar.aj")) {
  214. assertEquals("expected MyBar.aj to have one relationships but found "
  215. + relationships.size(),1,relationships.size());
  216. Relationship rel = (Relationship)relationships.get(0);
  217. assertEquals("expected relationship to be 'advises' but was "
  218. + rel.getName(), "advises", rel.getName());
  219. List targets = rel.getTargets();
  220. assertEquals("expected one target but found " + targets.size(),1,targets.size());
  221. IProgramElement link = top.findElementForHandle((String)targets.get(0));
  222. assertEquals("expected target 'method-call(void foo.MyFoo.main())' but target " + link.getName(),
  223. "method-call(void foo.MyFoo.main())",link.getName());
  224. String fileName = link.getSourceLocation().getSourceFile().toString();
  225. assertTrue("expected 'main' to be in class MyFoo.java but found it " +
  226. "in " + fileName,fileName.indexOf("MyFoo.java") != -1);
  227. } else if (ipe.getName().equals("method-call(void foo.MyFoo.main())")) {
  228. String fileName = ipe.getSourceLocation().getSourceFile().toString();
  229. assertTrue("expected 'method-call(void foo.MyFoo.main())' to be in " +
  230. "class MyFoo.java but found it in"
  231. + fileName,fileName.indexOf("MyFoo.java") != -1);
  232. assertEquals("expected 'method-call(void foo.MyFoo.main())' " +
  233. "to have one relationships but found "
  234. + relationships.size(),1,relationships.size());
  235. Relationship rel = (Relationship)relationships.get(0);
  236. assertEquals("expected relationship to be 'advised by' but was "
  237. + rel.getName(), "advised by", rel.getName());
  238. List targets = rel.getTargets();
  239. assertEquals("expected one target but found " + targets.size(),1,targets.size());
  240. IProgramElement link = top.findElementForHandle((String)targets.get(0));
  241. assertEquals("expected target 'MyBar.aj' but target " + link.getName(),
  242. "MyBar.aj",link.getName());
  243. } else {
  244. fail("unexpected element " + ipe.getName() + " in the relationship map");
  245. }
  246. }
  247. } finally {
  248. World.createInjarHierarchy = true;
  249. }
  250. }
  251. // if not filling in the model for classes contained in jar files then
  252. // want to ensure that the relationship map is correct and has nodes
  253. // which can be used in AJDT - ensure no NPE occurs for the end of
  254. // the relationship with inpath
  255. public void testNoNPEWithInpathWhenNotFillingInModel_pr141730() {
  256. World.createInjarHierarchy = false;
  257. try {
  258. runTest("ensure inpath injar relationships are correct when not filling in model");
  259. // the aspect used for this test has advice, declare parents, deow,
  260. // and declare @type, @constructor, @field and @method. We only expect
  261. // there to be relationships in the map for declare parents and declare @type
  262. // (provided the model isn't being filled in) because the logic in the other
  263. // addXXXRelationship methods use AspectJElementHierarchy.findElementForType().
  264. // This method which returns null because there is no such ipe. The relationship is
  265. // therefore not added to the model. Adding declare @type and declare parents
  266. // uses AspectJElementHierarchy.findElementForHandle() which returns the file
  267. // node ipe if it can't find one for the given handle. Therefore the relationships
  268. // are added against the file node. Before change to using ipe's to create handles
  269. // we also had the deow relationship, however, now we don't because this also
  270. // uses findElementForType to find the targetNode which in the inpath case is null.
  271. // just check that the number of entries is what we expect:
  272. // We expect 3 (the declare @type and declare parents statements plus the filenode)
  273. IRelationshipMap relMap = AsmManager.getDefault().getRelationshipMap();
  274. assertEquals("expected 3 entries in the relationship map but found "
  275. + relMap.getEntries().size(), 3, relMap.getEntries().size());
  276. } finally {
  277. World.createInjarHierarchy = true;
  278. }
  279. }
  280. public void testPCDInClassAppearsInModel_pr148027() {
  281. // only want to test that its there if we're creating the uses pointcut
  282. // relationship. This should be addressed by pr148027
  283. if (!AsmHierarchyBuilder.shouldAddUsesPointcut) return;
  284. World.createInjarHierarchy = false;
  285. try {
  286. runTest("ensure pcd declare in class appears in model");
  287. IHierarchy top = AsmManager.getDefault().getHierarchy();
  288. IProgramElement pcd = top.findElementForLabel(top.getRoot(),IProgramElement.Kind.POINTCUT,"pointcutInClass()");
  289. IRelationshipMap relMap = AsmManager.getDefault().getRelationshipMap();
  290. List relationships = relMap.get(pcd);
  291. assertNotNull("expected relationships for pointcut " + pcd.toLinkLabelString()
  292. + " but didn't", relationships);
  293. pcd = top.findElementForLabel(top.getRoot(),IProgramElement.Kind.POINTCUT,"pointcutInAspect()");
  294. relationships = relMap.get(pcd);
  295. assertNotNull("expected relationships for pointcut " + pcd.toLinkLabelString()
  296. + " but didn't", relationships);
  297. } finally {
  298. World.createInjarHierarchy = true;
  299. }
  300. }
  301. // public void testFunkyGenericErrorWithITDs_pr126355_2() {
  302. // runTest("bizarre generic error with itds - 2");
  303. // // public class Pair<F,S> affected by pertarget aspect
  304. // GenericsTests.verifyClassSignature(ajc,"Pair","<F:Ljava/lang/Object;S:Ljava/lang/Object;>Ljava/lang/Object;LIdempotentCache$ajcMightHaveAspect;;");
  305. // }
  306. public void testNoAspects(){
  307. // setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
  308. runTest("Ensure no weaving without included aspects");
  309. }
  310. public void testWeaveinfoMessages (){
  311. runTest("weaveinfo messages with include and exclude");
  312. }
  313. // tests that can't be included for some reason
  314. // Not valid whilst the ajc compiler forces debug on (ignores -g:none) - it will be green but is invalid, trust me
  315. // public void testLongWindedMessages_pr129408() { runTest("long winded ataj messages");}
  316. // ---------------- helper methods ---------------
  317. private void checkParametersForIPE(String ipeLabel, IProgramElement.Kind kind, String expectedParm, boolean getHandles) {
  318. IHierarchy top = AsmManager.getDefault().getHierarchy();
  319. IProgramElement ipe = top.findElementForLabel(top.getRoot(),kind,ipeLabel);
  320. assertNotNull("Couldn't find '" + ipeLabel + "' element in the tree",ipe);
  321. List l = new ArrayList();
  322. if (getHandles) {
  323. l = ipe.getParameterSignatures();
  324. } else {
  325. l = ipe.getParameterTypes();
  326. }
  327. boolean eq = CharOperation.equals(((char[])l.get(0)),expectedParm.toCharArray());
  328. assertTrue("expected parameter to be '" + expectedParm + "' but found '" +
  329. new String(((char[])l.get(0))) + "'",eq);
  330. }
  331. private void checkSignatureOfIPE(String ipeLabel, IProgramElement.Kind kind) {
  332. checkSignatureOfIPE(ipeLabel,kind,ipeLabel);
  333. }
  334. private void checkSignatureOfIPE(String ipeLabel, IProgramElement.Kind kind, String expectedSig) {
  335. IHierarchy top = AsmManager.getDefault().getHierarchy();
  336. IProgramElement ipe = top.findElementForLabel(
  337. top.getRoot(),kind,ipeLabel);
  338. assertNotNull("Couldn't find '" + ipeLabel + "' element in the tree",ipe);
  339. assertEquals("expected signature to be '"+ expectedSig + "' but was " +
  340. ipe.toSignatureString(true),expectedSig,ipe.toSignatureString(true));
  341. }
  342. /////////////////////////////////////////
  343. public static Test suite() {
  344. return XMLBasedAjcTestCase.loadSuite(Ajc152Tests.class);
  345. }
  346. protected File getSpecFile() {
  347. return new File("../tests/src/org/aspectj/systemtest/ajc152/ajc152.xml");
  348. }
  349. }