btf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / event / CTFEventFieldTest.java
index 2e7224009c0ecd28837b985baa93841dbfa3293d..366c7e65cdc909711a5a1bb9859afbfc9b40f63f 100644 (file)
@@ -21,14 +21,15 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
+import org.eclipse.linuxtools.ctf.core.event.types.IDefinition;
 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
-import org.eclipse.linuxtools.ctf.core.event.types.SequenceDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition;
 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
+import org.eclipse.linuxtools.internal.ctf.core.event.types.SequenceDeclaration;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -43,7 +44,8 @@ import com.google.common.collect.ImmutableList;
 @SuppressWarnings("javadoc")
 public class CTFEventFieldTest {
 
-    @NonNull private static final String fieldName = "id";
+    @NonNull
+    private static final String fieldName = "id";
 
     /**
      * Run the CTFEventField parseField(Definition,String) method test.
@@ -78,16 +80,24 @@ public class CTFEventFieldTest {
                 });
 
         SequenceDeclaration sd = new SequenceDeclaration(lengthName, id);
-        ByteBuffer byb = ByteBuffer.allocate(1024);
+        ByteBuffer byb = testMemory(ByteBuffer.allocate(1024));
         for (int i = 0; i < 1024; i++) {
             byb.put((byte) i);
         }
         BitBuffer bb = new BitBuffer(byb);
-        Definition fieldDef = sd.createDefinition(structDef, "fff-fffield", bb);
+        IDefinition fieldDef = sd.createDefinition(structDef, "fff-fffield", bb);
 
         assertNotNull(fieldDef);
     }
 
+    @NonNull
+    private static ByteBuffer testMemory(ByteBuffer buffer) {
+        if (buffer == null) {
+            throw new IllegalStateException("Failed to allocate memory");
+        }
+        return buffer;
+    }
+
     /**
      * Run the CTFEventField parseField(Definition,String) method test.
      *
@@ -97,9 +107,8 @@ public class CTFEventFieldTest {
     public void testParseField_simple() throws CTFReaderException {
         final StringDeclaration elemType = new StringDeclaration();
         byte[] bytes = { 'T', 'e', 's', 't', '\0' };
-        ByteBuffer bb = ByteBuffer.wrap(bytes);
-
-        Definition fieldDef = elemType.createDefinition(null, fieldName, new BitBuffer(bb));
+        ByteBuffer bb = testMemory(ByteBuffer.wrap(bytes));
+        IDefinition fieldDef = elemType.createDefinition(null, fieldName, new BitBuffer(bb));
 
         assertNotNull(fieldDef);
     }
This page took 0.025179 seconds and 5 git commands to generate.