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.

JavadocComparePackageMode.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import java.io.IOException;
  2. import java.util.Vector;
  3. import common.OutputComparator;
  4. import org.aspectj.testing.Tester;
  5. public class JavadocComparePackageMode {
  6. static final String INPUT_FILES = "-classpath input/pkgExample aPack bPack.cPack";
  7. static final String FILE_1 = "aPack/Class2.html";
  8. static final String FILE_2 = "bPack/cPack/Class3.html";
  9. static final String AJDOC_DIR = "output/packageMode1";
  10. static final String JAVADOC_DIR = "output/packageMode2";
  11. static final String AJDOC_CALL = "java org.aspectj.tools.ajdoc.Main -d " + AJDOC_DIR + " " + INPUT_FILES;
  12. static final String JAVADOC_CALL = "javadoc -package -d " + JAVADOC_DIR + " " + INPUT_FILES;
  13. public static void main(String[] args) { test(); }
  14. /**
  15. * <UL>
  16. * <LI>step 1: run ajdoc as a command
  17. * <LI>step 2: run javadoc
  18. * <LI>step 3: compare differences
  19. * </UL>
  20. */
  21. public static void test() {
  22. OutputComparator outputComparator = new OutputComparator();
  23. System.out.println("> running ajdoc");
  24. runCommand(AJDOC_CALL);
  25. System.out.println("> running javadoc");
  26. runCommand(JAVADOC_CALL);
  27. Vector diffs1 = null;
  28. Vector diffs2 = null;
  29. try {
  30. diffs1 = outputComparator.compareFilesByLine(AJDOC_DIR + "/" + FILE_1,
  31. JAVADOC_DIR + "/" + FILE_1);
  32. diffs2 = outputComparator.compareFilesByLine(AJDOC_DIR + "/" + FILE_1,
  33. JAVADOC_DIR + "/" + FILE_1);
  34. }
  35. catch (IOException ioe) {
  36. System.out.println("Couldn't compare files: " + ioe.getMessage());
  37. }
  38. String result1 = "";
  39. String result2 = "";
  40. if (diffs1 != null) result1 = diffs1.toString();
  41. if (diffs2 != null) result2 = diffs2.toString();
  42. Tester.checkEqual(result1, "", "diffs from: " + FILE_1);
  43. Tester.checkEqual(result2, "", "diffs from: " + FILE_2);
  44. }
  45. public static void runCommand(String command) {
  46. try {
  47. Runtime runtime = Runtime.getRuntime();
  48. Process result = runtime.exec(command);
  49. }
  50. catch ( Exception ioe ) {
  51. throw new RuntimeException("could not execute: " + command +
  52. ", " + ioe.getMessage() );
  53. }
  54. }
  55. }