Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

DeclareFormsTest.java 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. /* *******************************************************************
  2. * Copyright (c) 2003 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Mik Kersten initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.tools.ajdoc;
  13. import java.io.File;
  14. import java.util.List;
  15. /**
  16. * @author Mik Kersten
  17. */
  18. public class DeclareFormsTest extends AjdocTestCase {
  19. private String declareError = "declare error: quot;Illegal construct..quot";
  20. private String declareWarningQuotes = "declare warning: quot;Illegal call.quot;";
  21. private String declareWarning = "declare warning: \"Illegal call.\"";
  22. private String declareParentsImpl = "declare parents: implements Serializable";
  23. private String declareSoft = "declare soft: foo.SizeException2";
  24. private String declarePrecedence = "declare precedence: foo.DeclareCoverage2, foo.InterTypeDecCoverage2";
  25. private String doItHref = "HREF=\"../foo/Main2.html#doIt()\"";
  26. private String pointHref = "HREF=\"../foo/Point2.html\"";
  27. private String cHref = "HREF=\"../foo/C.html\"";
  28. private String doIt = "doIt()";
  29. public void testCoverage() {
  30. initialiseProject("declareForms");
  31. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage.java")};
  32. runAjdoc("private","1.4",files);
  33. }
  34. /**
  35. * Test that the declare statements appear in the Declare Detail
  36. * and Declare Summary sections of the ajdoc
  37. */
  38. public void testDeclareStatments() throws Exception {
  39. initialiseProject("declareForms");
  40. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  41. runAjdoc("private","1.4",files);
  42. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
  43. if (!htmlFile.exists()) {
  44. fail("couldn't find " + htmlFile.getAbsolutePath()
  45. + " - were there compilation errors?");
  46. }
  47. // check the contents of the declare detail summary
  48. String[] strings = {
  49. declareError,
  50. declareWarning,
  51. declareParentsImpl,
  52. declareSoft,
  53. declarePrecedence};
  54. List missing = AjdocOutputChecker.getMissingStringsInSection(
  55. htmlFile,strings,"DECLARE DETAIL SUMMARY");
  56. assertTrue(htmlFile.getName() + " should contain all declare statements in " +
  57. "the Declare Detail section",missing.isEmpty());
  58. // check the contents of the declare summary - should contain
  59. // the same strings
  60. missing = AjdocOutputChecker.getMissingStringsInSection(
  61. htmlFile,strings,"DECLARE SUMMARY");
  62. assertTrue(htmlFile.getName() + " should contain all declare statements in " +
  63. "the Declare Summary section",missing.isEmpty());
  64. }
  65. /**
  66. * Declare warning's should have the 'matched by' relationship
  67. * in the ajdoc for the declaring aspect
  68. */
  69. public void testDeclareWarning() throws Exception {
  70. initialiseProject("declareForms");
  71. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  72. runAjdoc("private","1.4",files);
  73. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
  74. if (!htmlFile.exists()) {
  75. fail("couldn't find " + htmlFile.getAbsolutePath()
  76. + " - were there compilation errors?");
  77. }
  78. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  79. htmlFile,"DECLARE DETAIL SUMMARY",
  80. declareWarningQuotes,
  81. HtmlDecorator.HtmlRelationshipKind.MATCHED_BY,
  82. doItHref);
  83. assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref +
  84. "' in the Declare Detail section", b);
  85. b = AjdocOutputChecker.summarySectionContainsRel(
  86. htmlFile,"DECLARE SUMMARY",
  87. declareWarningQuotes,
  88. HtmlDecorator.HtmlRelationshipKind.MATCHED_BY,
  89. doItHref);
  90. assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref +
  91. "' in the Declare Summary section", b);
  92. }
  93. /**
  94. * The target of a declare warning should have the 'matches
  95. * declare' relationship in the ajdoc - test the case when
  96. * the declare warning matches a call join point
  97. */
  98. public void testMatchesDeclareCall() throws Exception {
  99. initialiseProject("declareForms");
  100. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  101. runAjdoc("private","1.4",files);
  102. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
  103. if (!htmlFile.exists()) {
  104. fail("couldn't find " + htmlFile.getAbsolutePath()
  105. + " - were there compilation errors?");
  106. }
  107. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  108. htmlFile,"=== METHOD DETAIL",
  109. doIt,
  110. HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
  111. declareWarningQuotes);
  112. assertTrue("Should have '" + doIt + " matches declare " +
  113. declareWarningQuotes + "' in the Declare Detail section", b);
  114. b = AjdocOutputChecker.summarySectionContainsRel(
  115. htmlFile,"=== METHOD SUMMARY",
  116. doIt,
  117. HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
  118. declareWarningQuotes);
  119. assertTrue("Should have '" + doIt + " matches declare " +
  120. declareWarningQuotes + "' in the Declare Summary section", b);
  121. }
  122. /**
  123. * The target of a declare warning should have the 'matches
  124. * declare' relationship in the ajdoc - test the case when
  125. * the declare warning matches an execution join point
  126. */
  127. public void testMatchesDeclareExecution() throws Exception {
  128. initialiseProject("declareForms");
  129. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  130. runAjdoc("private","1.4",files);
  131. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
  132. if (!htmlFile.exists()) {
  133. fail("couldn't find " + htmlFile.getAbsolutePath()
  134. + " - were there compilation errors?");
  135. }
  136. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  137. htmlFile,"=== METHOD DETAIL",
  138. "setX(int)",
  139. HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
  140. "declare warning: quot;blahquot;");
  141. assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
  142. "' in the Method Detail section", b);
  143. b = AjdocOutputChecker.summarySectionContainsRel(
  144. htmlFile,"=== METHOD SUMMARY",
  145. "setX(int)",
  146. HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
  147. "declare warning: quot;blahquot;");
  148. assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
  149. "' in the Method Summary section", b);
  150. }
  151. /**
  152. * Declare parents's should have the 'declared on' relationship
  153. * in the ajdoc for the declaring aspect
  154. */
  155. public void testDeclareParents() throws Exception {
  156. initialiseProject("declareForms");
  157. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  158. runAjdoc("private","1.4",files);
  159. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
  160. if (!htmlFile.exists()) {
  161. fail("couldn't find " + htmlFile.getAbsolutePath()
  162. + " - were there compilation errors?");
  163. }
  164. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  165. htmlFile,"DECLARE DETAIL SUMMARY",
  166. declareParentsImpl,
  167. HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
  168. pointHref);
  169. assertTrue("Should have ' " + declareParentsImpl + " declared on " +
  170. pointHref + "' in the Declare Detail section", b);
  171. b = AjdocOutputChecker.summarySectionContainsRel(
  172. htmlFile,"DECLARE SUMMARY",
  173. declareParentsImpl,
  174. HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
  175. pointHref);
  176. assertTrue("Should have ' " + declareParentsImpl + " declared on " +
  177. pointHref + "' in the Declare Summary section", b);
  178. }
  179. /**
  180. * The target of a declare parent should have the 'aspect
  181. * declarations' relationship in the ajdoc
  182. */
  183. public void testAspectDeclarations() throws Exception {
  184. initialiseProject("declareForms");
  185. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  186. runAjdoc("private","1.4",files);
  187. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
  188. if (!htmlFile.exists()) {
  189. fail("couldn't find " + htmlFile.getAbsolutePath()
  190. + " - were there compilation errors?");
  191. }
  192. boolean b = AjdocOutputChecker.classDataSectionContainsRel(
  193. htmlFile,
  194. HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS,
  195. "declare parents: implements Serializable");
  196. assertTrue("The class data section should have 'aspect declarations" +
  197. " declare parents: implements Serializable'",b);
  198. }
  199. /**
  200. * Declare soft's should have the 'softens' relationship
  201. * in the ajdoc for the declaring aspect
  202. */
  203. public void testDeclareSoft() throws Exception {
  204. initialiseProject("declareForms");
  205. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  206. runAjdoc("private","1.4",files);
  207. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
  208. if (!htmlFile.exists()) {
  209. fail("couldn't find " + htmlFile.getAbsolutePath()
  210. + " - were there compilation errors?");
  211. }
  212. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  213. htmlFile,"DECLARE DETAIL SUMMARY",
  214. declareSoft,
  215. HtmlDecorator.HtmlRelationshipKind.SOFTENS,
  216. doItHref);
  217. assertTrue("Should have '" + declareSoft + " softens " + doItHref +
  218. "' in the Declare Detail section", b);
  219. b = AjdocOutputChecker.summarySectionContainsRel(
  220. htmlFile,"DECLARE SUMMARY",
  221. declareSoft,
  222. HtmlDecorator.HtmlRelationshipKind.SOFTENS,
  223. doItHref);
  224. assertTrue("Should have '" + declareSoft + " softens " + doItHref +
  225. "' in the Declare Summary section", b);
  226. }
  227. /**
  228. * The target of a declare soft should have the 'softened
  229. * by' relationship in the ajdoc
  230. */
  231. public void testSoftenedBy() throws Exception {
  232. initialiseProject("declareForms");
  233. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
  234. runAjdoc("private","1.4",files);
  235. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
  236. if (!htmlFile.exists()) {
  237. fail("couldn't find " + htmlFile.getAbsolutePath()
  238. + " - were there compilation errors?");
  239. }
  240. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  241. htmlFile,"=== METHOD DETAIL",
  242. doIt,
  243. HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY,
  244. declareSoft);
  245. assertTrue("Should have '" + doIt + " softened by " + declareSoft +
  246. "' in the Method Detail section", b);
  247. b = AjdocOutputChecker.summarySectionContainsRel(
  248. htmlFile,"=== METHOD SUMMARY",
  249. doIt,
  250. HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY,
  251. declareSoft);
  252. assertTrue("Should have '" + doIt + " softened by " + declareSoft +
  253. "' in the Method Summary section", b);
  254. }
  255. /**
  256. * Declare annotation should have the 'annotates' relationship
  257. * in the ajdoc for the declaring aspect
  258. */
  259. public void testDeclareAnnotation() throws Exception {
  260. initialiseProject("declareForms");
  261. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
  262. runAjdoc("private","1.5",files);
  263. // Aspect AnnotationTest should contain within it's declare
  264. // detail and summary the declare annotation statement.
  265. // Check for this....
  266. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareAtType.html");
  267. if (!htmlFile.exists()) {
  268. fail("couldn't find " + htmlFile.getAbsolutePath()
  269. + " - were there compilation errors?");
  270. }
  271. // check there's no return type for the declare annotation
  272. // statement in the declare summary section
  273. String[] returnType = {"[]"};
  274. List missing = AjdocOutputChecker.getMissingStringsInSection(
  275. htmlFile,returnType,"DECLARE SUMMARY");
  276. assertEquals("there should be no return type for declare annotation" +
  277. " in the ajdoc",1,missing.size());
  278. assertEquals("there shouldn't be the '[]' return type for declare annotation" +
  279. " in the ajdoc","[]",missing.get(0));
  280. // check that the 'annotates' relationship is there
  281. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  282. htmlFile,"DECLARE DETAIL SUMMARY",
  283. "declare @type: foo.C : @MyAnnotation",
  284. HtmlDecorator.HtmlRelationshipKind.ANNOTATES,
  285. cHref);
  286. assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates "
  287. + cHref + "' in the Declare Detail section", b);
  288. b = AjdocOutputChecker.summarySectionContainsRel(
  289. htmlFile,"DECLARE SUMMARY",
  290. "declare @type: foo.C : @MyAnnotation",
  291. HtmlDecorator.HtmlRelationshipKind.ANNOTATES,
  292. cHref);
  293. assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates "
  294. + cHref + "' in the Declare Summary section", b);
  295. }
  296. /**
  297. * The target of a declare method annotation should have the
  298. * 'annotated by' relationship in the ajdoc within the method
  299. * information
  300. */
  301. public void testMethodAnnotatedBy() throws Exception {
  302. initialiseProject("declareForms");
  303. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtMethod.aj")};
  304. runAjdoc("private","1.5",files);
  305. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
  306. if (!htmlFile.exists()) {
  307. fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
  308. }
  309. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  310. htmlFile,"=== METHOD DETAIL",
  311. "amethod()",
  312. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  313. "declare @method: public * foo.C.*(..) : @MyAnnotation");
  314. assertTrue("Should have 'amethod() annotated by " +
  315. "declare @method: public * foo.C.*(..) : @MyAnnotation" +
  316. "' in the Method Detail section", b);
  317. b = AjdocOutputChecker.summarySectionContainsRel(
  318. htmlFile,"=== METHOD SUMMARY",
  319. "amethod()",
  320. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  321. "declare @method: public * foo.C.*(..) : @MyAnnotation");
  322. assertTrue("Should have 'amethod() annotated by " +
  323. "declare @method: public * foo.C.*(..) : @MyAnnotation" +
  324. "' in the Method Summary section", b);
  325. }
  326. /**
  327. * The target of a declare method annotation should have the
  328. * 'annotated by' relationship in the ajdoc within the method
  329. * information
  330. */
  331. public void testConstructorAnnotatedBy() throws Exception {
  332. initialiseProject("declareForms");
  333. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtConstructor.aj")};
  334. runAjdoc("private","1.5",files);
  335. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
  336. if (!htmlFile.exists()) {
  337. fail("couldn't find " + htmlFile.getAbsolutePath()
  338. + " - were there compilation errors?");
  339. }
  340. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  341. htmlFile,"=== CONSTRUCTOR DETAIL",
  342. "C(java.lang.String)",
  343. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  344. "declare @constructor: foo.C.new(..) : @MyAnnotation");
  345. assertTrue("Should have '" + doIt + " annotated by " +
  346. "declare @constructor: foo.C.new(..) : @MyAnnotation" +
  347. "' in the Method Detail section", b);
  348. b = AjdocOutputChecker.summarySectionContainsRel(
  349. htmlFile,"=== CONSTRUCTOR SUMMARY",
  350. "C(java.lang.String)",
  351. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  352. "declare @constructor: foo.C.new(..) : @MyAnnotation");
  353. assertTrue("Should have '" + doIt + " annotated by " +
  354. "declare @constructor: foo.C.new(..) : @MyAnnotation" +
  355. "' in the Method Summary section", b);
  356. }
  357. /**
  358. * The target of a declare method annotation should have the
  359. * 'annotated by' relationship in the ajdoc within the method
  360. * information
  361. */
  362. public void testFieldAnnotatedBy() throws Exception {
  363. initialiseProject("declareForms");
  364. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtField.aj")};
  365. runAjdoc("private","1.5",files);
  366. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
  367. if (!htmlFile.exists()) {
  368. fail("couldn't find " + htmlFile.getAbsolutePath()
  369. + " - were there compilation errors?");
  370. }
  371. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  372. htmlFile,"=== FIELD DETAIL",
  373. "x",
  374. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  375. "declare @field: int foo.C.* : @MyAnnotation");
  376. assertTrue("Should have '" + doIt + " annotated by " +
  377. "declare @field: int foo.C.* : @MyAnnotation" +
  378. "' in the Field Detail section", b);
  379. b = AjdocOutputChecker.summarySectionContainsRel(
  380. htmlFile,"=== FIELD SUMMARY",
  381. "x",
  382. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  383. "declare @field: int foo.C.* : @MyAnnotation");
  384. assertTrue("Should have '" + doIt + " annotated by " +
  385. "declare @field: int foo.C.* : @MyAnnotation" +
  386. "' in the Field Summary section", b);
  387. }
  388. /**
  389. * The target of a declare method annotation should have the
  390. * 'annotated by' relationship in the ajdoc within the method
  391. * information
  392. */
  393. public void testTypeAnnotatedBy() throws Exception {
  394. initialiseProject("declareForms");
  395. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
  396. runAjdoc("private","1.5",files);
  397. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
  398. if (!htmlFile.exists()) {
  399. fail("couldn't find " + htmlFile.getAbsolutePath()
  400. + " - were there compilation errors?");
  401. }
  402. boolean b = AjdocOutputChecker.classDataSectionContainsRel(
  403. htmlFile,
  404. HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
  405. "declare @type: foo.C : @MyAnnotation");
  406. assertTrue("The class data section should have 'annotated by" +
  407. " declare @type: foo.C : @MyAnnotation'",b);
  408. }
  409. /**
  410. * Test that info for both "matches declare" and "advised by"
  411. * appear in the ajdoc for a method when the method is affected
  412. * by both.
  413. */
  414. public void testMatchesDeclareAndAdvisedBy() throws Exception {
  415. initialiseProject("declareForms");
  416. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "A.aj")};
  417. runAjdoc("private","1.4",files);
  418. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
  419. if (!htmlFile.exists()) {
  420. fail("couldn't find " + htmlFile.getAbsolutePath()
  421. + " - were there compilation errors?");
  422. }
  423. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  424. htmlFile,"=== METHOD DETAIL",
  425. "amethod()",
  426. HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
  427. "declare warning: quot;warningquot;");
  428. assertTrue("Should have 'amethod() matches declare declare warning: " +
  429. "quot;warningquot;' in the Method Detail section", b);
  430. b = AjdocOutputChecker.summarySectionContainsRel(
  431. htmlFile,"=== METHOD SUMMARY",
  432. "amethod()",
  433. HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
  434. "declare warning: quot;warningquot;");
  435. assertTrue("Should have 'amethod() matches declare declare warning: " +
  436. "quot;warningquot;' in the Method Summary section", b);
  437. b = AjdocOutputChecker.detailSectionContainsRel(
  438. htmlFile,"=== METHOD DETAIL",
  439. "amethod()",
  440. HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
  441. "before(): p..");
  442. assertTrue("the Method Detail should have amethod() advised by before(): p..",b);
  443. b = AjdocOutputChecker.summarySectionContainsRel(
  444. htmlFile,"=== METHOD SUMMARY",
  445. "amethod()",
  446. HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
  447. "before(): p..");
  448. assertTrue("the Method Summary should have amethod() advised by before(): p..",b);
  449. }
  450. /**
  451. * Test that if there are two declare parents statements within
  452. * an aspect, one which extends and one which implements, that the
  453. * ajdoc shows the correct information
  454. */
  455. public void testTwoDeclareParents() throws Exception {
  456. initialiseProject("declareForms");
  457. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareParents.aj")};
  458. runAjdoc("private","1.4",files);
  459. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareParents.html");
  460. if (!htmlFile.exists()) {
  461. fail("couldn't find " + htmlFile.getAbsolutePath()
  462. + " - were there compilation errors?");
  463. }
  464. String[] strings = {
  465. "declare parents: implements Serializable",
  466. "HREF=\"../foo/Class1.html\"",
  467. "declare parents: extends Observable",
  468. "HREF=\"../foo/Class2.html\""};
  469. // check that the correct declare statements are there
  470. for (int i = 0; i < strings.length - 1; i = i+2) {
  471. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  472. htmlFile,"DECLARE DETAIL SUMMARY",strings[i],
  473. HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
  474. strings[i+1]);
  475. assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] +
  476. "' in the Declare Detail section", b);
  477. }
  478. for (int i = 0; i < strings.length - 1; i = i+2) {
  479. boolean b = AjdocOutputChecker.summarySectionContainsRel(
  480. htmlFile,"DECLARE SUMMARY",
  481. strings[i],
  482. HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
  483. strings[i+1]);
  484. assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] +
  485. "' in the Declare Summary section", b);
  486. }
  487. // check that we don't have declare statements for those that don't
  488. // exist in the code
  489. boolean b = AjdocOutputChecker.detailSectionContainsRel(
  490. htmlFile,"DECLARE DETAIL SUMMARY",strings[0],
  491. HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
  492. strings[3]);
  493. assertFalse("Should not have ' " + strings[0] + " declared on " + strings[3] +
  494. "' in the Declare Detail section", b);
  495. }
  496. }