Update for Bug287562 (Event Model code refresh + JUnits)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.tests / src / org / eclipse / linuxtools / tmf / event / TmfTraceEventTest.java
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.event;
14
15 import static org.junit.Assert.assertEquals;
16
17 import org.junit.Test;
18
19 /**
20 * <b><u>TmfTraceEventTest</u></b>
21 * <p>
22 * JUnit test suite for the TmfTraceEvent class.
23 */
24 public class TmfTraceEventTest {
25
26 // ========================================================================
27 // Constructor
28 // ========================================================================
29
30 @Test
31 public void testTmfTraceEvent() throws Exception {
32 TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5);
33 TmfEventSource source = new TmfEventSource("Source");
34 TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" });
35 TmfEventType type = new TmfEventType("Type", format);
36 TmfEventContent content = new TmfEventContent("Some content", format);
37 TmfEventReference reference = new TmfEventReference("Reference");
38
39 // Create the trace event
40 TmfTraceEvent event =
41 new TmfTraceEvent(timestamp, source, type, content, reference, "path", "filename", 10);
42
43 // Check the event timestamp
44 TmfTimestamp evTS = event.getTimestamp();
45 assertEquals("getValue", 12345, evTS.getValue());
46 assertEquals("getscale", 2, evTS.getScale());
47 assertEquals("getPrecision", 5, evTS.getPrecision());
48
49 // Check the event source
50 TmfEventSource evSrc = event.getSource();
51 assertEquals("getValue", "Source", evSrc.getSourceId());
52
53 // Check the event type
54 TmfEventType evType = event.getType();
55 assertEquals("getValue", "Type", evType.getTypeId());
56 assertEquals("getFormat", "field1", evType.getFormat().getLabels()[0]);
57 assertEquals("getFormat", "field2", evType.getFormat().getLabels()[1]);
58
59 // Check the event content
60 TmfEventContent evContent = event.getContent();
61 assertEquals("getField", 1, evContent.getFields().length);
62 assertEquals("getField", "Some content", evContent.getField(0).toString());
63
64 // Check the event reference
65 TmfEventReference evRef = event.getReference();
66 assertEquals("getValue", "Reference", evRef.getValue());
67
68 // Check the event file reference
69 assertEquals("getPath", "path", event.getSourcePath());
70 assertEquals("getFile", "filename", event.getFileName());
71 assertEquals("getLineNumber", 10, event.getLineNumber());
72 }
73
74 }
This page took 0.031171 seconds and 5 git commands to generate.