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 3.8KB

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