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.

ResultCollector.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fotreetest;
  19. import java.util.ArrayList;
  20. import java.util.Collections;
  21. import java.util.List;
  22. /**
  23. * This class collects failures for assertions injected into the FO stream.
  24. */
  25. public class ResultCollector {
  26. private static ResultCollector instance;
  27. private List<String> results = new ArrayList<String>();
  28. /** @return the ResultCollector singleton */
  29. public static ResultCollector getInstance() {
  30. if (instance == null) {
  31. instance = new ResultCollector();
  32. }
  33. return instance;
  34. }
  35. /** Main constructor. */
  36. public ResultCollector() {
  37. //nop
  38. }
  39. /**
  40. * This notifies the ResultCollector about an assertion failure.
  41. *
  42. * @param message the message containing the details
  43. */
  44. public void notifyAssertionFailure(String message) {
  45. System.out.println(message);
  46. results.add(message);
  47. }
  48. /**
  49. * This notifies the ResultCollector about a testcase that ended
  50. * with a fatal error
  51. *
  52. * @param message the message containing the details
  53. */
  54. public void notifyError(String message) {
  55. results.add(message);
  56. }
  57. /** Resets the result list. */
  58. public void reset() {
  59. results.clear();
  60. }
  61. /** @return the list of results */
  62. public List<String> getResults() {
  63. return Collections.unmodifiableList(results);
  64. }
  65. }