1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertNotNull
;
5 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
6 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
7 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
8 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDefinition
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.TestParams
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
15 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.io
.BitBuffer
;
17 import org
.junit
.After
;
18 import org
.junit
.Before
;
19 import org
.junit
.Test
;
22 * The class <code>StringDefinitionTest</code> contains tests for the class
23 * <code>{@link StringDefinition}</code>.
26 * @version $Revision: 1.0 $
28 public class StringDefinitionTest
{
30 private StringDefinition fixture
;
36 * the command line arguments
38 public static void main(String
[] args
) {
39 new org
.junit
.runner
.JUnitCore().run(StringDefinitionTest
.class);
43 * Perform pre-test initialization.
45 * @throws CTFReaderException
48 public void setUp() throws CTFReaderException
{
49 CTFTrace trace
= TestParams
.createTrace();
50 CTFTraceReader tr
= new CTFTraceReader(trace
);
51 String name
= ""; //$NON-NLS-1$
52 StructDefinition structDef
= null;
53 boolean found
= false;
55 while (tr
.hasMoreEvents() && !found
) {
57 EventDefinition ed
= tr
.getCurrentEventDef();
58 for (String key
: ed
.fields
.getDefinitions().keySet()) {
59 structDef
= ed
.fields
;
60 Definition d
= structDef
.lookupDefinition(key
);
61 if (d
instanceof StringDefinition
) {
68 fixture
= structDef
.lookupString(name
);
72 * Perform post-test clean-up.
75 public void tearDown() {
76 // Add additional tear down code here
80 * Run the StringDefinition(StringDeclaration,DefinitionScope,String)
84 public void testStringDefinition() {
85 StringDeclaration declaration
= new StringDeclaration();
86 IDefinitionScope definitionScope
= null;
87 String fieldName
= ""; //$NON-NLS-1$
89 StringDefinition result
= new StringDefinition(declaration
,
90 definitionScope
, fieldName
);
92 assertNotNull(result
);
96 * Run the StringDeclaration getDeclaration() method test.
99 public void testGetDeclaration() {
100 fixture
.setString(new StringBuilder());
101 StringDeclaration result
= fixture
.getDeclaration();
102 assertNotNull(result
);
106 * Run the StringBuilder getString() method test.
109 public void testGetString() {
110 fixture
.setString(new StringBuilder());
111 StringBuilder result
= fixture
.getString();
112 assertNotNull(result
);
116 * Run the String getValue() method test.
119 public void testGetValue() {
120 fixture
.setString(new StringBuilder());
121 String result
= fixture
.getValue();
122 assertNotNull(result
);
126 * Run the void read(BitBuffer) method test.
129 public void testRead() {
130 fixture
.setString(new StringBuilder());
131 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
136 * Run the void setDeclaration(StringDeclaration) method test.
139 public void testSetDeclaration() {
140 fixture
.setString(new StringBuilder());
141 StringDeclaration declaration
= new StringDeclaration();
142 fixture
.setDeclaration(declaration
);
146 * Run the void setString(StringBuilder) method test.
149 public void testSetString() {
150 fixture
.setString(new StringBuilder());
151 StringBuilder string
= new StringBuilder();
152 fixture
.setString(string
);
156 * Run the String toString() method test.
159 public void testToString() {
160 fixture
.setString(new StringBuilder());
161 String result
= fixture
.toString();
162 assertNotNull(result
);