Fix for Bug373118
authorFrancois Chouinard <fchouinard@gmail.com>
Fri, 2 Mar 2012 16:45:40 +0000 (11:45 -0500)
committerFrancois Chouinard <fchouinard@gmail.com>
Fri, 2 Mar 2012 16:45:40 +0000 (11:45 -0500)
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEvent.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEvent.java

index 8bfadfc71bf9f9c4493f611da2b554c48cc4a26e..812c60fb72054d80cc828e3980357a1a7740d6ca 100644 (file)
@@ -22,7 +22,7 @@ public class LttngEvent extends TmfEvent {
     // Parameter-less constructor
     public LttngEvent() {
         super();
-        fType = LttngEventType.DEFAULT_EVENT_TYPE;
+        super.setType(LttngEventType.DEFAULT_EVENT_TYPE);
     }
 
     /**
@@ -47,9 +47,9 @@ public class LttngEvent extends TmfEvent {
             String reference, JniEvent lttEvent)
     {
         super(timestamp, source, type, reference);
-        fContent = content;
+        super.setContent(content);
         jniEventReference = lttEvent;
-        setParentTrace(parent);
+        super.setTrace(parent);
     }
 
     /**
@@ -76,7 +76,7 @@ public class LttngEvent extends TmfEvent {
      * @param parentTrace The new parent
      */
     public void setParentTrace(TmfTrace<LttngEvent> parentTrace) {
-               fTrace = parentTrace;
+        super.setTrace(parentTrace);
        }
     
     
@@ -121,25 +121,25 @@ public class LttngEvent extends TmfEvent {
 
     @Override
     public LttngEventContent getContent() {
-        return (LttngEventContent) fContent;
+        return (LttngEventContent) super.getContent();
     }
 
     public void setContent(LttngEventContent newContent) {
-        fContent = newContent;
+        super.setContent(newContent);
     }
 
     @Override
     public void setReference(String reference) {
-        fReference = reference;
+        super.setReference(reference);
     }
 
     @Override
     public LttngEventType getType() {
-        return (LttngEventType) fType;
+        return (LttngEventType) super.getType();
     }
 
     public void setType(LttngEventType newType) {
-        fType = newType;
+        super.setType(newType);
     }
 
     /**
index c906f19691d4ed560f0ccadf4dc7f903a379a88b..a563c1839b52d5f658ee1eb929279a97a796582e 100644 (file)
@@ -24,6 +24,8 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
@@ -75,6 +77,8 @@ public class TmfEventTest extends TestCase {
     private final String fReference2 = "Some other reference";
     private final TmfEvent fEvent2 = new TmfEvent(null, 1, fTimestamp2, fSource, fType, fContent2, fReference2);
 
+    private final String fTracePath = "testfiles" + File.separator + "A-Test-10K";
+
     // ------------------------------------------------------------------------
     // Housekeeping
     // ------------------------------------------------------------------------
@@ -221,23 +225,95 @@ public class TmfEventTest extends TestCase {
     // Setters
     // ------------------------------------------------------------------------
 
-    public void testSetSource() {
-        TmfEvent event = new TmfEvent(fEvent1);
-        assertEquals("setSource", fSource, event.getSource());
+    private class TestEvent extends TmfEvent {
+        
+        public TestEvent(TmfEvent event) {
+            super(event);
+        }
 
-        String source2 = "another source";
-        event.setSource(source2);
-        assertEquals("setContent", source2, event.getSource());
+        @Override
+        public void setTrace(ITmfTrace<? extends ITmfEvent> trace) {
+            super.setTrace(trace);
+        }
 
-        event.setSource(null);
-        assertNull("setContent", event.getSource());
+        @Override
+        public void setRank(long rank) {
+            super.setRank(rank);
+        }
+
+        @Override
+        public void setTimestamp(ITmfTimestamp timestamp) {
+            super.setTimestamp(timestamp);
+        }
+
+        @Override
+        public void setSource(String source) {
+            super.setSource(source);
+        }
+
+        @Override
+        public void setType(ITmfEventType type) {
+            super.setType(type);
+        }
+
+        @Override
+        public void setContent(ITmfEventField content) {
+            super.setContent(content);
+        }
+
+        @Override
+        public void setReference(String reference) {
+            super.setReference(reference);
+        }
 
-        event.setSource(fSource);
-        assertEquals("setContent", fSource, event.getSource());
+    }
+
+    private ITmfTrace<TmfEvent> setupTrace() {
+        ITmfTrace<TmfEvent> trace = null;
+        try {
+            URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(fTracePath), null);
+            File test = new File(FileLocator.toFileURL(location).toURI());
+            trace = new TmfTraceStub(test.toURI().getPath(), 500, false);
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return trace;
+    }
+
+    public void testSetTrace() {
+        ITmfTrace<TmfEvent> trace = setupTrace();
+        assertNotNull(trace);
+
+        TestEvent event = new TestEvent(fEvent1);
+        assertNull("setTrace", event.getTrace());
+
+        event.setTrace(trace);
+        assertEquals("setTrace", trace, event.getTrace());
+
+        event.setTrace(null);
+        assertNull("setTrace", event.getTrace());
+        
+        trace.dispose();
+    }
+
+    public void testSetRank() {
+        TestEvent event = new TestEvent(fEvent1);
+        assertEquals("setRank", 0, event.getRank());
+
+        event.setRank(1);
+        assertEquals("setRank", 1, event.getRank());
+
+        event.setRank(-1);
+        assertEquals("setRank", -1, event.getRank());
+
+        event.setRank(0);
+        assertEquals("setRank", 0, event.getRank());
     }
 
     public void testSetTimestamp() {
-        TmfEvent event = new TmfEvent(fEvent1);
+        TestEvent event = new TestEvent(fEvent1);
         assertEquals("setTimestamp", fTimestamp1, event.getTimestamp());
 
         event.setTimestamp(fTimestamp2);
@@ -250,8 +326,23 @@ public class TmfEventTest extends TestCase {
         assertEquals("setTimestamp", fTimestamp1, event.getTimestamp());
     }
 
+    public void testSetSource() {
+        TestEvent event = new TestEvent(fEvent1);
+        assertEquals("setSource", fSource, event.getSource());
+
+        String source2 = "another source";
+        event.setSource(source2);
+        assertEquals("setContent", source2, event.getSource());
+
+        event.setSource(null);
+        assertNull("setContent", event.getSource());
+
+        event.setSource(fSource);
+        assertEquals("setContent", fSource, event.getSource());
+    }
+
     public void testSetType() {
-        TmfEvent event = new TmfEvent(fEvent1);
+        TestEvent event = new TestEvent(fEvent1);
         assertEquals("setType", fType, event.getType());
 
         String typeId = "OtherTestType";
@@ -269,7 +360,7 @@ public class TmfEventTest extends TestCase {
     }
 
     public void testSetContent() {
-        TmfEvent event = new TmfEvent(fEvent1);
+        TestEvent event = new TestEvent(fEvent1);
         assertEquals("setContent", fContent1, event.getContent());
 
         event.setContent(fContent2);
@@ -283,7 +374,7 @@ public class TmfEventTest extends TestCase {
     }
 
     public void testSetReference() {
-        TmfEvent event = new TmfEvent(fEvent1);
+        TestEvent event = new TestEvent(fEvent1);
         assertEquals("setReference", fReference1, event.getReference());
 
         event.setReference(fReference2);
index 5cbac392cb08a76fff607b9e45ff19d91a5b313b..cc4299ea053b97c87ab05e72863db9c405f325fb 100644 (file)
@@ -30,40 +30,13 @@ public class TmfEvent implements ITmfEvent {
     // Attributes
     // ------------------------------------------------------------------------
 
-    /**
-     * The trace containing the event
-     */
-    protected ITmfTrace<? extends ITmfEvent> fTrace;
-
-    /**
-     * The event rank within the trace
-     */
-    protected long fRank;
-    
-    /**
-     * The event timestamp
-     */
-    protected ITmfTimestamp fTimestamp;
-    
-    /**
-     * The event source
-     */
-    protected String fSource;
-    
-    /**
-     * The event type
-     */
-    protected ITmfEventType fType;
-    
-    /**
-     * The event content (root field)
-     */
-    protected ITmfEventField fContent;
-    
-    /**
-     * The event reference
-     */
-    protected String fReference;
+    private ITmfTrace<? extends ITmfEvent> fTrace;
+    private long fRank;
+    private ITmfTimestamp fTimestamp;
+    private String fSource;
+    private ITmfEventType fType;
+    private ITmfEventField fContent;
+    private String fReference;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -212,38 +185,52 @@ public class TmfEvent implements ITmfEvent {
     // Convenience setters
     // ------------------------------------------------------------------------
 
+    /**
+     * @param trace the new event tarce
+     */
+    protected void setTrace(ITmfTrace<? extends ITmfEvent> trace) {
+        fTrace = trace;
+    }
+
     /**
      * @param source the new event source
      */
-    public void setSource(String source) {
-        fSource = source;
+    protected void setRank(long rank) {
+        fRank = rank;
     }
 
     /**
      * @param timestamp the new event timestamp
      */
-    public void setTimestamp(ITmfTimestamp timestamp) {
+    protected void setTimestamp(ITmfTimestamp timestamp) {
         fTimestamp = timestamp;
     }
 
+    /**
+     * @param source the new event source
+     */
+    protected void setSource(String source) {
+        fSource = source;
+    }
+
     /**
      * @param type the new event type
      */
-    public void setType(ITmfEventType type) {
+    protected void setType(ITmfEventType type) {
         fType = type;
     }
 
     /**
      * @param content the event new content
      */
-    public void setContent(ITmfEventField content) {
+    protected void setContent(ITmfEventField content) {
         fContent = content;
     }
 
     /**
      * @param reference the new event reference
      */
-    public void setReference(String reference) {
+    protected void setReference(String reference) {
         fReference = reference;
     }
 
index 6e31cf85a8056d734fe79871cca708a71675d9cd..84f373965b7d2f8266b2c23eaab95e8ab157c1ae 100644 (file)
@@ -87,17 +87,14 @@ public class TmfBaseColumnDataProviderTest extends TestCase {
 
         fTestName = name;
 
-        fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference);
         fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content");
-        fEvent1.setContent(fContent1);
+        fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
-        fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference);
         fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content");
-        fEvent2.setContent(fContent2);
+        fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType2, fContent2, fReference);
 
-        fEvent3 = new TmfEvent(fTimestamp3, fSource, fType3, fReference);
         fContent3 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other different content");
-        fEvent3.setContent(fContent3);
+        fEvent3 = new TmfEvent(null, fTimestamp3, fSource, fType3, fContent3, fReference);
 
         fStatsData = new TmfBaseStatisticsTree();
         fExtraInfo = new ITmfExtraEventInfo() {
index f3be43e0d1622526cedad227a356e308b0f76c99..4f7dcec53d20f459206873541cdf09fd25702385 100755 (executable)
@@ -84,17 +84,14 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         
         fTestName = name;
         
-        fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference);
         fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content");
-        fEvent1.setContent(fContent1);
+        fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
-        fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference);
         fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content");
-        fEvent2.setContent(fContent2);
+        fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType2, fContent2, fReference);
         
-        fEvent3 = new TmfEvent(fTimestamp3, fSource, fType3, fReference);
         fContent3 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other different content");
-        fEvent3.setContent(fContent3);
+        fEvent3 = new TmfEvent(null, fTimestamp3, fSource, fType3, fContent3, fReference);
         
         fStatsData = new TmfBaseStatisticsTree();
         fExtraInfo = new ITmfExtraEventInfo() {
index 88acdba33859c736813479e5fbcb8edb4be0168b..3793d5136a667eafb429d58d2c97057cafc39ce0 100755 (executable)
@@ -85,18 +85,15 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         
         fTestName = name;
         
-        fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference);
         fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content");
-        fEvent1.setContent(fContent1);
+        fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
-        fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference);
         fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content");
-        fEvent2.setContent(fContent2);
+        fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType2, fContent2, fReference);
         
-        fEvent3 = new TmfEvent(fTimestamp3, fSource, fType3, fReference);
         fContent3 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other different content");
-        fEvent3.setContent(fContent3);
-        
+        fEvent3 = new TmfEvent(null, fTimestamp3, fSource, fType3, fContent3, fReference);
+
         fStatsData = new TmfBaseStatisticsTree();
         fExtraInfo = new ITmfExtraEventInfo() {
             @Override
index db218effc6cffcd4d7a3d2d1114f370c8acd3fcd..f50fb8ed4d11ea0d726ff7a81fb8f0479797b4bb 100755 (executable)
@@ -84,13 +84,11 @@ public class TmfTreeContentProviderTest extends TestCase {
 
         fTestName = name;
 
-        fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference);
         fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content");
-        fEvent1.setContent(fContent1);
+        fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
-        fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference);
         fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content");
-        fEvent2.setContent(fContent2);
+        fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType2, fContent2, fReference);
 
         fStatsData = new TmfBaseStatisticsTree();
         fExtraInfo = new ITmfExtraEventInfo() {
index 15ae4737f5623b6208bf392dd0088197f2cea34c..db31e1b9daa299ab583d8cd28455e9a78c1b5b13 100644 (file)
@@ -58,7 +58,6 @@ public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> {
             String[] labels = {"sender", "receiver", "signal"};
 
             TmfEventType tmfEventType = new TmfEventType("UnitTest", type, TmfEventField.makeRoot(labels));
-            TmfEvent tmfEvent = new TmfEvent(new TmfTimestamp(ts, -9), source, tmfEventType, reference);
 
             String content = "[";
             content += sender;
@@ -73,7 +72,7 @@ public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> {
             fields[2] = new TmfEventField("signal", signal);
             
             ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_ID, content, fields);
-            tmfEvent.setContent(tmfContent);
+            TmfEvent tmfEvent = new TmfEvent(eventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference);
 
             return tmfEvent;
         } catch (EOFException e) {
index 4547f1cb6a20c30492b2f8d2884ae084e5ec6fd4..f471e076776857b4132b1f2279c7c6501a207c46 100644 (file)
@@ -72,12 +72,12 @@ public class CustomEvent extends TmfEvent {
             SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampInputFormat);\r
             try {\r
                 date = dateFormat.parse(timeStampString);\r
-                fTimestamp = new TmfTimestamp(date.getTime(), TIMESTAMP_SCALE);\r
+                setTimestamp(new TmfTimestamp(date.getTime(), TIMESTAMP_SCALE));\r
             } catch (ParseException e) {\r
-                fTimestamp = TmfTimestamp.Zero;\r
+                setTimestamp(TmfTimestamp.Zero);\r
             }\r
         } else {\r
-            fTimestamp = TmfTimestamp.Zero;\r
+            setTimestamp(TmfTimestamp.Zero);\r
         }\r
         \r
         int i = 0;\r
index 6dd2644bc4e48609b7964f2d35935c21a648fb92..086ba86f9cdb2b68c5a257c7dfa3ab99a32c9cac 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom;
 \r
 import java.util.regex.Matcher;\r
 \r
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
@@ -25,7 +26,7 @@ public class CustomTxtEvent extends CustomEvent {
 \r
     public CustomTxtEvent(CustomTxtTraceDefinition definition) {\r
         super(definition);\r
-        fType = new CustomTxtEventType(definition);\r
+        setType(new CustomTxtEventType(definition));\r
     }\r
 \r
     public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {\r
@@ -36,6 +37,11 @@ public class CustomTxtEvent extends CustomEvent {
         super(definition, parentTrace, timestamp, source, type, reference);\r
     }\r
 \r
+    @Override\r
+    public void setContent(ITmfEventField content) {\r
+        setContent(content);\r
+    }\r
+\r
     public void processGroups(InputLine input, Matcher matcher) {\r
        if (input.columns == null) {\r
                return;\r
index fc7a783ef6ecc678d26b846df8ac845b0b3ab0c9..e69b9d580929e8b646924fbc9f9543e6850d8460 100644 (file)
@@ -12,6 +12,7 @@
 \r
 package org.eclipse.linuxtools.tmf.ui.parsers.custom;\r
 \r
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
@@ -21,7 +22,7 @@ public class CustomXmlEvent extends CustomEvent {
 \r
     public CustomXmlEvent(CustomXmlTraceDefinition definition) {\r
         super(definition);\r
-        fType = new CustomXmlEventType(definition);\r
+        setType(new CustomXmlEventType(definition));\r
     }\r
 \r
     public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {\r
@@ -32,6 +33,11 @@ public class CustomXmlEvent extends CustomEvent {
         super(definition, parentTrace, timestamp, source, type, reference);\r
     }\r
 \r
+    @Override\r
+    public void setContent(ITmfEventField content) {\r
+        setContent(content);\r
+    }\r
+\r
     public void parseInput(String value, String name, int inputAction, String inputFormat) {\r
         if (value.length() == 0) {\r
             return;\r
This page took 0.036138 seconds and 5 git commands to generate.