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.2KB

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