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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  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.isVMGreaterOrEqual(9);
  26. private static boolean is10VMOrGreater = LangUtil.isVMGreaterOrEqual(10);
  27. private static boolean is11VMOrGreater = LangUtil.isVMGreaterOrEqual(11);
  28. private static boolean is12VMOrGreater = LangUtil.isVMGreaterOrEqual(12);
  29. private static boolean is13VMOrGreater = LangUtil.isVMGreaterOrEqual(13);
  30. private static boolean is14VMOrGreater = LangUtil.isVMGreaterOrEqual(14);
  31. private static boolean is15VMOrGreater = LangUtil.isVMGreaterOrEqual(15);
  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.println("TEST: " + getTitle());
  49. for (ITestStep step: testSteps) {
  50. step.setBaseDir(getDir());
  51. step.execute(testCase);
  52. }
  53. } finally {
  54. System.out.println("DONE");
  55. }
  56. return true;
  57. }
  58. public boolean canRunOnThisVM() {
  59. if (vmLevel.equals("1.3")) return true;
  60. boolean canRun = true;
  61. if (vmLevel.equals("1.4")) canRun = is1dot4VMOrGreater;
  62. if (vmLevel.equals("1.5")) canRun = is1dot5VMOrGreater;
  63. if (vmLevel.equals("1.6")) canRun = is1dot6VMOrGreater;
  64. if (vmLevel.equals("1.7")) canRun = is1dot7VMOrGreater;
  65. if (vmLevel.equals("1.8")) canRun = is1dot8VMOrGreater;
  66. if (vmLevel.equals("1.9")) canRun = is9VMOrGreater;
  67. if (vmLevel.equals("10")) canRun = is10VMOrGreater;
  68. if (vmLevel.equals("11")) canRun = is11VMOrGreater;
  69. if (vmLevel.equals("12")) canRun = is12VMOrGreater;
  70. if (vmLevel.equals("13")) canRun = is13VMOrGreater;
  71. if (vmLevel.equals("14")) canRun = is14VMOrGreater;
  72. if (!canRun) {
  73. System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
  74. + ", currently running on " + System.getProperty("java.vm.version"));
  75. }
  76. return canRun;
  77. }
  78. /**
  79. * @return Returns the comment.
  80. */
  81. public String getComment() {
  82. return comment;
  83. }
  84. /**
  85. * @param comment The comment to set.
  86. */
  87. public void setComment(String comment) {
  88. this.comment = comment;
  89. }
  90. /**
  91. * @return Returns the dir.
  92. */
  93. public String getDir() {
  94. return dir;
  95. }
  96. /**
  97. * @param dir The dir to set.
  98. */
  99. public void setDir(String dir) {
  100. dir = "../tests/" + dir;
  101. this.dir = dir;
  102. }
  103. /**
  104. * @return Returns the keywords.
  105. */
  106. public String getKeywords() {
  107. return keywords;
  108. }
  109. /**
  110. * @param keywords The keywords to set.
  111. */
  112. public void setKeywords(String keywords) {
  113. this.keywords = keywords;
  114. }
  115. /**
  116. * @return Returns the pr.
  117. */
  118. public String getPr() {
  119. return pr;
  120. }
  121. /**
  122. * @param pr The pr to set.
  123. */
  124. public void setPr(String pr) {
  125. this.pr = pr;
  126. }
  127. /**
  128. * @return Returns the title.
  129. */
  130. public String getTitle() {
  131. return title;
  132. }
  133. /**
  134. * @param title The title to set.
  135. */
  136. public void setTitle(String title) {
  137. this.title = title;
  138. }
  139. /**
  140. * @param vmLevel The vmLevel to set.
  141. */
  142. public void setVm(String vmLevel) {
  143. this.vmLevel = vmLevel;
  144. }
  145. /**
  146. * @return Returns the vmLevel.
  147. */
  148. public String getVmLevel() {
  149. return vmLevel;
  150. }
  151. }