Commit | Line | Data |
---|---|---|
4ab33d2b AO |
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: | |
1f506a43 | 10 | * Francois Chouinard - Initial API and implementation |
4ab33d2b AO |
11 | *******************************************************************************/ |
12 | ||
13 | package org.eclipse.linuxtools.tmf.event; | |
14 | ||
5c2b49c4 | 15 | import static org.junit.Assert.assertEquals; |
4ab33d2b AO |
16 | |
17 | import org.junit.Test; | |
18 | ||
19 | /** | |
20 | * <b><u>TmfEventFormatTest</u></b> | |
21 | * <p> | |
1f506a43 | 22 | * JUnit test suite for the TmfEventFormat class. |
4ab33d2b AO |
23 | */ |
24 | public class TmfEventFormatTest { | |
25 | ||
26 | // ======================================================================== | |
27 | // Constructors | |
28 | // ======================================================================== | |
29 | ||
30 | @Test | |
31 | public void testBasicTmfEventFormat() { | |
32 | TmfEventFormat format = new TmfEventFormat(); | |
33 | assertEquals("getLabels", 1, format.getLabels().length); | |
34 | assertEquals("getValue", "Content", format.getLabels()[0]); | |
35 | } | |
36 | ||
37 | @Test | |
38 | public void testEmptyConstructor() { | |
39 | TmfEventFormat format = new TmfEventFormat(new String[] {}); | |
40 | assertEquals("getLabels", 0, format.getLabels().length); | |
41 | } | |
42 | ||
43 | @Test | |
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]); | |
50 | } | |
51 | ||
52 | @Test | |
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]); | |
61 | } | |
62 | ||
63 | // ======================================================================== | |
64 | // parse | |
65 | // ======================================================================== | |
66 | ||
67 | @Test | |
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()); | |
73 | } | |
74 | ||
75 | @Test | |
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()); | |
85 | } | |
86 | ||
87 | } |