2 package org
.eclipse
.linuxtools
.lttng
.tests
.jni
;
4 import org
.eclipse
.linuxtools
.lttng
.jni
.JniEvent
;
5 import org
.eclipse
.linuxtools
.lttng
.jni
.JniException
;
6 import org
.eclipse
.linuxtools
.lttng
.jni
.JniMarker
;
7 import org
.eclipse
.linuxtools
.lttng
.jni
.JniMarkerField
;
8 import org
.eclipse
.linuxtools
.lttng
.jni
.JniTrace
;
9 import org
.eclipse
.linuxtools
.lttng
.jni
.Jni_C_Pointer
;
11 import junit
.framework
.TestCase
;
14 Functions tested here :
15 public JniMarkerField(JniMarkerField oldMarkerField)
16 public JniMarkerField(long newMarkerPtr) throws JniException
18 public String getField()
19 public String getFormat()
21 public String toString()
22 public void printMarkerFieldInformation()
25 public class JniMarkerFieldTest
extends TestCase
27 private final static boolean printLttDebug
= false;
29 private final static String tracepath
="traceset/trace-15316events_nolost_newformat";
30 private final static String eventName
="kernel0";
32 private JniMarkerField
prepareMarkerFieldToTest() {
34 JniEvent tmpEvent
= null;
35 JniMarkerField tmpMarkerField
= null;
37 // This trace should be valid
38 // We will read the first 2 event to have something interesting to test on
40 tmpEvent
= new JniTrace(tracepath
, printLttDebug
).requestEventByName(eventName
);
41 tmpEvent
.readNextEvent();
42 tmpEvent
.readNextEvent();
44 // Use the first field
45 tmpMarkerField
= tmpEvent
.requestEventMarker().getMarkerFieldsArrayList().get(0);
47 catch( JniException e
) { }
49 return tmpMarkerField
;
52 public void testEventConstructors() {
54 JniMarker tmpMarker
= null;
56 JniMarkerField tmpMarkerField1
= null;
57 JniMarkerField tmpMarkerField2
= null;
59 // This event should be valid and will be used in test
61 tmpMarker
= new JniTrace(tracepath
, printLttDebug
).requestEventByName(eventName
).requestEventMarker();
63 catch( JniException e
) { }
65 // Test constructor with pointer on a wrong pointer
67 tmpMarkerField1
= new JniMarkerField( new Jni_C_Pointer(0) );
68 fail("Construction with wrong pointer should fail!");
70 catch( JniException e
) {
73 // Test constructor with pointer on a correct pointer
75 tmpMarkerField1
= new JniMarkerField( tmpMarker
.getMarkerFieldsArrayList().get(0).getMarkerFieldPtr() );
77 catch( JniException e
) {
78 fail("Construction with correct pointer failed!");
82 // Test copy constructor
84 tmpMarkerField1
= new JniMarkerField( tmpMarker
.getMarkerFieldsArrayList().get(0) );
85 tmpMarkerField2
= new JniMarkerField( tmpMarkerField1
);
88 fail("Copy constructor failed!");
91 assertSame("JniMarker name not same after using copy constructor", tmpMarkerField1
.getField() , tmpMarkerField2
.getField());
95 public void testGetSet() {
97 JniMarkerField testMarkerField
= prepareMarkerFieldToTest();
99 // Test that all Get/Set return data
100 assertNotSame("getName is empty","",testMarkerField
.getField() );
101 assertNotSame("getFormat is empty","",testMarkerField
.getFormat() );
102 assertNotSame("getMarkerFieldPtr is 0",0,testMarkerField
.getMarkerFieldPtr() );
105 public void testPrintAndToString() {
107 JniMarkerField testMarkerField
= prepareMarkerFieldToTest();
109 // Test printMarkerInformation
111 testMarkerField
.printMarkerFieldInformation();
113 catch( Exception e
) {
114 fail("printMarkerFieldInformation failed!");
118 assertNotSame("toString returned empty data","",testMarkerField
.toString() );