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.

RunSpec.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-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 java.util.StringTokenizer;
  16. import org.aspectj.tools.ajc.AjcTestCase;
  17. /**
  18. * @author colyer
  19. *
  20. * TODO To change the template for this generated type comment go to
  21. * Window - Preferences - Java - Code Style - Code Templates
  22. */
  23. public class RunSpec implements ITestStep {
  24. private List expected = new ArrayList();
  25. private String classToRun;
  26. private String baseDir;
  27. private String options;
  28. private AjcTest myTest;
  29. public RunSpec() {
  30. }
  31. /* (non-Javadoc)
  32. * @see org.aspectj.testing.ITestStep#execute(org.aspectj.tools.ajc.AjcTestCase)
  33. */
  34. public void execute(AjcTestCase inTestCase) {
  35. if (!expected.isEmpty()) {
  36. System.err.println("Warning, message spec for run command is currently ignored (org.aspectj.testing.RunSpec)");
  37. }
  38. String[] args = buildArgs();
  39. AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(),args,null);
  40. }
  41. public void addExpectedMessage(ExpectedMessageSpec message) {
  42. expected.add(message);
  43. }
  44. public void setBaseDir(String dir) {
  45. this.baseDir = dir;
  46. }
  47. public void setTest(AjcTest test) {
  48. this.myTest = test;
  49. }
  50. public String getOptions() {
  51. return options;
  52. }
  53. public void setOptions(String options) {
  54. this.options = options;
  55. }
  56. /**
  57. * @return Returns the classToRun.
  58. */
  59. public String getClassToRun() {
  60. return classToRun;
  61. }
  62. /**
  63. * @param classToRun The classToRun to set.
  64. */
  65. public void setClassToRun(String classToRun) {
  66. this.classToRun = classToRun;
  67. }
  68. private String[] buildArgs() {
  69. if (options == null) return new String[0];
  70. StringTokenizer strTok = new StringTokenizer(options,",");
  71. String[] ret = new String[strTok.countTokens()];
  72. for (int i = 0; i < ret.length; i++) {
  73. ret[i] = strTok.nextToken();
  74. }
  75. return ret;
  76. }
  77. }