2010-06-05 fchouinard@gmail.com Contributions for bugs 292965, 292963, 293102,...
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.tests / src / org / eclipse / linuxtools / lttng / tests / event / LttngEventContentTest.java
index 6a7fb471dbf0c482c75fbfaed09ff9c8d2925f61..546fd68996746208cb60fa96d627ce0130b4b0eb 100644 (file)
@@ -140,126 +140,126 @@ public class LttngEventContentTest extends TestCase {
        }
        
        
-//     public void testGetter() {
-//             LttngEventContent testContent = null;
-//     LTTngTextTrace tmpStream = null;
-//     LttngEvent tmpEvent = null;
-//     TmfContext tmpContext = null;
-//     
-//     // Require an event
-//     tmpStream = initializeEventStream();
-//     tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-//     tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
-//             testContent = prepareToTest();
-//     // getFieldS()
-//     assertNotSame("getFields() returned null!",null,testContent.getFields() );
-//     
-//     // *** FIXME ***
-//     // Depending from the Java version because of the "hashcode()" on String. 
-//     // We can't really test that safetly
-//     //
-//     // getField(int)
-//     //assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString());
-//     assertNotSame("getField(int) returned unexpected result!",null, testContent.getField(0).toString());
-//     
-//     
-//     // getField(name)
-//     assertEquals("getField(name) returned unexpected result!",firstEventContentFirstField, testContent.getField(firstEventContentFirstFieldName).toString());
-//     // getRawContent
-//     assertNotSame("getRawContent() returned null!",null, testContent.getRawContent());
-//     // Test that get event return the correct event
-//     assertTrue("getEvent() returned unexpected result!", tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue());
-//     // getType()
-//     assertEquals("getType() returned unexpected result!",firstEventContentType, testContent.getType().toString());
-//     
-//     //*** To test getFields with a fields number >0, we need to move to an event that have some more
-//     tmpStream = initializeEventStream();
-//     tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-//     // Skip first events and seek to event pass metadata
-//     tmpContext= tmpStream.seekEvent(new LttngTimestamp(timestampAfterMetadata) );
-//     // Skip first one 
-//     tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
-//     
-//     // Second event past metadata should have more fields
-//     tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
-//     // Get the content
-//     testContent = tmpEvent.getContent();
-//     
-//     // Test that get event return the correct event
-//     assertTrue("getEvent() returned unexpected result!",tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue());
-//     // getType()
-//     assertEquals("getType() returned unexpected result!",secondEventContentType, testContent.getType().toString());
-//     
-//     
-//     // getFieldS()
-//     assertNotSame("getFields() returned null!",null,testContent.getFields() );
-//     // getField(int)
-//     assertEquals("getField(int) returned unexpected result!",secondEventContentSecondField, testContent.getField(1).toString());
-//     // getField(name)
-//     assertEquals("getField(name) returned unexpected result!",secondEventContentSecondField, testContent.getField(secondEventContentSecondFieldName).toString());
-//     // getRawContent
-//     assertNotSame("getRawContent() returned null!",null, testContent.getRawContent());
-//     
-//    }
-//     
-//     public void testSetter() {
-//             // Not much to test here, we will just make sure the set does not fail for any reason.
-//     // It's pointless to test with a getter...
-//     LTTngTextTrace tmpStream = null;
-//     LttngEvent tmpEvent = null;
-//     TmfContext tmpContext = null;
-//     
-//     // Require an event
-//     tmpStream = initializeEventStream();
-//     tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-//     tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
-//             
-//     LttngEventContent tmpContent = prepareToTest();
-//     try {
-//             tmpContent.setEvent(tmpEvent);
-//     }
-//     catch( Exception e) { 
-//             fail("setEvent(event) failed!");
-//        }
-//     
-//     
-//     LttngEventType testType = new LttngEventType();
-//     try {
-//             tmpContent.setType(testType);
-//     }
-//     catch( Exception e) { 
-//             fail("setType(type) failed!");
-//        }
-//     }
-//     
-//     public void testEmptyContent() {
-//             LttngEventContent testContent = null;
-//     LTTngTextTrace tmpStream = null;
-//     LttngEvent tmpEvent = null;
-//     TmfContext tmpContext = null;
-//     
-//     // Require an event
-//     tmpStream = initializeEventStream();
-//     tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-//     tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
-//     // Get the content
-//     testContent = tmpEvent.getContent();
-//     // Get all the fields to make sure there is something in the HashMap
-//     testContent.getFields();
-//     // Just making sure there is something in the HashMap
-//     assertNotSame("HashMap is empty but should not!", 0, testContent.getRawContent().size() );
-//     
-//     // This is the actual test
-//     testContent.emptyContent();
-//     assertSame("HashMap is not empty but should be!", 0, testContent.getRawContent().size() );
-//     }
-//    
-//     public void testToString() {
-//     LttngEventContent tmpContent = prepareToTest();
-//     
-//             // Just make sure toString() does not return null or the java reference
-//             assertNotSame("toString returned null",null, tmpContent.toString() );
-//             assertNotSame("toString is not overridded!", tmpContent.getClass().getName() + '@' + Integer.toHexString(tmpContent.hashCode()), tmpContent.toString() );
-//    }
+       public void testGetter() {
+               LttngEventContent testContent = null;
+       LTTngTextTrace tmpStream = null;
+       LttngEvent tmpEvent = null;
+       TmfContext tmpContext = null;
+       
+       // Require an event
+       tmpStream = initializeEventStream();
+       tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
+       tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+               testContent = prepareToTest();
+       // getFieldS()
+       assertNotSame("getFields() returned null!",null,testContent.getFields() );
+       
+       // *** FIXME ***
+       // Depending from the Java version because of the "hashcode()" on String. 
+       // We can't really test that safetly
+       //
+       // getField(int)
+       //assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString());
+       assertNotSame("getField(int) returned unexpected result!",null, testContent.getField(0).toString());
+       
+       
+       // getField(name)
+       assertEquals("getField(name) returned unexpected result!",firstEventContentFirstField, testContent.getField(firstEventContentFirstFieldName).toString());
+       // getRawContent
+       assertNotSame("getRawContent() returned null!",null, testContent.getRawContent());
+       // Test that get event return the correct event
+       assertTrue("getEvent() returned unexpected result!", tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue());
+       // getType()
+       assertEquals("getType() returned unexpected result!",firstEventContentType, testContent.getType().toString());
+       
+       //*** To test getFields with a fields number >0, we need to move to an event that have some more
+       tmpStream = initializeEventStream();
+       tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
+       // Skip first events and seek to event pass metadata
+       tmpContext= tmpStream.seekEvent(new LttngTimestamp(timestampAfterMetadata) );
+       // Skip first one 
+       tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+       
+       // Second event past metadata should have more fields
+       tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+       // Get the content
+       testContent = tmpEvent.getContent();
+       
+       // Test that get event return the correct event
+       assertTrue("getEvent() returned unexpected result!",tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue());
+       // getType()
+       assertEquals("getType() returned unexpected result!",secondEventContentType, testContent.getType().toString());
+       
+       
+       // getFieldS()
+       assertNotSame("getFields() returned null!",null,testContent.getFields() );
+       // getField(int)
+       assertEquals("getField(int) returned unexpected result!",secondEventContentSecondField, testContent.getField(1).toString());
+       // getField(name)
+       assertEquals("getField(name) returned unexpected result!",secondEventContentSecondField, testContent.getField(secondEventContentSecondFieldName).toString());
+       // getRawContent
+       assertNotSame("getRawContent() returned null!",null, testContent.getRawContent());
+       
+    }
+       
+       public void testSetter() {
+               // Not much to test here, we will just make sure the set does not fail for any reason.
+       // It's pointless to test with a getter...
+       LTTngTextTrace tmpStream = null;
+       LttngEvent tmpEvent = null;
+       TmfContext tmpContext = null;
+       
+       // Require an event
+       tmpStream = initializeEventStream();
+       tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
+       tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+               
+       LttngEventContent tmpContent = prepareToTest();
+       try {
+               tmpContent.setEvent(tmpEvent);
+       }
+       catch( Exception e) { 
+               fail("setEvent(event) failed!");
+        }
+       
+       
+       LttngEventType testType = new LttngEventType();
+       try {
+               tmpContent.setType(testType);
+       }
+       catch( Exception e) { 
+               fail("setType(type) failed!");
+        }
+       }
+       
+       public void testEmptyContent() {
+               LttngEventContent testContent = null;
+       LTTngTextTrace tmpStream = null;
+       LttngEvent tmpEvent = null;
+       TmfContext tmpContext = null;
+       
+       // Require an event
+       tmpStream = initializeEventStream();
+       tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
+       tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+       // Get the content
+       testContent = tmpEvent.getContent();
+       // Get all the fields to make sure there is something in the HashMap
+       testContent.getFields();
+       // Just making sure there is something in the HashMap
+       assertNotSame("HashMap is empty but should not!", 0, testContent.getRawContent().size() );
+       
+       // This is the actual test
+       testContent.emptyContent();
+       assertSame("HashMap is not empty but should be!", 0, testContent.getRawContent().size() );
+       }
+    
+       public void testToString() {
+       LttngEventContent tmpContent = prepareToTest();
+       
+               // Just make sure toString() does not return null or the java reference
+               assertNotSame("toString returned null",null, tmpContent.toString() );
+               assertNotSame("toString is not overridded!", tmpContent.getClass().getName() + '@' + Integer.toHexString(tmpContent.hashCode()), tmpContent.toString() );
+    }
        
 }
This page took 0.030742 seconds and 5 git commands to generate.