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.

DeclareFormsTest.java 22KB

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