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.

JUnitDriver.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package org.aspectj.tools.ajdoc;
  2. import junit.framework.Test;
  3. import junit.framework.Assert;
  4. import junit.textui.TestRunner;
  5. import junit.framework.TestCase;
  6. import junit.framework.TestSuite;
  7. import java.io.File;
  8. import org.aspectj.tools.ajdoc.Main;
  9. /**
  10. * Test driver for ajdoc
  11. * currently only has disabled test cases to invoke ajdoc
  12. * but not verify results.
  13. * @deprecated org.aspectj.testing.harness.AjdocScript
  14. */
  15. public class JUnitDriver extends TestCase {
  16. private static final String[] ME
  17. = new String[] {"org.aspectj.tools.ajdoc.JUnitDriver"};
  18. static final String ajbase = "c:/home/wes/aj";
  19. static final String testbase = ajbase + "/aj-build-modules/tests/ajdoc/JUnitDriver";
  20. static final String srcbase = ajbase + "/aspectj/modules/ajdoc/testsrc";
  21. private AjdocTestCase[] CASES;
  22. protected void setUp() {
  23. assertTrue(null == CASES);
  24. System.setProperty("seetag.debug", "on");
  25. CASES = new AjdocTestCase[]
  26. { // both disabled as samples not checked in
  27. // getLinkTestCase()
  28. //, getJUnitTestCase()
  29. };
  30. }
  31. AjdocTestCase getLinkTestCase() {
  32. String outDir = testbase + "/link/api";
  33. new File(outDir).mkdirs();
  34. return new AjdocTestCase("Link", new String[]
  35. {
  36. "-d", outDir
  37. , "-private"
  38. , "-sourcepath", srcbase
  39. , "test" // doc test package only
  40. });
  41. }
  42. AjdocTestCase getJUnitTestCase() {
  43. String outDir = "c:/home/doc/junit/api";
  44. new File(outDir).mkdir();
  45. return new AjdocTestCase("JUnit", new String[]
  46. {
  47. "-d", outDir
  48. , "-private"
  49. , "-sourcepath"
  50. , "c:/home/doc/junit/src"
  51. , "junitjunit.awtui"
  52. , "junit.extensions"
  53. , "junit.framework"
  54. , "junit.runner"
  55. , "junit.swingui"
  56. , "junit.swingui.icons"
  57. , "junit.textui"
  58. , "junit.ui"
  59. });
  60. }
  61. public static void main(String[] args) {
  62. TestRunner.main(ME);
  63. }
  64. /** todo result logging? */
  65. public static void log(String s) {
  66. System.err.println(""+s);
  67. }
  68. /** load all KNOWN_TEST_CLASSES */
  69. public static Test suite() {
  70. TestSuite result = new TestSuite();
  71. result.addTestSuite(JUnitDriver.class);
  72. return result;
  73. }
  74. //------------------ instance members
  75. public JUnitDriver(String name) { super(name); }
  76. /**
  77. * Run known test cases in CASES
  78. */
  79. public void testAll() {
  80. assertTrue(null != CASES);
  81. for (int i = 0; i < CASES.length; i++) {
  82. CASES[i].run(this);
  83. }
  84. }
  85. /** this just invokes AJDoc but does not verify results */
  86. static class AjdocTestCase {
  87. private final String label;
  88. public final String[] args;
  89. public AjdocTestCase(String label, String[] args) {
  90. this.label = (null == label ? "no label" : label);
  91. this.args = (null == args? new String[] {"help"} : args);
  92. }
  93. public void run(Assert assert) {
  94. int result = Main.execute(args);
  95. assert.assertTrue("result: " + result,0 == result);
  96. // now verify...
  97. }
  98. }
  99. }