Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 151266 Details for
Bug 287562
[TMF] Update the Event Model code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
TMF Event update + JUnits
org.eclipse.linuxtools.tmf.patch (text/plain), 23.20 KB, created by
Francois Chouinard
on 2009-11-04 00:18:23 EST
(
hide
)
Description:
TMF Event update + JUnits
Filename:
MIME Type:
Creator:
Francois Chouinard
Created:
2009-11-04 00:18:23 EST
Size:
23.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.linuxtools.tmf.ui >Index: src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java (working copy) >@@ -215,7 +215,7 @@ > event.getSource().getSourceId().toString(), > event.getType().getTypeId().toString(), > event.getReference().getValue().toString(), >- event.getContent().getContent() >+ event.getContent().toString() > }; > } > return fields; >@@ -292,4 +292,4 @@ > } > } > >-} >\ No newline at end of file >+} >#P org.eclipse.linuxtools.tmf.tests >Index: stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java >=================================================================== >--- stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java (revision 23558) >+++ stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java (working copy) >@@ -12,6 +12,9 @@ > > package org.eclipse.linuxtools.tmf.event; > >+import java.util.HashMap; >+import java.util.Map; >+ > /** > * <b><u>TmfEventFormatStub</u></b> > * <p> >@@ -17,7 +20,7 @@ > * <p> > * TODO: Implement me. Please. > */ >-public class TmfEventFormatStub extends TmfEventFormat { >+public class TmfEventContentStub extends TmfEventContent { > > // ======================================================================== > // Attributes >@@ -23,17 +26,23 @@ > // Attributes > // ======================================================================== > >- // ======================================================================== >+ private static final String fTypeId = "typeId"; >+ private static final String[] fLabels = new String[] { "label1", "label2", "label3", "label4", "label5" }; >+ private static final TmfEventType fType = new TmfEventType(fTypeId, fLabels); >+ >+ private static final String[] fFields = new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" }; >+ >+ // ======================================================================== > // Constructors > // ======================================================================== > >- public TmfEventFormatStub() { >- super(new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" }); >+ public TmfEventContentStub() { >+ super(fType, fFields); > } > >- // ======================================================================== >- // Accessors >- // ======================================================================== >+ public TmfEventContentStub(TmfEventType type, Object content) { >+ super(type, content); >+ } > > // ======================================================================== > // Operators >@@ -39,17 +48,14 @@ > // Operators > // ======================================================================== > >- /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tmf.event.TmfEventFormat#parse(java.lang.Object) >- */ >- @Override >- public TmfEventField[] parse(Object content) { >- TmfEventField field1 = new TmfEventField(1); >- TmfEventField field2 = new TmfEventField(-10); >- TmfEventField field3 = new TmfEventField(true); >- TmfEventField field4 = new TmfEventField("some string"); >- TmfEventField field5 = new TmfEventField(new TmfTimestamp(1, (byte) 2, 3)); >- return new TmfEventField[] { field1, field2, field3, field4, field5 }; >+ @Override >+ public Map<String, TmfEventField> parseContent() { >+ Map<String, TmfEventField> fields = new HashMap<String, TmfEventField>(); >+ for (int i = 0; i < fLabels.length; i++) { >+ TmfEventField field = new TmfEventField(this, fLabels[i], fFields[i]); >+ fields.put(fLabels[i], field); >+ } >+ return fields; > } > > // ======================================================================== >@@ -56,4 +62,4 @@ > // Helper functions > // ======================================================================== > >-} >+} >\ No newline at end of file >Index: stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java >=================================================================== >--- stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java (revision 23558) >+++ stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java (working copy) >@@ -1,59 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 Ericsson >- * >- * All rights reserved. This program and the accompanying materials are >- * made available under the terms of the Eclipse Public License v1.0 which >- * accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Francois Chouinard - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.linuxtools.tmf.event; >- >-/** >- * <b><u>TmfEventFormatStub</u></b> >- * <p> >- * TODO: Implement me. Please. >- */ >-public class TmfEventFormatStub extends TmfEventFormat { >- >- // ======================================================================== >- // Attributes >- // ======================================================================== >- >- // ======================================================================== >- // Constructors >- // ======================================================================== >- >- public TmfEventFormatStub() { >- super(new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" }); >- } >- >- // ======================================================================== >- // Accessors >- // ======================================================================== >- >- // ======================================================================== >- // Operators >- // ======================================================================== >- >- /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tmf.event.TmfEventFormat#parse(java.lang.Object) >- */ >- @Override >- public TmfEventField[] parse(Object content) { >- TmfEventField field1 = new TmfEventField(1); >- TmfEventField field2 = new TmfEventField(-10); >- TmfEventField field3 = new TmfEventField(true); >- TmfEventField field4 = new TmfEventField("some string"); >- TmfEventField field5 = new TmfEventField(new TmfTimestamp(1, (byte) 2, 3)); >- return new TmfEventField[] { field1, field2, field3, field4, field5 }; >- } >- >- // ======================================================================== >- // Helper functions >- // ======================================================================== >- >-} >Index: stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java >=================================================================== >--- stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java (revision 23558) >+++ stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java (working copy) >@@ -15,11 +15,9 @@ > import java.io.EOFException; > import java.io.IOException; > import java.io.RandomAccessFile; >-import java.util.Vector; > > import org.eclipse.linuxtools.tmf.event.TmfEvent; >-import org.eclipse.linuxtools.tmf.event.TmfEventContent; >-import org.eclipse.linuxtools.tmf.event.TmfEventFormat; >+import org.eclipse.linuxtools.tmf.event.TmfEventContentStub; > import org.eclipse.linuxtools.tmf.event.TmfEventReference; > import org.eclipse.linuxtools.tmf.event.TmfEventSource; > import org.eclipse.linuxtools.tmf.event.TmfEventType; >@@ -36,8 +34,8 @@ > // Attributes > // ======================================================================== > >- private final int NB_FORMATS = 10; >- private final TmfEventFormat[] fFormats; >+ private final int NB_TYPES = 10; >+ private final String[][] fFormats; > > // ======================================================================== > // Constructors >@@ -44,14 +42,12 @@ > // ======================================================================== > > public TmfEventParserStub() { >- fFormats = new TmfEventFormat[NB_FORMATS]; >- for (int i = 0; i < NB_FORMATS; i++) { >- Vector<String> format = new Vector<String>(); >+ fFormats = new String[NB_TYPES][]; >+ for (int i = 0; i < NB_TYPES; i++) { >+ fFormats[i] = new String[i]; > for (int j = 1; j <= i; j++) { >- format.add(new String("Fmt-" + i + "-Fld-" + j)); >+ fFormats[i][j] = "Fmt-" + i + "-Fld-" + j; > } >- String[] fields = new String[i]; >- fFormats[i] = new TmfEventFormat(format.toArray(fields)); > } > } > >@@ -105,11 +101,14 @@ > } > content += "]"; > >+ String[] labels = fFormats[typeIndex]; >+ TmfEventType eventType = new TmfEventType(type, labels); >+ > TmfEvent event = new TmfEvent( > new TmfTimestamp(ts, (byte) -3, 0), // millisecs > new TmfEventSource(source), >- new TmfEventType(type, fFormats[typeIndex]), >- new TmfEventContent(content, fFormats[typeIndex]), >+ eventType, >+ new TmfEventContentStub(eventType, labels), > new TmfEventReference(name)); > return event; > } catch (EOFException e) { >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java (working copy) >@@ -31,7 +31,6 @@ > public void testEmptyConstructor() { > TmfEventType type = new TmfEventType("", null); > assertEquals("getValue", "", type.getTypeId()); >- assertEquals("getFormat", null, type.getFormat()); > } > > @Test >@@ -36,10 +35,10 @@ > > @Test > public void testNormalConstructor() { >- TmfEventType type = new TmfEventType("Type", new TmfEventFormat(new String[] { "field1", "field2" })); >+ TmfEventType type = new TmfEventType("Type", new String[] { "field1", "field2" }); > assertEquals("getValue", "Type", type.getTypeId()); >- assertEquals("getFormat", "field1", type.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", type.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "field1", type.getLabels()[0]); >+ assertEquals("getFormat", "field2", type.getLabels()[1]); > } > > } >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java (working copy) >@@ -1,87 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 Ericsson >- * >- * All rights reserved. This program and the accompanying materials are >- * made available under the terms of the Eclipse Public License v1.0 which >- * accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Francois Chouinard - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.linuxtools.tmf.event; >- >-import static org.junit.Assert.assertEquals; >- >-import org.junit.Test; >- >-/** >- * <b><u>TmfEventFormatTest</u></b> >- * <p> >- * JUnit test suite for the TmfEventFormat class. >- */ >-public class TmfEventFormatTest { >- >- // ======================================================================== >- // Constructors >- // ======================================================================== >- >- @Test >- public void testBasicTmfEventFormat() { >- TmfEventFormat format = new TmfEventFormat(); >- assertEquals("getLabels", 1, format.getLabels().length); >- assertEquals("getValue", "Content", format.getLabels()[0]); >- } >- >- @Test >- public void testEmptyConstructor() { >- TmfEventFormat format = new TmfEventFormat(new String[] {}); >- assertEquals("getLabels", 0, format.getLabels().length); >- } >- >- @Test >- public void testNormalConstructor() { >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2", "field3" }); >- assertEquals("getLabels", 3, format.getLabels().length); >- assertEquals("getLabels", "field1", format.getLabels()[0]); >- assertEquals("getLabels", "field2", format.getLabels()[1]); >- assertEquals("getLabels", "field3", format.getLabels()[2]); >- } >- >- @Test >- public void testExtendedConstructor() { >- TmfEventFormatStub format = new TmfEventFormatStub(); >- assertEquals("getLabels", 5, format.getLabels().length); >- assertEquals("getLabels", "Field1", format.getLabels()[0]); >- assertEquals("getLabels", "Field2", format.getLabels()[1]); >- assertEquals("getLabels", "Field3", format.getLabels()[2]); >- assertEquals("getLabels", "Field4", format.getLabels()[3]); >- assertEquals("getLabels", "Field5", format.getLabels()[4]); >- } >- >- // ======================================================================== >- // parse >- // ======================================================================== >- >- @Test >- public void testBasicParse() { >- TmfEventFormat format = new TmfEventFormat(); >- TmfEventField[] content = format.parse(new TmfTimestamp()); >- assertEquals("length", 1, content.length); >- assertEquals("getValue", "[TmfTimestamp:0,0,0]", content[0].toString()); >- } >- >- @Test >- public void testExtendedParse() { >- TmfEventFormatStub format = new TmfEventFormatStub(); >- TmfEventField[] content = format.parse(new TmfTimestamp()); >- assertEquals("length", 5, content.length); >- assertEquals("getValue", "1", content[0].toString()); >- assertEquals("getValue", "-10", content[1].toString()); >- assertEquals("getValue", "true", content[2].toString()); >- assertEquals("getValue", "some string", content[3].toString()); >- assertEquals("getValue", "[TmfTimestamp:1,2,3]", content[4].toString()); >- } >- >-} >Index: src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java (working copy) >@@ -29,11 +29,14 @@ > > @Test > public void testTmfTraceEvent() throws Exception { >- TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); >+ >+ String[] labels = new String[] { "label1", "label2" }; >+ String[] fields = new String[] { "field1", "field2" }; >+ >+ TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); > TmfEventSource source = new TmfEventSource("Source"); >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); >- TmfEventType type = new TmfEventType("Type", format); >- TmfEventContent content = new TmfEventContent("Some content", format); >+ TmfEventType type = new TmfEventType("Type", labels); >+ TmfEventContent content = new TmfEventContentStub(type, fields); > TmfEventReference reference = new TmfEventReference("Reference"); > > // Create the trace event >@@ -53,13 +56,13 @@ > // Check the event type > TmfEventType evType = event.getType(); > assertEquals("getValue", "Type", evType.getTypeId()); >- assertEquals("getFormat", "field1", evType.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", evType.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "label1", evType.getLabels()[0]); >+ assertEquals("getFormat", "label2", evType.getLabels()[1]); > > // Check the event content > TmfEventContent evContent = event.getContent(); >- assertEquals("getField", 1, evContent.getFields().length); >- assertEquals("getField", "Some content", evContent.getField(0).toString()); >+ assertEquals("getField", 2, evContent.getFields().length); >+ assertEquals("getField", "[field:label1,value:Field1]", evContent.getField(evType.getLabels()[0]).toString()); > > // Check the event reference > TmfEventReference evRef = event.getReference(); >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java (working copy) >@@ -29,10 +29,12 @@ > > @Test > public void testTmfEventContent() { >- TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat()); >- assertEquals("getFormat", 1, content.getFormat().getLabels().length); >- assertEquals("getLabels", "Content", content.getFormat().getLabels()[0]); >- assertEquals("getContent", "Some content", content.getContent()); >+ TmfEventContent content = new TmfEventContentStub(); >+ assertEquals("getType", "typeId", content.getType().getTypeId()); >+ if (content.getContent() instanceof String) { >+ String value = (String) content.getContent(); >+ assertEquals("getContent", "Some content", value); >+ } > } > > // ======================================================================== >@@ -40,21 +42,14 @@ > // ======================================================================== > > @Test >- public void testBasicGetField() { >- TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat()); >- assertEquals("getField", 1, content.getFields().length); >- assertEquals("getField", "Some content", content.getField(0).toString()); >- } >- >- @Test >- public void testExtendedGetField() { >- TmfEventContent content = new TmfEventContent("", new TmfEventFormatStub()); >+ public void testGetField() { >+ TmfEventContent content = new TmfEventContentStub(); > assertEquals("getField", 5, content.getFields().length); >- assertEquals("getField", "1", content.getField(0).toString()); >- assertEquals("getField", "-10", content.getField(1).toString()); >- assertEquals("getField", "true", content.getField(2).toString()); >- assertEquals("getField", "some string", content.getField(3).toString()); >- assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4).toString()); >+ assertEquals("getField", "[field:label1,value:Field1]", content.getField("label1").toString()); >+ assertEquals("getField", "[field:label2,value:Field2]", content.getField("label2").toString()); >+ assertEquals("getField", "[field:label3,value:Field3]", content.getField("label3").toString()); >+ assertEquals("getField", "[field:label4,value:Field4]", content.getField("label4").toString()); >+ assertEquals("getField", "[field:label5,value:Field5]", content.getField("label5").toString()); > } > >-} >+} >\ No newline at end of file >Index: src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java (working copy) >@@ -29,11 +29,14 @@ > > @Test > public void testTmfEvent() { >+ >+ String[] labels = new String[] { "label1", "label2" }; >+ String[] fields = new String[] { "field1", "field2" }; >+ > TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5); > TmfEventSource source = new TmfEventSource("Source"); >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); >- TmfEventType type = new TmfEventType("Type", format); >- TmfEventContent content = new TmfEventContent("Some content", format); >+ TmfEventType type = new TmfEventType("Type", labels); >+ TmfEventContent content = new TmfEventContentStub(type, fields); > TmfEventReference reference = new TmfEventReference("Reference"); > > // Create the event >@@ -58,13 +61,13 @@ > // Check the event type > TmfEventType tp = event.getType(); > assertEquals("getValue", "Type", tp.getTypeId()); >- assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "label1", tp.getLabels()[0]); >+ assertEquals("getFormat", "label2", tp.getLabels()[1]); > > // Check the event content > TmfEventContent cnt = event.getContent(); >- assertEquals("getField", 1, cnt.getFields().length); >- assertEquals("getField", "Some content", cnt.getField(0).toString()); >+ assertEquals("getField", 2, cnt.getFields().length); >+ assertEquals("getField", "[field:label1,value:Field1]", cnt.getField(tp.getLabels()[0]).toString()); > > // Check the event reference > TmfEventReference ref = event.getReference(); >@@ -73,12 +76,15 @@ > > @Test > public void testTmfEvent2() { >- TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5); >+ >+ String[] labels = new String[] { "label1", "label2" }; >+ String[] fields = new String[] { "field1", "field2" }; >+ >+ TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5); > TmfTimestamp effective = new TmfTimestamp(12350, (byte) 2, 5); > TmfEventSource source = new TmfEventSource("Source"); >- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" }); >- TmfEventType type = new TmfEventType("Type", format); >- TmfEventContent content = new TmfEventContent("Some content", format); >+ TmfEventType type = new TmfEventType("Type", labels); >+ TmfEventContent content = new TmfEventContentStub(type, fields); > TmfEventReference reference = new TmfEventReference("Reference"); > > // Create the event >@@ -103,13 +109,13 @@ > // Check the event type > TmfEventType tp = event.getType(); > assertEquals("getValue", "Type", tp.getTypeId()); >- assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]); >- assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]); >+ assertEquals("getFormat", "label1", tp.getLabels()[0]); >+ assertEquals("getFormat", "label2", tp.getLabels()[1]); > > // Check the event content > TmfEventContent cnt = event.getContent(); >- assertEquals("getField", 1, cnt.getFields().length); >- assertEquals("getField", "Some content", cnt.getField(0).toString()); >+ assertEquals("getField", 2, cnt.getFields().length); >+ assertEquals("getField", "[field:label1,value:Field1]", cnt.getField(tp.getLabels()[0]).toString()); > > // Check the event reference > TmfEventReference ref = event.getReference(); >Index: src/org/eclipse/linuxtools/tmf/event/AllEventTests.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/event/AllEventTests.java (revision 23558) >+++ src/org/eclipse/linuxtools/tmf/event/AllEventTests.java (working copy) >@@ -20,7 +20,6 @@ > TmfTimestampTest.class, > TmfTimeRangeTest.class, > TmfEventTypeTest.class, >- TmfEventFormatTest.class, > TmfEventContentTest.class, > TmfEventTest.class, > TmfTraceEventTest.class
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 287562
:
145578
|
151266
|
151267
|
151666