From 2ba3d0a19664aeb0c66a032fac1dcc05ef164188 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 25 Jan 2013 15:05:20 -0500 Subject: [PATCH] lttng: Port unit tests to JUnit4 Refs bug 393449. Change-Id: I84d3f62d0e1dd1b8bd1d0ad00f3347cc86df6ad2 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/10056 Tested-by: Hudson CI Reviewed-by: Patrick Tasse IP-Clean: Patrick Tasse --- .../lttng2/core/tests/ActivatorTest.java | 53 ++--------- .../lttng2/core/tests/AllTests.java | 27 +++--- .../tests/control/model/impl/AllTests.java | 40 ++++----- .../control/model/impl/BaseEventInfoTest.java | 75 +++++++++------- .../control/model/impl/ChannelInfoTest.java | 81 ++++++++++------- .../control/model/impl/DomainInfoTest.java | 75 ++++++++++------ .../control/model/impl/EventInfoTest.java | 64 +++++++++----- .../control/model/impl/FieldInfoTest.java | 67 ++++++++------ .../control/model/impl/ModelImplFactory.java | 1 + .../model/impl/ProbeEventInfoTest.java | 58 ++++++++----- .../control/model/impl/SessionInfoTest.java | 76 ++++++++++------ .../control/model/impl/TraceInfoTest.java | 65 ++++++++------ .../model/impl/UstProviderInfoTest.java | 81 ++++++++++------- .../META-INF/MANIFEST.MF | 2 +- .../lttng2/kernel/core/tests/AllTests.java | 3 +- .../CtfKernelStateInputTest.java | 27 +++--- .../core/tests/stateprovider/TestAll.java | 9 +- .../lttng2/kernel/ui/tests/ActivatorTest.java | 48 ++-------- .../lttng2/kernel/ui/tests/AllTests.java | 25 ++---- .../lttng2/ui/tests/ActivatorTest.java | 48 ++-------- .../linuxtools/lttng2/ui/tests/AllTests.java | 29 +++---- .../control/model/component/AllTests.java | 38 ++++---- .../component/TraceControlComponentTest.java | 87 +++++++------------ .../TraceControlKernelProviderTests.java | 49 ++++------- .../TraceControlKernelSessionTests.java | 51 +++++------ .../component/TraceControlPropertiesTest.java | 57 +++--------- .../component/TraceControlTestFacility.java | 1 + .../TraceControlTreeModelNoProvidersTest.java | 43 ++++----- .../component/TraceControlTreeModelTest.java | 43 ++++----- .../TraceControlUstProviderTests.java | 41 +++------ .../TraceControlUstSessionTests.java | 41 +++------ .../ui/tests/control/service/AllTests.java | 23 ++--- .../service/LTTngControlServiceTest.java | 73 ++++++++++------ 33 files changed, 717 insertions(+), 784 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/ActivatorTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/ActivatorTest.java index 1d87f386d7..4882f03c8f 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/ActivatorTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/ActivatorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,61 +8,26 @@ * * Contributors: * Francois Chouinard - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ package org.eclipse.linuxtools.lttng2.core.tests; -import junit.framework.TestCase; +import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** - * ActivatorTest - *

- * Test suite for the Activator class - *

+ * Test stubs for the Activator. */ -@SuppressWarnings("javadoc") -public class ActivatorTest extends TestCase { - - // ------------------------------------------------------------------------ - // JUnit - // ------------------------------------------------------------------------ - - @BeforeClass - public static void setUpBeforeClass() { - } - - @AfterClass - public static void tearDownAfterClass() { - } - - /** - * @throws java.lang.Exception - */ - @Before - @Override - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - @Override - public void tearDown() throws Exception { - } +public class ActivatorTest { // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** - * Test method for {@link org.eclipse.linuxtools.lttng2.core.Activator#Activator()}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.core.Activator#Activator()}. */ @Test public void testActivator() { @@ -70,7 +35,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.lttng2.core.Activator#getDefault()}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.core.Activator#getDefault()}. */ @Test public void testGetDefault() { @@ -78,7 +43,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.lttng2.core.Activator#start(org.osgi.framework.BundleContext)}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.core.Activator#start(org.osgi.framework.BundleContext)}. */ @Test public void testStartBundleContext() { @@ -86,7 +51,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.lttng2.core.Activator#stop(org.osgi.framework.BundleContext)}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.core.Activator#stop(org.osgi.framework.BundleContext)}. */ @Test public void testStopBundleContext() { diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/AllTests.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/AllTests.java index 3f83720290..6248314ea8 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,29 +8,22 @@ * * Contributors: * Francois Chouinard - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ package org.eclipse.linuxtools.lttng2.core.tests; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** - * AllTests - *

+ * Run all the tests in the lttng2.core plugin. */ -@SuppressWarnings("javadoc") +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ActivatorTest.class, + org.eclipse.linuxtools.lttng2.core.tests.control.model.impl.AllTests.class +}) public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite(AllTests.class.getName()); - // $JUnit-BEGIN$ - - // Plug-in - suite.addTestSuite(ActivatorTest.class); - suite.addTest(org.eclipse.linuxtools.lttng2.core.tests.control.model.impl.AllTests.suite()); - - // $JUnit-END$ - return suite; - } } diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/AllTests.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/AllTests.java index e502b82858..fdbf937756 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Ericsson + * Copyright (c) 2011, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,29 +8,29 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; -@SuppressWarnings("javadoc") +/** + * Runner for the LTTng2.core unit tests + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + BaseEventInfoTest.class, + ChannelInfoTest.class, + DomainInfoTest.class, + EventInfoTest.class, + FieldInfoTest.class, + ProbeEventInfoTest.class, + SessionInfoTest.class, + TraceInfoTest.class, + UstProviderInfoTest.class +}) public class AllTests { - public static Test suite() { - - TestSuite suite = new TestSuite(AllTests.class.getName()); - //$JUnit-BEGIN$ - suite.addTestSuite(FieldInfoTest.class); - suite.addTestSuite(BaseEventInfoTest.class); - suite.addTestSuite(DomainInfoTest.class); - suite.addTestSuite(EventInfoTest.class); - suite.addTestSuite(ProbeEventInfoTest.class); - suite.addTestSuite(ChannelInfoTest.class); - suite.addTestSuite(SessionInfoTest.class); - suite.addTestSuite(TraceInfoTest.class); - suite.addTestSuite(UstProviderInfoTest.class); - //$JUnit-END$ - return suite; - } } diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/BaseEventInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/BaseEventInfoTest.java index 352a8ffab1..3004974f06 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/BaseEventInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/BaseEventInfoTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,30 +8,36 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; +import static org.junit.Assert.*; + import java.util.LinkedList; import java.util.List; -import junit.framework.TestCase; - import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class BaseEventInfoTest contains test for the class {@link BaseEventInfo}. + * The class BaseEventInfoTest contains test for the class + * {@link BaseEventInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class BaseEventInfoTest extends TestCase { +@SuppressWarnings("nls") +public class BaseEventInfoTest { // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IBaseEventInfo fEventInfo1 = null; private IBaseEventInfo fEventInfo2 = null; @@ -40,36 +46,22 @@ public class BaseEventInfoTest extends TestCase { // ------------------------------------------------------------------------ /** * Perform pre-test initialization. - * - * @throws Exception if the initialization fails for some reason - * */ - @Override - public void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fEventInfo1 = factory.getBaseEventInfo1(); fEventInfo2 = factory.getBaseEventInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception if the clean-up fails for some reason - * - */ - @Override - public void tearDown() throws Exception { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** * Run the BaseEventInfo() constructor test. - * */ + @Test public void testBaseEventInfo() { BaseEventInfo fixture = new BaseEventInfo("event"); assertNotNull(fixture); @@ -92,6 +84,7 @@ public class BaseEventInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventInfoCopy() { BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo1); @@ -112,6 +105,7 @@ public class BaseEventInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventCopy2() { try { BaseEventInfo info = null; @@ -125,10 +119,8 @@ public class BaseEventInfoTest extends TestCase { /** * Run the TraceEventType getEventType() method test. - * - * @throws Exception - * */ + @Test public void testGetEventType_1() { BaseEventInfo fixture = new BaseEventInfo("event"); fixture.setEventType("unknown"); @@ -176,8 +168,8 @@ public class BaseEventInfoTest extends TestCase { /** * Run the void setEventType(TraceEventType) method test. - * */ + @Test public void testSetEventType_2() { BaseEventInfo fixture = new BaseEventInfo("event"); fixture.setEventType(TraceEventType.TRACEPOINT); @@ -220,8 +212,8 @@ public class BaseEventInfoTest extends TestCase { /** * Run the void setLogLevel(TraceLogLevel) method test. * Run the TraceLogLevel getLogLevel() method test - * */ + @Test public void testSetLogLevel1() { BaseEventInfo fixture = new BaseEventInfo("event"); fixture.setEventType(TraceEventType.TRACEPOINT); @@ -248,8 +240,8 @@ public class BaseEventInfoTest extends TestCase { /** * Run the void setLogLevel(String) method test. * Run the TraceLogLevel getLogLevel() method test - * */ + @Test public void testSetLogLevel2() { BaseEventInfo fixture = new BaseEventInfo("event"); fixture.setEventType(TraceEventType.TRACEPOINT); @@ -408,6 +400,7 @@ public class BaseEventInfoTest extends TestCase { /** * test filter expression */ + @Test public void testSetFields() { BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2); info.setFilterExpression("stringfield==test"); @@ -418,6 +411,7 @@ public class BaseEventInfoTest extends TestCase { /** * test add field */ + @Test public void testAddField() { BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2); @@ -438,6 +432,7 @@ public class BaseEventInfoTest extends TestCase { /** * test set fields */ + @Test public void testFields() { BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2); @@ -466,8 +461,8 @@ public class BaseEventInfoTest extends TestCase { /** * Run the String toString() method test. - * */ + @Test public void testToString_1() { BaseEventInfo fixture = new BaseEventInfo("event"); fixture.setName("testName"); @@ -484,6 +479,10 @@ public class BaseEventInfoTest extends TestCase { // equals // ------------------------------------------------------------------------ + /** + * Test the .equals() method. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fEventInfo1.equals(fEventInfo1)); assertTrue("equals", fEventInfo2.equals(fEventInfo2)); @@ -492,6 +491,10 @@ public class BaseEventInfoTest extends TestCase { assertTrue("equals", !fEventInfo2.equals(fEventInfo1)); } + /** + * Test the .equals() method. + */ + @Test public void testEqualsSymmetry() { BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1); BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2); @@ -503,6 +506,10 @@ public class BaseEventInfoTest extends TestCase { assertTrue("equals", fEventInfo2.equals(info2)); } + /** + * Test the .equals() method. + */ + @Test public void testEqualsTransivity() { BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1); BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo1); @@ -513,6 +520,10 @@ public class BaseEventInfoTest extends TestCase { assertTrue("equals", info1.equals(info3)); } + /** + * Test the .equals() method. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fEventInfo1.equals(null)); assertTrue("equals", !fEventInfo2.equals(null)); @@ -522,6 +533,10 @@ public class BaseEventInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Test the hashCode() method. + */ + @Test public void testHashCode() { BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1); BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ChannelInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ChannelInfoTest.java index 2c0d7c0aaf..dec59c2089 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ChannelInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ChannelInfoTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,29 +8,35 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; +import static org.junit.Assert.*; + import java.util.LinkedList; import java.util.List; -import junit.framework.TestCase; - import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class ChannelInfoTest contains tests for the class {@link ChannelInfo}. - * + * The class ChannelInfoTest contains tests for the class + * {@link ChannelInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class ChannelInfoTest extends TestCase { +@SuppressWarnings("nls") +public class ChannelInfoTest { + // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IChannelInfo fChannelInfo1 = null; private IChannelInfo fChannelInfo2 = null; @@ -40,29 +46,14 @@ public class ChannelInfoTest extends TestCase { /** * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * */ - @Override + @Before public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fChannelInfo1 = factory.getChannel1(); fChannelInfo2 = factory.getChannel2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - */ - @Override - public void tearDown() { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ @@ -73,8 +64,8 @@ public class ChannelInfoTest extends TestCase { /** * Run the ChannelInfo() constructor test. - * */ + @Test public void testChannelInfo() { ChannelInfo result = new ChannelInfo("test"); assertNotNull(result); @@ -89,6 +80,10 @@ public class ChannelInfoTest extends TestCase { assertEquals(0, result.getSwitchTimer()); } + /** + * Test copy constructor. + */ + @Test public void testChannelInfoCopy() { ChannelInfo channelInfo = new ChannelInfo((ChannelInfo)fChannelInfo1); @@ -108,6 +103,10 @@ public class ChannelInfoTest extends TestCase { } } + /** + * Test copy constructor with a null value. + */ + @Test public void testChannelCopy2() { try { ChannelInfo channel = null; @@ -121,8 +120,8 @@ public class ChannelInfoTest extends TestCase { /** * Run the IEventInfo[] getEvents() method test. - * */ + @Test public void testAddAndGetEvents_1() { ChannelInfo fixture = new ChannelInfo("test"); fixture.setSwitchTimer(1L); @@ -148,8 +147,8 @@ public class ChannelInfoTest extends TestCase { /** * Run the long getNumberOfSubBuffers() method test. - * */ + @Test public void testGetAndSetters() { ChannelInfo fixture = new ChannelInfo("test"); fixture.setSwitchTimer(2L); @@ -214,8 +213,8 @@ public class ChannelInfoTest extends TestCase { /** * Run the void setEvents(List) method test. - * */ + @Test public void testSetEvents_1() { ChannelInfo fixture = new ChannelInfo("test"); fixture.setSwitchTimer(1L); @@ -245,6 +244,10 @@ public class ChannelInfoTest extends TestCase { } } + /** + * Run the String toString() method test. + */ + @Test public void testToString_1() { ChannelInfo fixture = new ChannelInfo("channel"); fixture.setSwitchTimer(1L); @@ -262,9 +265,9 @@ public class ChannelInfoTest extends TestCase { } /** - * Run the String toString() method test. - * + * Run another String toString() method test. */ + @Test public void testToString_2() { String result = fChannelInfo1.toString(); @@ -276,6 +279,10 @@ public class ChannelInfoTest extends TestCase { // equals // ------------------------------------------------------------------------ + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fChannelInfo1.equals(fChannelInfo1)); assertTrue("equals", fChannelInfo2.equals(fChannelInfo2)); @@ -284,6 +291,10 @@ public class ChannelInfoTest extends TestCase { assertTrue("equals", !fChannelInfo2.equals(fChannelInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { ChannelInfo event1 = new ChannelInfo((ChannelInfo)fChannelInfo1); ChannelInfo event2 = new ChannelInfo((ChannelInfo)fChannelInfo2); @@ -295,6 +306,10 @@ public class ChannelInfoTest extends TestCase { assertTrue("equals", fChannelInfo2.equals(event2)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1); ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo1); @@ -305,6 +320,10 @@ public class ChannelInfoTest extends TestCase { assertTrue("equals", channel1.equals(channel3)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fChannelInfo1.equals(null)); assertTrue("equals", !fChannelInfo2.equals(null)); @@ -314,6 +333,10 @@ public class ChannelInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the hashCode() method test. + */ + @Test public void testHashCode() { ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1); ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/DomainInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/DomainInfoTest.java index 9f213b87f2..f1df153ab8 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/DomainInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/DomainInfoTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,27 +8,33 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; +import static org.junit.Assert.*; + import java.util.LinkedList; import java.util.List; -import junit.framework.TestCase; - import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class ChannelInfoTest contains tests for the class {@link DomainInfo}. - * + * The class ChannelInfoTest contains tests for the class + * {@link DomainInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class DomainInfoTest extends TestCase { +@SuppressWarnings("nls") +public class DomainInfoTest { + // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IDomainInfo fDomainInfo1 = null; private IDomainInfo fDomainInfo2 = null; private IChannelInfo fChannelInfo1 = null; @@ -40,12 +46,8 @@ public class DomainInfoTest extends TestCase { /** * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * */ - @Override + @Before public void setUp() { // Get test instances from the factory ModelImplFactory factory = new ModelImplFactory(); @@ -55,17 +57,6 @@ public class DomainInfoTest extends TestCase { fDomainInfo2 = factory.getDomainInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - */ - @Override - public void tearDown() { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ @@ -76,8 +67,8 @@ public class DomainInfoTest extends TestCase { /** * Run the ChannelInfo() constructor test. - * */ + @Test public void testDomainInfo() { DomainInfo result = new DomainInfo("test"); assertNotNull(result); @@ -86,6 +77,10 @@ public class DomainInfoTest extends TestCase { assertEquals(0, result.getChannels().length); } + /** + * Test the copy constructor. + */ + @Test public void testDomainInfoCopy() { DomainInfo channelInfo = new DomainInfo((DomainInfo)fDomainInfo1); IChannelInfo[] orignalEvents = fDomainInfo1.getChannels(); @@ -95,6 +90,10 @@ public class DomainInfoTest extends TestCase { } } + /** + * Test the copy constructor. + */ + @Test public void testDomainlCopy2() { try { DomainInfo domain = null; @@ -108,8 +107,8 @@ public class DomainInfoTest extends TestCase { /** * Run the long getNumberOfSubBuffers() method test. - * */ + @Test public void testGetAndSetters() { // Note that addChannel() has been executed in setUp() @@ -130,6 +129,10 @@ public class DomainInfoTest extends TestCase { assertEquals(fChannelInfo2, result[1]); } + /** + * Run the String toString() method test. + */ + @Test public void testToString_1() { DomainInfo fixture = new DomainInfo("domain"); @@ -140,8 +143,8 @@ public class DomainInfoTest extends TestCase { /** * Run the String toString() method test. - * */ + @Test public void testToString_2() { String result = fDomainInfo1.toString(); @@ -152,6 +155,10 @@ public class DomainInfoTest extends TestCase { // equals // ------------------------------------------------------------------------ + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fDomainInfo1.equals(fDomainInfo1)); assertTrue("equals", fDomainInfo2.equals(fDomainInfo2)); @@ -160,6 +167,10 @@ public class DomainInfoTest extends TestCase { assertTrue("equals", !fDomainInfo2.equals(fDomainInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { DomainInfo event1 = new DomainInfo((DomainInfo)fDomainInfo1); DomainInfo event2 = new DomainInfo((DomainInfo)fDomainInfo2); @@ -171,6 +182,10 @@ public class DomainInfoTest extends TestCase { assertTrue("equals", fDomainInfo2.equals(event2)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { DomainInfo channel1 = new DomainInfo((DomainInfo)fDomainInfo1); DomainInfo channel2 = new DomainInfo((DomainInfo)fDomainInfo1); @@ -181,6 +196,10 @@ public class DomainInfoTest extends TestCase { assertTrue("equals", channel1.equals(channel3)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fDomainInfo1.equals(null)); assertTrue("equals", !fDomainInfo2.equals(null)); @@ -190,6 +209,10 @@ public class DomainInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the hashCode() method test. + */ + @Test public void testHashCode() { DomainInfo channel1 = new DomainInfo((DomainInfo)fDomainInfo1); DomainInfo channel2 = new DomainInfo((DomainInfo)fDomainInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/EventInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/EventInfoTest.java index 10ac5932d9..2466c54407 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/EventInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/EventInfoTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,62 +8,59 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class BaseEventInfoTest contains test for the class {@link BaseEventInfo}. + * The class EventInfoTest contains test for the class + * {@link EventInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class EventInfoTest extends TestCase { +@SuppressWarnings("nls") +public class EventInfoTest { // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IEventInfo fEventInfo1 = null; private IEventInfo fEventInfo2 = null; // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ + /** * Perform pre-test initialization. - * - * @throws Exception if the initialization fails for some reason - * */ - @Override - public void setUp() throws Exception { + @Before + public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fEventInfo1 = factory.getEventInfo1(); fEventInfo2 = factory.getEventInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception if the clean-up fails for some reason - * - */ - @Override - public void tearDown() throws Exception { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** * Run the BaseEventInfo() constructor test. - * */ + @Test public void testBaseEventInfo() { EventInfo fixture = new EventInfo("event"); assertNotNull(fixture); @@ -87,6 +84,7 @@ public class EventInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventInfoCopy() { EventInfo info = new EventInfo((EventInfo)fEventInfo1); @@ -98,6 +96,7 @@ public class EventInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventCopy2() { try { EventInfo info = null; @@ -112,6 +111,7 @@ public class EventInfoTest extends TestCase { /** * Getter/Setter tests */ + @Test public void testGetAndSetter() { EventInfo fixture = new EventInfo("event"); @@ -193,6 +193,7 @@ public class EventInfoTest extends TestCase { /** * Run the String toString() method test. */ + @Test public void testToString_1() { EventInfo fixture = new EventInfo("event"); fixture.setName("testName"); @@ -207,6 +208,11 @@ public class EventInfoTest extends TestCase { // ------------------------------------------------------------------------ // equals // ------------------------------------------------------------------------ + + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fEventInfo1.equals(fEventInfo1)); assertTrue("equals", fEventInfo2.equals(fEventInfo2)); @@ -215,6 +221,10 @@ public class EventInfoTest extends TestCase { assertTrue("equals", !fEventInfo2.equals(fEventInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { EventInfo info1 = new EventInfo((EventInfo)fEventInfo1); EventInfo info2 = new EventInfo((EventInfo)fEventInfo2); @@ -226,6 +236,10 @@ public class EventInfoTest extends TestCase { assertTrue("equals", fEventInfo2.equals(info2)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { EventInfo info1 = new EventInfo((EventInfo)fEventInfo1); EventInfo info2 = new EventInfo((EventInfo)fEventInfo1); @@ -236,6 +250,10 @@ public class EventInfoTest extends TestCase { assertTrue("equals", info1.equals(info3)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fEventInfo1.equals(null)); assertTrue("equals", !fEventInfo2.equals(null)); @@ -245,6 +263,10 @@ public class EventInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the hashCode() method test. + */ + @Test public void testHashCode() { EventInfo info1 = new EventInfo((EventInfo)fEventInfo1); EventInfo info2 = new EventInfo((EventInfo)fEventInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java index 9e391b2c6c..3e2a7a334f 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,61 +8,54 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; -import junit.framework.TestCase; +import static org.junit.Assert.*; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class FieldInfoTest contains test for the class {@link FieldInfo}. + * The class FieldInfoTest contains test for the class + * {@link FieldInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class FieldInfoTest extends TestCase { +@SuppressWarnings("nls") +public class FieldInfoTest { // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IFieldInfo fFieldInfo1 = null; private IFieldInfo fFieldInfo2 = null; // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ + /** * Perform pre-test initialization. - * - * @throws Exception if the initialization fails for some reason - * */ - @Override - public void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fFieldInfo1 = factory.getFieldInfo1(); fFieldInfo2 = factory.getFieldInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception if the clean-up fails for some reason - * - */ - @Override - public void tearDown() throws Exception { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** * Run the BaseEventInfo() constructor test. - * */ + @Test public void testFiledInfo() { FieldInfo fixture = new FieldInfo("field"); assertNotNull(fixture); @@ -74,6 +67,7 @@ public class FieldInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventInfoCopy() { FieldInfo info = new FieldInfo((FieldInfo)fFieldInfo1); @@ -84,6 +78,7 @@ public class FieldInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventCopy2() { try { FieldInfo info = null; @@ -97,10 +92,8 @@ public class FieldInfoTest extends TestCase { /** * Run the TraceEventType getEventType() method test. - * - * @throws Exception - * */ + @Test public void testSetFieldType() { FieldInfo info = new FieldInfo((FieldInfo)fFieldInfo1); @@ -108,6 +101,10 @@ public class FieldInfoTest extends TestCase { assertEquals("string", info.getFieldType()); } + /** + * Run the toString() method test. + */ + @Test public void testToString() { String result = fFieldInfo1.toString(); @@ -119,6 +116,10 @@ public class FieldInfoTest extends TestCase { // equals // ------------------------------------------------------------------------ + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fFieldInfo1.equals(fFieldInfo1)); assertTrue("equals", fFieldInfo2.equals(fFieldInfo2)); @@ -127,6 +128,10 @@ public class FieldInfoTest extends TestCase { assertTrue("equals", !fFieldInfo2.equals(fFieldInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { FieldInfo info1 = new FieldInfo((FieldInfo)fFieldInfo1); FieldInfo info2 = new FieldInfo((FieldInfo)fFieldInfo2); @@ -138,6 +143,10 @@ public class FieldInfoTest extends TestCase { assertTrue("equals", fFieldInfo2.equals(info2)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { FieldInfo info1 = new FieldInfo((FieldInfo)fFieldInfo1); FieldInfo info2 = new FieldInfo((FieldInfo)fFieldInfo1); @@ -148,6 +157,10 @@ public class FieldInfoTest extends TestCase { assertTrue("equals", info1.equals(info3)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fFieldInfo1.equals(null)); assertTrue("equals", !fFieldInfo2.equals(null)); @@ -157,6 +170,10 @@ public class FieldInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the equals() method test. + */ + @Test public void testHashCode() { FieldInfo info1 = new FieldInfo((FieldInfo)fFieldInfo1); FieldInfo info2 = new FieldInfo((FieldInfo)fFieldInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ModelImplFactory.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ModelImplFactory.java index 5f8babb9a5..0c6e5c13dd 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ModelImplFactory.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ModelImplFactory.java @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation *******************************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ProbeEventInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ProbeEventInfoTest.java index 63c0b34b01..3f8811c2f3 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ProbeEventInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ProbeEventInfoTest.java @@ -8,25 +8,31 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; -import junit.framework.TestCase; +import static org.junit.Assert.*; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class BaseEventInfoTest contains test for the class {@link BaseEventInfo}. + * The class ProbEventInfoTest contains test for the class + * {@link ProbeEventInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class ProbeEventInfoTest extends TestCase { +@SuppressWarnings("nls") +public class ProbeEventInfoTest { // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IProbeEventInfo fEventInfo1 = null; private IProbeEventInfo fEventInfo2 = null; @@ -35,35 +41,22 @@ public class ProbeEventInfoTest extends TestCase { // ------------------------------------------------------------------------ /** * Perform pre-test initialization. - * - * @throws Exception if the initialization fails for some reason - * */ - @Override - public void setUp() throws Exception { + @Before + public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fEventInfo1 = factory.getProbeEventInfo1(); fEventInfo2 = factory.getProbeEventInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception if the clean-up fails for some reason - * - */ - @Override - public void tearDown() throws Exception { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** * Run the BaseEventInfo() constructor test. - * */ + @Test public void testBaseEventInfo() { ProbeEventInfo fixture = new ProbeEventInfo("event"); assertNotNull(fixture); @@ -90,6 +83,7 @@ public class ProbeEventInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventInfoCopy() { ProbeEventInfo info = new ProbeEventInfo((ProbeEventInfo)fEventInfo1); @@ -104,6 +98,7 @@ public class ProbeEventInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testEventCopy2() { try { ProbeEventInfo info = null; @@ -118,6 +113,7 @@ public class ProbeEventInfoTest extends TestCase { /** * Getter/Setter tests */ + @Test public void testGetAndSetter() { ProbeEventInfo fixture = new ProbeEventInfo("event"); @@ -143,6 +139,7 @@ public class ProbeEventInfoTest extends TestCase { /** * Run the String toString() method test. */ + @Test public void testToString_1() { assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)],fAddress=0xc1231234)]", fEventInfo1.toString()); assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent2)],type=UNKNOWN,level=TRACE_DEBUG)],State=DISABLED)],fOffset=0x100,fSymbol=init_post)]", fEventInfo2.toString()); @@ -151,6 +148,11 @@ public class ProbeEventInfoTest extends TestCase { // ------------------------------------------------------------------------ // equals // ------------------------------------------------------------------------ + + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fEventInfo1.equals(fEventInfo1)); assertTrue("equals", fEventInfo2.equals(fEventInfo2)); @@ -159,6 +161,10 @@ public class ProbeEventInfoTest extends TestCase { assertTrue("equals", !fEventInfo2.equals(fEventInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1); ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2); @@ -170,6 +176,10 @@ public class ProbeEventInfoTest extends TestCase { assertTrue("equals", fEventInfo2.equals(info2)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1); ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1); @@ -180,6 +190,10 @@ public class ProbeEventInfoTest extends TestCase { assertTrue("equals", info1.equals(info3)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fEventInfo1.equals(null)); assertTrue("equals", !fEventInfo2.equals(null)); @@ -189,6 +203,10 @@ public class ProbeEventInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the hashCode() method test. + */ + @Test public void testHashCode() { ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1); ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java index bfa6599105..ecab6559d4 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java @@ -8,28 +8,34 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; +import static org.junit.Assert.*; + import java.util.LinkedList; import java.util.List; -import junit.framework.TestCase; - import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class ChannelInfoTest contains tests for the class {@link SessionInfo}. - * + * The class ChannelInfoTest contains tests for the class + * {@link SessionInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class SessionInfoTest extends TestCase { +@SuppressWarnings("nls") +public class SessionInfoTest { + // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private ISessionInfo fSessionInfo1 = null; private ISessionInfo fSessionInfo2 = null; @@ -42,12 +48,8 @@ public class SessionInfoTest extends TestCase { /** * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * */ - @Override + @Before public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fSessionInfo1 = factory.getSessionInfo1(); @@ -56,17 +58,6 @@ public class SessionInfoTest extends TestCase { fDomainInfo2 = factory.getDomainInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - */ - @Override - public void tearDown() { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ @@ -77,8 +68,8 @@ public class SessionInfoTest extends TestCase { /** * Run the ChannelInfo() constructor test. - * */ + @Test public void testSessionInfo() { ISessionInfo result = new SessionInfo("test"); assertNotNull(result); @@ -93,6 +84,10 @@ public class SessionInfoTest extends TestCase { assertEquals(0, result.getDomains().length); } + /** + * Test copy constructor. + */ + @Test public void testSessionInfoCopy() { SessionInfo sessionInfo = new SessionInfo((SessionInfo)fSessionInfo1); @@ -107,6 +102,10 @@ public class SessionInfoTest extends TestCase { } } + /** + * Test copy constructor. + */ + @Test public void testSessionCopy2() { try { SessionInfo session = null; @@ -120,8 +119,8 @@ public class SessionInfoTest extends TestCase { /** * Run the long getNumberOfSubBuffers() method test. - * */ + @Test public void testGetAndSetters() { // Note that addDomain() has been executed in setUp() @@ -181,6 +180,10 @@ public class SessionInfoTest extends TestCase { assertEquals(0, state.ordinal()); } + /** + * Run the String toString() method test. + */ + @Test public void testToString_1() { ISessionInfo fixture = new SessionInfo("sessionName"); @@ -192,8 +195,8 @@ public class SessionInfoTest extends TestCase { /** * Run the String toString() method test. - * */ + @Test public void testToString_2() { String result = fSessionInfo1.toString(); @@ -205,6 +208,10 @@ public class SessionInfoTest extends TestCase { // equals // ------------------------------------------------------------------------ + /** + * Run the {@link SessionInfo#equals} method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fSessionInfo1.equals(fSessionInfo1)); assertTrue("equals", fSessionInfo2.equals(fSessionInfo2)); @@ -213,6 +220,10 @@ public class SessionInfoTest extends TestCase { assertTrue("equals", !fSessionInfo2.equals(fSessionInfo1)); } + /** + * Run the {@link SessionInfo#equals} method test. + */ + @Test public void testEqualsSymmetry() { SessionInfo event1 = new SessionInfo((SessionInfo)fSessionInfo1); SessionInfo event2 = new SessionInfo((SessionInfo)fSessionInfo2); @@ -224,6 +235,10 @@ public class SessionInfoTest extends TestCase { assertTrue("equals", fSessionInfo2.equals(event2)); } + /** + * Run the {@link SessionInfo#equals} method test. + */ + @Test public void testEqualsTransivity() { SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1); SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo1); @@ -234,6 +249,10 @@ public class SessionInfoTest extends TestCase { assertTrue("equals", channel1.equals(channel3)); } + /** + * Run the {@link SessionInfo#equals} method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fSessionInfo1.equals(null)); assertTrue("equals", !fSessionInfo2.equals(null)); @@ -243,6 +262,10 @@ public class SessionInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the {@link SessionInfo#hashCode} method test. + */ + @Test public void testHashCode() { SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1); SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo2); @@ -252,4 +275,5 @@ public class SessionInfoTest extends TestCase { assertTrue("hashCode", fSessionInfo1.hashCode() != channel2.hashCode()); assertTrue("hashCode", fSessionInfo2.hashCode() != channel1.hashCode()); - }} \ No newline at end of file + } +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/TraceInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/TraceInfoTest.java index e60169c117..48e60a1a6c 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/TraceInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/TraceInfoTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,23 +8,29 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; -import junit.framework.TestCase; +import static org.junit.Assert.*; import org.eclipse.linuxtools.internal.lttng2.core.control.model.ITraceInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class TraceInfoTest contains test for the class {@link TraceInfo}. + * The class TraceInfoTest contains test for the class + * {@link TraceInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class TraceInfoTest extends TestCase { +@SuppressWarnings("nls") +public class TraceInfoTest { // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private ITraceInfo fTraceInfo1 = null; private ITraceInfo fTraceInfo2 = null; @@ -32,36 +38,24 @@ public class TraceInfoTest extends TestCase { // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ + /** * Perform pre-test initialization. - * - * @throws Exception if the initialization fails for some reason - * */ - @Override - public void setUp() throws Exception { + @Before + public void setUp() { fTraceInfo1 = new TraceInfo("event1"); fTraceInfo2 = new TraceInfo("event2"); } - /** - * Perform post-test clean-up. - * - * @throws Exception if the clean-up fails for some reason - * - */ - @Override - public void tearDown() throws Exception { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** * Run the BaseEventInfo() constructor test. - * */ + @Test public void testTraceInfo() { TraceInfo fixture = new TraceInfo("event"); assertNotNull(fixture); @@ -72,6 +66,7 @@ public class TraceInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testTraceInfo2() { try { String name = null; @@ -86,6 +81,7 @@ public class TraceInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testTraceInfoCopy() { TraceInfo info = new TraceInfo((TraceInfo)fTraceInfo1); @@ -95,6 +91,7 @@ public class TraceInfoTest extends TestCase { /** * Test Copy Constructor */ + @Test public void testTraceCopy2() { try { TraceInfo info = null; @@ -108,8 +105,8 @@ public class TraceInfoTest extends TestCase { /** * Run the void setEventType(String) method test. - * */ + @Test public void testSetName() { TraceInfo fixture = new TraceInfo("event"); fixture.setName("newName"); @@ -118,8 +115,8 @@ public class TraceInfoTest extends TestCase { /** * Run the String toString() method test. - * */ + @Test public void testToString_1() { String result = fTraceInfo1.toString(); @@ -131,6 +128,10 @@ public class TraceInfoTest extends TestCase { // equals // ------------------------------------------------------------------------ + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fTraceInfo1.equals(fTraceInfo1)); assertTrue("equals", fTraceInfo2.equals(fTraceInfo2)); @@ -139,6 +140,10 @@ public class TraceInfoTest extends TestCase { assertTrue("equals", !fTraceInfo2.equals(fTraceInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1); TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo2); @@ -149,7 +154,10 @@ public class TraceInfoTest extends TestCase { assertTrue("equals", info2.equals(fTraceInfo2)); assertTrue("equals", fTraceInfo2.equals(info2)); } - + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1); TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo1); @@ -159,7 +167,10 @@ public class TraceInfoTest extends TestCase { assertTrue("equals", info2.equals(info3)); assertTrue("equals", info1.equals(info3)); } - + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fTraceInfo1.equals(null)); assertTrue("equals", !fTraceInfo2.equals(null)); @@ -169,6 +180,10 @@ public class TraceInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the hashCode() method test. + */ + @Test public void testHashCode() { TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1); TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/UstProviderInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/UstProviderInfoTest.java index de0facfaf2..a95e3ab9aa 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/UstProviderInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/UstProviderInfoTest.java @@ -8,28 +8,34 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; +import static org.junit.Assert.*; + import java.util.LinkedList; import java.util.List; -import junit.framework.TestCase; - import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo; +import org.junit.Before; +import org.junit.Test; /** - * The class ChannelInfoTest contains tests for the class {@link UstProviderInfo}. - * + * The class ChannelInfoTest contains tests for the class + * {@link UstProviderInfo}. */ -@SuppressWarnings({"nls", "javadoc"}) -public class UstProviderInfoTest extends TestCase { +@SuppressWarnings("nls") +public class UstProviderInfoTest { + // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private IUstProviderInfo fUstProviderInfo1 = null; private IUstProviderInfo fUstProviderInfo2 = null; @@ -42,12 +48,8 @@ public class UstProviderInfoTest extends TestCase { /** * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * */ - @Override + @Before public void setUp() { ModelImplFactory factory = new ModelImplFactory(); fUstProviderInfo1 = factory.getUstProviderInfo1(); @@ -56,17 +58,6 @@ public class UstProviderInfoTest extends TestCase { fEventInfo2 = factory.getBaseEventInfo2(); } - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - */ - @Override - public void tearDown() { - } - // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ @@ -77,8 +68,8 @@ public class UstProviderInfoTest extends TestCase { /** * Run the UstProviderInfo() constructor test. - * */ + @Test public void testUstProviderInfo() { IUstProviderInfo result = new UstProviderInfo("test"); assertNotNull(result); @@ -88,6 +79,10 @@ public class UstProviderInfoTest extends TestCase { assertEquals(0, result.getEvents().length); } + /** + * Test the copy constructor. + */ + @Test public void testUstProviderInfoCopy() { IUstProviderInfo providerInf = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1); @@ -102,6 +97,10 @@ public class UstProviderInfoTest extends TestCase { } } + /** + * Test the copy constructor. + */ + @Test public void testUstProviderCopy2() { try { UstProviderInfo providerInfo = null; @@ -115,8 +114,8 @@ public class UstProviderInfoTest extends TestCase { /** * Run the IEventInfo[] getEvents() method test. - * */ + @Test public void testGetAndSetters() { IUstProviderInfo fixture = new UstProviderInfo("test"); fixture.setPid(2468); @@ -138,8 +137,8 @@ public class UstProviderInfoTest extends TestCase { /** * Run the void setEvents(List) method test. - * */ + @Test public void testSetEvents_1() { UstProviderInfo fixture = new UstProviderInfo("test"); fixture.setPid(2468); @@ -157,6 +156,10 @@ public class UstProviderInfoTest extends TestCase { } } + /** + * Run the String toString() method test. + */ + @Test public void testToString_1() { UstProviderInfo fixture = new UstProviderInfo("test"); fixture.setPid(2468); @@ -167,20 +170,24 @@ public class UstProviderInfoTest extends TestCase { /** * Run the String toString() method test. - * */ + @Test public void testToString_2() { String result = fUstProviderInfo2.toString(); assertEquals("[EventInfo([TraceInfo(Name=myUST2)],PID=2345,Events=[BaseEventInfo([TraceInfo(Name=event1)]," + - "type=UNKNOWN,level=TRACE_DEBUG,Fields=[FieldInfo([TraceInfo(Name=intfield)],type=int[FieldInfo" + - "([TraceInfo(Name=stringfield)],type=string,Filter=intField==10)][BaseEventInfo([TraceInfo(Name=event2)]," + - "type=TRACEPOINT,level=TRACE_DEBUG)])]", result); + "type=UNKNOWN,level=TRACE_DEBUG,Fields=[FieldInfo([TraceInfo(Name=intfield)],type=int[FieldInfo" + + "([TraceInfo(Name=stringfield)],type=string,Filter=intField==10)][BaseEventInfo([TraceInfo(Name=event2)]," + + "type=TRACEPOINT,level=TRACE_DEBUG)])]", result); } // ------------------------------------------------------------------------ // equals // ------------------------------------------------------------------------ + /** + * Run the equals() method test. + */ + @Test public void testEqualsReflexivity() { assertTrue("equals", fUstProviderInfo1.equals(fUstProviderInfo1)); assertTrue("equals", fUstProviderInfo2.equals(fUstProviderInfo2)); @@ -189,6 +196,10 @@ public class UstProviderInfoTest extends TestCase { assertTrue("equals", !fUstProviderInfo2.equals(fUstProviderInfo1)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsSymmetry() { UstProviderInfo event1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1); UstProviderInfo event2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2); @@ -200,6 +211,10 @@ public class UstProviderInfoTest extends TestCase { assertTrue("equals", fUstProviderInfo2.equals(event2)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsTransivity() { UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1); UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1); @@ -210,6 +225,10 @@ public class UstProviderInfoTest extends TestCase { assertTrue("equals", UstProvider1.equals(UstProvider3)); } + /** + * Run the equals() method test. + */ + @Test public void testEqualsNull() { assertTrue("equals", !fUstProviderInfo1.equals(null)); assertTrue("equals", !fUstProviderInfo2.equals(null)); @@ -219,6 +238,10 @@ public class UstProviderInfoTest extends TestCase { // hashCode // ------------------------------------------------------------------------ + /** + * Run the hashCode() method test. + */ + @Test public void testHashCode() { UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1); UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2); diff --git a/org.eclipse.linuxtools.lttng2.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng2.core/META-INF/MANIFEST.MF index 3e26286103..8e0491dd0f 100644 --- a/org.eclipse.linuxtools.lttng2.core/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng2.core/META-INF/MANIFEST.MF @@ -9,6 +9,6 @@ Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.core.Activator Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.core.runtime -Export-Package: org.eclipse.linuxtools.internal.lttng2.core;x-internal:=true, +Export-Package: org.eclipse.linuxtools.internal.lttng2.core;x-friends:="org.eclipse.linuxtools.lttng2.core.tests", org.eclipse.linuxtools.internal.lttng2.core.control.model;x-friends:="org.eclipse.linuxtools.lttng2.ui", org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;x-friends:="org.eclipse.linuxtools.lttng2.ui" diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/AllTests.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/AllTests.java index 93d97234ff..c7ed8c897d 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/AllTests.java @@ -16,8 +16,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; /** - * AllTests - *

+ * Runner for the lttng2.kernel unit tests. */ @RunWith(Suite.class) @Suite.SuiteClasses({ diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CtfKernelStateInputTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CtfKernelStateInputTest.java index c7723096e2..518d0d9c72 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CtfKernelStateInputTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CtfKernelStateInputTest.java @@ -17,32 +17,33 @@ import static org.junit.Assert.assertEquals; import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateInput; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; /** * Tests for the LTTng 2.0 kernel state provider * - * @author alexmont - * + * @author Alexandre Montplaisir */ -@SuppressWarnings("javadoc") public class CtfKernelStateInputTest { static IStateChangeInput input; + /** + * Set-up. + * + * @throws TmfTraceException + * If we can't find the test traces + */ @BeforeClass public static void initialize() throws TmfTraceException { input = new CtfKernelStateInput(CtfTestFiles.getTestTrace()); } - @AfterClass - public static void cleanup() { - // - } - + /** + * Test loading the state provider. + */ @Test public void testOpening() { long testStartTime; @@ -50,12 +51,4 @@ public class CtfKernelStateInputTest { assertEquals(testStartTime, CtfTestFiles.startTime); } - //FIXME re-enable once we offer history-less state systems again -// @Test -// public void testRunning() { -// StateSystem ss = new StateSystem(); -// input.assignTargetStateSystem(ss); -// input.run(); -// } - } diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/TestAll.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/TestAll.java index a0f6817f4b..dc7bf950f4 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/TestAll.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/TestAll.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -16,12 +16,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; /** - * The class TestAll builds a suite that can be used to run all of - * the tests within its package as well as within any subpackages of its - * package. - * - * @author ematkho - * @version $Revision: 1.0 $ + * Runner for the LTTng kernel state system tests. */ @RunWith(Suite.class) @Suite.SuiteClasses({ diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/ActivatorTest.java b/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/ActivatorTest.java index 295f0e180a..5634a3c46a 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/ActivatorTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/ActivatorTest.java @@ -12,57 +12,21 @@ package org.eclipse.linuxtools.lttng2.kernel.ui.tests; -import junit.framework.TestCase; +import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** - * ActivatorTest - *

* Test suite for the Activator class - *

*/ -@SuppressWarnings("javadoc") -public class ActivatorTest extends TestCase { - - // ------------------------------------------------------------------------ - // JUnit - // ------------------------------------------------------------------------ - - @BeforeClass - public static void setUpBeforeClass() { - } - - @AfterClass - public static void tearDownAfterClass() { - } - - /** - * @throws java.lang.Exception - */ - @Before - @Override - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - @Override - public void tearDown() throws Exception { - } +public class ActivatorTest { // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** - * Test method for {@link org.eclipse.linuxtools.lttng2.kernel.ui.Activator#Activator()}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator#Activator()}. */ @Test public void testActivator() { @@ -70,7 +34,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.lttng2.kernel.ui.Activator#getDefault()}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator#getDefault()}. */ @Test public void testGetDefault() { @@ -78,7 +42,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.lttng2.kernel.ui.Activator#start(org.osgi.framework.BundleContext)}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator#start}. */ @Test public void testStartBundleContext() { @@ -86,7 +50,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.lttng2.kernel.ui.Activator#stop(org.osgi.framework.BundleContext)}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator#stop}. */ @Test public void testStopBundleContext() { diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/AllTests.java b/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/AllTests.java index b9a4109080..f37fdf03f0 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui.tests/src/org/eclipse/linuxtools/lttng2/kernel/ui/tests/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,28 +8,21 @@ * * Contributors: * Francois Chouinard - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ package org.eclipse.linuxtools.lttng2.kernel.ui.tests; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** - * AllTests - *

+ * Run the lttng2.ui unit tests. */ -@SuppressWarnings("javadoc") +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ActivatorTest.class, +}) public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite(AllTests.class.getName()); - // $JUnit-BEGIN$ - - // Plug-in - suite.addTestSuite(ActivatorTest.class); - - // $JUnit-END$ - return suite; - } } diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/ActivatorTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/ActivatorTest.java index 058fc71f9f..39089cfe5c 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/ActivatorTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/ActivatorTest.java @@ -12,57 +12,21 @@ package org.eclipse.linuxtools.lttng2.ui.tests; -import junit.framework.TestCase; +import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** - * ActivatorTest - *

* Test suite for the Activator class - *

*/ -@SuppressWarnings("javadoc") -public class ActivatorTest extends TestCase { - - // ------------------------------------------------------------------------ - // JUnit - // ------------------------------------------------------------------------ - - @BeforeClass - public static void setUpBeforeClass() { - } - - @AfterClass - public static void tearDownAfterClass() { - } - - /** - * @throws java.lang.Exception - */ - @Before - @Override - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - @Override - public void tearDown() throws Exception { - } +public class ActivatorTest { // ------------------------------------------------------------------------ // Tests // ------------------------------------------------------------------------ /** - * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#Activator()}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#Activator}. */ @Test public void testActivator() { @@ -70,7 +34,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#getDefault()}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#getDefault}. */ @Test public void testGetDefault() { @@ -78,7 +42,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#start(org.osgi.framework.BundleContext)}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#start}. */ @Test public void testStartBundleContext() { @@ -86,7 +50,7 @@ public class ActivatorTest extends TestCase { } /** - * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#stop(org.osgi.framework.BundleContext)}. + * Test method for {@link org.eclipse.linuxtools.internal.lttng2.ui.Activator#stop}. */ @Test public void testStopBundleContext() { diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/AllTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/AllTests.java index e34a1be605..bf338e73fc 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,30 +8,23 @@ * * Contributors: * Francois Chouinard - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ package org.eclipse.linuxtools.lttng2.ui.tests; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** - * AllTests - *

+ * Runner for the lttng2.ui unit tests. */ -@SuppressWarnings("javadoc") +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ActivatorTest.class, + org.eclipse.linuxtools.lttng2.ui.tests.control.model.component.AllTests.class, + org.eclipse.linuxtools.lttng2.ui.tests.control.service.AllTests.class +}) public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite(AllTests.class.getName()); - // $JUnit-BEGIN$ - - // Plug-in - suite.addTestSuite(ActivatorTest.class); - suite.addTest(org.eclipse.linuxtools.lttng2.ui.tests.control.service.AllTests.suite()); - suite.addTest(org.eclipse.linuxtools.lttng2.ui.tests.control.model.component.AllTests.suite()); - - // $JUnit-END$ - return suite; - } } diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/AllTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/AllTests.java index c255963ffa..922b8ba54b 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Ericsson + * Copyright (c) 2011, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,28 +8,28 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; -@SuppressWarnings("javadoc") +/** + * Runner for the control.model.component unit tests. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + TraceControlComponentTest.class, + TraceControlKernelProviderTests.class, + TraceControlKernelSessionTests.class, + TraceControlPropertiesTest.class, + TraceControlTreeModelNoProvidersTest.class, + TraceControlTreeModelTest.class, + TraceControlUstProviderTests.class, + TraceControlUstSessionTests.class +}) public class AllTests { - public static Test suite() { - - TestSuite suite = new TestSuite(AllTests.class.getName()); - //$JUnit-BEGIN$ - suite.addTestSuite(TraceControlComponentTest.class); - suite.addTestSuite(TraceControlTreeModelTest.class); - suite.addTestSuite(TraceControlTreeModelNoProvidersTest.class); - suite.addTestSuite(TraceControlKernelProviderTests.class); - suite.addTestSuite(TraceControlUstProviderTests.class); - suite.addTestSuite(TraceControlKernelSessionTests.class); - suite.addTestSuite(TraceControlUstSessionTests.class); - suite.addTestSuite(TraceControlPropertiesTest.class); - //$JUnit-END$ - return new ModelImplTestSetup(suite); - } } diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlComponentTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlComponentTest.java index d25c80baa8..234f711b25 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlComponentTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlComponentTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,16 +8,16 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.*; + import java.util.LinkedList; import java.util.List; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.commands.ExecutionException; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy; @@ -31,63 +31,19 @@ import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngCont import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; -import org.junit.After; -import org.junit.Before; +import org.junit.Test; /** - * The class TraceControlComponentTest contains tests for the class {@link TraceControlComponent}. - * + * The class TraceControlComponentTest contains tests for the class + * {@link TraceControlComponent}. */ @SuppressWarnings("nls") -public class TraceControlComponentTest extends TestCase { - - // ------------------------------------------------------------------------ - // Test data - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlComponentTest.class)); - } - - // ------------------------------------------------------------------------ - // Housekeeping - // ------------------------------------------------------------------------ - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - */ - @Override - @Before - public void setUp() throws Exception { - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - */ - @Override - @After - public void tearDown() throws Exception { - } +public class TraceControlComponentTest { /** * Run the TraceControlComponent(String) constructor test. */ + @Test public void testTraceControlComponent_1() { String name = "node"; @@ -106,6 +62,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the TraceControlComponent(String,ITraceControlComponent) constructor test. */ + @Test public void testTraceControlComponent_2() { String name = "node"; @@ -123,6 +80,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void addChild(ITraceControlComponent) method test. */ + @Test public void testAddAndGetChild1() { TraceControlComponent fixture = new TraceControlComponent("node", new TraceControlRoot()); fixture.setToolTip("This is the test node"); @@ -138,6 +96,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void addChild(ITraceControlComponent) method test. */ + @Test public void testAddAndGetChild2() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -150,6 +109,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void addComponentListener(ITraceControlComponentChangedListener) method test. */ + @Test public void testAddComponentListener_1() { TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null); fixture.setToolTip(""); @@ -171,6 +131,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the boolean containsChild(String) method test. */ + @Test public void testContainsChild_1() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -185,6 +146,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the boolean containsChild(String) method test. */ + @Test public void testContainsChild_2() { TraceControlComponent fixture = new TraceControlComponent("name", new TraceControlRoot()); fixture.setToolTip(""); @@ -199,6 +161,7 @@ public class TraceControlComponentTest extends TestCase { * Run the void fireCompenentRemoved(ITraceControlComponent,ITraceControlComponent) method test. * Run the void fireCompenentChanged(ITraceControlComponent) method test */ + @Test public void testFireCompenentUpdated() { ITraceControlComponent parent = new TraceControlRoot(); @@ -232,6 +195,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the Object getAdapter(Class) method test. */ + @Test public void testGetAdapter() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -246,6 +210,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the ITraceControlComponent[] getChildren() method test. */ + @Test public void testGetChildren_1() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -271,6 +236,7 @@ public class TraceControlComponentTest extends TestCase { * @throws ExecutionException * Would fail the test */ + @Test public void testGetAndSetControlService_1() throws ExecutionException { TraceControlComponent parent = new TraceControlComponent("parent") { @@ -311,6 +277,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the Image getImage() method test. */ + @Test public void testGetImage_1() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -326,6 +293,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the boolean hasChildren() method test. */ + @Test public void testHasChildren_1() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -339,6 +307,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the boolean hasChildren() method test. */ + @Test public void testHasChildren_2() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -351,6 +320,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void removeAllChildren() method test. */ + @Test public void testRemoveAllChildren_2() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -365,6 +335,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void removeChild(ITraceControlComponent) method test. */ + @Test public void testRemoveChild_1() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -378,6 +349,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void removeChild(ITraceControlComponent) method test. */ + @Test public void testRemoveChild_2() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -391,6 +363,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test. */ + @Test public void testRemoveComponentListener_1() { TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null); fixture.setToolTip(""); @@ -415,6 +388,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test. */ + @Test public void testRemoveComponentListener_2() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -428,6 +402,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void setChildren(List)/ITraceControlComponent[] getChildren() method test. */ + @Test public void testGetAndSetChildren() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -446,6 +421,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void String getName()/setName(String) method tests. */ + @Test public void testGetAndSetName() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -460,6 +436,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void ITraceControlComponent getParent()/setParent(ITraceControlComponent) method tests. */ + @Test public void testGetAndSetParent() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip(""); @@ -479,6 +456,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void TargetNodeState getTargetNodeState()/etTargetNodeState(TargetNodeState) method tests. */ + @Test public void testGetAndSetTargetNodeState_1() { TraceControlComponent parent = new TraceControlComponent("parent") { private TargetNodeState fState; @@ -539,6 +517,7 @@ public class TraceControlComponentTest extends TestCase { /** * Run the void setToolTip(String) method test. */ + @Test public void testGetSndSetToolTip() { TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); fixture.setToolTip("This is a tooltip"); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelProviderTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelProviderTests.java index 26db1586d5..b4e97a022a 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelProviderTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelProviderTests.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,16 +8,18 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.net.URL; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; @@ -44,40 +46,31 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** - * The class TraceControlKernelProviderTests contains UST provider handling - * test cases. + * The class TraceControlKernelProviderTests contains UST provider + * handling test cases. */ -@SuppressWarnings({"nls", "javadoc"}) -public class TraceControlKernelProviderTests extends TestCase { +@SuppressWarnings("nls") +public class TraceControlKernelProviderTests { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ + private static final String TEST_STREAM = "CreateTreeTest.cfg"; private static final String SCEN_SCENARIO1_TEST = "Scenario1"; // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private TraceControlTestFacility fFacility; private TestRemoteSystemProxy fProxy; private String fTestFile; - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlKernelProviderTests.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -87,9 +80,7 @@ public class TraceControlKernelProviderTests extends TestCase { * * @throws Exception * if the initialization fails for some reason - * */ - @Override @Before public void setUp() throws Exception { fFacility = TraceControlTestFacility.getInstance(); @@ -101,23 +92,21 @@ public class TraceControlKernelProviderTests extends TestCase { /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { fFacility.waitForJobs(); } /** * Run the TraceControlComponent. + * + * @throws Exception + * Would fail the test */ + @Test public void testKernelProviderTree() throws Exception { - fProxy.setTestFile(fTestFile); fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java index 6000c30fa4..b60f0f55d5 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,18 +8,22 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.List; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; @@ -48,41 +52,31 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** - * The class TraceControlKernelSessionTests contains Kernel session/channel/event - * handling test cases. + * The class TraceControlKernelSessionTests contains Kernel + * session/channel/event handling test cases. */ - -@SuppressWarnings({"nls", "javadoc"}) -public class TraceControlKernelSessionTests extends TestCase { +@SuppressWarnings("nls") +public class TraceControlKernelSessionTests { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ + private static final String TEST_STREAM = "CreateTreeTest.cfg"; private static final String SCEN_SCENARIO3_TEST = "Scenario3"; // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private TraceControlTestFacility fFacility; private TestRemoteSystemProxy fProxy; private String fTestFile; - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlKernelSessionTests.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -92,9 +86,7 @@ public class TraceControlKernelSessionTests extends TestCase { * * @throws Exception * if the initialization fails for some reason - * */ - @Override @Before public void setUp() throws Exception { fFacility = TraceControlTestFacility.getInstance(); @@ -106,20 +98,19 @@ public class TraceControlKernelSessionTests extends TestCase { /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { fFacility.waitForJobs(); } /** * Run the TraceControlComponent. + * + * @throws Exception + * Would fail the test */ + @Test public void testTraceSessionTree() throws Exception { fProxy.setTestFile(fTestFile); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java index 4d2dc7ab37..15b1984452 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,16 +8,16 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.*; + import java.io.File; import java.net.URL; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; @@ -52,67 +52,33 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.ui.views.properties.IPropertySource; import org.junit.After; -import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; - /** - * The class TraceControlPropertiesTest contains tests for the all property class. - * + * The class TraceControlPropertiesTest contains tests for the all + * property class. */ @SuppressWarnings("nls") -public class TraceControlPropertiesTest extends TestCase { +public class TraceControlPropertiesTest { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ + private static final String DIRECTORY = "testfiles"; private static final String TEST_STREAM = "ListInfoTest.cfg"; private static final String SCEN_LIST_INFO_TEST = "ListInfoTest"; - - // ------------------------------------------------------------------------ - // Test data - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlPropertiesTest.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - */ - @Override - @Before - public void setUp() throws Exception { - } - /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { TraceControlTestFacility.getInstance().waitForJobs(); } @@ -122,6 +88,7 @@ public class TraceControlPropertiesTest extends TestCase { * @throws Exception * This will fail the test */ + @Test public void testComponentProperties() throws Exception { TestRemoteSystemProxy proxy = new TestRemoteSystemProxy(); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTestFacility.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTestFacility.java index e03b8eea40..410cf890d9 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTestFacility.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTestFacility.java @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation *******************************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; import org.eclipse.core.commands.ExecutionException; diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelNoProvidersTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelNoProvidersTest.java index 70095241e0..4ee0594727 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelNoProvidersTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelNoProvidersTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,16 +8,20 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.net.URL; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; @@ -36,15 +40,16 @@ import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.swt.graphics.Image; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** * The class TraceControlTreeModelNoProvidersTest verifies that the - * Tracer Control can handle the case where no kernel provider and only UST provider - * are available. + * Tracer Control can handle the case where no kernel provider and only UST + * provider are available. */ @SuppressWarnings("nls") -public class TraceControlTreeModelNoProvidersTest extends TestCase { +public class TraceControlTreeModelNoProvidersTest { // ------------------------------------------------------------------------ // Constants @@ -61,18 +66,6 @@ public class TraceControlTreeModelNoProvidersTest extends TestCase { private TestRemoteSystemProxy fProxy; private String fTestFile; - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlTreeModelNoProvidersTest.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -82,9 +75,7 @@ public class TraceControlTreeModelNoProvidersTest extends TestCase { * * @throws Exception * if the initialization fails for some reason - * */ - @Override @Before public void setUp() throws Exception { fProxy = new TestRemoteSystemProxy(); @@ -95,14 +86,9 @@ public class TraceControlTreeModelNoProvidersTest extends TestCase { /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { TraceControlTestFacility.getInstance().waitForJobs(); } @@ -112,6 +98,7 @@ public class TraceControlTreeModelNoProvidersTest extends TestCase { * @throws Exception * This will fail the test */ + @Test public void testTraceControlComponents() throws Exception { fProxy.setTestFile(fTestFile); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelTest.java index 73b3a80e19..2cb7c3b850 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlTreeModelTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,16 +8,21 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.net.URL; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; @@ -47,13 +52,15 @@ import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.swt.graphics.Image; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** - * The class TraceControlTreeModelTest contains tests for the tree component classes. + * The class TraceControlTreeModelTest contains tests for the tree + * component classes. */ @SuppressWarnings("nls") -public class TraceControlTreeModelTest extends TestCase { +public class TraceControlTreeModelTest { // ------------------------------------------------------------------------ // Constants @@ -70,18 +77,6 @@ public class TraceControlTreeModelTest extends TestCase { private TestRemoteSystemProxy fProxy; private String fTestFile; - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlTreeModelTest.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -91,9 +86,7 @@ public class TraceControlTreeModelTest extends TestCase { * * @throws Exception * if the initialization fails for some reason - * */ - @Override @Before public void setUp() throws Exception { fProxy = new TestRemoteSystemProxy(); @@ -104,14 +97,9 @@ public class TraceControlTreeModelTest extends TestCase { /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { TraceControlTestFacility.getInstance().waitForJobs(); } @@ -121,6 +109,7 @@ public class TraceControlTreeModelTest extends TestCase { * @throws Exception * This will fail the test */ + @Test public void testTraceControlComponents() throws Exception { fProxy.setTestFile(fTestFile); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java index e519a57d35..7072500e25 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,16 +8,16 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.*; + import java.io.File; import java.net.URL; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; @@ -45,40 +45,31 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** - * The class TraceControlUstProviderTests contains UST provider handling - * test cases. + * The class TraceControlUstProviderTests contains UST provider + * handling test cases. */ @SuppressWarnings("nls") -public class TraceControlUstProviderTests extends TestCase { +public class TraceControlUstProviderTests { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ + private static final String TEST_STREAM = "CreateTreeTest.cfg"; private static final String SCEN_SCENARIO2_TEST = "Scenario2"; // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private TraceControlTestFacility fFacility; private TestRemoteSystemProxy fProxy; private String fTestFile; - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlUstProviderTests.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -88,9 +79,7 @@ public class TraceControlUstProviderTests extends TestCase { * * @throws Exception * if the initialization fails for some reason - * */ - @Override @Before public void setUp() throws Exception { fFacility = TraceControlTestFacility.getInstance(); @@ -102,14 +91,9 @@ public class TraceControlUstProviderTests extends TestCase { /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { fFacility.waitForJobs(); } @@ -119,6 +103,7 @@ public class TraceControlUstProviderTests extends TestCase { * @throws Exception * This will fail the test */ + @Test public void testUstProviderTree() throws Exception { fProxy.setTestFile(fTestFile); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java index 9856aa8ac0..ff46051714 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,18 +8,18 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; +import static org.junit.Assert.*; + import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.List; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType; @@ -47,40 +47,31 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; /** - * The class TraceControlUstSessionTests contains UST session/channel/event - * handling test cases. + * The class TraceControlUstSessionTests contains UST + * session/channel/event handling test cases. */ @SuppressWarnings("nls") -public class TraceControlUstSessionTests extends TestCase { +public class TraceControlUstSessionTests { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ + private static final String TEST_STREAM = "CreateTreeTest.cfg"; private static final String SCEN_SCENARIO4_TEST = "Scenario4"; // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private TraceControlTestFacility fFacility; private TestRemoteSystemProxy fProxy; private String fTestFile; - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - /** - * Returns test setup used when executing test case stand-alone. - * @return Test setup class - */ - public static Test suite() { - return new ModelImplTestSetup(new TestSuite(TraceControlUstSessionTests.class)); - } - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -90,9 +81,7 @@ public class TraceControlUstSessionTests extends TestCase { * * @throws Exception * if the initialization fails for some reason - * */ - @Override @Before public void setUp() throws Exception { fFacility = TraceControlTestFacility.getInstance(); @@ -104,14 +93,9 @@ public class TraceControlUstSessionTests extends TestCase { /** * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * */ - @Override @After - public void tearDown() throws Exception { + public void tearDown() { fFacility.waitForJobs(); } @@ -121,6 +105,7 @@ public class TraceControlUstSessionTests extends TestCase { * @throws Exception * This will fail the test */ + @Test public void testTraceSessionTree() throws Exception { fProxy.setTestFile(fTestFile); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/AllTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/AllTests.java index 7ad5ed2c16..57d397c871 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/AllTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Ericsson + * Copyright (c) 2011, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,20 +8,21 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 *******************************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.service; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; -@SuppressWarnings("javadoc") +/** + * Runner for the control.service unit tests. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + LTTngControlServiceTest.class +}) public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite(AllTests.class.getName()); - //$JUnit-BEGIN$ - suite.addTestSuite(LTTngControlServiceTest.class); - //$JUnit-END$ - return suite; - } } diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java index 167dd7ef7f..d13c2ecdb3 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,9 +8,13 @@ * * Contributors: * Bernd Hufmann - Initial API and implementation + * Alexandre Montplaisir - Port to JUnit4 **********************************************************************/ + package org.eclipse.linuxtools.lttng2.ui.tests.control.service; +import static org.junit.Assert.*; + import java.io.File; import java.net.URL; import java.util.ArrayList; @@ -18,8 +22,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import junit.framework.TestCase; - import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.NullProgressMonitor; @@ -42,12 +44,16 @@ import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceFactory; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.FrameworkUtil; + /** - * The class LTTngControlServiceTest contains test for the class {@link LTTngControlService}. + * The class LTTngControlServiceTest contains test for the class + * {@link LTTngControlService}. */ @SuppressWarnings({"nls", "javadoc"}) -public class LTTngControlServiceTest extends TestCase { +public class LTTngControlServiceTest { private static final String DIRECTORY = "testfiles"; private static final String TEST_STREAM = "LTTngServiceTest.cfg"; @@ -81,28 +87,24 @@ public class LTTngControlServiceTest extends TestCase { // ------------------------------------------------------------------------ // Test data // ------------------------------------------------------------------------ + private CommandShellFactory fShellFactory; private String fTestfile; private LTTngToolsFileShell fShell; private ILttngControlService fService; - - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ + /** * Perform pre-test initialization. * - * @throws Exception if the initialization fails for some reason - * + * @throws Exception + * if the initialization fails for some reason */ - @Override + @Before public void setUp() throws Exception { - super.setUp(); fShellFactory = CommandShellFactory.getInstance(); URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null); @@ -114,20 +116,11 @@ public class LTTngControlServiceTest extends TestCase { fService = new LTTngControlService(fShell); } - /** - * Perform post-test clean-up. - * - * @throws Exception if the clean-up fails for some reason - * - */ - @Override - public void tearDown() throws Exception { - } - // ------------------------------------------------------------------------ // Test Cases // ------------------------------------------------------------------------ + @Test public void testVersion() { try { fShell.setScenario(SCEN_LTTNG_VERSION); @@ -139,6 +132,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testVersionWithPrompt() { try { fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT); @@ -150,6 +144,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testUnsupportedVersion() { try { fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION); @@ -160,6 +155,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testNoVersion() { try { fShell.setScenario(SCEN_LTTNG_NO_VERSION); @@ -170,6 +166,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testLttngNotInstalled() { try { fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED); @@ -180,6 +177,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetSessionNames1() { try { fShell.setScenario(SCEN_NO_SESSION_AVAILABLE); @@ -193,6 +191,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetSessionNames2() { try { fShell.setScenario(SCEN_GET_SESSION_NAMES1); @@ -208,6 +207,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetSessionNotExist() { try { fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST); @@ -219,6 +219,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetSessionNameGarbage() { try { fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT); @@ -232,6 +233,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetSession1() { try { fShell.setScenario(SCEN_GET_SESSION1); @@ -379,6 +381,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetKernelProviderNoKernel1() { try { fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL1); @@ -393,6 +396,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetKernelProviderNoKernel2() { try { fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL2); @@ -407,7 +411,7 @@ public class LTTngControlServiceTest extends TestCase { } } - + @Test public void testGetUstProvider() { try { fShell.setScenario(SCEN_GET_UST_PROVIDER1); @@ -462,6 +466,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testUstProvider2() { try { fShell.setScenario(SCEN_GET_UST_PROVIDER2); @@ -475,6 +480,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testGetUstProvider3() { try { fShell.setScenario(SCEN_GET_UST_PROVIDER3); @@ -551,6 +557,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testCreateSession() { try { fShell.setScenario(SCEN_CREATE_SESSION1); @@ -566,6 +573,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testCreateSessionWithPrompt() { try { // First line has the shell prompt before the command output @@ -584,7 +592,7 @@ public class LTTngControlServiceTest extends TestCase { } } - + @Test public void testCreateSessionVariants() { fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); @@ -635,6 +643,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testDestroySession() { try { fShell.setScenario(SCEN_DESTROY_SESSION1); @@ -644,6 +653,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testCreateChannel() { try { @@ -682,6 +692,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testDisableChannel() { try { @@ -704,6 +715,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testEnableChannel() { try { @@ -739,6 +751,7 @@ public class LTTngControlServiceTest extends TestCase { // } // } + @Test public void testEnableEvents() { try { // 1) session name, channel = null, 3 event names, kernel @@ -777,6 +790,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testEnableSyscalls() { try { // 1) session name, channel = null, 3 event names, kernel @@ -796,6 +810,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testDynamicProbe() { try { // 1) session name, channel = null, 3 event names, kernel @@ -819,6 +834,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testEnableLogLevel() { try { // 1) session name, channel = null, 3 event names, kernel @@ -842,6 +858,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testAddContext() { try { // 1) session name, channel = null, 3 event names, kernel @@ -883,6 +900,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testAddContextFailure() { // 1) session name, channel = null, 3 event names, kernel @@ -908,6 +926,7 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testCalibrate() { try { fShell.setScenario(SCEN_CALIBRATE_HANDLING); @@ -918,8 +937,8 @@ public class LTTngControlServiceTest extends TestCase { } } + @Test public void testCalibrateFailure() { - try { fShell.setScenario(SCEN_CALIBRATE_HANDLING); fService.calibrate(false, new NullProgressMonitor()); -- 2.34.1