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
.event
;
15 import static org
.junit
.Assert
.assertEquals
;
17 import org
.junit
.Test
;
20 * <b><u>TmfTraceEventTest</u></b>
22 * JUnit test suite for the TmfTraceEvent class.
24 public class TmfTraceEventTest
{
26 // ========================================================================
28 // ========================================================================
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");
39 // Create the trace event
41 new TmfTraceEvent(timestamp
, source
, type
, content
, reference
, "path", "filename", 10);
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());
49 // Check the event source
50 TmfEventSource evSrc
= event
.getSource();
51 assertEquals("getValue", "Source", evSrc
.getSourceId());
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]);
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());
64 // Check the event reference
65 TmfEventReference evRef
= event
.getReference();
66 assertEquals("getValue", "Reference", evRef
.getValue());
68 // Check the event file reference
69 assertEquals("getPath", "path", event
.getSourcePath());
70 assertEquals("getFile", "filename", event
.getFileName());
71 assertEquals("getLineNumber", 10, event
.getLineNumber());