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.

AjcTest.java 4.1KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
13 years ago
13 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* *******************************************************************
  2. * Copyright (c) 2004,2013 IBM Corporation, 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. package org.aspectj.testing;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. import org.aspectj.tools.ajc.AjcTestCase;
  13. /**
  14. * @author Adrian Colyer
  15. * @author Andy Clement
  16. */
  17. public class AjcTest {
  18. // private static boolean is13VMOrGreater = true;
  19. private static boolean is14VMOrGreater = true;
  20. private static boolean is15VMOrGreater = false;
  21. private static boolean is16VMOrGreater = false;
  22. private static boolean is17VMOrGreater = false;
  23. private static boolean is18VMOrGreater = false;
  24. static { // matching logic is also in org.aspectj.util.LangUtil
  25. String vm = System.getProperty("java.version"); // JLS 20.18.7
  26. if (vm==null) vm = System.getProperty("java.runtime.version");
  27. if (vm==null) vm = System.getProperty("java.vm.version");
  28. if (vm.startsWith("1.3")) {
  29. is14VMOrGreater = false;
  30. } else if (vm.startsWith("1.5")) {
  31. is15VMOrGreater = true;
  32. } else if (vm.startsWith("1.6")) {
  33. is15VMOrGreater = true;
  34. is16VMOrGreater = true;
  35. } else if (vm.startsWith("1.7")) {
  36. is15VMOrGreater = true;
  37. is16VMOrGreater = true;
  38. is17VMOrGreater = true;
  39. } else if (vm.startsWith("1.8")) {
  40. is15VMOrGreater = true;
  41. is16VMOrGreater = true;
  42. is17VMOrGreater = true;
  43. is18VMOrGreater = true;
  44. }
  45. }
  46. private List<ITestStep> testSteps = new ArrayList<ITestStep>();
  47. private String dir;
  48. private String pr;
  49. private String title;
  50. private String keywords;
  51. private String comment;
  52. private String vmLevel = "1.3";
  53. public AjcTest() {
  54. }
  55. public void addTestStep(ITestStep step) {
  56. testSteps.add(step);
  57. step.setTest(this);
  58. }
  59. public boolean runTest(AjcTestCase testCase) {
  60. if (!canRunOnThisVM()) return false;
  61. try {
  62. System.out.print("TEST: " + getTitle() + "\t");
  63. for (ITestStep step: testSteps) {
  64. step.setBaseDir(getDir());
  65. System.out.print(".");
  66. step.execute(testCase);
  67. }
  68. } finally {
  69. System.out.println("DONE");
  70. }
  71. return true;
  72. }
  73. public boolean canRunOnThisVM() {
  74. if (vmLevel.equals("1.3")) return true;
  75. boolean canRun = true;
  76. if (vmLevel.equals("1.4")) canRun = is14VMOrGreater;
  77. if (vmLevel.equals("1.5")) canRun = is15VMOrGreater;
  78. if (vmLevel.equals("1.6")) canRun = is16VMOrGreater;
  79. if (vmLevel.equals("1.7")) canRun = is17VMOrGreater;
  80. if (vmLevel.equals("1.8")) canRun = is18VMOrGreater;
  81. if (!canRun) {
  82. System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
  83. + ", currently running on " + System.getProperty("java.vm.version"));
  84. }
  85. return canRun;
  86. }
  87. /**
  88. * @return Returns the comment.
  89. */
  90. public String getComment() {
  91. return comment;
  92. }
  93. /**
  94. * @param comment The comment to set.
  95. */
  96. public void setComment(String comment) {
  97. this.comment = comment;
  98. }
  99. /**
  100. * @return Returns the dir.
  101. */
  102. public String getDir() {
  103. return dir;
  104. }
  105. /**
  106. * @param dir The dir to set.
  107. */
  108. public void setDir(String dir) {
  109. dir = "../tests/" + dir;
  110. this.dir = dir;
  111. }
  112. /**
  113. * @return Returns the keywords.
  114. */
  115. public String getKeywords() {
  116. return keywords;
  117. }
  118. /**
  119. * @param keywords The keywords to set.
  120. */
  121. public void setKeywords(String keywords) {
  122. this.keywords = keywords;
  123. }
  124. /**
  125. * @return Returns the pr.
  126. */
  127. public String getPr() {
  128. return pr;
  129. }
  130. /**
  131. * @param pr The pr to set.
  132. */
  133. public void setPr(String pr) {
  134. this.pr = pr;
  135. }
  136. /**
  137. * @return Returns the title.
  138. */
  139. public String getTitle() {
  140. return title;
  141. }
  142. /**
  143. * @param title The title to set.
  144. */
  145. public void setTitle(String title) {
  146. this.title = title;
  147. }
  148. /**
  149. * @param vmLevel The vmLevel to set.
  150. */
  151. public void setVm(String vmLevel) {
  152. this.vmLevel = vmLevel;
  153. }
  154. /**
  155. * @return Returns the vmLevel.
  156. */
  157. public String getVmLevel() {
  158. return vmLevel;
  159. }
  160. }