aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/testng/remote/strprotocol/GenericMessage.java
blob: 8c23ea0300f813700d22a6a891879bcfd1fad9c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package org.testng.remote.strprotocol;




/**
 * A generic message to be used with remote listeners.
 * It is described by a {@link #m_messageType} and can contain a <code>Map</code>
 * or values.
 *
 * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
 */
public class GenericMessage implements IStringMessage {
//  protected Map m_properties;
  protected final int m_messageType;
  private int m_suiteCount;

  private int m_testCount;

  public GenericMessage(final int type) {
    m_messageType = type;
  }

  public int getSuiteCount() {
    return m_suiteCount;
  }

  public void setSuiteCount(int suiteCount) {
    m_suiteCount = suiteCount;
  }

  public int getTestCount() {
    return m_testCount;
  }

  public void setTestCount(int testCount) {
    m_testCount = testCount;
  }

//  public GenericMessage(final int type, Map props) {
//    m_messageType = type;
//    m_properties = props;
//  }

//  public GenericMessage addProperty(final String propName, final Object propValue) {
//    m_properties.put(propName, propValue);
//
//    return this;
//  }

  public GenericMessage addProperty(final String propName, final int propValue) {
    return addProperty(propName, propValue);
  }

//  public String getProperty(final String propName) {
//    return (String) m_properties.get(propName);
//  }

  @Override
  public String getMessageAsString() {
    StringBuffer buf = new StringBuffer();

    buf.append(m_messageType);
    buf.append(MessageHelper.DELIMITER).append("testCount").append(getTestCount())
        .append(MessageHelper.DELIMITER).append("suiteCount").append(getSuiteCount());

//        for(Iterator it = m_properties.entrySet().iterator(); it.hasNext(); ) {
//          Map.Entry entry = (Map.Entry) it.next();
//
//          buf.append(MessageHelper.DELIMITER)
//              .append(entry.getKey())
//              .append(MessageHelper.DELIMITER)
//              .append(entry.getValue())
//              ;
//        }


    return buf.toString();
  }

  @Override
  public String toString() {
    return "[GenericMessage suiteCount:" + m_suiteCount + " testCount:" + m_testCount + "]";
  }
}