1. /*
  2. * Copyright 2000,2002-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional;
  18. import java.util.Vector;
  19. import org.apache.tools.ant.BuildException;
  20. import org.apache.tools.ant.taskdefs.Java;
  21. /**
  22. * This is a primitive task to execute a unit test in the
  23. * org.apache.testlet framework.
  24. *
  25. * @deprecated testlet has been abandoned in favor of JUnit by the
  26. * Avalon community
  27. *
  28. * @ant.task ignore="true"
  29. */
  30. public class Test extends Java {
  31. protected Vector m_tests = new Vector();
  32. /**
  33. * testlet to run
  34. */
  35. protected static final class TestletEntry {
  36. protected String m_testname = "";
  37. /** name of test. No property expansion takes place here */
  38. public void addText(final String testname) {
  39. m_testname += testname;
  40. }
  41. public String toString() {
  42. return m_testname;
  43. }
  44. }
  45. public Test() {
  46. setClassname("org.apache.testlet.engine.TextTestEngine");
  47. }
  48. /**
  49. * add a declaration of a testlet to run
  50. */
  51. public TestletEntry createTestlet() {
  52. final TestletEntry entry = new TestletEntry();
  53. m_tests.addElement(entry);
  54. return entry;
  55. }
  56. /**
  57. * a boolean value indicating whether tests should display a
  58. * message on success; optional
  59. */
  60. public void setShowSuccess(final boolean showSuccess) {
  61. createArg().setValue("-s=" + showSuccess);
  62. }
  63. /**
  64. * a boolean value indicating whether a banner should be displayed
  65. * when starting testlet engine; optional.
  66. */
  67. public void setShowBanner(final String showBanner) {
  68. createArg().setValue("-b=" + showBanner);
  69. }
  70. /**
  71. * a boolean indicating that a stack trace is displayed on
  72. * error (but not normal failure); optional.
  73. */
  74. public void setShowTrace(final boolean showTrace) {
  75. createArg().setValue("-t=" + showTrace);
  76. }
  77. public void setForceShowTrace(final boolean forceShowTrace) {
  78. createArg().setValue("-f=" + forceShowTrace);
  79. }
  80. public void execute()
  81. throws BuildException {
  82. final int size = m_tests.size();
  83. for (int i = 0; i < size; i++) {
  84. createArg().setValue(m_tests.elementAt(i).toString());
  85. }
  86. super.execute();
  87. }
  88. }