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>TmfEventFormatTest</u></b>
22 * JUnit test suite for the TmfEventFormat class.
24 public class TmfEventFormatTest
{
26 // ========================================================================
28 // ========================================================================
31 public void testBasicTmfEventFormat() {
32 TmfEventFormat format
= new TmfEventFormat();
33 assertEquals("getLabels", 1, format
.getLabels().length
);
34 assertEquals("getValue", "Content", format
.getLabels()[0]);
38 public void testEmptyConstructor() {
39 TmfEventFormat format
= new TmfEventFormat(new String
[] {});
40 assertEquals("getLabels", 0, format
.getLabels().length
);
44 public void testNormalConstructor() {
45 TmfEventFormat format
= new TmfEventFormat(new String
[] { "field1", "field2", "field3" });
46 assertEquals("getLabels", 3, format
.getLabels().length
);
47 assertEquals("getLabels", "field1", format
.getLabels()[0]);
48 assertEquals("getLabels", "field2", format
.getLabels()[1]);
49 assertEquals("getLabels", "field3", format
.getLabels()[2]);
53 public void testExtendedConstructor() {
54 TmfEventFormatStub format
= new TmfEventFormatStub();
55 assertEquals("getLabels", 5, format
.getLabels().length
);
56 assertEquals("getLabels", "Field1", format
.getLabels()[0]);
57 assertEquals("getLabels", "Field2", format
.getLabels()[1]);
58 assertEquals("getLabels", "Field3", format
.getLabels()[2]);
59 assertEquals("getLabels", "Field4", format
.getLabels()[3]);
60 assertEquals("getLabels", "Field5", format
.getLabels()[4]);
63 // ========================================================================
65 // ========================================================================
68 public void testBasicParse() {
69 TmfEventFormat format
= new TmfEventFormat();
70 TmfEventField
[] content
= format
.parse(new TmfTimestamp());
71 assertEquals("length", 1, content
.length
);
72 assertEquals("getValue", "[TmfTimestamp:0,0,0]", content
[0].toString());
76 public void testExtendedParse() {
77 TmfEventFormatStub format
= new TmfEventFormatStub();
78 TmfEventField
[] content
= format
.parse(new TmfTimestamp());
79 assertEquals("length", 5, content
.length
);
80 assertEquals("getValue", "1", content
[0].toString());
81 assertEquals("getValue", "-10", content
[1].toString());
82 assertEquals("getValue", "true", content
[2].toString());
83 assertEquals("getValue", "some string", content
[3].toString());
84 assertEquals("getValue", "[TmfTimestamp:1,2,3]", content
[4].toString());