1 package net.sourceforge.selfesteem;
2
3 import org.jdom.Element;
4
5 import java.util.Iterator;
6
7
8 public class TestNode implements Node {
9 private String _storyName;
10 private String _name;
11 private boolean _passing;
12 private double _time;
13 private String _errorMessage;
14 private String _stackTrace;
15
16 public TestNode(String name, boolean passing, double time) {
17 int i = name.indexOf('/');
18 if (i == -1) {
19 throw new SelfEsteemException("You must specify story for test (" + name +
20 ") in the form of (<story>/" + name + ")");
21 }
22
23 _storyName = name.substring(0, i);
24 _name = name.substring(i + 1);
25 _passing = passing;
26 _time = time;
27 }
28
29 public TestNode(Element element) {
30 this(element.getAttributeValue("name"), true, Double.parseDouble(element.getAttributeValue("time")));
31
32 for (Iterator i = element.getChildren().iterator(); i.hasNext();) {
33 Element child = (Element) i.next();
34 if (child.getName().equals("error") || child.getName().equals("failure")) {
35 _passing = false;
36 _errorMessage = child.getAttributeValue("message");
37 _stackTrace = child.getText();
38 }
39 }
40 }
41
42 public String getName() {
43 return _name;
44 }
45
46 public Node get(int i) {
47 throw new ArrayIndexOutOfBoundsException();
48 }
49
50 public boolean isPassing() {
51 return _passing;
52 }
53
54 public double getTime() {
55 return _time;
56 }
57
58 public String getStoryName() {
59 return _storyName;
60 }
61
62 public String toString() {
63 return _name + (!_passing ? " - " + _errorMessage : "");
64 }
65
66 public String getErrorMessage() {
67 return _errorMessage;
68 }
69
70 public String getStackTrace() {
71 return _stackTrace;
72 }
73
74 public void serialize(Serializer serializer, int level) {
75 serializer.addLine(level, toString());
76 }
77 }
This page was automatically generated by Maven