1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertNotNull
;
4 import static org
.junit
.Assert
.assertNull
;
6 import java
.nio
.ByteBuffer
;
7 import java
.util
.HashMap
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.io
.BitBuffer
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.ArrayDefinition
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.EnumDefinition
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDefinition
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.SequenceDefinition
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDefinition
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
18 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.VariantDefinition
;
20 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.TestParams
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
25 import org
.junit
.After
;
26 import org
.junit
.Before
;
27 import org
.junit
.Test
;
30 * The class <code>StructDefinitionTest</code> contains tests for the class
31 * <code>{@link StructDefinition}</code>.
34 * @version $Revision: 1.0 $
36 public class StructDefinitionTest
{
38 private StructDefinition fixture
;
40 private static final String VAR_FIELD_NAME
= "SomeVariant"; //$NON-NLS-1$
46 * the command line arguments
48 public static void main(String
[] args
) {
49 new org
.junit
.runner
.JUnitCore().run(StructDefinitionTest
.class);
53 * Perform pre-test initialization.
55 * @throws CTFReaderException
58 public void setUp() throws CTFReaderException
{
59 CTFTrace c
= TestParams
.createTrace();
60 CTFTraceReader tr
= new CTFTraceReader(c
);
61 EventDefinition ed
= tr
.getCurrentEventDef();
66 * Perform post-test clean-up.
69 public void tearDown() {
70 // Add additional tear down code here
74 * Run the StructDeclaration getDeclaration() method test.
77 public void testGetDeclaration() {
78 StructDeclaration result
= fixture
.getDeclaration();
79 assertNotNull(result
);
83 * Run the HashMap<String, Definition> getDefinitions() method test.
86 public void testGetDefinitions_1() {
87 HashMap
<String
, Definition
> result
= fixture
.getDefinitions();
88 assertNotNull(result
);
92 * Run the ArrayDefinition lookupArray(String) method test.
95 public void testLookupArray() {
96 String name
= "id"; //$NON-NLS-1$
97 ArrayDefinition result
= fixture
.lookupArray(name
);
103 * Run the Definition lookupDefinition(String) method test.
106 public void testLookupDefinition() {
107 String lookupPath
= "id"; //$NON-NLS-1$
108 Definition result
= fixture
.lookupDefinition(lookupPath
);
110 assertNotNull(result
);
114 * Run the EnumDefinition lookupEnum(String) method test.
117 public void testLookupEnum() {
118 String name
= ""; //$NON-NLS-1$
119 EnumDefinition result
= fixture
.lookupEnum(name
);
121 /* There are no enums in the test trace */
126 * Run the IntegerDefinition lookupInteger(String) method test.
129 public void testLookupInteger_1() {
130 String name
= "id"; //$NON-NLS-1$
131 IntegerDefinition result
= fixture
.lookupInteger(name
);
133 assertNotNull(result
);
137 * Run the IntegerDefinition lookupInteger(String) method test.
140 public void testLookupInteger_2() {
141 String name
= VAR_FIELD_NAME
;
142 IntegerDefinition result
= fixture
.lookupInteger(name
);
148 * Run the SequenceDefinition lookupSequence(String) method test.
151 public void testLookupSequence() {
152 String name
= VAR_FIELD_NAME
;
153 SequenceDefinition result
= fixture
.lookupSequence(name
);
159 * Run the StringDefinition lookupString(String) method test.
162 public void testLookupString() {
163 String name
= VAR_FIELD_NAME
;
164 StringDefinition result
= fixture
.lookupString(name
);
170 * Run the StructDefinition lookupStruct(String) method test.
173 public void testLookupStruct() {
174 String name
= VAR_FIELD_NAME
;
175 StructDefinition result
= fixture
.lookupStruct(name
);
181 * Run the VariantDefinition lookupVariant(String) method test.
184 public void testLookupVariant() {
185 String name
= VAR_FIELD_NAME
;
186 VariantDefinition result
= fixture
.lookupVariant(name
);
192 * Run the void read(BitBuffer) method test.
195 public void testRead_() {
196 ByteBuffer bb
= ByteBuffer
.allocateDirect(128);
198 BitBuffer input
= new BitBuffer(bb
);
204 * Run the String toString() method test.
207 public void testToString() {
208 String result
= fixture
.toString();
209 assertNotNull(result
);