| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2009 Ericsson |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which |
| 6 | * accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Francois Chouinard - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.tmf.tests.event; |
| 14 | |
| 15 | import org.eclipse.linuxtools.tmf.event.TmfEventContent; |
| 16 | import org.eclipse.linuxtools.tmf.event.TmfEventReference; |
| 17 | import org.eclipse.linuxtools.tmf.event.TmfEventSource; |
| 18 | import org.eclipse.linuxtools.tmf.event.TmfEventType; |
| 19 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; |
| 20 | import org.eclipse.linuxtools.tmf.event.TmfTraceEvent; |
| 21 | |
| 22 | import junit.framework.TestCase; |
| 23 | |
| 24 | /** |
| 25 | * <b><u>TmfTraceEventTest</u></b> |
| 26 | * <p> |
| 27 | * Test suite for the TmfTraceEvent class. |
| 28 | */ |
| 29 | @SuppressWarnings("nls") |
| 30 | public class TmfTraceEventTest extends TestCase { |
| 31 | |
| 32 | // ------------------------------------------------------------------------ |
| 33 | // Variables |
| 34 | // ------------------------------------------------------------------------ |
| 35 | |
| 36 | private final String fTypeId = "Some type"; |
| 37 | private final String fLabel0 = "label1"; |
| 38 | private final String fLabel1 = "label2"; |
| 39 | private final String[] fLabels = new String[] { fLabel0, fLabel1 }; |
| 40 | |
| 41 | private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5); |
| 42 | private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5); |
| 43 | private final TmfEventSource fSource = new TmfEventSource("Source"); |
| 44 | private final TmfEventType fType = new TmfEventType(fTypeId, fLabels); |
| 45 | private final TmfEventReference fReference = new TmfEventReference("Some reference"); |
| 46 | |
| 47 | private final TmfTraceEvent fEvent1; |
| 48 | private final TmfTraceEvent fEvent2; |
| 49 | |
| 50 | private final TmfEventContent fContent1; |
| 51 | private final TmfEventContent fContent2; |
| 52 | |
| 53 | private final String fPath = "/some/path/"; |
| 54 | private final String fFile = "filename"; |
| 55 | private final int fLine = 10; |
| 56 | |
| 57 | // ------------------------------------------------------------------------ |
| 58 | // Housekeeping |
| 59 | // ------------------------------------------------------------------------ |
| 60 | |
| 61 | /** |
| 62 | * @param name the test name |
| 63 | */ |
| 64 | public TmfTraceEventTest(String name) { |
| 65 | super(name); |
| 66 | |
| 67 | fEvent1 = new TmfTraceEvent(fTimestamp1, fSource, fType, fReference, fPath, fFile, fLine); |
| 68 | fContent1 = new TmfEventContent(fEvent1, "Some content"); |
| 69 | fEvent1.setContent(fContent1); |
| 70 | |
| 71 | fEvent2 = new TmfTraceEvent(fTimestamp1, fTimestamp2, fSource, fType, fReference, fPath, fFile, fLine); |
| 72 | fContent2 = new TmfEventContent(fEvent2, "Some other content"); |
| 73 | fEvent2.setContent(fContent2); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | protected void setUp() throws Exception { |
| 78 | super.setUp(); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | protected void tearDown() throws Exception { |
| 83 | super.tearDown(); |
| 84 | } |
| 85 | |
| 86 | // ------------------------------------------------------------------------ |
| 87 | // Constructors |
| 88 | // ------------------------------------------------------------------------ |
| 89 | |
| 90 | public void testTmfTraceEvent() throws Exception { |
| 91 | assertEquals("getTimestamp", fTimestamp1, fEvent1.getTimestamp()); |
| 92 | assertEquals("getOriginalTimestamp", fTimestamp1, fEvent1.getOriginalTimestamp()); |
| 93 | assertEquals("getSource", fSource, fEvent1.getSource()); |
| 94 | assertEquals("getType", fType, fEvent1.getType()); |
| 95 | assertEquals("getContent", fContent1, fEvent1.getContent()); |
| 96 | assertEquals("getReference", fReference, fEvent1.getReference()); |
| 97 | assertEquals("getSourcePath", fPath, fEvent1.getSourcePath()); |
| 98 | assertEquals("getFileName", fFile, fEvent1.getFileName()); |
| 99 | assertEquals("getLineNumber", fLine, fEvent1.getLineNumber()); |
| 100 | } |
| 101 | |
| 102 | public void testTmfTraceEvent2() throws Exception { |
| 103 | assertEquals("getTimestamp", fTimestamp2, fEvent2.getTimestamp()); |
| 104 | assertEquals("getOriginalTimestamp", fTimestamp1, fEvent2.getOriginalTimestamp()); |
| 105 | assertEquals("getSource", fSource, fEvent2.getSource()); |
| 106 | assertEquals("getType", fType, fEvent2.getType()); |
| 107 | assertEquals("getContent", fContent2, fEvent2.getContent()); |
| 108 | assertEquals("getReference", fReference, fEvent2.getReference()); |
| 109 | assertEquals("getSourcePath", fPath, fEvent2.getSourcePath()); |
| 110 | assertEquals("getFileName", fFile, fEvent2.getFileName()); |
| 111 | assertEquals("getLineNumber", fLine, fEvent2.getLineNumber()); |
| 112 | } |
| 113 | |
| 114 | public void testTmfTraceEventCopy() throws Exception { |
| 115 | TmfTraceEvent event = new TmfTraceEvent(fEvent2); |
| 116 | assertEquals("getTimestamp", fTimestamp2, event.getTimestamp()); |
| 117 | assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp()); |
| 118 | assertEquals("getSource", fSource, event.getSource()); |
| 119 | assertEquals("getType", fType, event.getType()); |
| 120 | assertEquals("getContent", fContent2, event.getContent()); |
| 121 | assertEquals("getReference", fReference, event.getReference()); |
| 122 | assertEquals("getSourcePath", fPath, event.getSourcePath()); |
| 123 | assertEquals("getFileName", fFile, event.getFileName()); |
| 124 | assertEquals("getLineNumber", fLine, event.getLineNumber()); |
| 125 | } |
| 126 | |
| 127 | // ------------------------------------------------------------------------ |
| 128 | // equals |
| 129 | // ------------------------------------------------------------------------ |
| 130 | |
| 131 | // ------------------------------------------------------------------------ |
| 132 | // toString |
| 133 | // ------------------------------------------------------------------------ |
| 134 | |
| 135 | } |
| 136 | |