Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core.tests / src / org / eclipse / linuxtools / lttng / core / tests / jni / JniMarkerFieldTest.java
1
2 package org.eclipse.linuxtools.lttng.core.tests.jni;
3
4
5 import junit.framework.TestCase;
6
7 import org.eclipse.linuxtools.lttng.jni.JniEvent;
8 import org.eclipse.linuxtools.lttng.jni.JniMarker;
9 import org.eclipse.linuxtools.lttng.jni.JniMarkerField;
10 import org.eclipse.linuxtools.lttng.jni.exception.JniException;
11 import org.eclipse.linuxtools.lttng.jni.factory.JniTraceFactory;
12
13 /*
14 Functions tested here :
15 public JniMarkerField(JniMarkerField oldMarkerField)
16 public JniMarkerField(long newMarkerPtr) throws JniException
17
18 public String getField()
19 public String getFormat()
20
21 public String toString()
22 public void printMarkerFieldInformation()
23 */
24
25 @SuppressWarnings("nls")
26 public class JniMarkerFieldTest extends TestCase
27 {
28 private final static boolean printLttDebug = false;
29
30 private final static String tracepath="traceset/trace-15316events_nolost_newformat";
31 private final static String eventName="kernel0";
32
33 private JniMarkerField prepareMarkerFieldToTest() {
34
35 JniEvent tmpEvent = null;
36 JniMarkerField tmpMarkerField = null;
37
38 // This trace should be valid
39 // We will read the first 2 event to have something interesting to test on
40 try {
41 tmpEvent = JniTraceFactory.getJniTrace(tracepath, null, printLttDebug).requestEventByName(eventName);
42 tmpEvent.readNextEvent();
43 tmpEvent.readNextEvent();
44
45 // Use the first field
46 tmpMarkerField = tmpEvent.requestEventMarker().getMarkerFieldsArrayList().get(0);
47 }
48 catch( JniException e) { }
49
50 return tmpMarkerField;
51 }
52
53 public void testEventConstructors() {
54
55 JniMarker tmpMarker = null;
56
57 @SuppressWarnings("unused")
58 JniMarkerField tmpMarkerField1 = null;
59 @SuppressWarnings("unused")
60 JniMarkerField tmpMarkerField2 = null;
61
62 // This event should be valid and will be used in test
63 try {
64 tmpMarker = JniTraceFactory.getJniTrace(tracepath, null, printLttDebug).requestEventByName(eventName).requestEventMarker();
65 }
66 catch( JniException e) { }
67
68 // Test constructor with pointer on a correct pointer
69 try {
70 tmpMarkerField1 = tmpMarker.allocateNewJniMarkerField( tmpMarker.getMarkerFieldsArrayList().get(0).getMarkerFieldPtr() );
71 }
72 catch( JniException e) {
73 fail("Construction with correct pointer failed!");
74 }
75
76 /*
77 // Test copy constructor
78 try {
79 tmpMarkerField1 = new JniMarkerField( tmpMarker.getMarkerFieldsArrayList().get(0) );
80 tmpMarkerField2 = new JniMarkerField( tmpMarkerField1);
81 }
82 catch( Exception e) {
83 fail("Copy constructor failed!");
84 }
85 assertSame("JniMarker name not same after using copy constructor", tmpMarkerField1.getField() , tmpMarkerField2.getField());
86 */
87
88 }
89
90 public void testGetSet() {
91
92 JniMarkerField testMarkerField = prepareMarkerFieldToTest();
93
94 // Test that all Get/Set return data
95 assertNotSame("getName is empty","",testMarkerField.getField() );
96 assertNotSame("getFormat is empty","",testMarkerField.getFormat() );
97 assertNotSame("getMarkerFieldPtr is 0",0,testMarkerField.getMarkerFieldPtr() );
98 }
99
100 public void testPrintAndToString() {
101
102 JniMarkerField testMarkerField = prepareMarkerFieldToTest();
103
104 // Test printMarkerInformation
105 try {
106 testMarkerField.printMarkerFieldInformation();
107 }
108 catch( Exception e) {
109 fail("printMarkerFieldInformation failed!");
110 }
111
112 // Test ToString()
113 assertNotSame("toString returned empty data","",testMarkerField.toString() );
114 }
115 }
This page took 0.046107 seconds and 5 git commands to generate.