Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* *******************************************************************
  2. * Copyright (c) 2005 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 PointcutVisibilityTest extends AjdocTestCase {
  19. /**
  20. * Test that passing the "public" argument only shows
  21. * public pointcuts in the ajdoc
  22. */
  23. public void testCoveragePublicMode() throws Exception {
  24. initialiseProject("bug82340");
  25. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
  26. runAjdoc("public",files);
  27. // ajdoc for Pointcut.java should contain info about
  28. // the public pointcuts but not the protected and
  29. // private one (since "public" was an argument)
  30. // Check that this is the case......
  31. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
  32. if (!htmlFile.exists()) {
  33. fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
  34. }
  35. // check the contents of the pointcut summary
  36. String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
  37. List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
  38. assertEquals("There should be two missing strings",2,missing.size());
  39. assertTrue("passing the 'public' argument means the private pointcut shouldn't appear in the ajdoc", missing.contains("privatePointcut"));
  40. assertTrue("passing the 'public' argument means the protected pointcut shouldn't appear in the ajdoc", missing.contains("protectedPointcut"));
  41. }
  42. /**
  43. * Test that passing the "protected" argument only shows
  44. * public and protected pointcuts in the ajdoc
  45. */
  46. public void testCoverageProtectedMode() throws Exception {
  47. initialiseProject("bug82340");
  48. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
  49. runAjdoc("protected",files);
  50. // ajdoc for Pointcut.java should contain info about
  51. // the public and protected pointcuts but not the
  52. // private one (since "protected" was an argument)
  53. // Check that this is the case......
  54. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
  55. if (!htmlFile.exists()) {
  56. fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
  57. }
  58. // check the contents of the pointcut summary
  59. String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
  60. List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
  61. assertEquals("There should be one missing strings",1,missing.size());
  62. assertEquals("passing the 'protected' argument means the private pointcut shouldn't appear in the ajdoc",
  63. "privatePointcut", missing.get(0));
  64. }
  65. /**
  66. * Test that passing the "private" argument shows all
  67. * pointcuts (public, protected and private) in the ajdoc
  68. */
  69. public void testCoveragePrivateMode() throws Exception {
  70. initialiseProject("bug82340");
  71. File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
  72. runAjdoc("private",files);
  73. // ajdoc for Pointcut.java should contain info about
  74. // the public, protected and private pointcuts
  75. // (since "private" was an argument)
  76. // Check that this is the case......
  77. File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
  78. if (!htmlFile.exists()) {
  79. fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
  80. }
  81. // check the contents of the pointcut summary
  82. String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
  83. List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
  84. assertTrue("passing the 'private' modifier means that private, protected and public " +
  85. "pointcuts should appear in the ajdoc",missing.isEmpty());
  86. }
  87. }