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 | ||
6acf8488 | 15 | import static org.junit.Assert.assertEquals; |
4ab33d2b AO |
16 | |
17 | import org.junit.Test; | |
18 | ||
19 | /** | |
20 | * <b><u>TmfEventContentTest</u></b> | |
21 | * <p> | |
1f506a43 | 22 | * JUnit test suite for the TmfEventContent class. |
4ab33d2b AO |
23 | */ |
24 | public class TmfEventContentTest { | |
25 | ||
6acf8488 FC |
26 | // ======================================================================== |
27 | // Constructors | |
28 | // ======================================================================== | |
29 | ||
30 | @Test | |
31 | public void testTmfEventContent() { | |
1f506a43 | 32 | TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat()); |
6acf8488 FC |
33 | assertEquals("getFormat", 1, content.getFormat().getLabels().length); |
34 | assertEquals("getLabels", "Content", content.getFormat().getLabels()[0]); | |
35 | assertEquals("getContent", "Some content", content.getContent()); | |
36 | } | |
37 | ||
38 | // ======================================================================== | |
39 | // getField | |
40 | // ======================================================================== | |
41 | ||
42 | @Test | |
43 | public void testBasicGetField() { | |
1f506a43 | 44 | TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat()); |
6acf8488 FC |
45 | assertEquals("getField", 1, content.getFields().length); |
46 | assertEquals("getField", "Some content", content.getField(0).toString()); | |
47 | } | |
48 | ||
49 | @Test | |
50 | public void testExtendedGetField() { | |
5c2b49c4 | 51 | TmfEventContent content = new TmfEventContent("", new TmfEventFormatStub()); |
6acf8488 FC |
52 | assertEquals("getField", 5, content.getFields().length); |
53 | assertEquals("getField", "1", content.getField(0).toString()); | |
54 | assertEquals("getField", "-10", content.getField(1).toString()); | |
55 | assertEquals("getField", "true", content.getField(2).toString()); | |
56 | assertEquals("getField", "some string", content.getField(3).toString()); | |
1f506a43 | 57 | assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4).toString()); |
6acf8488 | 58 | } |
4ab33d2b AO |
59 | |
60 | } |