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.

BuildModuleTests.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Common Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/cpl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. // default package
  14. import org.aspectj.internal.tools.ant.taskdefs.Checklics;
  15. import org.aspectj.internal.build.BuildModuleTest;
  16. import org.aspectj.internal.build.ModulesTest;
  17. import java.io.File;
  18. import junit.framework.*;
  19. public class BuildModuleTests extends TestCase {
  20. /** if true, then replace old headers with new first */
  21. private static final boolean replacing = false; // XXX never to enable again...
  22. /** if any replace failed, halt all */
  23. private static boolean replaceFailed = false;
  24. private static final String BASE_DIR = "../";
  25. private static final String[] JDT_SOURCE_DIRS = new String[] {};
  26. // sources moved to shadow/ directory
  27. // {"antadapter", "batch", "codeassist", "compiler",
  28. // "dom", "eval", "formatter", "model", "search" };
  29. public static Test suite() {
  30. TestSuite suite = new TestSuite("Build module tests");
  31. suite.addTestSuite(BuildModuleTests.class);
  32. suite.addTestSuite(BuildModuleTest.class);
  33. suite.addTestSuite(ModulesTest.class);
  34. return suite;
  35. }
  36. /** @return String tag of license if not default */
  37. public static String getLicense(String module) {
  38. if ("org.eclipse.jdt.core".equals(module)) {
  39. return Checklics.CPL_IBM_PARC_TAG;
  40. }
  41. return null;
  42. }
  43. public BuildModuleTests(String name) { super(name); }
  44. public void testLicense_ajbrowser() {
  45. checkLicense("ajbrowser");
  46. }
  47. public void testLicense_ajde() {
  48. checkLicense("ajde");
  49. }
  50. public void testLicense_asm() {
  51. checkLicense("asm");
  52. }
  53. public void testLicense_bridge() {
  54. checkLicense("bridge");
  55. }
  56. public void testLicense_build() {
  57. checkLicense("build");
  58. }
  59. public void testLicense_org_aspectj_ajdt_core() {
  60. checkLicense("org.aspectj.ajdt.core");
  61. }
  62. public void testLicense_org_eclipse_jdt_core() {
  63. final String mod = "org.eclipse.jdt.core";
  64. final String pre = BASE_DIR + mod + "/";
  65. for (int i = 0; i < JDT_SOURCE_DIRS.length; i++) {
  66. checkSourceDirectory(pre + JDT_SOURCE_DIRS[i], mod);
  67. }
  68. }
  69. public void testLicense_runtime() {
  70. checkLicense("runtime");
  71. }
  72. public void testLicense_taskdefs() {
  73. checkLicense("taskdefs");
  74. }
  75. public void testLicense_testing() {
  76. checkLicense("testing");
  77. }
  78. public void testLicense_testing_client() {
  79. checkLicense("testing-client");
  80. }
  81. public void testLicense_testing_drivers() {
  82. checkLicense("testing-drivers");
  83. }
  84. public void testLicense_testing_util() {
  85. checkLicense("testing-util");
  86. }
  87. public void testLicense_util() {
  88. checkLicense("util");
  89. }
  90. public void testLicense_weaver() {
  91. String module = "weaver";
  92. checkSourceDirectory("../" + module + "/src", module);
  93. checkSourceDirectory("../" + module + "/testsrc/org", module);
  94. }
  95. void checkLicense(String module) {
  96. checkSourceDirectory("../" + module + "/src", module);
  97. checkSourceDirectory("../" + module + "/testsrc", module);
  98. }
  99. void checkSourceDirectory(String path, String module) {
  100. File moduleDir = new File(path);
  101. final String label = "source dir " + moduleDir + " (module " + module + ")";
  102. assertTrue(label, (moduleDir.exists() && moduleDir.isDirectory()));
  103. String license = getLicense(module);
  104. // if (replacing) {
  105. // if (replacing && true) {
  106. // throw new Error("replacing done - code left for other replaces");
  107. // }
  108. // assertTrue("aborting - replace failed", !replaceFailed);
  109. // // do the replace
  110. // int fails = Checklics.runDirect(moduleDir.getPath(), "replace-headers");
  111. // replaceFailed = (0 != fails);
  112. // assertTrue(!replaceFailed);
  113. // license = Checklics.CPL_IBM_PARC_XEROX_TAG;
  114. // }
  115. int fails = Checklics.runDirect(moduleDir.getPath(), license);
  116. if (0 != fails) {
  117. if (replacing) {
  118. replaceFailed = true;
  119. }
  120. assertTrue(label + " fails", false);
  121. }
  122. }
  123. }