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 / VariantDefinitionTest.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.ByteOrder;
7 import java.util.HashMap;
8
9 import org.eclipse.linuxtools.ctf.core.event.types.ArrayDefinition;
10 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
11 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
12 import org.eclipse.linuxtools.ctf.core.event.types.EnumDeclaration;
13 import org.eclipse.linuxtools.ctf.core.event.types.EnumDefinition;
14 import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
15 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
16 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
17 import org.eclipse.linuxtools.ctf.core.event.types.SequenceDefinition;
18 import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition;
19 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
20 import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
21 import org.eclipse.linuxtools.ctf.core.event.types.VariantDeclaration;
22 import org.eclipse.linuxtools.ctf.core.event.types.VariantDefinition;
23 import org.eclipse.linuxtools.ctf.core.tests.TestParams;
24 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 /**
30 * The class <code>VariantDefinitionTest</code> contains tests for the class
31 * <code>{@link VariantDefinition}</code>.
32 *
33 * @author ematkho
34 * @version $Revision: 1.0 $
35 */
36 public class VariantDefinitionTest {
37
38 private VariantDefinition fixture;
39
40 /**
41 * Launch the test.
42 *
43 * @param args
44 * the command line arguments
45 */
46 public static void main(String[] args) {
47 new org.junit.runner.JUnitCore().run(VariantDefinitionTest.class);
48 }
49
50 /**
51 * Perform pre-test initialization.
52 *
53 * Not sure it needs to be that complicated, oh well...
54 *
55 * @throws CTFReaderException
56 */
57 @Before
58 public void setUp() throws CTFReaderException {
59 VariantDeclaration vDecl1, vDecl2, vDecl3;
60 VariantDefinition vDef1, vDef2;
61 StructDefinition sDef1, sDef2;
62 EnumDefinition eDef;
63 String fName = ""; //$NON-NLS-1$
64
65 vDecl1 = new VariantDeclaration();
66 vDecl2 = new VariantDeclaration();
67 vDecl3 = new VariantDeclaration();
68 vDecl1.setTag(fName);
69 vDecl2.setTag(fName);
70 vDecl3.setTag(fName);
71
72 vDef1 = new VariantDefinition(vDecl2, TestParams.createTrace(), fName);
73 vDef2 = new VariantDefinition(vDecl3, TestParams.createTrace(), fName);
74
75 sDef1 = new StructDefinition(new StructDeclaration(1L), vDef1, fName);
76 sDef2 = new StructDefinition(new StructDeclaration(1L), vDef2, fName);
77
78 eDef = new EnumDefinition(new EnumDeclaration(new IntegerDeclaration(1,
79 true, 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII)), sDef2, fName);
80
81 fixture = new VariantDefinition(vDecl1, sDef1, fName);
82 fixture.setTagDefinition(eDef);
83 fixture.setCurrentField(fName);
84 }
85
86 /**
87 * Perform post-test clean-up.
88 */
89 @After
90 public void tearDown() {
91 // Add additional tear down code here
92 }
93
94 /**
95 * Run the VariantDefinition(VariantDeclaration,DefinitionScope,String)
96 *
97 * @throws CTFReaderException
98 */
99 @Test
100 public void testVariantDefinition() throws CTFReaderException {
101 VariantDeclaration declaration = new VariantDeclaration();
102 declaration.setTag(""); //$NON-NLS-1$
103 VariantDeclaration variantDeclaration = new VariantDeclaration();
104 variantDeclaration.setTag(""); //$NON-NLS-1$
105 VariantDefinition variantDefinition = new VariantDefinition(
106 variantDeclaration, TestParams.createTrace(), ""); //$NON-NLS-1$
107 IDefinitionScope definitionScope = new StructDefinition(
108 new StructDeclaration(1L), variantDefinition, ""); //$NON-NLS-1$
109 String fieldName = ""; //$NON-NLS-1$
110
111 VariantDefinition result = new VariantDefinition(declaration,
112 definitionScope, fieldName);
113 assertNotNull(result);
114 }
115
116 /**
117 * Run the Definition getCurrentField() method test.
118 */
119 @Test
120 public void testGetCurrentField() {
121 Definition result = fixture.getCurrentField();
122 assertNull(result);
123 }
124
125 /**
126 * Run the String getCurrentFieldName() method test.
127 */
128 @Test
129 public void testGetCurrentFieldName() {
130 String result = fixture.getCurrentFieldName();
131 assertNotNull(result);
132 }
133
134 /**
135 * Run the VariantDeclaration getDeclaration() method test.
136 */
137 @Test
138 public void testGetDeclaration() {
139 VariantDeclaration result = fixture.getDeclaration();
140 assertNotNull(result);
141 }
142
143 /**
144 * Run the HashMap<String, Definition> getDefinitions() method test.
145 */
146 @Test
147 public void testGetDefinitions() {
148 HashMap<String, Definition> result = fixture.getDefinitions();
149 assertNotNull(result);
150 }
151
152 /**
153 * Run the String getPath() method test.
154 */
155 @Test
156 public void testGetPath() {
157 String result = fixture.getPath();
158 assertNotNull(result);
159 }
160
161 /**
162 * Run the EnumDefinition getTagDefinition() method test.
163 */
164 @Test
165 public void testGetTagDefinition() {
166 EnumDefinition result = fixture.getTagDefinition();
167 assertNotNull(result);
168 }
169
170 /**
171 * Run the ArrayDefinition lookupArray(String) method test.
172 */
173 @Test
174 public void testLookupArray() {
175 String name = ""; //$NON-NLS-1$
176 ArrayDefinition result = fixture.lookupArray(name);
177 assertNull(result);
178 }
179
180 /**
181 * Run the Definition lookupDefinition(String) method test.
182 */
183 @Test
184 public void testLookupDefinition() {
185 String lookupPath = ""; //$NON-NLS-1$
186 Definition result = fixture.lookupDefinition(lookupPath);
187 assertNull(result);
188 }
189
190 /**
191 * Run the EnumDefinition lookupEnum(String) method test.
192 */
193 @Test
194 public void testLookupEnum() {
195 String name = ""; //$NON-NLS-1$
196 EnumDefinition result = fixture.lookupEnum(name);
197 assertNull(result);
198 }
199
200 /**
201 * Run the IntegerDefinition lookupInteger(String) method test.
202 */
203 @Test
204 public void testLookupInteger() {
205 String name = ""; //$NON-NLS-1$
206 IntegerDefinition result = fixture.lookupInteger(name);
207 assertNull(result);
208 }
209
210 /**
211 * Run the SequenceDefinition lookupSequence(String) method test.
212 */
213 @Test
214 public void testLookupSequence_1() throws Exception {
215 String name = ""; //$NON-NLS-1$
216 SequenceDefinition result = fixture.lookupSequence(name);
217 assertNull(result);
218 }
219
220 /**
221 * Run the StringDefinition lookupString(String) method test.
222 */
223 @Test
224 public void testLookupString() {
225 String name = ""; //$NON-NLS-1$
226 StringDefinition result = fixture.lookupString(name);
227 assertNull(result);
228 }
229
230 /**
231 * Run the StructDefinition lookupStruct(String) method test.
232 */
233 @Test
234 public void testLookupStruct() {
235 String name = ""; //$NON-NLS-1$
236 StructDefinition result = fixture.lookupStruct(name);
237 assertNull(result);
238 }
239
240 /**
241 * Run the VariantDefinition lookupVariant(String) method test.
242 */
243 @Test
244 public void testLookupVariant() {
245 String name = ""; //$NON-NLS-1$
246 VariantDefinition result = fixture.lookupVariant(name);
247 assertNull(result);
248 }
249
250 /**
251 * Run the void setCurrentField(String) method test.
252 */
253 @Test
254 public void testSetCurrentField() {
255 String currentField = ""; //$NON-NLS-1$
256 fixture.setCurrentField(currentField);
257 }
258
259 /**
260 * Run the void setDeclaration(VariantDeclaration) method test.
261 */
262 @Test
263 public void testSetDeclaration() {
264 VariantDeclaration declaration = new VariantDeclaration();
265 fixture.setDeclaration(declaration);
266 }
267
268 /**
269 * Run the void setDefinitions(HashMap<String,Definition>) method test.
270 */
271 @Test
272 public void testSetDefinitions() {
273 HashMap<String, Definition> definitions = new HashMap<String, Definition>();
274 fixture.setDefinitions(definitions);
275 }
276
277 /**
278 * Run the void setTagDefinition(EnumDefinition) method test.
279 *
280 * @throws CTFReaderException
281 */
282 @Test
283 public void testSetTagDefinition() throws CTFReaderException {
284 VariantDeclaration vDecl;
285 VariantDefinition vDef;
286 StructDefinition structDef;
287 EnumDefinition tagDefinition;
288 String fName = ""; //$NON-NLS-1$
289
290 vDecl = new VariantDeclaration();
291 vDecl.setTag(fName);
292 vDef = new VariantDefinition(vDecl, TestParams.createTrace(), fName);
293 structDef = new StructDefinition(new StructDeclaration(1L), vDef, fName);
294 tagDefinition = new EnumDefinition(new EnumDeclaration(
295 new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
296 Encoding.ASCII)), structDef, fName);
297
298 fixture.setTagDefinition(tagDefinition);
299 }
300 }
This page took 0.119768 seconds and 6 git commands to generate.