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.

JavadocTest.java 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Common Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/cpl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial implementation
  10. *******************************************************************************/
  11. package org.aspectj.ajdt.internal.compiler.batch;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.Iterator;
  15. import java.util.List;
  16. import org.aspectj.bridge.IMessage;
  17. import org.aspectj.tools.ajc.AjcTestCase;
  18. import org.aspectj.tools.ajc.CompilationResult;
  19. public class JavadocTest extends AjcTestCase {
  20. public static final String PROJECT_DIR = "javadoc";
  21. private File baseDir;
  22. protected void setUp() throws Exception {
  23. super.setUp();
  24. baseDir = new File("../org.aspectj.ajdt.core/testdata",PROJECT_DIR);
  25. }
  26. /**
  27. * Aim: Check javadoc warning that appear are appropriate
  28. *
  29. * ajc -warn:allJavadoc World.java
  30. *
  31. */
  32. public void testMissingJavadoc () {
  33. String[] args = new String[] {"World.java","-warn:allJavadoc"};
  34. List warningMessages = new ArrayList();
  35. // These warnings are against public textX() methods declared in the World.java
  36. // type. These test methods are spread between AJ constructuts, meaning
  37. // if someone messes up and the javadoc is not associated with the aspectj
  38. // construct then it will associated by accident with one of the testX() methods.
  39. // By checking we get a warning against every testX() method, we are verifying
  40. // that the javadoc is being attached to the aspectj constructs.
  41. warningMessages.add(new Message(10,"Missing comment for public declaration"));
  42. warningMessages.add(new Message(18,"Missing comment for public declaration"));
  43. warningMessages.add(new Message(28,"Missing comment for public declaration"));
  44. warningMessages.add(new Message(36,"Missing comment for public declaration"));
  45. warningMessages.add(new Message(44,"Missing comment for public declaration"));
  46. warningMessages.add(new Message(53,"Missing comment for public declaration"));
  47. warningMessages.add(new Message(61,"Missing comment for public declaration"));
  48. warningMessages.add(new Message(69,"Missing comment for public declaration"));
  49. MessageSpec spec = new MessageSpec(warningMessages,null);
  50. CompilationResult result = ajc(baseDir,args);
  51. assertMessages(result,spec);
  52. // dump(result.getWarningMessages());
  53. // System.err.println("-----------\n"+ajc.getLastCompilationResult().getStandardError());
  54. // List l = result.getWarningMessages();
  55. // IMessage m = ((IMessage)l.get(0));
  56. }
  57. private void dump(List l) {
  58. for (Iterator iter = l.iterator(); iter.hasNext();) {
  59. IMessage element = (IMessage) iter.next();
  60. System.err.println("Warning: "+element);
  61. }
  62. }
  63. }