1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.event
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventContent
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventReference
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventSource
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventType
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTraceEvent
;
22 import junit
.framework
.TestCase
;
25 * <b><u>TmfTraceEventTest</u></b>
27 * Test suite for the TmfTraceEvent class.
29 @SuppressWarnings("nls")
30 public class TmfTraceEventTest
extends TestCase
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 private final String fTypeId
= "Some type";
37 private final String fLabel0
= "label1";
38 private final String fLabel1
= "label2";
39 private final String
[] fLabels
= new String
[] { fLabel0
, fLabel1
};
41 private final TmfTimestamp fTimestamp1
= new TmfTimestamp(12345, (byte) 2, 5);
42 private final TmfTimestamp fTimestamp2
= new TmfTimestamp(12350, (byte) 2, 5);
43 private final TmfEventSource fSource
= new TmfEventSource("Source");
44 private final TmfEventType fType
= new TmfEventType(fTypeId
, fLabels
);
45 private final TmfEventReference fReference
= new TmfEventReference("Some reference");
47 private final TmfTraceEvent fEvent1
;
48 private final TmfTraceEvent fEvent2
;
50 private final TmfEventContent fContent1
;
51 private final TmfEventContent fContent2
;
53 private final String fPath
= "/some/path/";
54 private final String fFile
= "filename";
55 private final int fLine
= 10;
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
62 * @param name the test name
64 public TmfTraceEventTest(String name
) {
67 fEvent1
= new TmfTraceEvent(fTimestamp1
, fSource
, fType
, fReference
, fPath
, fFile
, fLine
);
68 fContent1
= new TmfEventContent(fEvent1
, "Some content");
69 fEvent1
.setContent(fContent1
);
71 fEvent2
= new TmfTraceEvent(fTimestamp1
, fTimestamp2
, fSource
, fType
, fReference
, fPath
, fFile
, fLine
);
72 fContent2
= new TmfEventContent(fEvent2
, "Some other content");
73 fEvent2
.setContent(fContent2
);
77 protected void setUp() throws Exception
{
82 protected void tearDown() throws Exception
{
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
90 public void testTmfTraceEvent() throws Exception
{
91 assertEquals("getTimestamp", fTimestamp1
, fEvent1
.getTimestamp());
92 assertEquals("getOriginalTimestamp", fTimestamp1
, fEvent1
.getOriginalTimestamp());
93 assertEquals("getSource", fSource
, fEvent1
.getSource());
94 assertEquals("getType", fType
, fEvent1
.getType());
95 assertEquals("getContent", fContent1
, fEvent1
.getContent());
96 assertEquals("getReference", fReference
, fEvent1
.getReference());
97 assertEquals("getSourcePath", fPath
, fEvent1
.getSourcePath());
98 assertEquals("getFileName", fFile
, fEvent1
.getFileName());
99 assertEquals("getLineNumber", fLine
, fEvent1
.getLineNumber());
102 public void testTmfTraceEvent2() throws Exception
{
103 assertEquals("getTimestamp", fTimestamp2
, fEvent2
.getTimestamp());
104 assertEquals("getOriginalTimestamp", fTimestamp1
, fEvent2
.getOriginalTimestamp());
105 assertEquals("getSource", fSource
, fEvent2
.getSource());
106 assertEquals("getType", fType
, fEvent2
.getType());
107 assertEquals("getContent", fContent2
, fEvent2
.getContent());
108 assertEquals("getReference", fReference
, fEvent2
.getReference());
109 assertEquals("getSourcePath", fPath
, fEvent2
.getSourcePath());
110 assertEquals("getFileName", fFile
, fEvent2
.getFileName());
111 assertEquals("getLineNumber", fLine
, fEvent2
.getLineNumber());
114 public void testTmfTraceEventCopy() throws Exception
{
115 TmfTraceEvent event
= new TmfTraceEvent(fEvent2
);
116 assertEquals("getTimestamp", fTimestamp2
, event
.getTimestamp());
117 assertEquals("getOriginalTimestamp", fTimestamp1
, event
.getOriginalTimestamp());
118 assertEquals("getSource", fSource
, event
.getSource());
119 assertEquals("getType", fType
, event
.getType());
120 assertEquals("getContent", fContent2
, event
.getContent());
121 assertEquals("getReference", fReference
, event
.getReference());
122 assertEquals("getSourcePath", fPath
, event
.getSourcePath());
123 assertEquals("getFileName", fFile
, event
.getFileName());
124 assertEquals("getLineNumber", fLine
, event
.getLineNumber());
127 // ------------------------------------------------------------------------
129 // ------------------------------------------------------------------------
131 // ------------------------------------------------------------------------
133 // ------------------------------------------------------------------------