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

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