From 95bf10e715ae54f4d7e7b782b024769efb8cea69 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 15 Jun 2012 10:48:19 -0400 Subject: [PATCH] tmf: Clean up the ctfAdaptor unit tests Signed-off-by: Alexandre Montplaisir --- .../tests/ctfadaptor/CtfIteratorTest.java | 576 +++----------- .../tests/ctfadaptor/CtfLocationTest.java | 134 ++-- .../tests/ctfadaptor/CtfTmfContentTest.java | 124 ++- .../ctfadaptor/CtfTmfEventFieldTest.java | 170 ++-- .../tests/ctfadaptor/CtfTmfEventTest.java | 31 +- .../tests/ctfadaptor/CtfTmfEventTypeTest.java | 105 ++- .../tests/ctfadaptor/CtfTmfTimestampTest.java | 307 ++------ .../tests/ctfadaptor/CtfTmfTraceTest.java | 742 +++--------------- .../tmf/core/tests/ctfadaptor/TestAll.java | 31 +- .../tmf/core/tests/ctfadaptor/TestParams.java | 20 +- .../tests/ctfadaptor/headless/Benchmark.java | 25 +- .../ctfadaptor/headless/RequestBenchmark.java | 73 +- 12 files changed, 603 insertions(+), 1735 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java index af4e75a557..4b59579ffe 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; @@ -15,61 +28,94 @@ import org.junit.Before; import org.junit.Test; /** - * The class CtfIteratorTest contains tests for the class {@link CtfIterator}. + * The class CtfIteratorTest contains tests for the class + * {@link CtfIterator}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ -@SuppressWarnings("static-method") public class CtfIteratorTest { + + private CtfIterator fixture; + /** - * Run the CtfIterator(CtfTmfTrace) constructor test. + * Launch the test. * - * @throws Exception + * @param args + * the command line arguments + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfIteratorTest.class); + } + + /** + * Perform pre-test initialization. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @throws TmfTraceException + * If the test trace is not found + */ + @Before + public void setUp() throws TmfTraceException { + fixture = new CtfIterator(createTrace()); + CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); + ctfLocation.setLocation(Long.valueOf(1)); + fixture.setLocation(ctfLocation); + fixture.increaseRank(); + } + + /** + * Perform post-test clean-up. + */ + @After + public void tearDown() { + fixture.dispose(); + } + + + private static CtfTmfTrace createTrace() throws TmfTraceException { + return TestParams.createTrace(); + } + + /** + * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace. + * + * @throws TmfTraceException + * If the test trace is not found */ @Test - public void testCtfIterator_1() - throws Exception { + public void testCtfIterator_noinit() throws TmfTraceException { CtfTmfTrace trace = createTrace(); CtfIterator result = new CtfIterator(trace); assertNotNull(result); } /** - * Run the CtfIterator(CtfTmfTrace) constructor test. - * - * @throws Exception + * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @throws TmfTraceException + * If the test trace is not found */ @Test - public void testCtfIterator_2() - throws Exception { + public void testCtfIterator_init() throws TmfTraceException { CtfTmfTrace trace = createTrace(); trace.init("test"); //$NON-NLS-1$ - CtfIterator result = new CtfIterator(trace); assertNotNull(result); } /** - * Run the CtfIterator(CtfTmfTrace,long,long) constructor test. + * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which + * specifies an initial position for the iterator. * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @throws TmfTraceException + * If the test trace is not found */ @Test - public void testCtfIterator_3() - throws Exception { + public void testCtfIterator_position() throws TmfTraceException { CtfTmfTrace trace = createTrace(); long timestampValue = 1L; long rank = 1L; - CtfIterator result = new CtfIterator(trace, timestampValue, rank); assertNotNull(result); @@ -78,61 +124,18 @@ public class CtfIteratorTest { /** * Run the boolean advance() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testAdvance_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - - boolean result = fixture.advance(); - assertTrue(result); - } - - /** - * Run the boolean advance() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testAdvance_2() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testAdvance() { boolean result = fixture.advance(); - assertTrue(result); } /** * Run the CtfIterator clone() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testClone_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testClone() { CtfIterator result = fixture.clone(); assertNotNull(result); } @@ -140,111 +143,26 @@ public class CtfIteratorTest { /** * Run the int compareTo(CtfIterator) method test. * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - - @Test - public void testCompareTo_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - CtfIterator o = new CtfIterator(createTrace()); - - int result = fixture.compareTo(o); - - assertEquals(1L, result); - } - - /** - * @return * @throws TmfTraceException - */ - private CtfTmfTrace createTrace() throws TmfTraceException { - return TestParams.createTrace(); - } - - /** - * Run the int compareTo(CtfIterator) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * If the test trace is not found */ @Test - public void testCompareTo_2() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); + public void testCompareTo() throws TmfTraceException { CtfIterator o = new CtfIterator(createTrace()); - int result = fixture.compareTo(o); - assertEquals(1, result); - } - - /** - * Run the int compareTo(CtfIterator) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testCompareTo_3() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - CtfIterator o = new CtfIterator(createTrace()); - - int result = fixture.compareTo(o); - assertEquals(1, result); - } - - /** - * Run the void dispose() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testDispose_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - - fixture.dispose(); + assertEquals(1L, result); } /** - * Run the boolean equals(Object) method test. - * - * @throws Exception + * Run the boolean equals(Object) method test. Compare with another iterator + * on the same trace. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @throws TmfTraceException + * If the test trace is not found */ @Test - public void testEquals_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); + public void testEquals_other() throws TmfTraceException { CtfIterator obj = new CtfIterator(createTrace()); CtfLocation ctfLocation1 = new CtfLocation(Long.valueOf(1)); ctfLocation1.setLocation(Long.valueOf(1)); @@ -252,49 +170,15 @@ public class CtfIteratorTest { obj.increaseRank(); boolean result = fixture.equals(obj); - assertTrue(result); } /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the boolean equals(Object) method test. Compare with an empty object. */ @Test - public void testEquals_2() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); + public void testEquals_empty() { Object obj = new Object(); - - boolean result = fixture.equals(obj); - - assertFalse(result); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testEquals_3() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - Object obj = new Object(); - boolean result = fixture.equals(obj); assertFalse(result); @@ -302,209 +186,54 @@ public class CtfIteratorTest { /** * Run the CtfTmfTrace getCtfTmfTrace() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetCtfTmfTrace_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testGetCtfTmfTrace() { CtfTmfTrace result = fixture.getCtfTmfTrace(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) assertNotNull(result); } /** * Run the CtfTmfEvent getCurrentEvent() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetCurrentEvent_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testGetCurrentEvent() { CtfTmfEvent result = fixture.getCurrentEvent(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) - assertNotNull(result); - } - - /** - * Run the CtfTmfEvent getCurrentEvent() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testGetCurrentEvent_2() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - - CtfTmfEvent result = fixture.getCurrentEvent(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) assertNotNull(result); } /** * Run the CtfLocation getLocation() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetLocation_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testGetLocation() { CtfLocation result = fixture.getLocation(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) assertNotNull(result); } /** * Run the long getRank() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetRank_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testGetRank() { long result = fixture.getRank(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) assertEquals(1L, result); } /** * Run the boolean hasValidRank() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testHasValidRank_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testHasValidRank() { boolean result = fixture.hasValidRank(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) - assertTrue(result); - } - - /** - * Run the boolean hasValidRank() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testHasValidRank_2() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - - boolean result = fixture.hasValidRank(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) assertTrue(result); } /** * Run the int hashCode() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testHashCode_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - + public void testHashCode() { int result = fixture.hashCode(); int result2 = fixture.hashCode(); assertEquals(result, result2); @@ -512,152 +241,29 @@ public class CtfIteratorTest { /** * Run the void increaseRank() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testIncreaseRank_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); - - fixture.increaseRank(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) - } - - /** - * Run the boolean seek(long) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSeek_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); + public void testIncreaseRank() { fixture.increaseRank(); - long timestamp = 1L; - - boolean result = fixture.seek(timestamp); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) - assertTrue(result); } /** * Run the boolean seek(long) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSeek_2() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); + public void testSeek() { long timestamp = 1L; - boolean result = fixture.seek(timestamp); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) assertTrue(result); } - /** * Run the void setLocation(ITmfLocation) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSetLocation_1() - throws Exception { - CtfIterator fixture = new CtfIterator(createTrace()); - CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1)); - ctfLocation.setLocation(Long.valueOf(1)); - fixture.setLocation(ctfLocation); - fixture.increaseRank(); + public void testSetLocation() { CtfLocation location = new CtfLocation(Long.valueOf(1)); location.setLocation(Long.valueOf(1)); - fixture.setLocation(location); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // java.lang.NullPointerException - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152) - // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.(CTFTraceReader.java:92) - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.(CtfIterator.java:40) - } - - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfIteratorTest.class); } -} \ No newline at end of file +} diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfLocationTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfLocationTest.java index 5b0fe7a49f..6f337cb81b 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfLocationTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfLocationTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; @@ -11,75 +24,86 @@ import org.junit.Before; import org.junit.Test; /** - * The class CtfLocationTest contains tests for the class {@link CtfLocation}. + * The class CtfLocationTest contains tests for the class + * {@link CtfLocation}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ public class CtfLocationTest { + + private CtfLocation fixture; + /** - * Run the CtfLocation(Long) constructor test. + * Launch the test. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @param args + * the command line arguments + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfLocationTest.class); + } + + /** + * Perform pre-test initialization. + */ + @Before + public void setUp() { + fixture = new CtfLocation(Long.valueOf(1)); + fixture.setLocation(Long.valueOf(1)); + } + + /** + * Perform post-test clean-up. + */ + @After + public void tearDown() { + // Add additional tear down code here + } + + + /** + * Run the CtfLocation(Long) constructor test. */ @Test - public void testCtfLocation_1() { + public void testCtfLocation_long() { Long location = Long.valueOf(1); - CtfLocation result = new CtfLocation(location); - // add additional test code here assertNotNull(result); assertEquals(Long.valueOf(1), result.getLocation()); } /** * Run the CtfLocation(ITmfTimestamp) constructor test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testCtfLocation_2() { + public void testCtfLocation_timestamp() { ITmfTimestamp timestamp = new TmfTimestamp(); - CtfLocation result = new CtfLocation(timestamp); - // add additional test code here assertNotNull(result); assertEquals(new Long(0L), result.getLocation()); } /** * Run the CtfLocation clone() method test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testClone_1() { - CtfLocation fixture = new CtfLocation(Long.valueOf(1)); - fixture.setLocation(Long.valueOf(1)); - + public void testClone() { CtfLocation result = fixture.clone(); - // add additional test code here assertNotNull(result); assertEquals(Long.valueOf(1), result.getLocation()); } /** * Run the Long getLocation() method test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetLocation_1() { - CtfLocation fixture = new CtfLocation(Long.valueOf(1)); - fixture.setLocation(Long.valueOf(1)); - + public void testGetLocation() { Long result = fixture.getLocation(); - // add additional test code here assertNotNull(result); assertEquals("1", result.toString()); //$NON-NLS-1$ assertEquals((byte) 1, result.byteValue()); @@ -92,60 +116,28 @@ public class CtfLocationTest { /** * Run the void setLocation(Long) method test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSetLocation_1() { - CtfLocation fixture = new CtfLocation(Long.valueOf(1)); - fixture.setLocation(Long.valueOf(1)); + public void testSetLocation() { Long location = Long.valueOf(1); - fixture.setLocation(location); - - // add additional test code here - } - - @Test - public void testToString1(){ - CtfLocation fixture = new CtfLocation(new Long(1337L)); - assertEquals("CtfLocation: 1337",fixture.toString()); //$NON-NLS-1$ - } - - @Test - public void testToString2(){ - CtfLocation fixture = new CtfLocation(new Long(-1L)); - assertEquals("CtfLocation: INVALID",fixture.toString()); //$NON-NLS-1$ } /** - * Perform pre-test initialization. - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Test the toString() method with a valid location. */ - @Before - public void setUp() { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @After - public void tearDown() { - // Add additional tear down code here + @Test + public void testToString_valid(){ + CtfLocation fixture2 = new CtfLocation(new Long(1337L)); + assertEquals("CtfLocation: 1337",fixture2.toString()); //$NON-NLS-1$ } /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Test the toString() method with an invalid location. */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfLocationTest.class); + @Test + public void testToString_invalid(){ + CtfLocation fixture2 = new CtfLocation(new Long(-1L)); + assertEquals("CtfLocation: INVALID",fixture2.toString()); //$NON-NLS-1$ } -} \ No newline at end of file +} diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContentTest.java index 13a527fa97..af474c4ea9 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContentTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContentTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; @@ -10,107 +23,64 @@ import org.junit.Before; import org.junit.Test; /** - * The class CtfTmfContentTest contains tests for the class {@link CtfTmfContent}. + * The class CtfTmfContentTest contains tests for the class + * {@link CtfTmfContent}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ public class CtfTmfContentTest { - /** - * Run the CtfTmfContent(String,ITmfEventField[]) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testCtfTmfContent_1() - throws Exception { - String name = ""; //$NON-NLS-1$ - ITmfEventField[] fields = new ITmfEventField[] {}; - - CtfTmfContent result = new CtfTmfContent(name, fields); - - // add additional test code here - assertNotNull(result); - assertEquals("", result.toString()); //$NON-NLS-1$ - assertEquals("", result.getName()); //$NON-NLS-1$ - assertEquals(null, result.getValue()); - } - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testToString_1() - throws Exception { - CtfTmfContent fixture = new CtfTmfContent("", new ITmfEventField[] {}); //$NON-NLS-1$ - - String result = fixture.toString(); - - // add additional test code here - assertEquals("", result); //$NON-NLS-1$ - } + private CtfTmfContent fixture; /** - * Run the String toString() method test. - * - * @throws Exception + * Launch the test. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @param args + * the command line arguments */ - @Test - public void testToString_2() - throws Exception { - CtfTmfContent fixture = new CtfTmfContent("", new ITmfEventField[] {}); //$NON-NLS-1$ - - String result = fixture.toString(); - - // add additional test code here - assertEquals("", result); //$NON-NLS-1$ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfTmfContentTest.class); } /** * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Before - public void setUp() - throws Exception { - // add additional set up code here + public void setUp() { + fixture = new CtfTmfContent("", new ITmfEventField[] {}); //$NON-NLS-1$ } /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @After - public void tearDown() - throws Exception { + public void tearDown() { // Add additional tear down code here } + /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the CtfTmfContent(String,ITmfEventField[]) constructor test. */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfTmfContentTest.class); + @Test + public void testCtfTmfContent() { + String name = ""; //$NON-NLS-1$ + ITmfEventField[] fields = new ITmfEventField[] {}; + CtfTmfContent result = new CtfTmfContent(name, fields); + + assertNotNull(result); + assertEquals("", result.toString()); //$NON-NLS-1$ + assertEquals("", result.getName()); //$NON-NLS-1$ + assertEquals(null, result.getValue()); + } + + /** + * Run the String toString() method test. + */ + @Test + public void testToString() { + String result = fixture.toString(); + assertEquals("", result); //$NON-NLS-1$ } -} \ No newline at end of file +} diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java index b2093c0d14..21acfd0351 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; @@ -25,9 +38,8 @@ import org.junit.Test; * The class CtfTmfEventFieldTest contains tests for the class * {@link CtfTmfEventField}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ public class CtfTmfEventFieldTest { @@ -40,40 +52,85 @@ public class CtfTmfEventFieldTest { private static final String INT = "int"; //$NON-NLS-1$ private static final String NAME = "test"; //$NON-NLS-1$ + private StructDefinition fixture; + /** - * Run the CtfTmfEventField parseField(Definition,String) method test. + * Launch the test. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @param args + * the command line arguments + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfTmfEventFieldTest.class); + } + + /** + * Perform pre-test initialization. + */ + @Before + public void setUp() { + StructDeclaration sDec = new StructDeclaration(1l); + StringDeclaration strDec = new StringDeclaration(); + IntegerDeclaration intDec = new IntegerDeclaration(8, false, 8, + ByteOrder.BIG_ENDIAN, Encoding.NONE, null, 8); + FloatDeclaration flDec = new FloatDeclaration(8, 24, + ByteOrder.BIG_ENDIAN, 8); + ArrayDeclaration arrDec = new ArrayDeclaration(2, intDec); + SequenceDeclaration seqDec = new SequenceDeclaration(LEN, intDec); + sDec.addField(INT, intDec); + sDec.addField(LEN, intDec); + sDec.addField(FLOAT, flDec); + sDec.addField(STR, strDec); + sDec.addField(ARRAY, arrDec); + sDec.addField(SEQ, seqDec); + fixture = sDec.createDefinition(fixture, ROOT); + int capacity = 1024; + java.nio.ByteBuffer bb = java.nio.ByteBuffer.allocateDirect(capacity); + for (int i = 0; i < capacity; i++) { + bb.put((byte) 2); + } + bb.position(20); + bb.put((byte) 0); + bb.position(0); + fixture.read(new BitBuffer(bb)); + } + + /** + * Perform post-test clean-up. + */ + @After + public void tearDown() { + // Add additional tear down code here + } + + /** + * Run the CtfTmfEventField parseField(Definition,String) method test. */ @Test - public void testParseField_1() { - FloatDefinition fieldDef = (FloatDefinition) fixture - .lookupDefinition(FLOAT); + public void testParseField_float() { + FloatDefinition fieldDef; + fieldDef = (FloatDefinition) fixture.lookupDefinition(FLOAT); CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, "_"+NAME); //$NON-NLS-1$ - String result2 =CtfTmfEventField.copyFrom(result).toString(); + String result2 = CtfTmfEventField.copyFrom(result).toString(); assertEquals( result2, "test=9.551467814359616E-38"); //$NON-NLS-1$ } /** * Run the CtfTmfEventField parseField(Definition,String) method test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testParseField_2() { - CtfTmfEventField result = CtfTmfEventField.parseField( - fixture.lookupArray(ARRAY), NAME); - String result2 =CtfTmfEventField.copyFrom(result).toString(); + public void testParseField_array() { + CtfTmfEventField result; + result = CtfTmfEventField.parseField(fixture.lookupArray(ARRAY), NAME); + String result2 = CtfTmfEventField.copyFrom(result).toString(); assertEquals( result2, "test={ 2, 2}"); //$NON-NLS-1$ } /** * Run the CtfTmfEventField parseField(Definition,String) method test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testParseField_3() { + public void testParseField_int() { Definition fieldDef = fixture.lookupDefinition(INT); CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME); String result2 =CtfTmfEventField.copyFrom(result).toString(); @@ -82,11 +139,9 @@ public class CtfTmfEventFieldTest { /** * Run the CtfTmfEventField parseField(Definition,String) method test. - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testParseField_4() { + public void testParseField_sequence() { Definition fieldDef = fixture.lookupDefinition(SEQ); CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME); String result2 =CtfTmfEventField.copyFrom(result).toString(); @@ -95,87 +150,22 @@ public class CtfTmfEventFieldTest { /** * Run the CtfTmfEventField parseField(Definition,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testParseField_5() { + public void testParseField_string() { Definition fieldDef = fixture.lookupDefinition(STR); CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME); String result2 =CtfTmfEventField.copyFrom(result).toString(); assertEquals( result2, "test="); //$NON-NLS-1$ } + /** + * Test the clone() method. + */ @Test public void testClone() { Definition fieldDef = fixture.lookupDefinition(STR); CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME); assertNotNull(result.clone()); } - - - StructDefinition fixture; - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Before - public void setUp() throws Exception { - StructDeclaration sDec = new StructDeclaration(1l); - StringDeclaration strDec = new StringDeclaration(); - IntegerDeclaration intDec = new IntegerDeclaration(8, false, 8, - ByteOrder.BIG_ENDIAN, Encoding.NONE, null, 8); - FloatDeclaration flDec = new FloatDeclaration(8, 24, - ByteOrder.BIG_ENDIAN, 8); - ArrayDeclaration arrDec = new ArrayDeclaration(2, intDec); - SequenceDeclaration seqDec = new SequenceDeclaration(LEN, intDec); - sDec.addField(INT, intDec); - sDec.addField(LEN, intDec); - sDec.addField(FLOAT, flDec); - sDec.addField(STR, strDec); - sDec.addField(ARRAY, arrDec); - sDec.addField(SEQ, seqDec); - fixture = sDec.createDefinition(fixture, ROOT); - int capacity = 1024; - java.nio.ByteBuffer bb = java.nio.ByteBuffer.allocateDirect(capacity); - for (int i = 0; i < capacity; i++) { - bb.put((byte) 2); - } - bb.position(20); - bb.put((byte) 0); - bb.position(0); - fixture.read(new BitBuffer(bb)); - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @After - public void tearDown() throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args - * the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfTmfEventFieldTest.class); - } -} \ No newline at end of file +} diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java index ddbc8ddf0f..a121ab1d9b 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertArrayEquals; @@ -15,8 +28,8 @@ import org.junit.Before; import org.junit.Test; /** - * The class CTFEventTest contains tests for the class - * {@link CTFEvent}. + * The class CtfTmfEventTest contains tests for the class + * {@link CtfTmfEvent}. * * @author ematkho * @version $Revision: 1.0 $ @@ -38,7 +51,8 @@ public class CtfTmfEventTest { /** * Perform pre-test initialization. * - * @throws FileNotFoundException + * @throws TmfTraceException + * If the test trace is not found */ @Before public void setUp() throws TmfTraceException { @@ -140,6 +154,9 @@ public class CtfTmfEventTest { assertEquals(-1L, result); } + /** + * Test the clone method + */ @Test public void testClone() { CtfTmfEvent other = CtfTmfEvent.getNullEvent().clone(); @@ -174,8 +191,11 @@ public class CtfTmfEventTest { assertEquals(-1L, result); } + /** + * Test the getters for the channel name, reference, source and type. + */ @Test - public void testRankTraceRefSourceType() { + public void testGetters() { long rank = fixture.getRank(); CtfTmfTrace trace = fixture.getTrace(); String channelName = fixture.getChannelName(); @@ -190,6 +210,9 @@ public class CtfTmfEventTest { assertEquals(type.toString(), "lttng_statedump_vm_map"); //$NON-NLS-1$ } + /** + * Test the toString() method + */ @Test public void testToString() { String s = fixture.getContent().toString(); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTypeTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTypeTest.java index 6b197da287..4a7baf3187 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTypeTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTypeTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; @@ -11,89 +24,65 @@ import org.junit.Before; import org.junit.Test; /** - * The class CtfTmfEventTypeTest contains tests for the class {@link CtfTmfEventType}. + * The class CtfTmfEventTypeTest contains tests for the class + * {@link CtfTmfEventType}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ public class CtfTmfEventTypeTest { - /** - * Run the CtfTmfEventType(String,String,ITmfEventField) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testCtfTmfEventType_1() { -// String contextId = ""; //$NON-NLS-1$ - String eventName = ""; //$NON-NLS-1$ - ITmfEventField content = new TmfEventField("", new ITmfEventField[] {}); //$NON-NLS-1$ - - CtfTmfEventType result = new CtfTmfEventType( eventName, content); - - // add additional test code here - assertNotNull(result); - assertEquals("", result.toString()); //$NON-NLS-1$ - assertEquals("", result.getName()); //$NON-NLS-1$ - assertEquals("Ctf Event", result.getContext()); //$NON-NLS-1$ - } /** - * Run the String toString() method test. - * - * @throws Exception + * Launch the test. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @param args the command line arguments */ - @Test - public void testToString_1() - throws Exception { - CtfTmfEventType fixture = new CtfTmfEventType("", new TmfEventField("", new ITmfEventField[] {})); //$NON-NLS-1$ //$NON-NLS-2$ - - String result = fixture.toString(); - - // add additional test code here - assertEquals("", result); //$NON-NLS-1$ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfTmfEventTypeTest.class); } /** * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Before - public void setUp() - throws Exception { + public void setUp() { // add additional set up code here } /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @After - public void tearDown() - throws Exception { + public void tearDown() { // Add additional tear down code here } + /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the CtfTmfEventType(String,String,ITmfEventField) constructor test. */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfTmfEventTypeTest.class); + @Test + public void testCtfTmfEventType() { + String eventName = ""; //$NON-NLS-1$ + ITmfEventField content = new TmfEventField("", new ITmfEventField[] {}); //$NON-NLS-1$ + CtfTmfEventType result = new CtfTmfEventType( eventName, content); + + assertNotNull(result); + assertEquals("", result.toString()); //$NON-NLS-1$ + assertEquals("", result.getName()); //$NON-NLS-1$ + assertEquals("Ctf Event", result.getContext()); //$NON-NLS-1$ + } + + /** + * Run the String toString() method test. + */ + @Test + public void testToString() { + ITmfEventField emptyField = new TmfEventField("", new ITmfEventField[] {}); //$NON-NLS-1$ + CtfTmfEventType fixture = new CtfTmfEventType("", emptyField); //$NON-NLS-1$ + + String result = fixture.toString(); + + assertEquals("", result); //$NON-NLS-1$ } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTimestampTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTimestampTest.java index 805e91f3ba..fa74315faf 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTimestampTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTimestampTest.java @@ -1,7 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp.TimestampType; @@ -12,180 +27,92 @@ import org.junit.Before; import org.junit.Test; /** - * The class CtfTmfTimestampTest contains tests for the class {@link CtfTmfTimestamp}. + * The class CtfTmfTimestampTest contains tests for the class + * {@link CtfTmfTimestamp}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ public class CtfTmfTimestampTest { - /** - * Run the CtfTmfTimestamp(long) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testCtfTmfTimestamp() - throws Exception { - long timestamp = 1L; - - CtfTmfTimestamp result = new CtfTmfTimestamp(timestamp); - result.setType(TimestampType.NANOS); - - // add additional test code here - assertNotNull(result); - assertEquals("1 ns", result.toString()); //$NON-NLS-1$ - assertEquals(0, result.getPrecision()); - assertEquals(-9, result.getScale()); - assertEquals(1L, result.getValue()); - } + private CtfTmfTimestamp fixture; /** - * Run the boolean equals(Object) method test. - * - * @throws Exception + * Launch the test. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @param args the command line arguments */ - @Test - public void testEquals_1() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - CtfTmfTimestamp obj = new CtfTmfTimestamp(1L); - obj.setType(CtfTmfTimestamp.TimestampType.DAY); - - boolean result = fixture.equals(obj); - - // add additional test code here - assertEquals(true, result); + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfTmfTimestampTest.class); } /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Perform pre-test initialization. */ - @Test - public void testEquals_2() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); + @Before + public void setUp() { + fixture = new CtfTmfTimestamp(1L); fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - Object obj = new Object(); - - boolean result = fixture.equals(obj); - - // add additional test code here - assertEquals(false, result); } /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Perform post-test clean-up. */ - @Test - public void testEquals_3() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - Object obj = new Object(); - - boolean result = fixture.equals(obj); - - // add additional test code here - assertEquals(false, result); + @After + public void tearDown() { + // Add additional tear down code here } + /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the CtfTmfTimestamp(long) constructor test. */ @Test - public void testEquals_4() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - CtfTmfTimestamp obj = new CtfTmfTimestamp(1L); - obj.setType(CtfTmfTimestamp.TimestampType.DAY); + public void testCtfTmfTimestamp() { + long timestamp = 1L; - boolean result = fixture.equals(obj); + CtfTmfTimestamp result = new CtfTmfTimestamp(timestamp); + result.setType(TimestampType.NANOS); - // add additional test code here - assertEquals(true, result); + assertNotNull(result); + assertEquals("1 ns", result.toString()); //$NON-NLS-1$ + assertEquals(0, result.getPrecision()); + assertEquals(-9, result.getScale()); + assertEquals(1L, result.getValue()); } + /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the boolean equals(Object) method test with another identical object. */ @Test - public void testEquals_5() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); + public void testEquals_same() { CtfTmfTimestamp obj = new CtfTmfTimestamp(1L); obj.setType(CtfTmfTimestamp.TimestampType.DAY); boolean result = fixture.equals(obj); - - // add additional test code here - assertEquals(true, result); + assertTrue(result); } /** - * Run the ITmfTimestamp getDelta(ITmfTimestamp) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the boolean equals(Object) method test, with an empty object. */ @Test - public void testGetDelta_1() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - ITmfTimestamp ts = new TmfTimestamp(); - - ITmfTimestamp result = fixture.getDelta(ts); + public void testEquals_empty() { + Object obj = new Object(); - // add additional test code here - assertNotNull(result); - assertEquals(0, result.getPrecision()); - assertEquals(-9, result.getScale()); - assertEquals(1L, result.getValue()); + boolean result = fixture.equals(obj); + assertFalse(result); } /** * Run the ITmfTimestamp getDelta(ITmfTimestamp) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetDelta_2() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); + public void testGetDelta() { ITmfTimestamp ts = new TmfTimestamp(); - ITmfTimestamp result = fixture.getDelta(ts); - // add additional test code here assertNotNull(result); assertEquals(0, result.getPrecision()); assertEquals(-9, result.getScale()); @@ -194,20 +121,11 @@ public class CtfTmfTimestampTest { /** * Run the CtfTmfTimestamp.TimestampType getType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetType_1() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - + public void testGetType() { CtfTmfTimestamp.TimestampType result = fixture.getType(); - // add additional test code here assertNotNull(result); assertEquals("DAY", result.name()); //$NON-NLS-1$ assertEquals("DAY", result.toString()); //$NON-NLS-1$ @@ -216,173 +134,68 @@ public class CtfTmfTimestampTest { /** * Run the int hashCode() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testHashCode_1() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - + public void testHashCode() { int result = fixture.hashCode(); - - // add additional test code here assertEquals(1012115, result); } /** * Run the int hashCode() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testHashCode_2() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); + public void testHashCode_nullType() { fixture.setType(null); - int result = fixture.hashCode(); - - // add additional test code here assertEquals(944663, result); } /** * Run the void setType(TimestampType) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSetType_1() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); + public void testSetType() { CtfTmfTimestamp.TimestampType value = CtfTmfTimestamp.TimestampType.DAY; - fixture.setType(value); - - // add additional test code here } /** * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testToString_1() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); + public void testToString_ns() { fixture.setType(CtfTmfTimestamp.TimestampType.NANOS); - String result = fixture.toString(); - - // add additional test code here assertEquals("1 ns", result); //$NON-NLS-1$ } /** * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testToString_2() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); + public void testToString_s() { fixture.setType(CtfTmfTimestamp.TimestampType.SECONDS); - String result = fixture.toString(); - - // add additional test code here assertEquals("1.0E-9 s", result); //$NON-NLS-1$ } /** * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testToString_3() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); - fixture.setType(CtfTmfTimestamp.TimestampType.DAY); - + public void testToString_day() { String result = fixture.toString(); - - // add additional test code here assertEquals("19:00:00.000000001", result); //$NON-NLS-1$ } /** * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testToString_4() - throws Exception { - CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); + public void testToString_full() { fixture.setType(CtfTmfTimestamp.TimestampType.FULL_DATE); - String result = fixture.toString(); - - // add additional test code here assertEquals("1969-12-31 19:00:00.000000001", result); //$NON-NLS-1$ } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfTmfTimestampTest.class); - } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java index a509ea07cb..ac7617260f 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; @@ -24,149 +37,131 @@ import org.junit.Before; import org.junit.Test; /** - * The class CtfTmfTraceTest contains tests for the class {@link CtfTmfTrace}. + * The class CtfTmfTraceTest contains tests for the class + * {@link CtfTmfTrace}. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ public class CtfTmfTraceTest { + private static final String PATH = TestParams.getPath(); + private CtfTmfTrace fixture; + /** - * Run the CtfTmfTrace() constructor test. + * Launch the test. * - * @throws Exception + * @param args + * the command line arguments + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(CtfTmfTraceTest.class); + } + + /** + * Perform pre-test initialization. * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @throws TmfTraceException + * If the test trace is not found */ - @Test - public void testCtfTmfTrace_1() - throws Exception { + @Before + public void setUp() throws TmfTraceException { + fixture = new CtfTmfTrace(); + fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class); + } + /** + * Perform post-test clean-up. + */ + @After + public void tearDown() { + fixture.dispose(); + } + + /** + * Run the CtfTmfTrace() constructor test. + */ + @Test + public void testCtfTmfTrace() { CtfTmfTrace result = new CtfTmfTrace(); - // add additional test code here assertNotNull(result); - assertEquals(null, result.getEventType()); + assertNull(result.getEventType()); assertEquals(1000, result.getCacheSize()); assertEquals(0L, result.getNbEvents()); assertEquals(0L, result.getStreamingInterval()); - assertEquals(null, result.getStateSystem()); - assertEquals(null, result.getResource()); + assertNull(result.getStateSystem()); + assertNull(result.getResource()); assertEquals(1000, result.getQueueSize()); - assertEquals(null, result.getType()); + assertNull(result.getType()); } + /** + * Test the parseEvent() method + */ @Test - public void testParseEvent() throws TmfTraceException{ - CtfTmfTrace fixture = initTrace(); + public void testParseEvent() { ITmfContext ctx = fixture.seekEvent(0); fixture.getNext(ctx); CtfTmfEvent event = fixture.parseEvent(ctx); assertNotNull(event); } - /** - * @return - * @throws TmfTraceException - */ - private static CtfTmfTrace initTrace() throws TmfTraceException { - CtfTmfTrace fixture = new CtfTmfTrace(); - fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class); - return fixture; - } /** * Run the void broadcast(TmfSignal) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testBroadcast_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testBroadcast() { TmfSignal signal = new TmfEndSynchSignal(1); - fixture.broadcast(signal); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) } /** * Run the void dispose() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testDispose_1() - throws Exception { - CtfTmfTrace fixture = new CtfTmfTrace(); - - fixture.dispose(); + public void testDispose() { + CtfTmfTrace emptyFixture = new CtfTmfTrace(); + emptyFixture.dispose(); } /** * Run the int getCacheSize() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetCacheSize_1() - throws Exception { - CtfTmfTrace fixture = new CtfTmfTrace(); - - int result = fixture.getCacheSize(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) + public void testGetCacheSize() { + CtfTmfTrace emptyFixture = new CtfTmfTrace(); + int result = emptyFixture.getCacheSize(); assertEquals(1000, result); } /** * Run the ITmfLocation getCurrentLocation() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetCurrentLocation_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetCurrentLocation() { CtfLocation result = (CtfLocation) fixture.getCurrentLocation(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNull(result); } + /** + * Test the seekEvent() method with a null location. + */ @Test - public void testSeekEventLoc_1() throws TmfTraceException { - CtfTmfTrace fixture = initTrace(); + public void testSeekEventLoc_null() { CtfLocation loc = null; fixture.seekEvent(loc); assertNotNull(fixture); } + /** + * Test the seekEvent() method with a location from a timestamp. + */ @Test - public void testSeekEventLoc_2() throws TmfTraceException { - CtfTmfTrace fixture = initTrace(); + public void testSeekEventLoc_timetamp(){ CtfLocation loc = new CtfLocation(new CtfTmfTimestamp(0L)); fixture.seekEvent(loc); assertNotNull(fixture); @@ -175,743 +170,202 @@ public class CtfTmfTraceTest { /** * Run the ITmfTimestamp getEndTime() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetEndTime_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testGetEndTime() { ITmfTimestamp result = fixture.getEndTime(); assertNotNull(result); } /** * Run the String[] getEnvNames() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetEnvNames_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetEnvNames() { String[] result = fixture.getEnvNames(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the String getEnvValue(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetEnvValue_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testGetEnvValue() { String key = "tracer_name"; //$NON-NLS-1$ - String result = fixture.getEnvValue(key); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertEquals("\"lttng-modules\"",result); //$NON-NLS-1$ } /** * Run the Class getEventType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetEventType_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetEventType() { Class result = fixture.getEventType(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the double getLocationRatio(ITmfLocation) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetLocationRatio_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testGetLocationRatio() { CtfLocation location = new CtfLocation(Long.valueOf(1)); location.setLocation(Long.valueOf(1)); - double result = fixture.getLocationRatio(location); - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertEquals(Double.NEGATIVE_INFINITY, result, 0.1); } /** * Run the String getName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testGetName_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - - String result = fixture.getName(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) - assertNotNull(result); - } - - /** - * Run the String getName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testGetName_2() - throws Exception { - CtfTmfTrace fixture = initTrace(); - - String result = fixture.getName(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) - assertNotNull(result); - } - - /** - * Run the String getName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetName_3() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetName() { String result = fixture.getName(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the int getNbEnvVars() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetNbEnvVars_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetNbEnvVars() { int result = fixture.getNbEnvVars(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertEquals(8, result); } /** * Run the long getNbEvents() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetNbEvents_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetNbEvents() { long result = fixture.getNbEvents(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertEquals(0L, result); } /** * Run the CtfTmfEvent getNext(ITmfContext) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetNext_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testGetNext() { ITmfContext context = fixture.seekEvent(0); - CtfTmfEvent result = fixture.getNext(context); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the String getPath() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetPath_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetPath() { String result = fixture.getPath(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the IResource getResource() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetResource_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetResource() { IResource result = fixture.getResource(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNull(result); } /** * Run the ITmfTimestamp getStartTime() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetStartTime_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetStartTime() { ITmfTimestamp result = fixture.getStartTime(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the IStateSystemQuerier getStateSystem() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetStateSystem_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testGetStateSystem() { IStateSystemQuerier result = fixture.getStateSystem(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNull(result); } /** * Run the long getStreamingInterval() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetStreamingInterval_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetStreamingInterval() { long result = fixture.getStreamingInterval(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertEquals(0L, result); } /** * Run the TmfTimeRange getTimeRange() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testGetTimeRange_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - + public void testGetTimeRange() { TmfTimeRange result = fixture.getTimeRange(); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_2() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_3() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_4() - throws Exception { - CtfTmfTrace fixture = initTrace(); - - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_5() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_6() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - - /** - * Run the void initTrace(IResource,String,Class) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testInitTrace_7() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IResource resource = null; - String path = PATH; - Class eventType = CtfTmfEvent.class; - - fixture.initTrace(resource, path, eventType); - - assertNotNull(fixture); - } - /** * Run the CtfTmfEvent readNextEvent(ITmfContext) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testReadNextEvent_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testReadNextEvent() { ITmfContext context = fixture.seekEvent(0); - CtfTmfEvent result = fixture.getNext(context); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the ITmfContext seekEvent(double) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSeekEvent_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testSeekEvent_ratio() { double ratio = 0.99; - ITmfContext result = fixture.seekEvent(ratio); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the ITmfContext seekEvent(long) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSeekEvent_2() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testSeekEvent_rank() { long rank = 1L; - ITmfContext result = fixture.seekEvent(rank); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } /** * Run the ITmfContext seekEvent(ITmfTimestamp) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testSeekEvent_3() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testSeekEvent_timestamp() { ITmfTimestamp timestamp = new TmfTimestamp(); - ITmfContext result = fixture.seekEvent(timestamp); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertNotNull(result); } -// /** -// * Run the ITmfContext seekEvent(ITmfLocation) method test. -// * -// * @throws Exception -// * -// * @generatedBy CodePro at 03/05/12 2:29 PM -// */ -// @Test -// public void testSeekEvent_4() -// throws Exception { -// CtfTmfTrace fixture = initTrace(); -// fixture.setStartTime(new TmfTimestamp()); -// CtfIterator ctfIterator = new CtfIterator(new CtfTmfTrace()); -// CtfLocation ctfLocation = new CtfLocation(new Long(1L)); -// ctfLocation.setLocation(new Long(1L)); -// ctfIterator.setLocation(ctfLocation); -// fixture.iterator = ctfIterator; -// fixture.ss = new StateHistorySystem(new HistoryTreeBackend(new File(PATH)), true); -// fixture.startSynch(new TmfStartSynchSignal(1)); -// fixture.fNbEvents = 1L; -// ITmfLocation location = new CtfLocation(new Long(1L)); -// -// ITmfContext result = fixture.seekEvent(location); -// -// // add additional test code here -// // An unexpected exception was thrown in user code while executing this test: -// // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory -// // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) -// assertNotNull(result); -// } -// -// /** -// * Run the ITmfContext seekEvent(ITmfLocation) method test. -// * -// * @throws Exception -// * -// * @generatedBy CodePro at 03/05/12 2:29 PM -// */ -// @Test -// public void testSeekEvent_5() -// throws Exception { -// CtfTmfTrace fixture = initTrace(); -// CtfIterator ctfIterator = new CtfIterator(new CtfTmfTrace()); -// CtfLocation ctfLocation = new CtfLocation(new Long(1L)); -// ITmfContext result = fixture.seekEvent(ctfLocation); -// assertNotNull(result); -// } - - - - /** - * Run the boolean validate(IProject,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Test - public void testValidate_1() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IProject project = null; - String path = PATH; - - boolean result = fixture.validate(project, path); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) - assertTrue(result); - } - /** - * Run the boolean validate(IProject,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * Run the ITmfContext seekEvent(ITmfLocation) method test. */ @Test - public void testValidate_2() - throws Exception { - CtfTmfTrace fixture = initTrace(); - IProject project = null; - String path = PATH; - - boolean result = fixture.validate(project, path); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) - assertTrue(result); + public void testSeekEvent_location() { + CtfLocation ctfLocation = new CtfLocation(new Long(1L)); + ITmfContext result = fixture.seekEvent(ctfLocation); + assertNotNull(result); } /** * Run the boolean validate(IProject,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 03/05/12 2:29 PM */ @Test - public void testValidate_3() - throws Exception { - CtfTmfTrace fixture = initTrace(); + public void testValidate() { IProject project = null; String path = PATH; - boolean result = fixture.validate(project, path); - - // add additional test code here - // An unexpected exception was thrown in user code while executing this test: - // org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory - // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98) assertTrue(result); } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(CtfTmfTraceTest.class); - } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestAll.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestAll.java index 7b424eb9f9..cc8e4b3d75 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestAll.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestAll.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial generation with CodePro tools + * Alexandre Montplaisir - Clean up, consolidate redundant tests + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import org.junit.runner.JUnitCore; @@ -9,29 +22,27 @@ import org.junit.runners.Suite; * of the tests within its package as well as within any subpackages of its * package. * - * @generatedBy CodePro at 03/05/12 2:29 PM * @author ematkho - * @version $Revision: 1.0 $ + * @version 1.0 */ @RunWith(Suite.class) @Suite.SuiteClasses({ - CtfTmfContentTest.class, - CtfTmfTimestampTest.class, - CtfTmfEventFieldTest.class, - CtfTmfEventTypeTest.class, CtfIteratorTest.class, CtfLocationTest.class, - CtfTmfTraceTest.class, + CtfTmfContentTest.class, + CtfTmfEventFieldTest.class, CtfTmfEventTest.class, + CtfTmfEventTypeTest.class, + CtfTmfTimestampTest.class, + CtfTmfTraceTest.class }) public class TestAll { /** * Launch the test. * - * @param args the command line arguments - * - * @generatedBy CodePro at 03/05/12 2:29 PM + * @param args + * the command line arguments */ public static void main(String[] args) { JUnitCore.runClasses(new Class[] { TestAll.class }); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java index f2c346dbaf..c2bf932672 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import java.io.File; @@ -6,11 +18,13 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; - -public abstract class TestParams { +/** + * This is the set up for the trace files to be used with the ctfAdaptor tests. + */ +abstract class TestParams { /* Path to test traces */ - private static final String testTracePath1 = "testfiles/kernel"; //$NON-NLS-1$ + private static final String testTracePath1 = "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"; //$NON-NLS-1$ private static CtfTmfTrace testTrace1 = null; private static final File emptyFile = new File(""); //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java index 201166ff7c..7c92ca4d09 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java @@ -9,6 +9,7 @@ * Contributors: * Matthew Khouzam - Initial API and implementation *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.headless; import java.util.Vector; @@ -18,14 +19,20 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; +/** + * Test and benchmark reading a CTF LTTng kernel trace. + * + * @author Matthew Khouzam + */ public class Benchmark { /** - * @param args + * Run the benchmark. + * + * @param args The command-line arguments */ - @SuppressWarnings("nls") public static void main(final String[] args) { - final String TRACE_PATH = "testfiles/kernel"; + final String TRACE_PATH = "testfiles/kernel"; //$NON-NLS-1$ final int NUM_LOOPS = 100; // Change this to enable text output @@ -61,9 +68,9 @@ public class Benchmark { nbEvent++; if (USE_TEXT) { - System.out.println("Event " + traceReader.getRank() + " Time " - + current.getTimestamp().toString() + " type " + current.getEventName() - + " on CPU " + current.getSource() + " " + current.getContent().toString()) ; + System.out.println("Event " + traceReader.getRank() + " Time " //$NON-NLS-1$ //$NON-NLS-2$ + + current.getTimestamp().toString() + " type " + current.getEventName() //$NON-NLS-1$ + + " on CPU " + current.getSource() + " " + current.getContent().toString()) ; //$NON-NLS-1$ //$NON-NLS-2$ } traceReader.advance(); current = traceReader.getCurrentEvent(); @@ -74,16 +81,16 @@ public class Benchmark { final double time = (stop - start) / (double) nbEvent; benchs.add(time); } - System.out.println(""); + System.out.println(""); //$NON-NLS-1$ double avg = 0; for (final Double val : benchs) { avg += val; } avg /= benchs.size(); - System.out.println("Time to read = " + avg + " events/ns"); + System.out.println("Time to read = " + avg + " events/ns"); //$NON-NLS-1$ //$NON-NLS-2$ for (final Double val : benchs) { System.out.print(val); - System.out.print(", "); + System.out.print(", "); //$NON-NLS-1$ } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/RequestBenchmark.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/RequestBenchmark.java index 45064e5e1b..57a7c7fbc9 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/RequestBenchmark.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/RequestBenchmark.java @@ -7,14 +7,15 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation + * William Bourque - Initial API and implementation + * Matthew Khouzam - Update to CtfTmf trace and events *******************************************************************************/ + package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.headless; import java.util.Vector; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; -import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; @@ -22,63 +23,61 @@ import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment; -@SuppressWarnings("nls") +/** + * Benchmark the event request subsystem of TMF. + */ public class RequestBenchmark extends TmfEventRequest { @SuppressWarnings("unchecked") - public RequestBenchmark(final Class dataType, + private RequestBenchmark(final Class dataType, final TmfTimeRange range, final int nbRequested) { super((Class) dataType, range, nbRequested, 1); } // Path of the trace - public static final String TRACE_PATH = "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"; - - // *** Change this to run several time over the same trace - public static final int NB_OF_PASS = 100; + private static final String TRACE_PATH = "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"; //$NON-NLS-1$ - // *** Change this to true to parse all the events in the trace - // Otherwise, events are just read - public final boolean PARSE_EVENTS = true; + // Change this to run several time over the same trace + private static final int NB_OF_PASS = 100; // Work variables - static int nbEvent = 0; - static int nbPassDone = 0; - static TmfExperiment fExperiment = null; - static Vector benchs = new Vector(); - + private static int nbEvent = 0; + private static TmfExperiment fExperiment = null; + private static Vector benchs = new Vector(); + + /** + * Run the benchmark + * + * @param args + * The command-line arguments + */ public static void main(final String[] args) { try { - // OUr experiment will contains ONE trace + /* Our experiment will contains ONE trace */ @SuppressWarnings("unchecked") - final - ITmfTrace[] traces = new ITmfTrace[1]; + final ITmfTrace[] traces = new ITmfTrace[1]; traces[0] = new CtfTmfTrace(); traces[0].initTrace(null, TRACE_PATH, CtfTmfEvent.class); - // Create our new experiment - fExperiment = new TmfExperiment(CtfTmfEvent.class, "Headless", traces); - - // Create a new time range from -infinity to +infinity - // That way, we will get "everything" in the trace - final CtfTmfTimestamp ts1 = new CtfTmfTimestamp(Long.MIN_VALUE); - final CtfTmfTimestamp ts2 = new CtfTmfTimestamp(Long.MAX_VALUE); - final TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2); + /* Create our new experiment */ + fExperiment = new TmfExperiment(CtfTmfEvent.class, "Headless", traces); //$NON-NLS-1$ - // We will issue a request for each "pass". - // TMF will then process them synchonously + /* + * We will issue a request for each "pass". TMF will then process + * them synchronously. + */ RequestBenchmark request = null; for (int x = 0; x < NB_OF_PASS; x++) { - request = new RequestBenchmark(CtfTmfEvent.class, tmpRange, - Integer.MAX_VALUE); + request = new RequestBenchmark(CtfTmfEvent.class, + TmfTimeRange.ETERNITY, Integer.MAX_VALUE); fExperiment.sendRequest(request); - nbPassDone++; } prev = System.nanoTime(); } catch (final NullPointerException e) { - // Silently dismiss Null pointer exception - // The only way to "finish" the threads in TMF is by crashing them - // with null + /* + * Silently dismiss Null pointer exception The only way to "finish" + * the threads in TMF is by crashing them with null. + */ } catch (final Exception e) { e.printStackTrace(); } @@ -106,10 +105,10 @@ public class RequestBenchmark extends TmfEventRequest { benchs.add(val); if (benchs.size() == NB_OF_PASS) { try { - System.out.println("Nb events : " + nbEvent2); + System.out.println("Nb events : " + nbEvent2); //$NON-NLS-1$ for (final double value : benchs) { - System.out.print(value + ", "); + System.out.print(value + ", "); //$NON-NLS-1$ } fExperiment.sendRequest(null); -- 2.34.1