|
Lines 12-18
Link Here
|
| 12 |
|
12 |
|
| 13 |
package org.eclipse.linuxtools.tmf.event; |
13 |
package org.eclipse.linuxtools.tmf.event; |
| 14 |
|
14 |
|
| 15 |
import static org.junit.Assert.*; |
15 |
import static org.junit.Assert.assertEquals; |
| 16 |
|
16 |
|
| 17 |
import org.junit.Test; |
17 |
import org.junit.Test; |
| 18 |
|
18 |
|
|
Lines 31-39
Link Here
|
| 31 |
public void testTmfEvent() { |
31 |
public void testTmfEvent() { |
| 32 |
TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); |
32 |
TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); |
| 33 |
TmfEventSource source = new TmfEventSource("Source"); |
33 |
TmfEventSource source = new TmfEventSource("Source"); |
| 34 |
TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); |
34 |
TmfEventType type = new TmfEventTypeStub(); |
| 35 |
TmfEventType type = new TmfEventType("Type", format); |
35 |
TmfEventContent content = new TmfEventContentStub(); |
| 36 |
TmfEventContent content = new TmfEventContent("Some content", format); |
|
|
| 37 |
TmfEventReference reference = new TmfEventReference("Reference"); |
36 |
TmfEventReference reference = new TmfEventReference("Reference"); |
| 38 |
|
37 |
|
| 39 |
// Create the event |
38 |
// Create the event |
|
Lines 57-70
Link Here
|
| 57 |
|
56 |
|
| 58 |
// Check the event type |
57 |
// Check the event type |
| 59 |
TmfEventType tp = event.getType(); |
58 |
TmfEventType tp = event.getType(); |
| 60 |
assertEquals("getValue", "Type", tp.getTypeId()); |
59 |
assertEquals("getValue", "TmfEventTypeStub", tp.getTypeId()); |
| 61 |
assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]); |
60 |
assertEquals("getLabels", "Field1", tp.getLabels()[0]); |
| 62 |
assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]); |
61 |
assertEquals("getLabels", "Field2", tp.getLabels()[1]); |
| 63 |
|
62 |
|
| 64 |
// Check the event content |
63 |
// Check the event content |
| 65 |
TmfEventContent cnt = event.getContent(); |
64 |
TmfEventContent cnt = event.getContent(); |
| 66 |
assertEquals("getField", 1, cnt.getFields().length); |
65 |
assertEquals("getField", 5, cnt.getFields().length); |
| 67 |
assertEquals("getField", "Some content", cnt.getField(0).toString()); |
66 |
assertEquals("getField", "some string", ((TmfEventField) cnt.getField(3)).getValue()); |
| 68 |
|
67 |
|
| 69 |
// Check the event reference |
68 |
// Check the event reference |
| 70 |
TmfEventReference ref = event.getReference(); |
69 |
TmfEventReference ref = event.getReference(); |
|
Lines 71-119
Link Here
|
| 71 |
assertEquals("getValue", "Reference", ref.getValue()); |
70 |
assertEquals("getValue", "Reference", ref.getValue()); |
| 72 |
} |
71 |
} |
| 73 |
|
72 |
|
| 74 |
@Test |
73 |
// @Test |
| 75 |
public void testTmfEvent2() { |
74 |
// public void testTmfEvent2() { |
| 76 |
TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5); |
75 |
// TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5); |
| 77 |
TmfTimestamp effective = new TmfTimestamp(12350, (byte) 2, 5); |
76 |
// TmfTimestamp effective = new TmfTimestamp(12350, (byte) 2, 5); |
| 78 |
TmfEventSource source = new TmfEventSource("Source"); |
77 |
// TmfEventSource source = new TmfEventSource("Source"); |
| 79 |
TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); |
78 |
// TmfEventType type = new TmfEventTypeStub(); |
| 80 |
TmfEventType type = new TmfEventType("Type", format); |
79 |
// TmfEventContent content = new TmfEventContentStub(); |
| 81 |
TmfEventContent content = new TmfEventContent("Some content", format); |
80 |
// TmfEventReference reference = new TmfEventReference("Reference"); |
| 82 |
TmfEventReference reference = new TmfEventReference("Reference"); |
81 |
// |
| 83 |
|
82 |
// // Create the event |
| 84 |
// Create the event |
83 |
// TmfEvent event = new TmfEvent(original, effective, source, type, content, reference); |
| 85 |
TmfEvent event = new TmfEvent(original, effective, source, type, content, reference); |
84 |
// |
| 86 |
|
85 |
// // Check the event timestamp |
| 87 |
// Check the event timestamp |
86 |
// TmfTimestamp ts = event.getTimestamp(); |
| 88 |
TmfTimestamp ts = event.getTimestamp(); |
87 |
// assertEquals("getValue", 12350, ts.getValue()); |
| 89 |
assertEquals("getValue", 12350, ts.getValue()); |
88 |
// assertEquals("getscale", 2, ts.getScale()); |
| 90 |
assertEquals("getscale", 2, ts.getScale()); |
89 |
// assertEquals("getPrecision", 5, ts.getPrecision()); |
| 91 |
assertEquals("getPrecision", 5, ts.getPrecision()); |
90 |
// |
| 92 |
|
91 |
// // Check the original event timestamp |
| 93 |
// Check the original event timestamp |
92 |
// ts = event.getOriginalTimestamp(); |
| 94 |
ts = event.getOriginalTimestamp(); |
93 |
// assertEquals("getValue", 12345, ts.getValue()); |
| 95 |
assertEquals("getValue", 12345, ts.getValue()); |
94 |
// assertEquals("getscale", 2, ts.getScale()); |
| 96 |
assertEquals("getscale", 2, ts.getScale()); |
95 |
// assertEquals("getPrecision", 5, ts.getPrecision()); |
| 97 |
assertEquals("getPrecision", 5, ts.getPrecision()); |
96 |
// |
| 98 |
|
97 |
// // Check the event source |
| 99 |
// Check the event source |
98 |
// TmfEventSource src = event.getSource(); |
| 100 |
TmfEventSource src = event.getSource(); |
99 |
// assertEquals("getValue", "Source", src.getSourceId()); |
| 101 |
assertEquals("getValue", "Source", src.getSourceId()); |
100 |
// |
| 102 |
|
101 |
// // Check the event type |
| 103 |
// Check the event type |
102 |
// TmfEventType tp = event.getType(); |
| 104 |
TmfEventType tp = event.getType(); |
103 |
// assertEquals("getValue", "TmfEventTypeStub", tp.getTypeId()); |
| 105 |
assertEquals("getValue", "Type", tp.getTypeId()); |
104 |
// assertEquals("getLabels", "field1", tp.getLabels()[0]); |
| 106 |
assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]); |
105 |
// assertEquals("getLabels", "field2", tp.getLabels()[1]); |
| 107 |
assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]); |
106 |
// |
| 108 |
|
107 |
// // Check the event content |
| 109 |
// Check the event content |
108 |
// TmfEventContent cnt = event.getContent(); |
| 110 |
TmfEventContent cnt = event.getContent(); |
109 |
// assertEquals("getField", 1, cnt.getFields().length); |
| 111 |
assertEquals("getField", 1, cnt.getFields().length); |
110 |
// assertEquals("getField", "Some content", cnt.getField(0).toString()); |
| 112 |
assertEquals("getField", "Some content", cnt.getField(0).toString()); |
111 |
// |
| 113 |
|
112 |
// // Check the event reference |
| 114 |
// Check the event reference |
113 |
// TmfEventReference ref = event.getReference(); |
| 115 |
TmfEventReference ref = event.getReference(); |
114 |
// assertEquals("getValue", "Reference", ref.getValue()); |
| 116 |
assertEquals("getValue", "Reference", ref.getValue()); |
115 |
// } |
| 117 |
} |
|
|
| 118 |
|
116 |
|
| 119 |
} |
117 |
} |