Don't catch the FileNotFound exception in CTF tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / StructDefinitionTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.types;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertNull;
5
6 import java.nio.ByteBuffer;
7 import java.util.HashMap;
8
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;
24
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 /**
30 * The class <code>StructDefinitionTest</code> contains tests for the class
31 * <code>{@link StructDefinition}</code>.
32 *
33 * @author ematkho
34 * @version $Revision: 1.0 $
35 */
36 public class StructDefinitionTest {
37
38 private StructDefinition fixture;
39
40 private static final String VAR_FIELD_NAME = "SomeVariant"; //$NON-NLS-1$
41
42 /**
43 * Launch the test.
44 *
45 * @param args
46 * the command line arguments
47 */
48 public static void main(String[] args) {
49 new org.junit.runner.JUnitCore().run(StructDefinitionTest.class);
50 }
51
52 /**
53 * Perform pre-test initialization.
54 *
55 * @throws CTFReaderException
56 */
57 @Before
58 public void setUp() throws CTFReaderException {
59 CTFTrace c = TestParams.createTrace();
60 CTFTraceReader tr = new CTFTraceReader(c);
61 EventDefinition ed = tr.getCurrentEventDef();
62 fixture = ed.fields;
63 }
64
65 /**
66 * Perform post-test clean-up.
67 */
68 @After
69 public void tearDown() {
70 // Add additional tear down code here
71 }
72
73 /**
74 * Run the StructDeclaration getDeclaration() method test.
75 */
76 @Test
77 public void testGetDeclaration() {
78 StructDeclaration result = fixture.getDeclaration();
79 assertNotNull(result);
80 }
81
82 /**
83 * Run the HashMap<String, Definition> getDefinitions() method test.
84 */
85 @Test
86 public void testGetDefinitions_1() {
87 HashMap<String, Definition> result = fixture.getDefinitions();
88 assertNotNull(result);
89 }
90
91 /**
92 * Run the ArrayDefinition lookupArray(String) method test.
93 */
94 @Test
95 public void testLookupArray() {
96 String name = "id"; //$NON-NLS-1$
97 ArrayDefinition result = fixture.lookupArray(name);
98
99 assertNull(result);
100 }
101
102 /**
103 * Run the Definition lookupDefinition(String) method test.
104 */
105 @Test
106 public void testLookupDefinition() {
107 String lookupPath = "id"; //$NON-NLS-1$
108 Definition result = fixture.lookupDefinition(lookupPath);
109
110 assertNotNull(result);
111 }
112
113 /**
114 * Run the EnumDefinition lookupEnum(String) method test.
115 */
116 @Test
117 public void testLookupEnum() {
118 String name = ""; //$NON-NLS-1$
119 EnumDefinition result = fixture.lookupEnum(name);
120
121 /* There are no enums in the test trace */
122 assertNull(result);
123 }
124
125 /**
126 * Run the IntegerDefinition lookupInteger(String) method test.
127 */
128 @Test
129 public void testLookupInteger_1() {
130 String name = "id"; //$NON-NLS-1$
131 IntegerDefinition result = fixture.lookupInteger(name);
132
133 assertNotNull(result);
134 }
135
136 /**
137 * Run the IntegerDefinition lookupInteger(String) method test.
138 */
139 @Test
140 public void testLookupInteger_2() {
141 String name = VAR_FIELD_NAME;
142 IntegerDefinition result = fixture.lookupInteger(name);
143
144 assertNull(result);
145 }
146
147 /**
148 * Run the SequenceDefinition lookupSequence(String) method test.
149 */
150 @Test
151 public void testLookupSequence() {
152 String name = VAR_FIELD_NAME;
153 SequenceDefinition result = fixture.lookupSequence(name);
154
155 assertNull(result);
156 }
157
158 /**
159 * Run the StringDefinition lookupString(String) method test.
160 */
161 @Test
162 public void testLookupString() {
163 String name = VAR_FIELD_NAME;
164 StringDefinition result = fixture.lookupString(name);
165
166 assertNull(result);
167 }
168
169 /**
170 * Run the StructDefinition lookupStruct(String) method test.
171 */
172 @Test
173 public void testLookupStruct() {
174 String name = VAR_FIELD_NAME;
175 StructDefinition result = fixture.lookupStruct(name);
176
177 assertNull(result);
178 }
179
180 /**
181 * Run the VariantDefinition lookupVariant(String) method test.
182 */
183 @Test
184 public void testLookupVariant() {
185 String name = VAR_FIELD_NAME;
186 VariantDefinition result = fixture.lookupVariant(name);
187
188 assertNull(result);
189 }
190
191 /**
192 * Run the void read(BitBuffer) method test.
193 */
194 @Test
195 public void testRead_() {
196 ByteBuffer bb = ByteBuffer.allocateDirect(128);
197 bb.put((byte) 20);
198 BitBuffer input = new BitBuffer(bb);
199
200 fixture.read(input);
201 }
202
203 /**
204 * Run the String toString() method test.
205 */
206 @Test
207 public void testToString() {
208 String result = fixture.toString();
209 assertNotNull(result);
210 }
211 }
This page took 0.038003 seconds and 5 git commands to generate.