Commit | Line | Data |
---|---|---|
d18dd09b ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.tests.event; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.event.TmfEventContent; | |
16 | import org.eclipse.linuxtools.tmf.event.TmfEventReference; | |
17 | import org.eclipse.linuxtools.tmf.event.TmfEventSource; | |
18 | import org.eclipse.linuxtools.tmf.event.TmfEventType; | |
19 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; | |
20 | import org.eclipse.linuxtools.tmf.event.TmfTraceEvent; | |
21 | ||
22 | import junit.framework.TestCase; | |
23 | ||
24 | /** | |
25 | * <b><u>TmfTraceEventTest</u></b> | |
26 | * <p> | |
27 | * Test suite for the TmfTraceEvent class. | |
28 | */ | |
29 | public class TmfTraceEventTest extends TestCase { | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Variables | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | private final String fTypeId = "Some type"; | |
36 | private final String fLabel0 = "label1"; | |
37 | private final String fLabel1 = "label2"; | |
38 | private final String[] fLabels = new String[] { fLabel0, fLabel1 }; | |
39 | ||
40 | private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5); | |
41 | private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5); | |
42 | private final TmfEventSource fSource = new TmfEventSource("Source"); | |
43 | private final TmfEventType fType = new TmfEventType(fTypeId, fLabels); | |
44 | private final TmfEventReference fReference = new TmfEventReference("Some reference"); | |
45 | ||
46 | private final TmfTraceEvent fEvent1; | |
47 | private final TmfTraceEvent fEvent2; | |
48 | ||
49 | private final TmfEventContent fContent1; | |
50 | private final TmfEventContent fContent2; | |
51 | ||
52 | private final String fPath = "/some/path/"; | |
53 | private final String fFile = "filename"; | |
54 | private final int fLine = 10; | |
55 | ||
56 | // ------------------------------------------------------------------------ | |
57 | // Housekeeping | |
58 | // ------------------------------------------------------------------------ | |
59 | ||
60 | /** | |
61 | * @param name the test name | |
62 | */ | |
63 | public TmfTraceEventTest(String name) { | |
64 | super(name); | |
65 | ||
66 | fEvent1 = new TmfTraceEvent(fTimestamp1, fSource, fType, fReference, fPath, fFile, fLine); | |
67 | fContent1 = new TmfEventContent(fEvent1, "Some content"); | |
68 | fEvent1.setContent(fContent1); | |
69 | ||
70 | fEvent2 = new TmfTraceEvent(fTimestamp1, fTimestamp2, fSource, fType, fReference, fPath, fFile, fLine); | |
71 | fContent2 = new TmfEventContent(fEvent2, "Some other content"); | |
72 | fEvent2.setContent(fContent2); | |
73 | } | |
74 | ||
75 | @Override | |
76 | protected void setUp() throws Exception { | |
77 | super.setUp(); | |
78 | } | |
79 | ||
80 | @Override | |
81 | protected void tearDown() throws Exception { | |
82 | super.tearDown(); | |
83 | } | |
84 | ||
85 | // ------------------------------------------------------------------------ | |
86 | // Constructors | |
87 | // ------------------------------------------------------------------------ | |
88 | ||
89 | public void testTmfTraceEvent() throws Exception { | |
90 | assertEquals("getTimestamp", fTimestamp1, fEvent1.getTimestamp()); | |
91 | assertEquals("getOriginalTimestamp", fTimestamp1, fEvent1.getOriginalTimestamp()); | |
92 | assertEquals("getSource", fSource, fEvent1.getSource()); | |
93 | assertEquals("getType", fType, fEvent1.getType()); | |
94 | assertEquals("getContent", fContent1, fEvent1.getContent()); | |
95 | assertEquals("getReference", fReference, fEvent1.getReference()); | |
96 | assertEquals("getSourcePath", fPath, fEvent1.getSourcePath()); | |
97 | assertEquals("getFileName", fFile, fEvent1.getFileName()); | |
98 | assertEquals("getLineNumber", fLine, fEvent1.getLineNumber()); | |
99 | } | |
100 | ||
101 | public void testTmfTraceEvent2() throws Exception { | |
102 | assertEquals("getTimestamp", fTimestamp2, fEvent2.getTimestamp()); | |
103 | assertEquals("getOriginalTimestamp", fTimestamp1, fEvent2.getOriginalTimestamp()); | |
104 | assertEquals("getSource", fSource, fEvent2.getSource()); | |
105 | assertEquals("getType", fType, fEvent2.getType()); | |
106 | assertEquals("getContent", fContent2, fEvent2.getContent()); | |
107 | assertEquals("getReference", fReference, fEvent2.getReference()); | |
108 | assertEquals("getSourcePath", fPath, fEvent2.getSourcePath()); | |
109 | assertEquals("getFileName", fFile, fEvent2.getFileName()); | |
110 | assertEquals("getLineNumber", fLine, fEvent2.getLineNumber()); | |
111 | } | |
112 | ||
113 | public void testTmfTraceEventCopy() throws Exception { | |
114 | TmfTraceEvent event = new TmfTraceEvent(fEvent2); | |
115 | assertEquals("getTimestamp", fTimestamp2, event.getTimestamp()); | |
116 | assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp()); | |
117 | assertEquals("getSource", fSource, event.getSource()); | |
118 | assertEquals("getType", fType, event.getType()); | |
119 | assertEquals("getContent", fContent2, event.getContent()); | |
120 | assertEquals("getReference", fReference, event.getReference()); | |
121 | assertEquals("getSourcePath", fPath, event.getSourcePath()); | |
122 | assertEquals("getFileName", fFile, event.getFileName()); | |
123 | assertEquals("getLineNumber", fLine, event.getLineNumber()); | |
124 | } | |
125 | ||
126 | // ------------------------------------------------------------------------ | |
127 | // equals | |
128 | // ------------------------------------------------------------------------ | |
129 | ||
130 | // ------------------------------------------------------------------------ | |
131 | // toString | |
132 | // ------------------------------------------------------------------------ | |
133 | ||
134 | } | |
135 |