Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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